Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 1.42 KB

README.md

File metadata and controls

70 lines (44 loc) · 1.42 KB

Build Status GoDoc GitHub license

Blockr

Overview

This is a library to send transactions and gether unspent transaction outputs(UTXO) by blockr web API.

Requirements

This requires

  • git
  • go 1.3+

Installation

 $ go get github.com/bitgoin/blockr

Example

(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)
}

Contribution

Improvements to the codebase and pull requests are encouraged.