Skip to content

Commit

Permalink
fix: replace RawTxInput to RawTxWitnessInput
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Dec 27, 2023
1 parent 2fe8a98 commit 3b70d56
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
23 changes: 15 additions & 8 deletions attestation/attestclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,15 @@ func (w *AttestClient) SignTransaction(hash chainhash.Hash, msgTx wire.MsgTx) (
return nil, prevTxErr
}

var inputs []btcjson.RawTxInput // new tx inputs
var keys []string // keys to sign inputs
var inputs []btcjson.RawTxWitnessInput // new tx inputs
var keys []string // keys to sign inputs

// add prev attestation tx input info and priv key
inputs = append(inputs, btcjson.RawTxInput{prevTxId.String(), 0,
hex.EncodeToString(prevTx.MsgTx().TxOut[0].PkScript), ""})
inputs = append(inputs, btcjson.RawTxWitnessInput{
Txid: prevTxId.String(),
Vout: 0,
ScriptPubKey: hex.EncodeToString(prevTx.MsgTx().TxOut[0].PkScript),
})
keys = append(keys, key.String())

// for any remaining vins - sign with topup privkey
Expand All @@ -456,14 +459,18 @@ func (w *AttestClient) SignTransaction(hash chainhash.Hash, msgTx wire.MsgTx) (
if prevTxErr != nil {
return nil, prevTxErr
}
inputs = append(inputs, btcjson.RawTxInput{prevTxId.String(), 0,
hex.EncodeToString(prevTx.MsgTx().TxOut[0].PkScript), w.scriptTopup})
inputs = append(inputs, btcjson.RawTxWitnessInput{
Txid: prevTxId.String(),
Vout: 0,
ScriptPubKey: hex.EncodeToString(prevTx.MsgTx().TxOut[0].PkScript),
RedeemScript: &w.scriptTopup,
})
keys = append(keys, w.WalletPrivTopup.String())
}

// attempt to sign transcation with provided inputs - keys
signedMsgTx, _, errSign := w.MainClient.SignRawTransaction3(
&msgTx, inputs, keys)
signedMsgTx, _, errSign := w.MainClient.SignRawTransactionWithWallet2(
&msgTx, inputs)
log.Infof("error: %v", errSign)
if errSign != nil {
return nil, errSign
Expand Down
2 changes: 1 addition & 1 deletion crypto/tweaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TweakExtendedKey(extndPubKey *hdkeychain.ExtendedKey, tweak []byte) (*hdkey
childInt := binary.BigEndian.Uint32(childBytes)

// get tweaked pubkey
extndPubKey, childErr = extndPubKey.Child(childInt)
extndPubKey, childErr = extndPubKey.Derive(childInt)
if childErr != nil {
return nil, childErr
}
Expand Down
15 changes: 11 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@ module mainstay
go 1.20

require (
github.com/btcsuite/btcd v0.20.0-beta
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d

github.com/btcsuite/btcd v0.22.0-beta
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
go.mongodb.org/mongo-driver v1.3.1
)

require (
github.com/aead/siphash v1.0.1 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/goleveldb v1.0.0 // indirect
github.com/btcsuite/snappy-go v1.0.0 // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/btcsuite/winsvc v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/lru v1.0.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jrick/logrotate v1.0.0 // indirect
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect
github.com/klauspost/compress v1.9.5 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc // indirect
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down

0 comments on commit 3b70d56

Please sign in to comment.