File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ # Convert from libsv/go-bt transaction
2+
3+ For users of libsv/go-bt library, this function illustrates the differences between the two transaction structures and converts from one to the other.
4+
5+ ``` go
6+ func GoBt2GoSDKTransaction (tx *bt .Tx ) *transaction .Transaction {
7+ sdkTx := &transaction.Transaction {
8+ Version: tx.Version ,
9+ LockTime: tx.LockTime ,
10+ }
11+
12+ sdkTx.Inputs = make ([]*transaction.TransactionInput , len (tx.Inputs ))
13+ for i , in := range tx.Inputs {
14+ sdkTx.Inputs [i] = &transaction.TransactionInput {
15+ SourceTXID: bt.ReverseBytes (in.PreviousTxID ()),
16+ SourceTxOutIndex: in.PreviousTxOutIndex ,
17+ UnlockingScript: (*script.Script )(in.UnlockingScript ),
18+ SequenceNumber: in.SequenceNumber ,
19+ }
20+ }
21+
22+ sdkTx.Outputs = make ([]*transaction.TransactionOutput , len (tx.Outputs ))
23+ for i , out := range tx.Outputs {
24+ sdkTx.Outputs [i] = &transaction.TransactionOutput {
25+ Satoshis: out.Satoshis ,
26+ LockingScript: (*script.Script )(out.LockingScript ),
27+ }
28+ }
29+
30+ return sdkTx
31+ }
32+ ```
Original file line number Diff line number Diff line change 11# Examples
22
33Here, you will find a number of common usage examples for the go-sdk.
4+
5+ ## Additional Example Documents
6+ - [ Converting Transactions from go-bt] [ GO_BT.md ]
You can’t perform that action at this time.
0 commit comments