Documentation ¶
Index ¶
- Constants
- Variables
- func IsTestnet(addr string) (bool, error)
- func Pay(keys []*Key, addresses []*Amounts, service Service) ([]byte, error)
- func PayWithCustomData(keys []*Key, addresses []*Amounts, service Service, customData []byte) ([]byte, error)
- func SetLogger(logger *log.Logger)
- func SetUTXOSpent(hash []byte)
- type Amounts
- type BlockrService
- type Key
- type Micropayee
- type Micropayer
- 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 //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 Micropayee ¶
type Micropayee struct {
// contains filtered or unexported fields
}
Micropayee represents payee of Micropayment.
func NewMicropayee ¶
func NewMicropayee(key *Key, publicKey *PublicKey, service Service) (*Micropayee, error)
NewMicropayee creates new MicroPayee struct.
func (*Micropayee) IncrementPayment ¶
func (m *Micropayee) IncrementPayment(increment uint64, sign []byte) error
IncrementPayment increment payment ,creates transaction and store its tx into struct.
func (*Micropayee) SendLastPayment ¶
func (m *Micropayee) SendLastPayment() ([]byte, error)
SendLastPayment sends last incremented tx and returns tx hash.
func (*Micropayee) SignToRefund ¶
func (m *Micropayee) SignToRefund(txHash []byte, amount uint64, lockTime *time.Time) ([]byte, error)
SignToRefund create signature of refund tx.
type Micropayer ¶
type Micropayer struct {
// contains filtered or unexported fields
}
Micropayer represents payer of Micropayment.
func NewMicropayer ¶
func NewMicropayer(key *Key, publicKey *PublicKey, service Service) (*Micropayer, error)
NewMicropayer creates new MicroPayer struct.
func (*Micropayer) CreateBond ¶
func (m *Micropayer) CreateBond(keys []*Key, amount uint64) ([]byte, error)
CreateBond creates bond and return its hash.
func (*Micropayer) SendRefund ¶
func (m *Micropayer) SendRefund() ([]byte, error)
SendRefund sends refunt tx and returns tx hash. bond tx will be locked after sending thye refund (?).
func (*Micropayer) SignToIncrementedPayment ¶
func (m *Micropayer) SignToIncrementedPayment(increment uint64) ([]byte, error)
SignToIncrementedPayment creates signature for incremented payment tx.
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 TX ¶
TX represents transaction.
func (*TX) AttachCustomData ¶
AttachCustomData will attach custom data to transaction (passed through an OP_RETURN operator) 40 bytes max alloxwed by bitcoin protocol
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
base58
Package base58 implements a human-friendly base58 encoding.
|
Package base58 implements a human-friendly base58 encoding. |
Package btcec implements support for the elliptic curves needed for bitcoin.
|
Package btcec implements support for the elliptic curves needed for bitcoin. |