Skip to content

Commit

Permalink
fix(BUX-644): fix xpriv derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Mar 23, 2024
1 parent 45adc67 commit 66a3440
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions transports/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,16 @@ func SignInputs(dt *models.DraftTransaction, xPriv *bip32.ExtendedKey) (signedHe
txDraft.Inputs[index].PreviousTxScript = ls
txDraft.Inputs[index].PreviousTxSatoshis = input.Satoshis

// Derive the child key (chain)
var chainKey *bip32.ExtendedKey
if chainKey, err = xPriv.Child(
dst.Chain,
); err != nil {
// Derive the child key (m/chain/num)
var derivedKey *bip32.ExtendedKey
if derivedKey, err = bitcoin.GetHDKeyByPath(xPriv, dst.Chain, dst.Num); err != nil {
resError = WrapError(err)
return
}

// Derive the child key (num)
var numKey *bip32.ExtendedKey
if numKey, err = chainKey.Child(
dst.Num,
); err != nil {
resError = WrapError(err)
return
}

// Derive key for paymail destination
// Derive key for paymail destination (m/chain/num/paymailNum)
if dst.PaymailExternalDerivationNum != nil {

Check failure on line 68 in transports/authentication.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

dst.PaymailExternalDerivationNum undefined (type models.Destination has no field or method PaymailExternalDerivationNum)

Check failure on line 68 in transports/authentication.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

dst.PaymailExternalDerivationNum undefined (type models.Destination has no field or method PaymailExternalDerivationNum)
if numKey, err = chainKey.Child(
if derivedKey, err = derivedKey.Child(
*dst.PaymailExternalDerivationNum,

Check failure on line 70 in transports/authentication.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

dst.PaymailExternalDerivationNum undefined (type models.Destination has no field or method PaymailExternalDerivationNum)

Check failure on line 70 in transports/authentication.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

dst.PaymailExternalDerivationNum undefined (type models.Destination has no field or method PaymailExternalDerivationNum)
); err != nil {
resError = WrapError(err)
Expand All @@ -87,9 +76,7 @@ func SignInputs(dt *models.DraftTransaction, xPriv *bip32.ExtendedKey) (signedHe

// Get the private key
var privateKey *bec.PrivateKey
if privateKey, err = bitcoin.GetPrivateKeyFromHDKey(
numKey,
); err != nil {
if privateKey, err = bitcoin.GetPrivateKeyFromHDKey(derivedKey); err != nil {
resError = WrapError(err)
return
}
Expand Down

0 comments on commit 66a3440

Please sign in to comment.