Documentation
¶
Index ¶
- Variables
- func CalculateFee(inputs, outputs int, feePerByte int64) int64
- func CreateRawTransaction(inputs []Input, outputs []Output) ([]byte, error)
- func CreateScriptPubKey(publicKeyBase58 string) ([]byte, error)
- func CreateTransaction(client BitcoinClient, origins []Origin, destinations []Destination, ...) ([]byte, error)
- func GenerateKeyPair() (string, string, error)
- func GetRawTransactionSignature(rawTransaction []byte, pk string) ([]byte, error)
- func PubKeyToAddress(pubKey string, testNet bool) (string, []byte, error)
- func Test(b bool) bool
- type BitcoinClient
- type Destination
- type GetRawTransactionResponseError
- type GetRawTransactionResponseResult
- type GetRawTransactionResponseResultInput
- type GetRawTransactionResponseResultInputSig
- type GetRawTransactionResponseResultOutput
- type GetRawTransactionResponseResultOutputScriptPubKey
- type Input
- type JsonRpcError
- type JsonRpcResponse
- type Origin
- type OriginWithAmount
- type Output
- type Sender
Constants ¶
This section is empty.
Variables ¶
var IdMismatch = errors.New("Ids do not match!")
var IsTest = false
var JsonRpcMessage = `{"jsonrpc":"%s","id":%v,"method":"%s","params":%s}`
var JsonRpcVersion = "1.0"
var SatoshiPerByte = int64(200)
The steps notated in the variable names here relate to the steps outlined in https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
var WeRequireAdditionalFunds = errors.New("Wallet address contains insufficient funds")
Errors
Functions ¶
func CalculateFee ¶
func CreateRawTransaction ¶
NOTE: This function presumes you're doing a pay to public key hash
* transaction and using a single script to authenticate the entire thing. More * complex stuff will come later.
func CreateScriptPubKey ¶
func CreateTransaction ¶
func CreateTransaction(client BitcoinClient, origins []Origin, destinations []Destination, sender Sender, feePerByte int64) ([]byte, error)
func GenerateKeyPair ¶
Types ¶
type BitcoinClient ¶
type BitcoinClient struct {
IsTest bool
Commands []string
Username string
Password string
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, host, username, password string) BitcoinClient
New creates a new RPC client based on the provided connection configuration details. The notification handlers parameter may be nil if you are not interested in receiving notifications and will be ignored if the configuration is set to run in HTTP POST mode.
func (*BitcoinClient) GetRawTransaction ¶
func (btcc *BitcoinClient) GetRawTransaction(txId string) (*JsonRpcResponse, error)
func (BitcoinClient) Post ¶
func (c BitcoinClient) Post(jsonRpcCommand string, id int64) (*JsonRpcResponse, error)
func (*BitcoinClient) SendRawTransaction ¶
func (btcc *BitcoinClient) SendRawTransaction(rawTransaction []byte) (string, error)
type Destination ¶
A Destination is the boiled-back simplistic form of a Bitcoin Output, denoting only the basics - where you want the money to end up, and how much of it you want there.
type GetRawTransactionResponseResultInput ¶
type GetRawTransactionResponseResultInput struct {
Txid string
Vout int
Scriptsig GetRawTransactionResponseResultInputSig
Txinwitness []string
Sequence int64
}
type GetRawTransactionResponseResultOutput ¶
type GetRawTransactionResponseResultOutput struct {
N int
Value float64
Scriptpubkey GetRawTransactionResponseResultOutputScriptPubKey
}
type Input ¶
type Input struct {
TxId string
OutputIndex int
ScriptSig []byte // This is not to be confused with the 'Script' of the Output. This is the key to the Script's lock.
}
An Input is a slightly more complete form of a Bitcoin Input, denoting everything the base algorithms need to do their job.
func OriginToInput ¶
type JsonRpcError ¶
type JsonRpcResponse ¶
type JsonRpcResponse struct {
Id int64 `json:"id"`
JsonRpcVersion string `json:"jsonrpc"`
Result ej.RawMessage `json:"result"`
Error JsonRpcError `json:"error"`
}
type Origin ¶
An Origin is the boiled-back simpistic form of a Bitcoin Input, denoting only the basics - where you want the money to come from.
func InputToOrigin ¶
func OriginsWithAmountToOrigins ¶
func OriginsWithAmountToOrigins(oris []OriginWithAmount) []Origin
type OriginWithAmount ¶
An OriginWithAmount is the boiled-back simpistic form of a Bitcoin Input, denoting where you want the money to come from and the amount.
func GetBitcoinTransactions ¶
func GetBitcoinTransactions(ctx context.Context, address string) ([]OriginWithAmount, error)
func PruneOriginsWithAmount ¶
func PruneOriginsWithAmount(oris []OriginWithAmount, amount int64) ([]OriginWithAmount, error)
type Output ¶
An Output is a slightly more complete from of a Bitcoin Output, denoting everything the base algorithms need to do their job.
func DestinationToOutput ¶
func DestinationToOutput(d Destination) Output