func write_tx_file(tx *btc.Tx) { var signedrawtx []byte if tx.SegWit != nil { signedrawtx = tx.SerializeNew() } else { signedrawtx = tx.Serialize() } tx.SetHash(signedrawtx) hs := tx.Hash.String() fmt.Println("TxID", hs) f, _ := os.Create(hs[:8] + ".txt") if f != nil { f.Write([]byte(hex.EncodeToString(signedrawtx))) f.Close() fmt.Println("Transaction data stored in", hs[:8]+".txt") } }