Documentation ¶
Index ¶
- type AddMultisigAddressResult
- type AddrsPrevTxs
- type Bitcoin
- func (b *Bitcoin) AddMultisigAddress(requiredSigs int, addresses []string, accountName string, ...) (*AddMultisigAddressResult, error)
- func (b *Bitcoin) AmountString(amt btcutil.Amount) string
- func (b *Bitcoin) BackupWallet(fileName string) error
- func (b *Bitcoin) CastStrBitToAmount(s string) (btcutil.Amount, error)
- func (b *Bitcoin) CastStrSatoshiToAmount(s string) (btcutil.Amount, error)
- func (b *Bitcoin) Client() *rpcclient.Client
- func (b *Bitcoin) Close()
- func (b *Bitcoin) CoinType() enum.CoinType
- func (b *Bitcoin) ConfirmationBlock() int
- func (b *Bitcoin) CreateNewAddress(accountName string) (btcutil.Address, error)
- func (b *Bitcoin) CreateRawTransaction(sendAddr string, amount btcutil.Amount, inputs []btcjson.TransactionInput) (*wire.MsgTx, error)
- func (b *Bitcoin) CreateRawTransactionWithOutput(inputs []btcjson.TransactionInput, outputs map[btcutil.Address]btcutil.Amount) (*wire.MsgTx, error)
- func (b *Bitcoin) CreateWallet(fileName string, disablePrivKey bool) error
- func (b *Bitcoin) DecodeAddress(addr string) (btcutil.Address, error)
- func (b *Bitcoin) DecodeRawTransaction(hexTx string) (*btcjson.TxRawResult, error)
- func (b *Bitcoin) DumpWallet(fileName string) error
- func (b *Bitcoin) EncryptWallet(passphrase string) error
- func (b *Bitcoin) EstimateSmartFee() (float64, error)
- func (b *Bitcoin) FeeRangeMax() float64
- func (b *Bitcoin) FeeRangeMin() float64
- func (b *Bitcoin) FloatBitToAmount(f float64) (btcutil.Amount, error)
- func (b *Bitcoin) FundRawTransaction(hex string) (*FundRawTransactionResult, error)
- func (b *Bitcoin) GetAccount(addr string) (string, error)
- func (b *Bitcoin) GetAccountAddress(accountName string) (btcutil.Address, error)
- func (b *Bitcoin) GetAddressInfo(addr string) (*GetAddressInfoResult, error)
- func (b *Bitcoin) GetAddressesByAccount(accountName string) ([]btcutil.Address, error)
- func (b *Bitcoin) GetAddressesByLabel(labelName string) ([]btcutil.Address, error)
- func (b *Bitcoin) GetBalanceByAccount(accountName string) (btcutil.Amount, error)
- func (b *Bitcoin) GetBlockCount() (int64, error)
- func (b *Bitcoin) GetChainConf() *chaincfg.Params
- func (b *Bitcoin) GetFee(tx *wire.MsgTx, adjustmentFee float64) (btcutil.Amount, error)
- func (b *Bitcoin) GetNetworkInfo() (*GetNetworkInfoResult, error)
- func (b *Bitcoin) GetRawTransactionByHex(strHashTx string) (*btcutil.Tx, error)
- func (b *Bitcoin) GetReceivedByAccountAndMinConf(accountName string, minConf int) (btcutil.Amount, error)
- func (b *Bitcoin) GetReceivedByLabelAndMinConf(accountName string, minConf int) (btcutil.Amount, error)
- func (b *Bitcoin) GetTransactionByTxID(txID string) (*btcjson.GetTransactionResult, error)
- func (b *Bitcoin) GetTransactionFee(tx *wire.MsgTx) (btcutil.Amount, error)
- func (b *Bitcoin) GetTxOutByTxID(txID string, index uint32) (*btcjson.GetTxOutResult, error)
- func (b *Bitcoin) ImportAddress(pubkey string) error
- func (b *Bitcoin) ImportAddressWithLabel(address, label string, rescan bool) error
- func (b *Bitcoin) ImportAddressWithoutReScan(pubkey string) error
- func (b *Bitcoin) ImportPrivKey(privKeyWIF *btcutil.WIF) error
- func (b *Bitcoin) ImportPrivKeyLabel(privKeyWIF *btcutil.WIF, label string) error
- func (b *Bitcoin) ImportPrivKeyWithoutReScan(privKeyWIF *btcutil.WIF, label string) error
- func (b *Bitcoin) ImportWallet(fileName string) error
- func (b *Bitcoin) ListAccounts() (map[string]btcutil.Amount, error)
- func (b *Bitcoin) ListUnspent() ([]ListUnspentResult, error)
- func (b *Bitcoin) ListUnspentByAccount(accountType enum.AccountType) ([]ListUnspentResult, []btcutil.Address, error)
- func (b *Bitcoin) LoadWallet(fileName string) error
- func (b *Bitcoin) LockUnspent(tx btcjson.ListUnspentResult) error
- func (b *Bitcoin) Logging() (*LoggingResult, error)
- func (b *Bitcoin) SendTransactionByByte(rawTx []byte) (*chainhash.Hash, error)
- func (b *Bitcoin) SendTransactionByHex(hex string) (*chainhash.Hash, error)
- func (b *Bitcoin) SetAccount(addr, account string) error
- func (b *Bitcoin) SetChainConf(conf *chaincfg.Params)
- func (b *Bitcoin) SetChainConfNet(btcNet wire.BitcoinNet)
- func (b *Bitcoin) SetCoinType(coinType enum.CoinType)
- func (b *Bitcoin) SetLabel(addr, label string) error
- func (b *Bitcoin) SetVersion(ver enum.BTCVersion)
- func (b *Bitcoin) Sign(tx *wire.MsgTx, strPrivateKey string) (string, error)
- func (b *Bitcoin) SignRawTransaction(tx *wire.MsgTx, prevtxs []PrevTx) (*wire.MsgTx, bool, error)
- func (b *Bitcoin) SignRawTransactionWithKey(tx *wire.MsgTx, privKeysWIF []string, prevtxs []PrevTx) (*wire.MsgTx, bool, error)
- func (b *Bitcoin) ToHex(tx *wire.MsgTx) (string, error)
- func (b *Bitcoin) ToMsgTx(txHex string) (*wire.MsgTx, error)
- func (b *Bitcoin) UnLoadWallet(fileName string) error
- func (b *Bitcoin) UnlockAllUnspentTransaction() error
- func (b *Bitcoin) ValidateAddress(addr string) (*btcjson.ValidateAddressWalletResult, error)
- func (b *Bitcoin) Version() enum.BTCVersion
- func (b *Bitcoin) WalletLock() error
- func (b *Bitcoin) WalletPassphrase(passphrase string, timeoutSecs int64) error
- func (b *Bitcoin) WalletPassphraseChange(old, new string) error
- type EstimateSmartFeeResult
- type FeeAdjustmentRate
- type FundRawTransactionResult
- type GetAddressInfoResult
- type GetNetworkInfoResult
- type Label
- type ListUnspentResult
- type LoadWalletResult
- type LoggingResult
- type Network
- type PrevTx
- type Purpose
- type SignRawTransactionError
- type SignRawTransactionResult
- type WalletResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddMultisigAddressResult ¶
type AddMultisigAddressResult struct { Address string `json:"address"` RedeemScript string `json:"redeemScript"` }
AddMultisigAddressResult addmultisigaddressをcallしたresponseの型
type AddrsPrevTxs ¶
type AddrsPrevTxs struct { Addrs []string PrevTxs []PrevTx SenderAccount enum.AccountType }
AddrsPrevTxs multisig用トランザクション生成時に必要な情報群
type Bitcoin ¶
type Bitcoin struct {
// contains filtered or unexported fields
}
Bitcoin includes Client to call Json-RPC
func NewBitcoin ¶
NewBitcoin Bitcoinオブジェクトを返す
func (*Bitcoin) AddMultisigAddress ¶
func (b *Bitcoin) AddMultisigAddress(requiredSigs int, addresses []string, accountName string, addressType enum.AddressType) (*AddMultisigAddressResult, error)
AddMultisigAddress マルチシグを Rawトランザクション用に作成する
- requiredSigs: 取引成立に必要なサイン数
- addresses: 自分のアドレス+承認者のアドレスxN をいれていく
clientのアドレスは不要。payment/receiptのアドレスはmultisig対応しておくこと
func (*Bitcoin) AmountString ¶
AmountString 1.0 BTCといったstringを1.0という単位を除いたstringとして返す
func (*Bitcoin) BackupWallet ¶
BackupWallet walletファイルをunloadする
Safely copies current wallet file to destination, which can be a directory or a path with filename
func (*Bitcoin) CastStrBitToAmount ¶
CastStrBitToAmount string型のBitcoinをAmountに変換する
func (*Bitcoin) CastStrSatoshiToAmount ¶
CastStrSatoshiToAmount string型のSatoshiをAmountに変換する
func (*Bitcoin) ConfirmationBlock ¶
ConfirmationBlock Confirmationに必要なブロック数を返す
func (*Bitcoin) CreateNewAddress ¶
CreateNewAddress アカウント名から新しいアドレスを生成する 常に新しいアドレスが生成される これによって作成されたアカウントはbitcoin core側のwalletで管理される TODO:おそらく本番では使わない
func (*Bitcoin) CreateRawTransaction ¶
func (b *Bitcoin) CreateRawTransaction(sendAddr string, amount btcutil.Amount, inputs []btcjson.TransactionInput) (*wire.MsgTx, error)
CreateRawTransaction Rawトランザクションを作成する
=> watch only wallet(online)で利用されることを想定
こちらは多対1用の送金、つまり入金時、集約用アドレスに一括して送信するケースで利用することを想定 [Noted] 手数料を考慮せず、全額送金しようとすると、SendRawTransaction()で、`min relay fee not met`エラーが発生する
func (*Bitcoin) CreateRawTransactionWithOutput ¶
func (b *Bitcoin) CreateRawTransactionWithOutput(inputs []btcjson.TransactionInput, outputs map[btcutil.Address]btcutil.Amount) (*wire.MsgTx, error)
CreateRawTransactionWithOutput 出金時に1対多で送信する場合に利用するトランザクションを作成する
func (*Bitcoin) CreateWallet ¶
CreateWallet Creates and loads a new wallet
func (*Bitcoin) DecodeAddress ¶
DecodeAddress string型のアドレスをDecodeしてAddress型に変換する
func (*Bitcoin) DecodeRawTransaction ¶
func (b *Bitcoin) DecodeRawTransaction(hexTx string) (*btcjson.TxRawResult, error)
DecodeRawTransaction Hex stringをデコードして、Rawのトランザクションデータに変換する
func (*Bitcoin) DumpWallet ¶
DumpWallet walletを指定したファイル名でdumpする (これをすることでkeyの存在しないwalletが作られるはず)
fileNameは絶対パス This does not allow overwriting existing files.
func (*Bitcoin) EncryptWallet ¶
EncryptWallet Walletの初回パスフレーズを設定 0.16.2の場合、`encryptwallet`というmethod名になっている。これは古いのかも
func (*Bitcoin) EstimateSmartFee ¶
EstimateSmartFee bitcoin coreの`estimatesmartfee`APIをcallする 戻り値はBTC/kB(float64)
func (*Bitcoin) FloatBitToAmount ¶
FloatBitToAmount BTC(float64)をSatoshi(Amount)に変換する e.g. 0.54 to 54000000
func (*Bitcoin) FundRawTransaction ¶
func (b *Bitcoin) FundRawTransaction(hex string) (*FundRawTransactionResult, error)
FundRawTransaction 送信したい金額に応じて、自動的にutxoを算出してくれる 未使用のため、コメントアウトしておいてもいいかも
func (*Bitcoin) GetAccount ¶
GetAccount 渡されたアドレスから該当するアカウント名を取得する
func (*Bitcoin) GetAccountAddress ¶
GetAccountAddress アカウントに紐づくアドレスを返す Deprecated, will be removed in V0.18.
func (*Bitcoin) GetAddressInfo ¶
func (b *Bitcoin) GetAddressInfo(addr string) (*GetAddressInfoResult, error)
GetAddressInfo getaddressinfo RPC をcallする version0.18より、getaccountは呼び出せなくなるので、こちらをcallすること 従来のvalidateaddressより取得していたaddressの詳細情報もこちらから取得可能
func (*Bitcoin) GetAddressesByAccount ¶
GetAddressesByAccount アカウント名から紐づくすべてのアドレスを取得する
func (*Bitcoin) GetAddressesByLabel ¶
GetAddressesByLabel 指定したラベルに紐づくaddressをすべて返す
func (*Bitcoin) GetBalanceByAccount ¶
GetBalanceByAccount アカウントに対してのBalanceを取得する
func (*Bitcoin) GetChainConf ¶
GetChainConf 接続先であるMainNet/TestNetに応じて必要なconfを返す
func (*Bitcoin) GetNetworkInfo ¶
func (b *Bitcoin) GetNetworkInfo() (*GetNetworkInfoResult, error)
GetNetworkInfo getnetworkinfo RPC をcallする
func (*Bitcoin) GetRawTransactionByHex ¶
GetRawTransactionByHex Hexからトランザクションを取得する
func (*Bitcoin) GetReceivedByAccountAndMinConf ¶
func (b *Bitcoin) GetReceivedByAccountAndMinConf(accountName string, minConf int) (btcutil.Amount, error)
GetReceivedByAccountAndMinConf アカウントに対してのBalanceを取得する
func (*Bitcoin) GetReceivedByLabelAndMinConf ¶
func (b *Bitcoin) GetReceivedByLabelAndMinConf(accountName string, minConf int) (btcutil.Amount, error)
GetReceivedByLabelAndMinConf ラベルに対してのBalanceを取得する
func (*Bitcoin) GetTransactionByTxID ¶
func (b *Bitcoin) GetTransactionByTxID(txID string) (*btcjson.GetTransactionResult, error)
GetTransactionByTxID txIDからトランザクション詳細を取得する
func (*Bitcoin) GetTransactionFee ¶
GetTransactionFee トランザクションサイズからfeeを算出する
func (*Bitcoin) GetTxOutByTxID ¶
GetTxOutByTxID TxOutを指定したトランザクションIDから取得する
func (*Bitcoin) ImportAddress ¶
ImportAddress アドレスをwalletにimportする
func (*Bitcoin) ImportAddressWithLabel ¶
ImportAddressWithLabel address, label, rescanをパラメータとしaddressをwalletにimportする
func (*Bitcoin) ImportAddressWithoutReScan ¶
ImportAddressWithoutReScan Rescanせずにアドレスをwalletにimportする
func (*Bitcoin) ImportPrivKey ¶
ImportPrivKey WIFをwalletに登録する
func (*Bitcoin) ImportPrivKeyLabel ¶
ImportPrivKeyLabel WIFをwalletに登録する、label付き
func (*Bitcoin) ImportPrivKeyWithoutReScan ¶
ImportPrivKeyWithoutReScan WIFをwalletに登録する、rescanはしない
func (*Bitcoin) ImportWallet ¶
ImportWallet walletファイルをimportする
func (*Bitcoin) ListAccounts ¶
ListAccounts これは単純にアカウントの資産一覧が表示されるだけ
func (*Bitcoin) ListUnspent ¶
func (b *Bitcoin) ListUnspent() ([]ListUnspentResult, error)
ListUnspent listunspentを呼び出す
func (*Bitcoin) ListUnspentByAccount ¶
func (b *Bitcoin) ListUnspentByAccount(accountType enum.AccountType) ([]ListUnspentResult, []btcutil.Address, error)
ListUnspentByAccount 指定したアカウントのlistunspentを取得する
func (*Bitcoin) LoadWallet ¶
LoadWallet walletファイルをimportする
Loads a wallet from a wallet file or directory. Note that all wallet command-line options used when starting bitcoind will be applied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc). e.g. bitcoin-cli loadwallet "test.dat"
func (*Bitcoin) LockUnspent ¶
func (b *Bitcoin) LockUnspent(tx btcjson.ListUnspentResult) error
LockUnspent 渡されたtxIDをロックする
func (*Bitcoin) Logging ¶
func (b *Bitcoin) Logging() (*LoggingResult, error)
Logging logging RPC をcallする
func (*Bitcoin) SendTransactionByByte ¶
SendTransactionByByte 外部から渡されたバイト列からRawトランザクションを送信する オンラインで実行される必要がある
func (*Bitcoin) SendTransactionByHex ¶
SendTransactionByHex 外部から渡されたバイト列からRawトランザクションを送信する オンラインで実行される必要があるため、watchOnlyWallet専用
func (*Bitcoin) SetAccount ¶
SetAccount 既存のimport済のアドレスにアカウント名をセットする
func (*Bitcoin) SetChainConf ¶
SetChainConf chainConfをセットする
func (*Bitcoin) SetChainConfNet ¶
func (b *Bitcoin) SetChainConfNet(btcNet wire.BitcoinNet)
SetChainConfNet conf.Netをセットする
func (*Bitcoin) SetCoinType ¶
SetCoinType CoinTypeをセットする
func (*Bitcoin) SetLabel ¶
SetLabel 既存のimport済のアドレスにラベル名をセットする version0.18より、setaccountは呼び出せなくなるので、SetLabel()をcallすること
func (*Bitcoin) SetVersion ¶
func (b *Bitcoin) SetVersion(ver enum.BTCVersion)
SetVersion バージョン情報をセットする
func (*Bitcoin) Sign ¶
Sign 署名を行う without Bitcoin Core [WIP] FIXME: これはColdWallet内で必要となるが、BitcoinCoreの機能が必要ないので、あれば実装しておきたい
func (*Bitcoin) SignRawTransaction ¶
SignRawTransaction *wire.MsgTxからRawのトランザクションに署名する 入金時のトランザクション(multisigではないトランザクション)用
func (*Bitcoin) SignRawTransactionWithKey ¶
func (b *Bitcoin) SignRawTransactionWithKey(tx *wire.MsgTx, privKeysWIF []string, prevtxs []PrevTx) (*wire.MsgTx, bool, error)
SignRawTransactionWithKey Multisig時、トランザクションへ署名をする Multisigの場合はこちら For above ver17
func (*Bitcoin) UnLoadWallet ¶
UnLoadWallet walletファイルをunloadする
Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument. Specifying the wallet name on a wallet endpoint is invalid. e.g. bitcoin-cli unloadwallet wallet_name
func (*Bitcoin) UnlockAllUnspentTransaction ¶
UnlockAllUnspentTransaction Lockされたトランザクションの解除
func (*Bitcoin) ValidateAddress ¶
func (b *Bitcoin) ValidateAddress(addr string) (*btcjson.ValidateAddressWalletResult, error)
ValidateAddress 渡されたアドレスの整合性をチェックする TODO: こちらの機能はCayenne側でも必要だが、Cayenneから直接利用する場合、Bitcoin Coreの機能に依存しているので、煩雑になってしまう
func (*Bitcoin) WalletLock ¶
WalletLock walletにロックをかける(walletpassphraseによってロックを解除するまで利用できない)
func (*Bitcoin) WalletPassphrase ¶
WalletPassphrase ロックを解除する
func (*Bitcoin) WalletPassphraseChange ¶
WalletPassphraseChange パスフレーズを変更する
type EstimateSmartFeeResult ¶
type EstimateSmartFeeResult struct { FeeRate float64 `json:"feerate"` Errors []string `json:"errors"` Blocks int64 `json:"blocks"` }
EstimateSmartFeeResult estimatesmartfeeをcallしたresponseの型
type FeeAdjustmentRate ¶
type FeeAdjustmentRate struct {
// contains filtered or unexported fields
}
FeeAdjustmentRate 手数料調整のRange
type FundRawTransactionResult ¶
type FundRawTransactionResult struct { Hex string `json:"hex"` Fee int64 `json:"fee"` Changepos int64 `json:"changepos"` }
FundRawTransactionResult fundrawtransactionをcallしたresponseの型
type GetAddressInfoResult ¶
type GetAddressInfoResult struct { Address string `json:"address"` ScriptPubKey string `json:"scriptPubKey"` Ismine bool `json:"ismine"` Iswatchonly bool `json:"iswatchonly"` Isscript bool `json:"isscript"` Iswitness bool `json:"iswitness"` Script string `json:"script"` Hex string `json:"hex"` Pubkey string `json:"pubkey"` Embedded struct { Isscript bool `json:"isscript"` Iswitness bool `json:"iswitness"` WitnessVersion int `json:"witness_version"` WitnessProgram string `json:"witness_program"` Pubkey string `json:"pubkey"` Address string `json:"address"` ScriptPubKey string `json:"scriptPubKey"` } `json:"embedded"` Label string `json:"label"` Timestamp int64 `json:"timestamp"` Labels []Label `json:"labels"` }
GetAddressInfoResult getaddressinfoをcallしたresponseの型
type GetNetworkInfoResult ¶
type GetNetworkInfoResult struct { Version enum.BTCVersion `json:"version"` Subversion string `json:"subversion"` Protocolversion int `json:"protocolversion"` Localservices string `json:"localservices"` Localrelay bool `json:"localrelay"` Timeoffset int `json:"timeoffset"` Networkactive bool `json:"networkactive"` Connections int `json:"connections"` Networks []Network `json:"networks"` Relayfee float64 `json:"relayfee"` Incrementalfee float64 `json:"incrementalfee"` Localaddresses []string `json:"localaddresses"` Warnings string `json:"warnings"` }
GetNetworkInfoResult getnetworkinfo RPC のレスポンス
type ListUnspentResult ¶
type ListUnspentResult struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` Address string `json:"address"` Label string `json:"label"` //to account ScriptPubKey string `json:"scriptPubKey"` Amount float64 `json:"amount"` Confirmations int64 `json:"confirmations"` RedeemScript string `json:"redeemScript"` Spendable bool `json:"spendable"` Solvable bool `json:"solvable"` //new Safe bool `json:"safe"` //new }
ListUnspentResult listunspentの戻り値
type LoadWalletResult ¶
LoadWalletResult loadwallet/createwallet RPCのレスポンス
type LoggingResult ¶
type LoggingResult struct { Net int64 `json:"net"` Tor int64 `json:"tor"` Mempool int64 `json:"mempool"` HTTP int64 `json:"http"` Bench int64 `json:"bench"` Zmq int64 `json:"zmq"` DB int64 `json:"db"` RPC int64 `json:"rpc"` EstimateFee int64 `json:"estimatefee"` Addrman int64 `json:"addrman"` SelectCoins int64 `json:"selectcoins"` ReIndex int64 `json:"reindex"` CmpctBlock int64 `json:"cmpctblock"` Rand int64 `json:"rand"` Prune int64 `json:"prune"` Proxy int64 `json:"proxy"` MempoolRej int64 `json:"mempoolrej"` LibEvent int64 `json:"libevent"` CoinDB int64 `json:"coindb"` Qt int64 `json:"qt"` LevelDB int64 `json:"leveldb"` }
LoggingResult logging RPC のレスポンス
type Network ¶
type Network struct { Name string `json:"name"` Limited bool `json:"limited"` Reachable bool `json:"reachable"` Proxy string `json:"proxy"` ProxyRandomizeCredentials bool `json:"proxy_randomize_credentials"` }
Network ネットワーク情報
type PrevTx ¶
type PrevTx struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptPubKey string `json:"scriptPubKey"` RedeemScript string `json:"redeemScript"` Amount float64 `json:"amount"` }
PrevTx multisig時のsignrawtransactionで必要なパラメータ
type SignRawTransactionError ¶
type SignRawTransactionError struct { Txid string `json:"txid"` Vout int64 `json:"vout"` ScriptSig string `json:"scriptSig"` Sequence int64 `json:"sequence"` Error string `json:"error"` }
SignRawTransactionError SignRawTransactionResult内のerrorオブジェクト
type SignRawTransactionResult ¶
type SignRawTransactionResult struct { Hex string `json:"hex"` Complete bool `json:"complete"` Errors []SignRawTransactionError `json:"errors"` }
SignRawTransactionResult signrawtransactionwithwalletをcallしたresponseの型
type WalletResult ¶
type WalletResult struct {
FileName string `json:"filename"`
}
WalletResult dumpwallet/dumpwallet RPC のレスポンス