Documentation ¶
Index ¶
- Constants
- Variables
- func AddChildAccount(walletname string, mnemonic string, publicKey []byte, privateKey []byte) error
- func AddrToPkScript(addr string) ([]byte, error)
- func DelChildAccount(walletname string) error
- func GetAllWalletAccounts() ([]string, error)
- func GetBTCBalance(address string) (*big.Float, *big.Float, error)
- func GetBTCBalance1(address string) (*big.Float, *big.Float, error)
- func GetDefaultWalletName() string
- func GetPrikey(walletName string) ([]byte, error)
- func GetRawTransaction(tx *wire.MsgTx, allowHighFees bool) (string, error)
- func GetScriptType(pkScript []byte) (uint32, error)
- func GetUserAccountID(walletName string) ([]byte, error)
- func InitWalletManager(workDir string)
- func LoadLocalWallet(workDir string) error
- func LogAddressType(address string)
- func LogMsgTx(tx *wire.MsgTx)
- func LogPsbt(pb *psbt.Packet)
- func PathExists(path string) bool
- func PkScriptToAddr(pkScript []byte) (string, error)
- func ResetInstance()
- func SendTransaction(raw string) (string, error)
- func SetWalletInfo(walletName string, WalletInfo *BTCWalletInfo) error
- type BTCAccountDetails
- type BTCAccountStatus
- type BTCAddress
- type BTCAddressDetails
- type BTCAddressInfo
- type BTCAddressSummary
- type BTCInOutSummary
- type BTCTXStatus
- type BTCTXStruct
- type BTCTXSummaryStruct
- type BTCTXVIn
- type BTCTXVOut
- type BTCTxRes
- type BTCUtxo
- type BTCUtxoResponse
- type BTCWallet
- func (wallet *BTCWallet) AccountCollect(address string, feeRate uint32) (string, error)
- func (wallet *BTCWallet) CreateOrdxTransaction(paymentAddress string, assetsUtxo string, outputs []*wire.TxOut, ...) (*wire.MsgTx, []*utxo, error)
- func (wallet *BTCWallet) CreateTransaction(paymentAddresses []string, outputs []*wire.TxOut, feeRate btcutil.Amount, ...) (*wire.MsgTx, []*utxo, error)
- func (wallet *BTCWallet) DelAddress(address string) error
- func (wallet *BTCWallet) GenerateAddress(channel uint32, addresstype uint32, AddressAlias string) (string, error)
- func (wallet *BTCWallet) GetAccountDetails() (*BTCAccountDetails, error)
- func (wallet *BTCWallet) GetAddress(addressKey *hdkeychain.ExtendedKey, addresstype uint32) (string, error)
- func (wallet *BTCWallet) GetAddressBalance(address string) (*big.Float, *big.Float, error)
- func (wallet *BTCWallet) GetAddressOrdxAssets(adddress string) ([]*OrdxAssetsInfo, error)
- func (wallet *BTCWallet) GetChangeAddress(paymentAddresses []string) (string, error)
- func (wallet *BTCWallet) GetDefaultAddress() (string, error)
- func (wallet *BTCWallet) GetLegacyAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
- func (wallet *BTCWallet) GetNativeSegwitAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
- func (wallet *BTCWallet) GetNestedSegwitAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
- func (wallet *BTCWallet) GetP2WSHAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
- func (wallet *BTCWallet) GetTaprootAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
- func (wallet *BTCWallet) GetUtxo(outPoint wire.OutPoint, paymentAddresses []string) (*utxo, string, error)
- func (wallet *BTCWallet) GetWalletMnemonic() (string, error)
- func (wallet *BTCWallet) RefreshAccountDetails() (*BTCAccountDetails, error)
- func (wallet *BTCWallet) SetAddressAlias(address string, alias string) error
- func (wallet *BTCWallet) SetChangeAddress(changeAddress string) error
- func (wallet *BTCWallet) SetDefaultAddress(defaultAddress string) error
- func (wallet *BTCWallet) Transaction(paymentAddress string, address string, amount *big.Float, fee uint32, ...) (string, error)
- func (wallet *BTCWallet) TransactionOrdx(paymentAddress string, address string, utxo string, fee uint32) (string, error)
- func (wallet *BTCWallet) UnanchorTransaction(paymentAddress string, unanchorScript []byte, amount *big.Float, fee uint32) (string, error)
- func (wallet *BTCWallet) UpdateWalletInfo() error
- type BTCWalletInfo
- type BTCWalletManager
- func (walletMgr *BTCWalletManager) AddBTCWallet(wallet *BTCWallet) error
- func (walletMgr *BTCWalletManager) DeleteWallet(walletname string) error
- func (walletMgr *BTCWalletManager) GetAllBTCWallets() map[string]*BTCWallet
- func (walletMgr *BTCWalletManager) GetDefaultAddress() (string, error)
- func (walletMgr *BTCWalletManager) GetDefaultWallet() (*BTCWallet, error)
- func (walletMgr *BTCWalletManager) GetWallet(walletName string) (*BTCWallet, error)
- func (walletMgr *BTCWalletManager) InitBTCWalletList(workDir string) error
- type OrdxAssets
- type OrdxAssetsInfo
- type WalletAccount
- type WalletAccountManager
Constants ¶
View Source
const ( CHANNEL_INTERNAL = 1 CHANNEL_EXTERNAL = 0 DEFAULT_ADDRESS = 3 AMT_ALL = 100000000 )
View Source
const ( BTC_ADDRESS_P2PKH uint32 = 0 // Legacy BTC_ADDRESS_P2SH uint32 = 1 // NestedSegwit BTC_ADDRESS_P2WKH uint32 = 2 // NativeSegwit BTC_ADDRESS_P2WSH uint32 = 3 // P2WSH BTC_ADDRESS_P2TR uint32 = 4 // Taproot BTC_ADDRESS_INSCRIPTIONCOMMIT uint32 = 5 // Inscription Commit Tx address BTC_ADDRESS_UNKNOWN uint32 = 0xffffffff // Unknow type BTC_WalletInfo_Templete = "/%s/%s/%s/walletinfo" // /mtv/userid/btcaccountname/walletinfo )
View Source
const ( HOST_BTCCHAIN_RELEASE = "https://blockstream.info/api" HOST_BTCCHAIN_TEST = "http://192.168.10.104:8019/testnet" URL_GETTXLIST = "%s/address/%s/txs" URL_GETBALANCE = "%s/address/%s" URL_GETUTXOS = "%s/allutxos/address/%s" URL_TRANSATION = "%s/tx" )
View Source
const (
FILENAME_LOCAL_WALLET = "localwallet.json"
)
Variables ¶
View Source
var ( // LeagacyAccountPath is the base path for BIP44 (m/44'/0'/0'). LeagacyAccountPath = []uint32{ 44 + hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, } // NativeSegwitAccountPath is the base path for BIP84 (m/84'/0'/0'). NativeSegwitAccountPath = []uint32{ 84 + hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, } // NestedSegwitAccountPath is the base path for BIP49 (m/49'/0'/0'). NestedSegwitAccountPath = []uint32{ 49 + hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, } // TaprootAccountPath is the base path for BIP86 (m/86'/0'/0'). TaprootAccountPath = []uint32{ 86 + hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, } )
Functions ¶
func AddChildAccount ¶
func AddrToPkScript ¶
func DelChildAccount ¶
func GetAllWalletAccounts ¶
func GetDefaultWalletName ¶
func GetDefaultWalletName() string
func GetScriptType ¶
func GetUserAccountID ¶
func InitWalletManager ¶
func InitWalletManager(workDir string)
func LoadLocalWallet ¶
func LogAddressType ¶
func LogAddressType(address string)
func PkScriptToAddr ¶
func ResetInstance ¶
func ResetInstance()
func SendTransaction ¶
func SetWalletInfo ¶
func SetWalletInfo(walletName string, WalletInfo *BTCWalletInfo) error
Types ¶
type BTCAccountDetails ¶
type BTCAccountDetails struct { // Address summary ExternalAddresses []*BTCAddressSummary `json:"ExternalAddresses,omitempty"` InternalAddresses []*BTCAddressSummary `json:"InternalAddresses,omitempty"` AddressCount int `json:"AddressCount,omitempty"` TotalAmount string `json:"TotalAmount,omitempty"` TotalMempoolAmount string `json:"TotalMempoolAmount,omitempty"` ChangeAddress string `json:"ChangeAddress,omitempty"` DefaultPayAddress string `json:"DefaultPayAddress,omitempty"` }
type BTCAccountStatus ¶
type BTCAddress ¶
type BTCAddress struct { Address string `json:"address"` ChainStats BTCAccountStatus `json:"chain_stats"` MempoolStats BTCAccountStatus `json:"mempool_stats"` }
type BTCAddressDetails ¶
type BTCAddressDetails struct { // Address meta BTCAddressInfo // contains filtered or unexported fields }
type BTCAddressInfo ¶
type BTCAddressInfo struct { Channel uint32 `protobuf:"varint,1,opt,name=Channel,proto3" json:"Channel,omitempty"` Index uint32 `protobuf:"varint,2,opt,name=Index,proto3" json:"Index,omitempty"` AddressType uint32 `protobuf:"varint,3,opt,name=AddressType,proto3" json:"AddressType,omitempty"` AddressAlias string `protobuf:"bytes,4,opt,name=AddressAlias,proto3" json:"AddressAlias,omitempty"` }
type BTCAddressSummary ¶
type BTCAddressSummary struct { Address string `json:"Address,omitempty"` Amount string `json:"Amount,omitempty"` MempoolAmount string `json:"MempoolAmount,omitempty"` Channel uint32 `json:"Channel,omitempty"` Index uint32 `json:"Index,omitempty"` AddressType uint32 `json:"AddressType,omitempty"` AddressAlias string `json:"AddressAlias,omitempty"` Path string `json:"Path,omitempty"` }
type BTCInOutSummary ¶
type BTCTXStatus ¶
type BTCTXStatus struct { Confirmed bool `json:"confirmed"` BlockHeight int64 `json:"block_height"` BlockHash string `json:"block_hash"` BlockTime int64 `json:"block_time"` }
status
type BTCTXStruct ¶
type BTCTXStruct struct { TX_ID string `json:"txid"` Version int `json:"version"` LockTime int64 `json:"locktime"` VIn []BTCTXVIn `json:"vin"` VOut []BTCTXVOut `json:"vout"` Size int64 `json:"size"` Weight int64 `json:"weight"` Fee int64 `json:"fee"` Status BTCTXStatus `json:"status"` }
BTC tx
func GetAllTxList ¶
func GetAllTxList(address string, startPage int, offset int) ([]*BTCTXStruct, error)
Get all tx list
type BTCTXSummaryStruct ¶
type BTCTXSummaryStruct struct { TX_ID string `json:"txid"` TxTime int64 `json:"txtime"` In []BTCInOutSummary `json:"in"` Out []BTCInOutSummary `json:"out"` Value int64 `json:"size"` Fee int64 `json:"fee"` Confirmed bool `json:"confirmed"` }
func GetAllTxSummary ¶
func GetAllTxSummary(address string) ([]*BTCTXSummaryStruct, error)
Get all tx list
type BTCTXVIn ¶
type BTCTXVIn struct { TX_ID string `json:"txid"` Vout int64 `json:"vout"` Prevout BTCTXVOut `json:"prevout"` ScriptSig string `json:"scriptsig"` ScriptSigAsm string `json:"scriptsig_asm"` Witness []string `json:"witness"` IsCoinBase bool `json:"is_coinbase"` Sequence int64 `json:"sequence"` }
vin
type BTCTXVOut ¶
type BTCTXVOut struct { ScriptPubKey string `json:"scriptpubkey"` SpriptPubkeyAsm string `json:"scriptpubkey_asm"` SpriptPubkeyType string `json:"scriptpubkey_type"` SpriptPubkeyAddress string `json:"scriptpubkey_address"` Value int64 `json:"value"` }
vout
type BTCUtxo ¶
type BTCUtxo struct { TXID string `json:"txid"` VOut int64 `json:"vout"` Value int64 `json:"value"` }
func GetBTCUtoxs ¶
type BTCUtxoResponse ¶
type BTCWallet ¶
type BTCWallet struct { // Wallet info metadata, it will be stored in dkvs WalletInfo *BTCWalletInfo sync.RWMutex // contains filtered or unexported fields }
func CreateBTCWallet ¶
func ImportWithPrivateKey ¶
func (*BTCWallet) AccountCollect ¶
func (*BTCWallet) CreateOrdxTransaction ¶
func (*BTCWallet) CreateTransaction ¶
func (*BTCWallet) DelAddress ¶
func (*BTCWallet) GenerateAddress ¶
func (*BTCWallet) GetAccountDetails ¶
func (wallet *BTCWallet) GetAccountDetails() (*BTCAccountDetails, error)
func (*BTCWallet) GetAddress ¶
func (wallet *BTCWallet) GetAddress(addressKey *hdkeychain.ExtendedKey, addresstype uint32) (string, error)
func (*BTCWallet) GetAddressBalance ¶
func (*BTCWallet) GetAddressOrdxAssets ¶
func (wallet *BTCWallet) GetAddressOrdxAssets(adddress string) ([]*OrdxAssetsInfo, error)
func (*BTCWallet) GetChangeAddress ¶
func (*BTCWallet) GetDefaultAddress ¶
func (*BTCWallet) GetLegacyAddress ¶
func (wallet *BTCWallet) GetLegacyAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
func (*BTCWallet) GetNativeSegwitAddress ¶
func (wallet *BTCWallet) GetNativeSegwitAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
func (*BTCWallet) GetNestedSegwitAddress ¶
func (wallet *BTCWallet) GetNestedSegwitAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
func (*BTCWallet) GetP2WSHAddress ¶
func (wallet *BTCWallet) GetP2WSHAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
func (*BTCWallet) GetTaprootAddress ¶
func (wallet *BTCWallet) GetTaprootAddress(addressKey *hdkeychain.ExtendedKey) (string, error)
func (*BTCWallet) GetWalletMnemonic ¶
func (*BTCWallet) RefreshAccountDetails ¶
func (wallet *BTCWallet) RefreshAccountDetails() (*BTCAccountDetails, error)
func (*BTCWallet) SetAddressAlias ¶
func (*BTCWallet) SetChangeAddress ¶
func (*BTCWallet) SetDefaultAddress ¶
func (*BTCWallet) Transaction ¶
func (*BTCWallet) TransactionOrdx ¶
func (*BTCWallet) UnanchorTransaction ¶
func (*BTCWallet) UpdateWalletInfo ¶
type BTCWalletInfo ¶
type BTCWalletInfo struct { Entropy []byte `protobuf:"bytes,1,opt,name=Entropy,proto3" json:"Entropy,omitempty"` ChangeAddress string `protobuf:"bytes,2,opt,name=ChangeAddress,proto3" json:"ChangeAddress,omitempty"` AddressInfoList []*BTCAddressInfo `protobuf:"bytes,3,rep,name=AddressInfoList,proto3" json:"AddressInfoList,omitempty"` CurrentIndex uint32 `protobuf:"varint,4,opt,name=CurrentIndex,proto3" json:"CurrentIndex,omitempty"` DefaultPayAddress string `protobuf:"bytes,5,opt,name=DefaultPayAddress,proto3" json:"DefaultPayAddress,omitempty"` }
func GetWalletInfo ¶
func GetWalletInfo(walletName string) (*BTCWalletInfo, error)
type BTCWalletManager ¶
var ( BtcWalletMgr *BTCWalletManager NetParams *chaincfg.Params )
func GetWalletInst ¶
func GetWalletInst() *BTCWalletManager
func (*BTCWalletManager) AddBTCWallet ¶
func (walletMgr *BTCWalletManager) AddBTCWallet(wallet *BTCWallet) error
func (*BTCWalletManager) DeleteWallet ¶
func (walletMgr *BTCWalletManager) DeleteWallet(walletname string) error
func (*BTCWalletManager) GetAllBTCWallets ¶
func (walletMgr *BTCWalletManager) GetAllBTCWallets() map[string]*BTCWallet
func (*BTCWalletManager) GetDefaultAddress ¶
func (walletMgr *BTCWalletManager) GetDefaultAddress() (string, error)
func (*BTCWalletManager) GetDefaultWallet ¶
func (walletMgr *BTCWalletManager) GetDefaultWallet() (*BTCWallet, error)
func (*BTCWalletManager) GetWallet ¶
func (walletMgr *BTCWalletManager) GetWallet(walletName string) (*BTCWallet, error)
func (*BTCWalletManager) InitBTCWalletList ¶
func (walletMgr *BTCWalletManager) InitBTCWalletList(workDir string) error
type OrdxAssets ¶
type OrdxAssets struct { Ticker string // contains filtered or unexported fields }
type OrdxAssetsInfo ¶
type WalletAccount ¶
type WalletAccount struct { WalletName string `json:"WalletName"` Mnemonic string `json:"Mnemonic"` PublicKey []byte `json:"PublicKey"` PrivateKey []byte `json:"PrivateKey"` WalletInfo *BTCWalletInfo }
type WalletAccountManager ¶
type WalletAccountManager struct { DefaultWallet string WalletCount int `json:"WalletCount"` WalletAccountList []*WalletAccount `json:"WalletAccountList"` }
Click to show internal directories.
Click to hide internal directories.