github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/tools/fetchtx/fetchtx.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "github.com/piotrnar/gocoin/lib/btc" 6 "io/ioutil" 7 "github.com/piotrnar/gocoin/lib/others/utils" 8 "github.com/piotrnar/gocoin" 9 "os" 10 ) 11 12 13 func main() { 14 fmt.Println("Gocoin FetchTx version", gocoin.Version) 15 16 if len(os.Args) < 2 { 17 fmt.Println("Specify transaction id on the command line (MSB).") 18 return 19 } 20 21 txid := btc.NewUint256FromString(os.Args[1]) 22 if txid == nil { 23 println("Incorrect transaction ID") 24 return 25 } 26 27 rawtx := utils.GetTxFromWeb(txid) 28 if rawtx==nil { 29 fmt.Println("Error fetching the transaction") 30 } else { 31 ioutil.WriteFile(txid.String()+".tx", rawtx, 0666) 32 } 33 }