This is a library to send transactions and gether unspent transaction outputs(UTXO) by blockr web API.
This requires
- git
- go 1.3+
$ go get github.com/bitgoin/blockr
(This example omits error handlings for simplicity.)
import "github.com/bitgoin/blockr"
func main(){
//prepare private key
txKey, err := address.FromWIF("some wif", address.BitcoinTest)
//make service struct
blk := Service{IsTestNet: true}
//get utxos.
txs, err := blk.GetUTXO(adr)
//convert to utxo which can be used in the tx package.
utxo, err := ToUTXO(txs, txKey)
//prepare send info.
send := []*tx.Send{
&tx.Send{
Addr: "n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi",
Amount: 0.01 * tx.Unit,
},
&tx.Send{
Addr: txKey.Publickey.Address(),
Amount: 0,
},
}
//create tx.
tx, err := tx.NewP2PK(0.0001*tx.Unit, utxo, 0, send...)
//send tx.
txhash, err = blk.SendTX(tx)
}
Improvements to the codebase and pull requests are encouraged.