Documentation
¶
Index ¶
- Constants
- Variables
- func IfOrString(flag bool, trueS, falseS string) string
- func NoPrintCmd(fn func())
- 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 Cli
- func (cli *Cli) Addmultisigaddress(cmd btcjson.AddMultisigAddressCmd) (string, error)
- func (cli *Cli) AppendArgs(args ...string) []string
- func (cli *Cli) Createmultisig(nRequired uint8, keys []string, addressType *string) (btcjson.CreateMultiSigResult, error)
- func (cli *Cli) Createrawtransaction(cmd btcjson.CreateRawTransactionCmd) (string, error)
- func (cli *Cli) DecodeAndPrintTX(title, rawtx string)
- func (cli *Cli) Decoderawtransaction(cmd btcjson.DecodeRawTransactionCmd) (*btcjson.DecodeRawTransactionResult, error)
- func (cli *Cli) Decodescript(hex string) (btcjson.DecodeScriptResult, error)
- func (cli *Cli) Dumpprivkey(addr string) (string, error)
- func (cli *Cli) Generatetoaddress(nBlocks uint, address string, maxtriesPtr *uint) ([]string, error)
- func (cli *Cli) GetMemPoolAncestors(txid string, verbose bool, ret *MemPoolAncestorsResult) error
- func (cli *Cli) GetWalletInfo() (map[string]interface{}, error)
- func (cli *Cli) Getbestblockhash() (string, error)
- func (cli *Cli) Getblock(hash string, verbosity int) (*string, *btcjson.GetBlockResultV1, *btcjson.GetBlockResultV2, error)
- func (cli *Cli) Getblockcount() (int, error)
- func (cli *Cli) Getblockhash(height int) (string, error)
- func (cli *Cli) Getnewaddress(labelPtr, addressTypePtr *string) (hexedAddress string, err error)
- func (cli *Cli) Getrawtransaction(cmd btcjson.GetRawTransactionCmd) (*btcjson.RawTx, error)
- func (cli *Cli) Getreceivedbyaddress(addr string, minconf int) (string, error)
- func (cli *Cli) Gettransaction(txid string, includeWatchonly bool) (*btcjson.GetTransactionResult, error)
- func (cli *Cli) Importaddress(cmd btcjson.ImportAddressCmd) error
- func (cli *Cli) Importprivkey(cmd btcjson.ImportPrivKeyCmd) error
- func (cli *Cli) Importpubkey(cmd btcjson.ImportPubKeyCmd) error
- func (cli *Cli) Listunspent(minconf, maxconf int, addresses []string) ([]btcjson.ListUnspentResult, error)
- func (cli *Cli) OmniCreatepaloadSimplesend(propertyID int, amount string) (string, error)
- func (cli *Cli) OmniCreaterawtxChange(rawtx string, prevtxs []btcjson.PreviousDependentTxOutput, destination string, ...) (string, error)
- func (cli *Cli) OmniCreaterawtxOpreturn(rawtx string, payload string) (string, error)
- func (cli *Cli) OmniCreaterawtxReference(rawtx, destination string, amount *int) (string, error)
- func (cli *Cli) OmniFundedSend(cmd OmniFundedSendCmd) (string, error)
- func (cli *Cli) OmniGetbalance(address string, propertyid int) (*OmniGetbalanceResult, error)
- func (cli *Cli) OmniGettransaction(txHash string) (*OmniGettransactionResult, error)
- func (cli *Cli) OmniSendissuancefixed(cmd *OmniSenddissuancefixedCmd) (string, error)
- func (cli *Cli) Sendrawtransaction(cmd btcjson.SendRawTransactionCmd) (string, error)
- func (cli *Cli) Sendtoaddress(cmd *btcjson.SendToAddressCmd) (string, error)
- func (cli *Cli) Signrawtransaction(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
- func (cli *Cli) Signrawtransactionwithkey(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
- func (cli *Cli) ToolGetSomeAddrs(n int) ([]Addr, error)
- func (cli *Cli) Validateaddress(addr string) (ValidateAddressResp, error)
- type MemPoolAncestorsResult
- type OmniFundedSendCmd
- type OmniGetbalanceResult
- type OmniGettransactionResult
- type OmniSenddissuancefixedCmd
- type RunOptions
- type RunningOmnicoredOptions
- type ValidateAddressResp
Constants ¶
const ( RPCUser = "rpcusr" RPCPasswd = "233" RPCPortRegtest = 18443 OmniBinPathEnv = "OMNI_BIN_PATH" CmdParamRegtest = "-regtest" )
固定常量
const ( NetRegtest = iota + 1 NetTestnet3 NetMainnet )
some net id
Variables ¶
var ( BasePath = "/Users/some_user/Applications/omnicore/bin" //see init() CmdOmnicored = BasePath + "/omnicored" CmdOmniCli = BasePath + "/omnicore-cli" )
omnicore 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 IfOrString ¶
IfOrString if flag return s ,or s2
func NoPrintCmd ¶
func NoPrintCmd(fn func())
func ToJsonIndent ¶
func ToJsonIndent(i interface{}) string
func WrapJSONDecodeError ¶
WrapJSONDecodeError include raw json in error
Types ¶
type Cli ¶
type Cli struct {
IgnoreCliCmd bool //not print cmd
IgnoreCliOut bool //not print cli out
// contains filtered or unexported fields
}
Cli .
func NewCliFromRunningOmnicored ¶
func NewCliFromRunningOmnicored(options RunningOmnicoredOptions) (*Cli, error)
NewCliFromRunningOmnicored .
func (*Cli) Addmultisigaddress ¶
func (cli *Cli) Addmultisigaddress(cmd btcjson.AddMultisigAddressCmd) (string, error)
Addmultisigaddress .
func (*Cli) Createmultisig ¶
func (cli *Cli) Createmultisig(nRequired uint8, keys []string, addressType *string) (btcjson.CreateMultiSigResult, error)
Createmultisig https://bitcoin.org/en/developer-reference#createmultisig
func (*Cli) Createrawtransaction ¶
func (cli *Cli) Createrawtransaction(cmd btcjson.CreateRawTransactionCmd) (string, error)
Createrawtransaction https://bitcoin.org/en/developer-reference#createrawtransaction
func (*Cli) DecodeAndPrintTX ¶
DecodeAndPrintTX panic on error
func (*Cli) Decoderawtransaction ¶
func (cli *Cli) Decoderawtransaction(cmd btcjson.DecodeRawTransactionCmd) (*btcjson.DecodeRawTransactionResult, error)
Decoderawtransaction https://bitcoin.org/en/developer-reference#decoderawtransaction
func (*Cli) Decodescript ¶
func (cli *Cli) Decodescript(hex string) (btcjson.DecodeScriptResult, error)
Decodescript https://bitcoin.org/en/developer-reference#decodescript
func (*Cli) Dumpprivkey ¶
Dumpprivkey https://bitcoin.org/en/developer-reference#dumpprivkey
func (*Cli) Generatetoaddress ¶
func (cli *Cli) Generatetoaddress(nBlocks uint, address string, maxtriesPtr *uint) ([]string, error)
Generatetoaddress https://bitcoin.org/en/developer-reference#generatetoaddress
func (*Cli) GetMemPoolAncestors ¶
func (cli *Cli) GetMemPoolAncestors(txid string, verbose bool, ret *MemPoolAncestorsResult) error
GetMemPoolAncestors .
func (*Cli) GetWalletInfo ¶
GetWalletInfo .
func (*Cli) Getbestblockhash ¶
Getbestblockhash .
func (*Cli) Getblock ¶
func (cli *Cli) Getblock(hash string, verbosity int) (*string, *btcjson.GetBlockResultV1, *btcjson.GetBlockResultV2, error)
Getblock https://bitcoin.org/en/developer-reference#getblock
func (*Cli) Getnewaddress ¶
Getnewaddress https://bitcoin.org/en/developer-reference#getnewaddress
func (*Cli) Getrawtransaction ¶
Getrawtransaction .
func (*Cli) Getreceivedbyaddress ¶
Getreceivedbyaddress https://bitcoin.org/en/developer-reference#getreceivedbyaddress
func (*Cli) Gettransaction ¶
func (cli *Cli) Gettransaction(txid string, includeWatchonly bool) (*btcjson.GetTransactionResult, error)
Gettransaction https://bitcoin.org/en/developer-reference#gettransaction
func (*Cli) Importaddress ¶
func (cli *Cli) Importaddress(cmd btcjson.ImportAddressCmd) error
Importaddress .
func (*Cli) Importprivkey ¶
func (cli *Cli) Importprivkey(cmd btcjson.ImportPrivKeyCmd) error
Importprivkey https://bitcoin.org/en/developer-reference#importprivkey
func (*Cli) Importpubkey ¶
func (cli *Cli) Importpubkey(cmd btcjson.ImportPubKeyCmd) error
Importpubkey https://bitcoin.org/en/developer-reference#importpubkey
func (*Cli) Listunspent ¶
func (cli *Cli) Listunspent(minconf, maxconf int, addresses []string) ([]btcjson.ListUnspentResult, error)
Listunspent https://bitcoin.org/en/developer-reference#listunspent
func (*Cli) OmniCreatepaloadSimplesend ¶
OmniCreatepaloadSimplesend .
func (*Cli) OmniCreaterawtxChange ¶
func (cli *Cli) OmniCreaterawtxChange(rawtx string, prevtxs []btcjson.PreviousDependentTxOutput, destination string, fee float64, position *int) (string, error)
OmniCreaterawtxChange https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_createrawtx_change
func (*Cli) OmniCreaterawtxOpreturn ¶
OmniCreaterawtxOpreturn 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 (*Cli) OmniCreaterawtxReference ¶
OmniCreaterawtxReference 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 (*Cli) OmniFundedSend ¶
func (cli *Cli) OmniFundedSend(cmd OmniFundedSendCmd) (string, error)
OmniFundedSend https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_funded_send
func (*Cli) OmniGetbalance ¶
func (cli *Cli) OmniGetbalance(address string, propertyid int) (*OmniGetbalanceResult, error)
OmniGetbalance https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_getbalance
func (*Cli) OmniGettransaction ¶
func (cli *Cli) OmniGettransaction(txHash string) (*OmniGettransactionResult, error)
OmniGettransaction .
func (*Cli) OmniSendissuancefixed ¶
func (cli *Cli) OmniSendissuancefixed(cmd *OmniSenddissuancefixedCmd) (string, error)
OmniSendissuancefixed https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_sendissuancefixed
func (*Cli) Sendrawtransaction ¶
func (cli *Cli) Sendrawtransaction(cmd btcjson.SendRawTransactionCmd) (string, error)
Sendrawtransaction https://bitcoin.org/en/developer-reference#sendrawtransaction
func (*Cli) Sendtoaddress ¶
func (cli *Cli) Sendtoaddress(cmd *btcjson.SendToAddressCmd) (string, error)
Sendtoaddress https://bitcoin.org/en/developer-reference#sendtoaddress
func (*Cli) Signrawtransaction ¶
func (cli *Cli) Signrawtransaction(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
Signrawtransaction .
func (*Cli) Signrawtransactionwithkey ¶
func (cli *Cli) Signrawtransactionwithkey(cmd btcjson.SignRawTransactionCmd) (btcjson.SignRawTransactionResult, error)
Signrawtransactionwithkey [Disabled in omni current version] https://bitcoin.org/en/developer-reference#signrawtransactionwithkey
func (*Cli) ToolGetSomeAddrs ¶
ToolGetSomeAddrs 一次获取n个地址(包含pub-priv key)
func (*Cli) Validateaddress ¶
func (cli *Cli) Validateaddress(addr string) (ValidateAddressResp, error)
Validateaddress .
type MemPoolAncestorsResult ¶
type MemPoolAncestorsResult struct {
NoVerbose []string
Verbose *btcjson.GetMempoolEntryResult
}
MemPoolAncestorsResult .
type OmniFundedSendCmd ¶
type OmniFundedSendCmd struct {
Fromaddress string //required the address to send the tokens from
Toaddress string //required the address of the receiver
Propertyid int //required the identifier of the tokens to send
Amount string //required the amount to send
Feeaddress string //required the address that is used for change and to pay for fees, if needed
}
OmniFundedSendCmd .
type OmniGetbalanceResult ¶
type OmniGetbalanceResult struct {
Balance string `json:"balance"`
Reserved string `json:"reserved"`
Frozen string `json:"frozen"`
}
OmniGetbalanceResult .
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 .
type OmniSenddissuancefixedCmd ¶
type OmniSenddissuancefixedCmd struct {
Fromaddress string
Ecosystem int
Typ int
Previousid int
Category, Subcategory, Name, URL, Data, Amount string
}
OmniSenddissuancefixedCmd . fromaddress string required the address to send from ecosystem number required the ecosystem to create the tokens in (1 for main ecosystem, 2 for test ecosystem) type number required the type of the tokens to create: (1 for indivisible tokens, 2 for divisible tokens) previousid number required an identifier of a predecessor token (0 for new tokens) category string required a category for the new tokens (can be "") subcategory string required a subcategory for the new tokens (can be "") name string required the name of the new tokens to create url string required an URL for further information about the new tokens (can be "") data string required a description for the new tokens (can be "") amount string required the number of tokens to create
type RunOptions ¶
RunOptions .
type RunningOmnicoredOptions ¶
type RunningOmnicoredOptions struct {
RPCPort uint
RPCUser string
RPCPassword string
DataDir string
NetID uint32
}
RunningOmnicoredOptions .
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 .