Documentation ¶
Index ¶
- Constants
- Variables
- func CliAddmultisigaddress(cmd btcjson.AddMultisigAddressCmd) (btcjson.CreateMultiSigResult, error)
- func CliCreatemultisig(nRequired uint8, keys []string, addressType *string) (btcjson.CreateMultiSigResult, error)
- func CliCreaterawtransaction(cmd btcjson.CreateRawTransactionCmd) (string, error)
- func CliDecoderawtransaction(cmd btcjson.DecodeRawTransactionCmd) (*btcjson.DecodeRawTransactionResult, error)
- func CliDecodescript(hex string) (btcjson.DecodeScriptResult, error)
- func CliDumpprivkey(addr string) (string, error)
- func CliGeneratetoaddress(nBlocks uint, address string, maxtriesPtr *uint) ([]string, error)
- func CliGetWalletInfo() (map[string]interface{}, error)
- func CliGetbestblockhash() (string, error)
- func CliGetblock(hash string, verbosity int) (*string, *btcjson.GetBlockResultV1, *btcjson.GetBlockResultV2, error)
- func CliGetblockcount() (int, error)
- func CliGetblockhash(height int) (string, error)
- func CliGetnewaddress(labelPtr, addressTypePtr *string) (hexedAddress string, err error)
- func CliGetrawtransaction(cmd btcjson.GetRawTransactionCmd) (*btcjson.RawTx, error)
- func CliGetreceivedbyaddress(addr string, minconf int) (string, error)
- func CliGettransaction(txid string, includeWatchonly bool) (*btcjson.GetTransactionResult, error)
- func CliImportaddress(cmd btcjson.ImportAddressCmd) error
- func CliImportprivkey(cmd btcjson.ImportPrivKeyCmd) error
- func CliImportpubkey(cmd btcjson.ImportPubKeyCmd) error
- func CliListunspent(minconf, maxconf int, addresses []string) ([]btcjson.ListUnspentResult, error)
- func CliOmniCreatepaloadSimplesend(propertyID int, amount string) (string, error)
- func CliOmniCreaterawtxChange(rawtx string, prevtxs []btcjson.PreviousDependentTxOutput, destination string, ...) (string, error)
- func CliOmniCreaterawtxOpreturn(rawtx string, payload string) (string, error)
- func CliOmniCreaterawtxReference(rawtx, destination string, amount *int) (string, error)
- func CliOmniSendissuancefixed(cmd *OmniSenddissuancefixedCmd) (string, error)
- func CliSendrawtransaction(cmd btcjson.SendRawTransactionCmd) (string, error)
- func CliSendtoaddress(cmd *btcjson.SendToAddressCmd) (string, error)
- func CliSignrawtransaction(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
- func CliSignrawtransactionwithkey(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
- func DecodeAndPrintTX(title, rawtx string)
- func IfOrString(flag bool, trueS, falseS string) string
- func NoPrintCmd(fn func())
- func StartOmnicored() (closeChan chan struct{}, err error)
- func ToError(str string) error
- func ToJson(i interface{}) string
- func ToJsonIndent(i interface{}) string
- func WrapJSONDecodeError(e error, rawJSON string) error
- type Addr
- type OmniGetbalanceResult
- type OmniGettransactionResult
- type OmniSenddissuancefixedCmd
- type ValidateAddressResp
Constants ¶
const ( RPCUser = "rpcusr" RPCPasswd = "233" RPCPortRegtest = 18443 OmniBinPathEnv = "OMNI_BIN_PATH" CmdParamRegtest = "-regtest" )
固定常量
Variables ¶
var ( BasePath = "/Users/some_user/Applications/bitcoin/bin" //see init() CmdOmnicored = BasePath + "/omnicored" CmdBitcoinCli = BasePath + "/omnicore-cli" )
bitcoin bin path
var ( // PresetAccounts 一些预置账号 PresetAccounts = []Addr{ {Address: "mt6WnfniPEKziTgmAdebBkT33vAcM7jJFC", Privkey: "cTBichWb6XBPa6F6NUc3gkLjYDufRWx74CnJWEypxuFNsXd6dJNb", Pubkey: "032affe4397f911be5d4ff84531d84b7d9498263731f8c205c1082e73abcc60955"}, {Address: "miP2AS7DQmQuc9WSYzz5uJrFh6xhe4TvYw", Privkey: "cVWuAHG981YURgJCFRYHuVdApgKtmciujVmkYFkZnaVeMLXz3pKX", Pubkey: "0264f183744e1dd7523ead4eef81b99e13870a8234724ee9035aee0ccfa70f1b1a"}, {Address: "n4ekdCUgRUCZxAiVTiCKfKVU4fz5SewcKr", Privkey: "cNczugkPEDYcCm1UhukMJp1XCGdtqez4cVfzK4yBfcxtYbF2Ui7r", Pubkey: "0383b83e84538b334df3f8820539053e635e30ba05b85a05850302971d9b3ece3c"}, {Address: "mrmsAWtDKgqGEppz2ULnd1yjthinGgZmY9", Privkey: "cNkMpgrsvvRjzkNYvBmMBWLbusFgCWJNrbfzhecmmSaKN7q9cgwx", Pubkey: "03ca007eefc39e3406d2131cf498efd5cca7fe3b3c5b61625b58a8342e84a4f947"}, {Address: "mtxrtZn5RnMGXADrfUaMcyrb8EJ1c7276W", Privkey: "cN4pHDRjKbCjHot5iyQorPRVQWQqfRuWTFbCgPCz2UG2y1K9oHv9", Pubkey: "02f0744be0f11fd0db10bd669bb20f29e8fdbfdc39b0b9d1f8c81be2f42d7068a7"}, {Address: "n162u2V7Sav6mUC1baJ1u7hGrBtsSLdszq", Privkey: "cN8Sq2fjq5bnUsRTQNL6CSdwxA7d2FmSsSG9r8h1DBwfY7eaz5EA", Pubkey: "02e5dcd14da054866160fa9adb1af3e04c21eae1d2677b46bded4d9b7f7b5a22b3"}, {Address: "mopaTypypdaFh3u5nV16vsqZb22DcqM1pf", Privkey: "cUCXumLXtHHjLBr3mn888uyBvx45ELwznnzPzuFCvk9SThUi7jUJ", Pubkey: "0285c13d0769efbf118a0b7f5b87150f8f87fbe07a7acca8fe3a92e8b6541b0a65"}, {Address: "mxFFWmHfp1Gz657QZeVuGiTCeEk71Z6aYX", Privkey: "cRsF4QaXXVwBNgunPEzNgEHkxz8GoeWzZ8jrk8JM46unBZaaiXmP", Pubkey: "03c935d1934055b83e1b19e60d16a8c9d4f89392aa3057d32b7d88a5ea36b098f6"}, {Address: "mqbyybrXRZwHUET7taiShJ1S6dScnBd7yg", Privkey: "cV7Z95EMA7G5vrQ9bCe1tZRmL5eMncimvVXPjY9FuR7UyKzWvdZH", Pubkey: "0326b988f6da309846aded94a56f3230e1bdd1494878343830e89053ddd596e069"}, {Address: "mzfveH16kQ7rNdPHNJMrkpWqjo7hVdpVHC", Privkey: "cPEnbKH87636VhGhsVQxHBV6RmPyp3d1NL9q9XQJGXpyMhyUJoMJ", Pubkey: "026c27bbb52665e6d1d3d1f5ccb8ac7b7b27ee8636019af14272ebaa0308b800b2"}, } )
var (
PrintCmdOut = true
)
global vars
Functions ¶
func CliAddmultisigaddress ¶
func CliAddmultisigaddress(cmd btcjson.AddMultisigAddressCmd) (btcjson.CreateMultiSigResult, error)
func CliCreatemultisig ¶
func CliCreatemultisig(nRequired uint8, keys []string, addressType *string) (btcjson.CreateMultiSigResult, error)
CliCreatemultisig https://bitcoin.org/en/developer-reference#createmultisig
func CliCreaterawtransaction ¶
func CliCreaterawtransaction(cmd btcjson.CreateRawTransactionCmd) (string, error)
CliCreaterawtransaction https://bitcoin.org/en/developer-reference#createrawtransaction
func CliDecoderawtransaction ¶
func CliDecoderawtransaction(cmd btcjson.DecodeRawTransactionCmd) (*btcjson.DecodeRawTransactionResult, error)
CliDecoderawtransaction https://bitcoin.org/en/developer-reference#decoderawtransaction
func CliDecodescript ¶
func CliDecodescript(hex string) (btcjson.DecodeScriptResult, error)
CliDecodescript https://bitcoin.org/en/developer-reference#decodescript
func CliDumpprivkey ¶
CliDumpprivkey https://bitcoin.org/en/developer-reference#dumpprivkey
func CliGeneratetoaddress ¶
CliGeneratetoaddress https://bitcoin.org/en/developer-reference#generatetoaddress
func CliGetWalletInfo ¶
func CliGetbestblockhash ¶
func CliGetblock ¶
func CliGetblock(hash string, verbosity int) (*string, *btcjson.GetBlockResultV1, *btcjson.GetBlockResultV2, error)
CliGetblock https://bitcoin.org/en/developer-reference#getblock
func CliGetblockcount ¶
func CliGetblockhash ¶
func CliGetnewaddress ¶
CliGetnewaddress https://bitcoin.org/en/developer-reference#getnewaddress
func CliGetrawtransaction ¶
func CliGetrawtransaction(cmd btcjson.GetRawTransactionCmd) (*btcjson.RawTx, error)
CliGetrawtransaction .
func CliGetreceivedbyaddress ¶
CliGetreceivedbyaddress https://bitcoin.org/en/developer-reference#getreceivedbyaddress
func CliGettransaction ¶
func CliGettransaction(txid string, includeWatchonly bool) (*btcjson.GetTransactionResult, error)
CliGettransaction https://bitcoin.org/en/developer-reference#gettransaction
func CliImportaddress ¶
func CliImportaddress(cmd btcjson.ImportAddressCmd) error
CliImportaddress .
func CliImportprivkey ¶
func CliImportprivkey(cmd btcjson.ImportPrivKeyCmd) error
CliImportprivkey https://bitcoin.org/en/developer-reference#importprivkey
func CliImportpubkey ¶
func CliImportpubkey(cmd btcjson.ImportPubKeyCmd) error
CliImportpubkey https://bitcoin.org/en/developer-reference#importpubkey
func CliListunspent ¶
func CliListunspent(minconf, maxconf int, addresses []string) ([]btcjson.ListUnspentResult, error)
CliListunspent https://bitcoin.org/en/developer-reference#listunspent
func CliOmniCreatepaloadSimplesend ¶
CliOmniCreatepaloadSimplesend .
func CliOmniCreaterawtxChange ¶
func CliOmniCreaterawtxChange(rawtx string, prevtxs []btcjson.PreviousDependentTxOutput, destination string, fee float64, position *int) (string, error)
CliOmniCreaterawtxChange https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_createrawtx_change
func CliOmniCreaterawtxOpreturn ¶
CliOmniCreaterawtxOpreturn Adds a payload with class C (op-return) encoding to the transaction. If no raw transaction is provided, a new transaction is created. If the data encoding fails, then the transaction is not modified.
func CliOmniCreaterawtxReference ¶
CliOmniCreaterawtxReference Adds a reference output to the transaction. If no raw transaction is provided, a new transaction is created. The output value is set to at least the dust threshold.
func CliOmniSendissuancefixed ¶
func CliOmniSendissuancefixed(cmd *OmniSenddissuancefixedCmd) (string, error)
CliOmniSendissuancefixed https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_sendissuancefixed
func CliSendrawtransaction ¶
func CliSendrawtransaction(cmd btcjson.SendRawTransactionCmd) (string, error)
CliSendrawtransaction https://bitcoin.org/en/developer-reference#sendrawtransaction
func CliSendtoaddress ¶
func CliSendtoaddress(cmd *btcjson.SendToAddressCmd) (string, error)
CliSendtoaddress https://bitcoin.org/en/developer-reference#sendtoaddress
func CliSignrawtransaction ¶
func CliSignrawtransaction(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
CliSignrawtransaction .
func CliSignrawtransactionwithkey ¶
func CliSignrawtransactionwithkey(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
CliSignrawtransactionwithkey [Disabled in omni current version] https://bitcoin.org/en/developer-reference#signrawtransactionwithkey
func IfOrString ¶
IfOrString if flag return s ,or s2
func NoPrintCmd ¶
func NoPrintCmd(fn func())
func StartOmnicored ¶
func StartOmnicored() (closeChan chan struct{}, err error)
StartOmnicored 启动bitcoind -regtest 用以测试. return close channel (cc)
func ToJsonIndent ¶
func ToJsonIndent(i interface{}) string
func WrapJSONDecodeError ¶
WrapJSONDecodeError include raw json in error
Types ¶
type Addr ¶
func CliToolGetSomeAddrs ¶
CliToolGetSomeAddrs 一次获取n个地址(包含pub-priv key)
type OmniGetbalanceResult ¶
type OmniGetbalanceResult struct { Balance string `json:"balance"` Reserved string `json:"reserved"` Frozen string `json:"frozen"` }
OmniGetbalanceResult .
func CliOmniGetbalance ¶
func CliOmniGetbalance(address string, propertyid int) (*OmniGetbalanceResult, error)
CliOmniGetbalance https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_getbalance
type OmniGettransactionResult ¶
type OmniGettransactionResult struct { Txid string `json:"txid"` // (string) the hex-encoded hash of the transaction Sendingaddress string `json:"sendingaddress"` // (string) the Bitcoin address of the sender Referenceaddress string `json:"referenceaddress"` // (string) a Bitcoin address used as reference (if any) Ismine bool `json:"ismine"` // (boolean) whether the transaction involes an address in the wallet Confirmations int `json:"confirmations"` // (number) the number of transaction confirmations Fee string `json:"fee"` // (string) the transaction fee in bitcoins Blocktime int `json:"blocktime"` // (number) the timestamp of the block that contains the transaction Valid bool `json:"valid"` // (boolean) whether the transaction is valid Positioninblock int `json:"positioninblock"` // (number) the position (index) of the transaction within the block Version int `json:"version"` // (number) the transaction version TypeInt int `json:"type_int"` // (number) the transaction type as number Type string `json:"type"` // (string) the transaction type as string //other Propertyid int `json:"propertyid"` }
OmniGettransactionResult .
func CliOmniGettransaction ¶
func CliOmniGettransaction(txHash string) (*OmniGettransactionResult, error)
CliOmniGettransaction .
type OmniSenddissuancefixedCmd ¶
type OmniSenddissuancefixedCmd struct { Fromaddress string Ecosystem int Typ int Previousid int Category, Subcategory, Name, URL, Data, Amount string }
OmniSenddissuancefixedCmd .
type ValidateAddressResp ¶
type ValidateAddressResp struct { Isvalid bool `json:"isvalid"` Address string `json:"address"` ScriptPubKey string `json:"scriptPubKey"` Isscript bool `json:"isscript"` Iswitness bool `json:"iswitness"` Pubkey string `json:"pubkey"` WitnessVersion string `json:"witness_version"` // version (numeric, optional) The version number of the witness program WitnessProgram string `json:"witness_program"` // "hex" (string, optional) The hex value of the witness program }
ValidateAddressResp .
func CliValidateaddress ¶
func CliValidateaddress(addr string) (ValidateAddressResp, error)
CliValidateaddress .