-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finishing mvp for create tx and tx from hex
- Loading branch information
Showing
5 changed files
with
256 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/bitcoinschema/go-bitcoin" | ||
) | ||
|
||
func main() { | ||
|
||
// Use a new UTXO | ||
utxo := &bitcoin.Utxo{ | ||
TxID: "b7b0650a7c3a1bd4716369783876348b59f5404784970192cec1996e86950576", | ||
Vout: 0, | ||
ScriptSig: "76a9149cbe9f5e72fa286ac8a38052d1d5337aa363ea7f88ac", | ||
Satoshis: 1000, | ||
} | ||
|
||
// Add a pay-to address | ||
payTo := &bitcoin.PayToAddress{ | ||
Address: "1C8bzHM8XFBHZ2ZZVvFy2NSoAZbwCXAicL", | ||
Satoshis: 500, | ||
} | ||
|
||
// Add some op return data | ||
opReturn1 := bitcoin.OpReturnData{[]byte("prefix1"), []byte("example data"), []byte{0x13, 0x37}} | ||
opReturn2 := bitcoin.OpReturnData{[]byte("prefix2"), []byte("more example data")} | ||
|
||
// Generate the TX | ||
rawTx, err := bitcoin.CreateTx([]*bitcoin.Utxo{utxo}, []*bitcoin.PayToAddress{payTo}, []bitcoin.OpReturnData{opReturn1, opReturn2}, "L3VJH2hcRGYYG6YrbWGmsxQC1zyYixA82YjgEyrEUWDs4ALgk8Vu") | ||
if err != nil { | ||
log.Printf("error occurred: %s", err.Error()) | ||
return | ||
} | ||
|
||
// Success! | ||
log.Printf("rawTx: %s", rawTx.ToString()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/bitcoinschema/go-bitcoin" | ||
) | ||
|
||
func main() { | ||
|
||
// Example raw tx | ||
exampleTx := "0100000001760595866e99c1ce920197844740f5598b34763878696371d41b3a7c0a65b0b7000000006b483045022100eea3d606bd1627be6459a9de4860919225db74843d2fc7f4e7caa5e01f42c2d0022017978d9c6a0e934955a70e7dda71d68cb614f7dd89eb7b9d560aea761834ddd4412102ea87d1fd77d169bd56a71e700628113d0f8dfe57faa0ba0e55a36f9ce8e10be3ffffffff03f4010000000000001976a9147a1980655efbfec416b2b0c663a7b3ac0b6a25d288ac00000000000000001a006a07707265666978310c6578616d706c65206461746102133700000000000000001c006a0770726566697832116d6f7265206578616d706c65206461746100000000" | ||
|
||
rawTx, err := bitcoin.TxFromHex(exampleTx) | ||
if err != nil { | ||
log.Printf("error occurred: %s", err.Error()) | ||
return | ||
} | ||
|
||
log.Printf("tx id: %s", rawTx.GetTxID()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters