Documentation ¶
Index ¶
- Constants
- Variables
- func Hello() string
- func NewBip44Deriver(bip44Path string, seed []byte, chainID int) (bip44.Deriver, error)
- func NewCoin(bip44Path string, seed []byte, chainID int) (core.Coin, error)
- func NewFromMetadata(metadata core.MetadataProvider) (c core.Coin, err error)
- func NewMultiSigAddress(mRequired, chainID int, keys string) (string, error)
- type BTCAddress
- type BTCAmount
- type BTCOutputAmount
- type BTCTransaction
- type BTCUnspent
- type Btc
- type SignRawTransactionResult
Constants ¶
const ChainMainNet = internal.ChainMainNet
ChainMainNet 链:MainNet
const ChainRegtest = internal.ChainRegtest
ChainRegtest 链:Regression
const ChainTestNet3 = internal.ChainTestNet3
ChainTestNet3 链:TestNet3
Variables ¶
var New = internal.New
Functions ¶
func NewBip44Deriver ¶
NewBip44Deriver btc bip44 实现
func NewFromMetadata ¶
func NewFromMetadata(metadata core.MetadataProvider) (c core.Coin, err error)
NewFromMetadata .
Types ¶
type BTCAddress ¶
type BTCAddress struct {
// contains filtered or unexported fields
}
BTCAddress .
func NewBTCAddressFromString ¶
func NewBTCAddressFromString(addr string, chainID int) (address *BTCAddress, err error)
NewBTCAddressFromString converts a string to a address value.
type BTCAmount ¶
type BTCAmount struct {
// contains filtered or unexported fields
}
BTCAmount 对float64 的封装
func NewBTCAmount ¶
NewBTCAmount 数量in BTC (not in satoshi)
type BTCOutputAmount ¶
type BTCOutputAmount struct {
// contains filtered or unexported fields
}
BTCOutputAmount 交易输出
func (*BTCOutputAmount) Add ¶
func (baa *BTCOutputAmount) Add(address *BTCAddress, amount *BTCAmount)
Add 添加一个交易输出 address 地址 amount 金额
type BTCTransaction ¶
type BTCTransaction struct {
// contains filtered or unexported fields
}
BTCTransaction represents a single bitcoin transaction.
func InternalNewBTCTransaction ¶
func InternalNewBTCTransaction(unSpent *BTCUnspent, amounts *BTCOutputAmount, change *BTCAddress, feeRate int64, chainID int, manualTxOuts []*wire.TxOut) (tr *BTCTransaction, err error)
InternalNewBTCTransaction 内部用,构造btc transaction
func NewBTCTransaction ¶
func NewBTCTransaction(unSpent *BTCUnspent, amounts *BTCOutputAmount, change *BTCAddress, feeRate int64, chainID int) (tr *BTCTransaction, err error)
NewBTCTransaction creates a new bitcoin transaction with the given properties. unSpent : listUnspent amounts: toAddress + amount change: 找零地址 feeRate: 单位手续费/byte testNet: 测试网络传true
func (BTCTransaction) Encode ¶
func (tx BTCTransaction) Encode() (string, error)
Encode encode to raw transaction
func (BTCTransaction) EncodeToSignCmd ¶
func (tx BTCTransaction) EncodeToSignCmd() (string, error)
EncodeToSignCmd 结果可以用于签名接口
func (BTCTransaction) EncodeToSignCmdForNextSigner ¶
func (tx BTCTransaction) EncodeToSignCmdForNextSigner(signedRawTX string) (string, error)
EncodeToSignCmdForNextSigner 构造给下个签名者签名的命令, signedRawTX: 当前签名者已签名好的交易数据
func (BTCTransaction) GetFee ¶
func (tx BTCTransaction) GetFee() (float64, error)
GetFee 获取目前的费率(in BTC, not satoshi) Returns the miner's fee for the current transaction
type BTCUnspent ¶
type BTCUnspent struct {
// contains filtered or unexported fields
}
BTCUnspent represents a single bitcoin transaction.
type SignRawTransactionResult ¶
type SignRawTransactionResult struct { Hex string Changed bool //is raw tx changed Complete bool //multi input,multisig require meetted Errors string }
SignRawTransactionResult 签名结果
func SignRawTransactionWithKey ¶
func SignRawTransactionWithKey(hexstring string, privateKeyWif string, unspents *BTCUnspent, chainFlag int) (*SignRawTransactionResult, error)
SignRawTransactionWithKey Refer to https://bitcoin.org/en/developer-reference#signrawtransactionwithkey Diff from rpc:
sighashtype is set to "ALL" single private key
func SignTransaction ¶
func SignTransaction(tx *BTCTransaction, privateKeyWif string, chainFlag int) (*SignRawTransactionResult, error)
SignTransaction signs tx with wif privateKey tx: transaction privateKeyWif: private key in wallet import format(wif) chainFlag: chain id
return: { changed: (bool, 签名后的内容是否发生变化,), complete: (bool, 含不同地址的输入或多重签名情况下即使提供正确的私钥也可能存在签名未完成的情况), hex: (string, 前后的rawTransactionHex) errors: (string 可作为调试参考的错误信息) }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
helpers
Package helpers provides convenience functions to simplify wallet code.
|
Package helpers provides convenience functions to simplify wallet code. |
txauthor
Package txauthor provides transaction creation code for wallets.
|
Package txauthor provides transaction creation code for wallets. |
txrules
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining.
|
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining. |