Documentation ¶
Index ¶
- Constants
- Variables
- func IsTestnet(addr string) (bool, error)
- func Pay(keys []*Key, addresses []*Amounts, service Service) ([]byte, error)
- func SetLogger(logger *log.Logger)
- func SetUTXOSpent(hash []byte)
- type Amounts
- type BlockrService
- type Key
- type PrivateKey
- type PublicKey
- type RedeemScript
- func (rs *RedeemScript) CreateRawTransactionHashed(addresses []*Amounts, service Service) ([]byte, *TX, error)
- func (rs *RedeemScript) GetAddress() string
- func (rs *RedeemScript) Pay(keys []*Key, amount uint64, service Service) ([]byte, error)
- func (rs *RedeemScript) Spend(tx *TX, signs [][]byte, service Service) ([]byte, error)
- type Service
- type TX
- type TXin
- type TXout
- type UTXO
- type UTXOs
Constants ¶
const ( //BTC is unit to convert BTC to satoshi BTC = 100000000 //100 million //Fee for a transaction DefaultFee = uint64(0.0001 * BTC) // 0.0001 BTC/kB )
Variables ¶
var Services = []func() (Service, error){ NewBlockrService, }
TestServices is an array containing generator of Services
var TestServices = []func() (Service, error){ NewBlockrServiceForTest, }
TestServices is an array containing generator of Services for testnet
Functions ¶
Types ¶
type BlockrService ¶
type BlockrService struct {
// contains filtered or unexported fields
}
BlockrService is a service using Blockr.io.
func (*BlockrService) GetServiceName ¶
func (b *BlockrService) GetServiceName() string
GetServiceName return service name.
type Key ¶
type Key struct { Pub *PublicKey Priv *PrivateKey }
Key includes PublicKey and PrivateKey.
func GenerateKey ¶
GenerateKey generates random PublicKey and PrivateKey.
func GetKeyFromWIF ¶
GetKeyFromWIF gets PublicKey and PrivateKey from private key of WIF format.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey represents private key for bitcoin
func (*PrivateKey) GetWIFAddress ¶
func (priv *PrivateKey) GetWIFAddress() string
GetWIFAddress returns WIF format string from PrivateKey
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents public key for bitcoin
func GetPublicKey ¶
GetPublicKey returns PublicKey struct using public key hex string.
func (*PublicKey) GetAddress ¶
GetAddress returns bitcoin address from PublicKey
type RedeemScript ¶
RedeemScript represents Redeem script for M of N multisig transaction.
func NewRedeemScript ¶
func NewRedeemScript(m int, publicKeys []*PublicKey) (*RedeemScript, error)
NewRedeemScript creates a M-of-N Multisig redeem script given m, n and n public keys and return RedeemScript struct.
func (*RedeemScript) CreateRawTransactionHashed ¶
func (rs *RedeemScript) CreateRawTransactionHashed(addresses []*Amounts, service Service) ([]byte, *TX, error)
CreateRawTransactionHashed returns a hash of raw transaction for signing.
func (*RedeemScript) GetAddress ¶
func (rs *RedeemScript) GetAddress() string
GetAddress creates P2SH multisig addresses.
type Service ¶
type Service interface { GetServiceName() string GetUTXO(string, *Key) (UTXOs, error) SendTX([]byte) ([]byte, error) }
Service is for getting UTXO or sending transactions , basically by using WEB API.
func NewBlockrService ¶
NewBlockrService creates BlockrService struct for not test.
func NewBlockrServiceForTest ¶
NewBlockrServiceForTest creates BlockrService struct for test.
func SelectService ¶
SelectService returns a service randomly.
type TXin ¶
type TXin struct { Hash []byte Index uint32 Sequence uint32 PrevScriptPubkey []byte CreateScriptSig func(rawTransactionHashed []byte) ([]byte, error) // contains filtered or unexported fields }
TXin represents tx input of a transaction.