Documentation ¶
Overview ¶
description: keybox
@author: xwc1125 @date: 2020/8/21 0021
description: keybox
@author: xwc1125 @date: 2020/8/24 0024
description: keybox
@author: xwc1125 @date: 2020/8/21 0021
description: keybox
@author: xwc1125 @date: 2020/8/21 0021
Index ¶
- func CreateMultiSig(cmd *btcjson.CreateMultisigCmd, chainParam *chaincfg.Params) (*btcjson.CreateMultiSigResult, error)
- func DecodeScript(c *btcjson.DecodeScriptCmd, chainCfg *chaincfg.Params) (reply btcjson.DecodeScriptResult, err error)
- func ParseNetworkToConf(network string) (*chaincfg.Params, error)
- func SignRawTransaction(cmd *SignRawTransactionCmd, chainCfg *chaincfg.Params) (*btcjson.SignRawTransactionResult, error)
- type BTCAddress
- type BTCAmount
- type BTCOutput
- type BTCTransaction
- type BTCUnspent
- type Chain
- func (a *Chain) ChainInfo() *keybox.ChainInfo
- func (a *Chain) ExportPrivateKey(priKey []byte, isCompressPubKey bool) (string, error)
- func (a *Chain) ExportPrivateKey2(priKey []byte, isCompressPubKey bool) (string, error)
- func (a *Chain) GetAddressFromPubKey(pubKey []byte) (string, error)
- func (c *Chain) SignRawTx(rawTx, privateKeyWif string) (signedRawTx string, err error)
- func (a *Chain) SignToStr(priKey []byte, rawTxBytes []byte) (string, error)
- type CustomHexMsg
- type RawTxInput
- type SignRawTransactionCmd
- type SignatureError
- type WalletTx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMultiSig ¶
func CreateMultiSig(cmd *btcjson.CreateMultisigCmd, chainParam *chaincfg.Params) (*btcjson.CreateMultiSigResult, error)
CreateMultiSig handles an createmultisig request by returning a multisig address for the given inputs. This method is originally copied and modified from https://github.com/btcsuite/btcwallet/blob/master/rpc/legacyrpc/methods.go
func DecodeScript ¶
func DecodeScript(c *btcjson.DecodeScriptCmd, chainCfg *chaincfg.Params) (reply btcjson.DecodeScriptResult, err error)
DecodeScript handles decodescript commands.
func SignRawTransaction ¶
func SignRawTransaction(cmd *SignRawTransactionCmd, chainCfg *chaincfg.Params) (*btcjson.SignRawTransactionResult, error)
SignRawTransaction handles the signrawtransaction command.
Types ¶
type BTCAddress ¶
type BTCAddress struct {
// contains filtered or unexported fields
}
func NewBTCAddressFromString ¶
func NewBTCAddressFromString(addr string, network string) (address *BTCAddress, err error)
将地址字符串转为BTC地址
type BTCAmount ¶
type BTCAmount struct {
// contains filtered or unexported fields
}
BTCAmount 对float64 的封装
func NewBTCAmount ¶
NewBTCAmount 数量in BTC (not in satoshi)
type BTCOutput ¶
type BTCOutput struct {
// contains filtered or unexported fields
}
BTCOutputAmount 交易输出
func (*BTCOutput) Add ¶
func (baa *BTCOutput) Add(address *BTCAddress, amount *BTCAmount)
Add 添加一个交易输出 address 地址 amount 金额
type BTCTransaction ¶
type BTCTransaction struct {
// contains filtered or unexported fields
}
func InternalNewBTCTransaction ¶
func InternalNewBTCTransaction(unSpent *BTCUnspent, amounts *BTCOutput, change *BTCAddress, feeRate int64, network string, manualTxOuts []*wire.TxOut) (tr *BTCTransaction, err error)
InternalNewBTCTransaction 内部用,构造btc transaction
func NewBTCTransaction ¶
func NewBTCTransaction(unSpent *BTCUnspent, amounts *BTCOutput, change *BTCAddress, feeRate int64, network string) (tr *BTCTransaction, err error)
NewBTCTransaction creates a new bitcoin transaction with the given properties. unSpent : listUnspent amounts: toAddress + amount change: 找零地址 feeRate: 单位手续费/byte network: 网络类型(mainnet,testnet,testnet3)
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 Chain ¶
func NewChain ¶
func NewChain(networkType chain.NetworkType) *Chain
func (*Chain) ExportPrivateKey ¶
比特币中的netId就是PrivateKeyID[wifPrvkey]
func (*Chain) ExportPrivateKey2 ¶
比特币中的netId就是PrivateKeyID[wifPrvkey]
func (*Chain) GetAddressFromPubKey ¶
从公钥获取地址
type CustomHexMsg ¶
type CustomHexMsg struct { SignRawTransactionCmd DecodeTransaction func(cmd *btcjson.DecodeRawTransactionCmd, params *chaincfg.Params) ( btcjson.TxRawDecodeResult, error) `json:"-,omitempty"` SignTransaction func() `json:"-,omitempty"` // contains filtered or unexported fields }
服务端发送的消息 "{hex:"",rawTxInput:[{scriptPubKey:"xxx",redeemScript:"xxx",amount:0}]}"
func (*CustomHexMsg) MarshalJSON ¶
func (c *CustomHexMsg) MarshalJSON() ([]byte, error)
func (*CustomHexMsg) MarshalToWalletTxJSON ¶
func (c *CustomHexMsg) MarshalToWalletTxJSON(chainCfg *chaincfg.Params) (tx string, err error)
func (*CustomHexMsg) UnmarshalJSON ¶
func (c *CustomHexMsg) UnmarshalJSON(msg string) (err error)
type RawTxInput ¶
type RawTxInput struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptPubKey string `json:"scriptPubKey"` RedeemScript string `json:"redeemScript"` Amount float64 `json:"amount,omitempty"` // only for bch }
RawTxInput models the data needed for raw transaction input that is used in the SignRawTransactionCmd struct.
type SignRawTransactionCmd ¶
type SignRawTransactionCmd struct { RawTx string Inputs *[]RawTxInput PrivKeys *[]string Flags *string `default:"\"ALL\""` }
SignRawTransactionCmd defines the signrawtransaction JSON-RPC command.
func NewSignRawTransactionCmd ¶
func NewSignRawTransactionCmd(hexEncodedTx string, inputs *[]RawTxInput, privKeys *[]string, flags *string) *SignRawTransactionCmd
NewSignRawTransactionCmd returns a new instance which can be used to issue a signrawtransaction JSON-RPC command.
The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.
type SignatureError ¶
SignatureError records the underlying error when validating a transaction input signature.
type WalletTx ¶
type WalletTx struct { Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Vin []vin `json:"vin"` Vout []vout `json:"vout"` }
WalletTx 钱包可读数据
* version : 2 * locktime : 0 * vin : [{"txid":"07d25a5793dd24cd6d1a810d8bb2958c271ed1971d7e1fb823217a1947170fed","output":0,"sequence":4294967295,"address":"38pfGw2jtkRvwJqXYqLtcFbPS7gHmkWfsN"}] * vout : [{"address":"38pfGw2jtkRvwJqXYqLtcFbPS7gHmkWfsN","amount":0.084},{"address":"1QLGpxXUfJUVfVNDUJsuQ4dxBppgeuGX5R","amount":0.1}]
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package helpers provides convenience functions to simplify wallet code.
|
Package helpers provides convenience functions to simplify wallet code. |
Package txauthor provides transaction creation code for wallets.
|
Package txauthor provides transaction creation code for wallets. |
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. |