Documentation ¶
Index ¶
- Constants
- Variables
- func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, net dex.Network) (asset.Wallet, error)
- type BTCCloneCFG
- type Balances
- type Driver
- func (d *Driver) Create(params *asset.CreateWalletParams) error
- func (d *Driver) DecodeCoinID(coinID []byte) (string, error)
- func (d *Driver) Exists(walletType, dataDir string, settings map[string]string, net dex.Network) (bool, error)
- func (d *Driver) Info() *asset.WalletInfo
- func (d *Driver) Open(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) (asset.Wallet, error)
- type ExchangeWalletFullNode
- func (btc ExchangeWalletFullNode) Address() (string, error)
- func (btc ExchangeWalletFullNode) AuditContract(coinID, contract, txData dex.Bytes, rebroadcast bool) (*asset.AuditInfo, error)
- func (btc ExchangeWalletFullNode) Balance() (*asset.Balance, error)
- func (btc ExchangeWalletFullNode) Connect(ctx context.Context) (*sync.WaitGroup, error)
- func (btc ExchangeWalletFullNode) EstimateRegistrationTxFee(feeRate uint64) uint64
- func (btc *ExchangeWalletFullNode) FeeRate() uint64
- func (btc ExchangeWalletFullNode) FindRedemption(ctx context.Context, coinID dex.Bytes) (redemptionCoin, secret dex.Bytes, err error)
- func (btc ExchangeWalletFullNode) FundOrder(ord *asset.Order) (asset.Coins, []dex.Bytes, error)
- func (btc ExchangeWalletFullNode) FundingCoins(ids []dex.Bytes) (asset.Coins, error)
- func (btc ExchangeWalletFullNode) Info() *asset.WalletInfo
- func (btc ExchangeWalletFullNode) IsDust(txOut *wire.TxOut, minRelayTxFee uint64) bool
- func (btc ExchangeWalletFullNode) Lock() error
- func (btc ExchangeWalletFullNode) Locked() bool
- func (btc ExchangeWalletFullNode) LocktimeExpired(contract dex.Bytes) (bool, time.Time, error)
- func (btc ExchangeWalletFullNode) MaxOrder(lotSize, feeSuggestion uint64, nfo *dex.Asset) (*asset.SwapEstimate, error)
- func (btc ExchangeWalletFullNode) Net() *chaincfg.Params
- func (btc ExchangeWalletFullNode) NewAddress() (string, error)
- func (btc ExchangeWalletFullNode) OwnsAddress(address string) (bool, error)
- func (btc ExchangeWalletFullNode) PayFee(address string, regFee, feeRate uint64) (asset.Coin, error)
- func (btc ExchangeWalletFullNode) PreRedeem(req *asset.PreRedeemForm) (*asset.PreRedeem, error)
- func (btc ExchangeWalletFullNode) PreSwap(req *asset.PreSwapForm) (*asset.PreSwap, error)
- func (btc ExchangeWalletFullNode) Redeem(form *asset.RedeemForm) ([]dex.Bytes, asset.Coin, uint64, error)
- func (btc ExchangeWalletFullNode) Refund(coinID, contract dex.Bytes, feeSuggestion uint64) (dex.Bytes, error)
- func (btc ExchangeWalletFullNode) RegFeeConfirmations(_ context.Context, id dex.Bytes) (confs uint32, err error)
- func (btc ExchangeWalletFullNode) ReturnCoins(unspents asset.Coins) error
- func (btc ExchangeWalletFullNode) SignMessage(coin asset.Coin, msg dex.Bytes) (pubkeys, sigs []dex.Bytes, err error)
- func (btc ExchangeWalletFullNode) Swap(swaps *asset.Swaps) ([]asset.Receipt, asset.Coin, uint64, error)
- func (btc ExchangeWalletFullNode) SwapConfirmations(_ context.Context, id dex.Bytes, contract dex.Bytes, startTime time.Time) (uint32, bool, error)
- func (btc ExchangeWalletFullNode) SyncStatus() (bool, float32, error)
- func (btc ExchangeWalletFullNode) Unlock(pw []byte) error
- func (btc ExchangeWalletFullNode) ValidateSecret(secret, secretHash []byte) bool
- func (btc ExchangeWalletFullNode) Withdraw(address string, value, feeRate uint64) (asset.Coin, error)
- type ExchangeWalletSPV
- func (btc ExchangeWalletSPV) Address() (string, error)
- func (btc ExchangeWalletSPV) AuditContract(coinID, contract, txData dex.Bytes, rebroadcast bool) (*asset.AuditInfo, error)
- func (btc ExchangeWalletSPV) Balance() (*asset.Balance, error)
- func (btc ExchangeWalletSPV) Connect(ctx context.Context) (*sync.WaitGroup, error)
- func (btc ExchangeWalletSPV) EstimateRegistrationTxFee(feeRate uint64) uint64
- func (btc ExchangeWalletSPV) FindRedemption(ctx context.Context, coinID dex.Bytes) (redemptionCoin, secret dex.Bytes, err error)
- func (btc ExchangeWalletSPV) FundOrder(ord *asset.Order) (asset.Coins, []dex.Bytes, error)
- func (btc ExchangeWalletSPV) FundingCoins(ids []dex.Bytes) (asset.Coins, error)
- func (btc ExchangeWalletSPV) Info() *asset.WalletInfo
- func (btc ExchangeWalletSPV) IsDust(txOut *wire.TxOut, minRelayTxFee uint64) bool
- func (btc ExchangeWalletSPV) Lock() error
- func (btc ExchangeWalletSPV) Locked() bool
- func (btc ExchangeWalletSPV) LocktimeExpired(contract dex.Bytes) (bool, time.Time, error)
- func (btc *ExchangeWalletSPV) LogFilePath() string
- func (btc ExchangeWalletSPV) MaxOrder(lotSize, feeSuggestion uint64, nfo *dex.Asset) (*asset.SwapEstimate, error)
- func (btc ExchangeWalletSPV) Net() *chaincfg.Params
- func (btc ExchangeWalletSPV) NewAddress() (string, error)
- func (btc ExchangeWalletSPV) OwnsAddress(address string) (bool, error)
- func (btc ExchangeWalletSPV) PayFee(address string, regFee, feeRate uint64) (asset.Coin, error)
- func (btc ExchangeWalletSPV) PreRedeem(req *asset.PreRedeemForm) (*asset.PreRedeem, error)
- func (btc ExchangeWalletSPV) PreSwap(req *asset.PreSwapForm) (*asset.PreSwap, error)
- func (btc ExchangeWalletSPV) Redeem(form *asset.RedeemForm) ([]dex.Bytes, asset.Coin, uint64, error)
- func (btc ExchangeWalletSPV) Refund(coinID, contract dex.Bytes, feeSuggestion uint64) (dex.Bytes, error)
- func (btc ExchangeWalletSPV) RegFeeConfirmations(_ context.Context, id dex.Bytes) (confs uint32, err error)
- func (btc *ExchangeWalletSPV) Rescan(_ context.Context) error
- func (btc ExchangeWalletSPV) ReturnCoins(unspents asset.Coins) error
- func (btc ExchangeWalletSPV) SignMessage(coin asset.Coin, msg dex.Bytes) (pubkeys, sigs []dex.Bytes, err error)
- func (btc ExchangeWalletSPV) Swap(swaps *asset.Swaps) ([]asset.Receipt, asset.Coin, uint64, error)
- func (btc ExchangeWalletSPV) SwapConfirmations(_ context.Context, id dex.Bytes, contract dex.Bytes, startTime time.Time) (uint32, bool, error)
- func (btc ExchangeWalletSPV) SyncStatus() (bool, float32, error)
- func (btc ExchangeWalletSPV) Unlock(pw []byte) error
- func (btc ExchangeWalletSPV) ValidateSecret(secret, secretHash []byte) bool
- func (btc ExchangeWalletSPV) Withdraw(address string, value, feeRate uint64) (asset.Coin, error)
- type GetAddressInfoResult
- type GetBalancesResult
- type GetTransactionResult
- type GetWalletInfoResult
- type ListUnspentResult
- type RPCOutpoint
- type RPCWalletConfig
- type RawRequester
- type RawRequesterWithContext
- type SignTxError
- type SignTxResult
- type TxInSigner
- type Wallet
- type WalletConfig
- type WalletTxCategory
- type WalletTxDetails
Constants ¶
const ( WalletTransactionNotFound = dex.ErrorKind("wallet transaction not found") SpentStatusUnknown = dex.ErrorKind("spend status not known") )
const (
// BipID is the BIP-0044 asset ID.
BipID = 0
)
Variables ¶
var ( // ContractSearchLimit is how far back in time AuditContract in SPV mode // will search for a contract if no txData is provided. This should be a // positive duration. ContractSearchLimit = 48 * time.Hour // WalletInfo defines some general information about a Bitcoin wallet. WalletInfo = &asset.WalletInfo{ Name: "Bitcoin", Version: version, UnitInfo: dexbtc.UnitInfo, AvailableWallets: []*asset.WalletDefinition{ spvWalletDefinition, rpcWalletDefinition, }, LegacyWalletIndex: 1, } )
Functions ¶
Types ¶
type BTCCloneCFG ¶
type BTCCloneCFG struct { WalletCFG *asset.WalletConfig MinNetworkVersion uint64 WalletInfo *asset.WalletInfo Symbol string Logger dex.Logger Network dex.Network ChainParams *chaincfg.Params Ports dexbtc.NetPorts DefaultFallbackFee uint64 // sats/byte DefaultFeeRateLimit uint64 // sats/byte // LegacyBalance is for clones that don't yet support the 'getbalances' RPC // call. LegacyBalance bool // If segwit is false, legacy addresses and contracts will be used. This // setting must match the configuration of the server's asset backend. Segwit bool // LegacyRawFeeLimit can be true if the RPC only supports the boolean // allowHighFees argument to the sendrawtransaction RPC. LegacyRawFeeLimit bool // AddressDecoder is an optional argument that can decode an address string // into btcutil.Address. If AddressDecoder is not supplied, // btcutil.DecodeAddress will be used. AddressDecoder dexbtc.AddressDecoder // BlockDeserializer can be used in place of (*wire.MsgBlock).Deserialize. BlockDeserializer func([]byte) (*wire.MsgBlock, error) // ArglessChangeAddrRPC can be true if the getrawchangeaddress takes no // address-type argument. ArglessChangeAddrRPC bool // NonSegwitSigner can be true if the transaction signature hash data is not // the standard for non-segwit Bitcoin. If nil, txscript. NonSegwitSigner TxInSigner // FeeEstimator provides a way to get fees given an RawRequest-enabled // client and a confirmation target. FeeEstimator func(RawRequester, uint64) (uint64, error) // OmitAddressType causes the address type (bech32, legacy) to be omitted // from calls to getnewaddress. OmitAddressType bool // LegacySignTxRPC causes the RPC client to use the signrawtransaction // endpoint instead of the signrawtransactionwithwallet endpoint. LegacySignTxRPC bool // BooleanGetBlockRPC causes the RPC client to use a boolean second argument // for the getblock endpoint, instead of Bitcoin's numeric. BooleanGetBlockRPC bool // LegacyValidateAddressRPC uses the validateaddress endpoint instead of // getwalletinfo in order to discover ownership of an address. LegacyValidateAddressRPC bool // SingularWallet signals that the node software supports only one wallet, // so the RPC endpoint does not have a /wallet/{walletname} path. SingularWallet bool // UnlockSpends manually unlocks outputs as they are spent. Most asses will // unlock wallet outputs automatically as they are spent. UnlockSpends bool // ConstantDustLimit is used if an asset enforces a dust limit (minimum // output value) that doesn't depend on the serialized size of the output. // If ConstantDustLimit is zero, dexbtc.IsDust is used. ConstantDustLimit uint64 }
BTCCloneCFG holds clone specific parameters.
type Balances ¶ added in v0.4.0
type Balances struct { Trusted float64 `json:"trusted"` Untrusted float64 `json:"untrusted_pending"` Immature float64 `json:"immature"` Used *float64 `json:"used,omitempty"` }
Balances is a categorical balance breakdown.
type Driver ¶
type Driver struct{}
Driver implements asset.Driver.
func (*Driver) Create ¶ added in v0.4.0
func (d *Driver) Create(params *asset.CreateWalletParams) error
Create creates a new SPV wallet.
func (*Driver) DecodeCoinID ¶
DecodeCoinID creates a human-readable representation of a coin ID for Bitcoin.
func (*Driver) Exists ¶ added in v0.4.0
func (d *Driver) Exists(walletType, dataDir string, settings map[string]string, net dex.Network) (bool, error)
Exists checks the existence of the wallet. Part of the Creator interface, so only used for wallets with WalletDefinition.Seeded = true.
func (*Driver) Info ¶
func (d *Driver) Info() *asset.WalletInfo
Info returns basic information about the wallet and asset.
type ExchangeWalletFullNode ¶ added in v0.4.3
type ExchangeWalletFullNode struct {
// contains filtered or unexported fields
}
ExchangeWalletFullNode implements Wallet and adds the FeeRate method.
func BTCCloneWallet ¶
func BTCCloneWallet(cfg *BTCCloneCFG) (*ExchangeWalletFullNode, error)
BTCCloneWallet creates a wallet backend for a set of network parameters and default network ports. A BTC clone can use this method, possibly in conjunction with ReadCloneParams, to create a ExchangeWallet for other assets with minimal coding.
func (ExchangeWalletFullNode) Address ¶ added in v0.4.3
Address returns an external address from the wallet.
func (ExchangeWalletFullNode) AuditContract ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) AuditContract(coinID, contract, txData dex.Bytes, rebroadcast bool) (*asset.AuditInfo, error)
AuditContract retrieves information about a swap contract from the provided txData. The extracted information would be used to audit the counter-party's contract during a swap. The txData may be empty to attempt retrieval of the transaction output from the network, but it is only ensured to succeed for a full node or, if the tx is confirmed, an SPV wallet. Normally the server should communicate this txData, and the caller can decide to require it. The ability to work with an empty txData is a convenience for recovery tools and testing, and it may change in the future if a GetTxData method is added for this purpose.
func (ExchangeWalletFullNode) Balance ¶ added in v0.4.3
Balance returns the total available funds in the wallet. Part of the asset.Wallet interface.
func (ExchangeWalletFullNode) Connect ¶ added in v0.4.3
Connect connects the wallet to the RPC server. Satisfies the dex.Connector interface.
func (ExchangeWalletFullNode) EstimateRegistrationTxFee ¶ added in v0.4.3
EstimateRegistrationTxFee returns an estimate for the tx fee needed to pay the registration fee using the provided feeRate.
func (*ExchangeWalletFullNode) FeeRate ¶ added in v0.4.3
func (btc *ExchangeWalletFullNode) FeeRate() uint64
FeeRate satisfies asset.FeeRater.
func (ExchangeWalletFullNode) FindRedemption ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) FindRedemption(ctx context.Context, coinID dex.Bytes) (redemptionCoin, secret dex.Bytes, err error)
FindRedemption watches for the input that spends the specified contract coin, and returns the spending input and the contract's secret key when it finds a spender.
This method blocks until the redemption is found, an error occurs or the provided context is canceled.
func (ExchangeWalletFullNode) FundOrder ¶ added in v0.4.3
FundOrder selects coins for use in an order. The coins will be locked, and will not be returned in subsequent calls to FundOrder or calculated in calls to Available, unless they are unlocked with ReturnCoins. The returned []dex.Bytes contains the redeem scripts for the selected coins. Equal number of coins and redeemed scripts must be returned. A nil or empty dex.Bytes should be appended to the redeem scripts collection for coins with no redeem script.
func (ExchangeWalletFullNode) FundingCoins ¶ added in v0.4.3
FundingCoins gets funding coins for the coin IDs. The coins are locked. This method might be called to reinitialize an order from data stored externally. This method will only return funding coins, e.g. unspent transaction outputs.
func (ExchangeWalletFullNode) Info ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Info() *asset.WalletInfo
Info returns basic information about the wallet and asset.
func (ExchangeWalletFullNode) IsDust ¶ added in v0.4.3
IsDust checks if the tx output's value is dust. If the dustLimit is set, it is compared against that, otherwise the formula in dexbtc.IsDust is used.
func (ExchangeWalletFullNode) Lock ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Lock() error
Lock locks the ExchangeWallet and the underlying bitcoind wallet.
func (ExchangeWalletFullNode) Locked ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Locked() bool
Locked will be true if the wallet is currently locked.
func (ExchangeWalletFullNode) LocktimeExpired ¶ added in v0.4.3
LocktimeExpired returns true if the specified contract's locktime has expired, making it possible to issue a Refund.
func (ExchangeWalletFullNode) MaxOrder ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) MaxOrder(lotSize, feeSuggestion uint64, nfo *dex.Asset) (*asset.SwapEstimate, error)
MaxOrder generates information about the maximum order size and associated fees that the wallet can support for the given DEX configuration. The fees are an estimate based on current network conditions, and will be <= the fees associated with nfo.MaxFeeRate. For quote assets, the caller will have to calculate lotSize based on a rate conversion from the base asset's lot size. lotSize must not be zero and will cause a panic if so.
func (ExchangeWalletFullNode) Net ¶ added in v0.4.3
Net returns the ExchangeWallet's *chaincfg.Params. This is not part of the asset.Wallet interface, but is provided as a convenience for embedding types.
func (ExchangeWalletFullNode) NewAddress ¶ added in v0.4.3
NewAddress returns a new address from the wallet. This satisfies the NewAddresser interface.
func (ExchangeWalletFullNode) OwnsAddress ¶ added in v0.4.3
OwnsAddress indicates if an address belongs to the wallet.
func (ExchangeWalletFullNode) PayFee ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) PayFee(address string, regFee, feeRate uint64) (asset.Coin, error)
PayFee sends the dex registration fee. Transaction fees are in addition to the registration fee, and the fee rate is taken from the DEX configuration.
func (ExchangeWalletFullNode) PreRedeem ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) PreRedeem(req *asset.PreRedeemForm) (*asset.PreRedeem, error)
PreRedeem generates an estimate of the range of redemption fees that could be assessed.
func (ExchangeWalletFullNode) PreSwap ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) PreSwap(req *asset.PreSwapForm) (*asset.PreSwap, error)
PreSwap get order estimates based on the available funds and the wallet configuration.
func (ExchangeWalletFullNode) Redeem ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Redeem(form *asset.RedeemForm) ([]dex.Bytes, asset.Coin, uint64, error)
Redeem sends the redemption transaction, completing the atomic swap.
func (ExchangeWalletFullNode) Refund ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Refund(coinID, contract dex.Bytes, feeSuggestion uint64) (dex.Bytes, error)
Refund revokes a contract. This can only be used after the time lock has expired. This MUST return an asset.CoinNotFoundError error if the coin is spent. NOTE: The contract cannot be retrieved from the unspent coin info as the wallet does not store it, even though it was known when the init transaction was created. The client should store this information for persistence across sessions.
func (ExchangeWalletFullNode) RegFeeConfirmations ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) RegFeeConfirmations(_ context.Context, id dex.Bytes) (confs uint32, err error)
RegFeeConfirmations gets the number of confirmations for the specified output by first checking for a unspent output, and if not found, searching indexed wallet transactions.
func (ExchangeWalletFullNode) ReturnCoins ¶ added in v0.4.3
ReturnCoins unlocks coins. This would be used in the case of a canceled or partially filled order. Part of the asset.Wallet interface.
func (ExchangeWalletFullNode) SignMessage ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) SignMessage(coin asset.Coin, msg dex.Bytes) (pubkeys, sigs []dex.Bytes, err error)
SignMessage signs the message with the private key associated with the specified unspent coin. A slice of pubkeys required to spend the coin and a signature for each pubkey are returned.
func (ExchangeWalletFullNode) Swap ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) Swap(swaps *asset.Swaps) ([]asset.Receipt, asset.Coin, uint64, error)
Swap sends the swaps in a single transaction and prepares the receipts. The Receipts returned can be used to refund a failed transaction. The Input coins are NOT manually unlocked because they're auto-unlocked when the transaction is broadcasted.
func (ExchangeWalletFullNode) SwapConfirmations ¶ added in v0.4.3
func (btc ExchangeWalletFullNode) SwapConfirmations(_ context.Context, id dex.Bytes, contract dex.Bytes, startTime time.Time) (uint32, bool, error)
SwapConfirmations gets the number of confirmations for the specified swap by first checking for a unspent output, and if not found, searching indexed wallet transactions.
func (ExchangeWalletFullNode) SyncStatus ¶ added in v0.4.3
SyncStatus is information about the blockchain sync status.
func (ExchangeWalletFullNode) Unlock ¶ added in v0.4.3
Unlock unlocks the ExchangeWallet. The pw supplied should be the same as the password for the underlying bitcoind wallet which will also be unlocked.
func (ExchangeWalletFullNode) ValidateSecret ¶ added in v0.4.3
ValidateSecret checks that the secret satisfies the contract.
type ExchangeWalletSPV ¶ added in v0.4.1
type ExchangeWalletSPV struct {
// contains filtered or unexported fields
}
ExchangeWalletSPV embeds a ExchangeWallet, but also provides the Rescan method to implement asset.Rescanner.
func (ExchangeWalletSPV) Address ¶ added in v0.4.3
Address returns an external address from the wallet.
func (ExchangeWalletSPV) AuditContract ¶ added in v0.4.3
func (btc ExchangeWalletSPV) AuditContract(coinID, contract, txData dex.Bytes, rebroadcast bool) (*asset.AuditInfo, error)
AuditContract retrieves information about a swap contract from the provided txData. The extracted information would be used to audit the counter-party's contract during a swap. The txData may be empty to attempt retrieval of the transaction output from the network, but it is only ensured to succeed for a full node or, if the tx is confirmed, an SPV wallet. Normally the server should communicate this txData, and the caller can decide to require it. The ability to work with an empty txData is a convenience for recovery tools and testing, and it may change in the future if a GetTxData method is added for this purpose.
func (ExchangeWalletSPV) Balance ¶ added in v0.4.3
Balance returns the total available funds in the wallet. Part of the asset.Wallet interface.
func (ExchangeWalletSPV) Connect ¶ added in v0.4.3
Connect connects the wallet to the RPC server. Satisfies the dex.Connector interface.
func (ExchangeWalletSPV) EstimateRegistrationTxFee ¶ added in v0.4.3
EstimateRegistrationTxFee returns an estimate for the tx fee needed to pay the registration fee using the provided feeRate.
func (ExchangeWalletSPV) FindRedemption ¶ added in v0.4.3
func (btc ExchangeWalletSPV) FindRedemption(ctx context.Context, coinID dex.Bytes) (redemptionCoin, secret dex.Bytes, err error)
FindRedemption watches for the input that spends the specified contract coin, and returns the spending input and the contract's secret key when it finds a spender.
This method blocks until the redemption is found, an error occurs or the provided context is canceled.
func (ExchangeWalletSPV) FundOrder ¶ added in v0.4.3
FundOrder selects coins for use in an order. The coins will be locked, and will not be returned in subsequent calls to FundOrder or calculated in calls to Available, unless they are unlocked with ReturnCoins. The returned []dex.Bytes contains the redeem scripts for the selected coins. Equal number of coins and redeemed scripts must be returned. A nil or empty dex.Bytes should be appended to the redeem scripts collection for coins with no redeem script.
func (ExchangeWalletSPV) FundingCoins ¶ added in v0.4.3
FundingCoins gets funding coins for the coin IDs. The coins are locked. This method might be called to reinitialize an order from data stored externally. This method will only return funding coins, e.g. unspent transaction outputs.
func (ExchangeWalletSPV) Info ¶ added in v0.4.3
func (btc ExchangeWalletSPV) Info() *asset.WalletInfo
Info returns basic information about the wallet and asset.
func (ExchangeWalletSPV) IsDust ¶ added in v0.4.3
IsDust checks if the tx output's value is dust. If the dustLimit is set, it is compared against that, otherwise the formula in dexbtc.IsDust is used.
func (ExchangeWalletSPV) Lock ¶ added in v0.4.3
func (btc ExchangeWalletSPV) Lock() error
Lock locks the ExchangeWallet and the underlying bitcoind wallet.
func (ExchangeWalletSPV) Locked ¶ added in v0.4.3
func (btc ExchangeWalletSPV) Locked() bool
Locked will be true if the wallet is currently locked.
func (ExchangeWalletSPV) LocktimeExpired ¶ added in v0.4.3
LocktimeExpired returns true if the specified contract's locktime has expired, making it possible to issue a Refund.
func (*ExchangeWalletSPV) LogFilePath ¶ added in v0.4.1
func (btc *ExchangeWalletSPV) LogFilePath() string
LogFilePath returns the path to the neutrino log file.
func (ExchangeWalletSPV) MaxOrder ¶ added in v0.4.3
func (btc ExchangeWalletSPV) MaxOrder(lotSize, feeSuggestion uint64, nfo *dex.Asset) (*asset.SwapEstimate, error)
MaxOrder generates information about the maximum order size and associated fees that the wallet can support for the given DEX configuration. The fees are an estimate based on current network conditions, and will be <= the fees associated with nfo.MaxFeeRate. For quote assets, the caller will have to calculate lotSize based on a rate conversion from the base asset's lot size. lotSize must not be zero and will cause a panic if so.
func (ExchangeWalletSPV) Net ¶ added in v0.4.3
Net returns the ExchangeWallet's *chaincfg.Params. This is not part of the asset.Wallet interface, but is provided as a convenience for embedding types.
func (ExchangeWalletSPV) NewAddress ¶ added in v0.4.3
NewAddress returns a new address from the wallet. This satisfies the NewAddresser interface.
func (ExchangeWalletSPV) OwnsAddress ¶ added in v0.4.3
OwnsAddress indicates if an address belongs to the wallet.
func (ExchangeWalletSPV) PayFee ¶ added in v0.4.3
PayFee sends the dex registration fee. Transaction fees are in addition to the registration fee, and the fee rate is taken from the DEX configuration.
func (ExchangeWalletSPV) PreRedeem ¶ added in v0.4.3
func (btc ExchangeWalletSPV) PreRedeem(req *asset.PreRedeemForm) (*asset.PreRedeem, error)
PreRedeem generates an estimate of the range of redemption fees that could be assessed.
func (ExchangeWalletSPV) PreSwap ¶ added in v0.4.3
func (btc ExchangeWalletSPV) PreSwap(req *asset.PreSwapForm) (*asset.PreSwap, error)
PreSwap get order estimates based on the available funds and the wallet configuration.
func (ExchangeWalletSPV) Redeem ¶ added in v0.4.3
func (btc ExchangeWalletSPV) Redeem(form *asset.RedeemForm) ([]dex.Bytes, asset.Coin, uint64, error)
Redeem sends the redemption transaction, completing the atomic swap.
func (ExchangeWalletSPV) Refund ¶ added in v0.4.3
func (btc ExchangeWalletSPV) Refund(coinID, contract dex.Bytes, feeSuggestion uint64) (dex.Bytes, error)
Refund revokes a contract. This can only be used after the time lock has expired. This MUST return an asset.CoinNotFoundError error if the coin is spent. NOTE: The contract cannot be retrieved from the unspent coin info as the wallet does not store it, even though it was known when the init transaction was created. The client should store this information for persistence across sessions.
func (ExchangeWalletSPV) RegFeeConfirmations ¶ added in v0.4.3
func (btc ExchangeWalletSPV) RegFeeConfirmations(_ context.Context, id dex.Bytes) (confs uint32, err error)
RegFeeConfirmations gets the number of confirmations for the specified output by first checking for a unspent output, and if not found, searching indexed wallet transactions.
func (*ExchangeWalletSPV) Rescan ¶ added in v0.4.1
func (btc *ExchangeWalletSPV) Rescan(_ context.Context) error
Rescan satisfies the asset.Rescanner interface, and issues a rescan wallet command if the backend is an SPV wallet.
func (ExchangeWalletSPV) ReturnCoins ¶ added in v0.4.3
ReturnCoins unlocks coins. This would be used in the case of a canceled or partially filled order. Part of the asset.Wallet interface.
func (ExchangeWalletSPV) SignMessage ¶ added in v0.4.3
func (btc ExchangeWalletSPV) SignMessage(coin asset.Coin, msg dex.Bytes) (pubkeys, sigs []dex.Bytes, err error)
SignMessage signs the message with the private key associated with the specified unspent coin. A slice of pubkeys required to spend the coin and a signature for each pubkey are returned.
func (ExchangeWalletSPV) Swap ¶ added in v0.4.3
Swap sends the swaps in a single transaction and prepares the receipts. The Receipts returned can be used to refund a failed transaction. The Input coins are NOT manually unlocked because they're auto-unlocked when the transaction is broadcasted.
func (ExchangeWalletSPV) SwapConfirmations ¶ added in v0.4.3
func (btc ExchangeWalletSPV) SwapConfirmations(_ context.Context, id dex.Bytes, contract dex.Bytes, startTime time.Time) (uint32, bool, error)
SwapConfirmations gets the number of confirmations for the specified swap by first checking for a unspent output, and if not found, searching indexed wallet transactions.
func (ExchangeWalletSPV) SyncStatus ¶ added in v0.4.3
SyncStatus is information about the blockchain sync status.
func (ExchangeWalletSPV) Unlock ¶ added in v0.4.3
Unlock unlocks the ExchangeWallet. The pw supplied should be the same as the password for the underlying bitcoind wallet which will also be unlocked.
func (ExchangeWalletSPV) ValidateSecret ¶ added in v0.4.3
ValidateSecret checks that the secret satisfies the contract.
type GetAddressInfoResult ¶
type GetAddressInfoResult struct {
IsMine bool `json:"ismine"`
}
GetAddressInfoResult models the data from the getaddressinfo command.
type GetBalancesResult ¶
GetBalancesResult models a successful response from the getbalances request.
type GetTransactionResult ¶
type GetTransactionResult struct { Amount float64 `json:"amount"` Fee float64 `json:"fee"` Confirmations uint64 `json:"confirmations"` BlockHash string `json:"blockhash"` BlockIndex int64 `json:"blockindex"` BlockTime uint64 `json:"blocktime"` TxID string `json:"txid"` Time uint64 `json:"time"` TimeReceived uint64 `json:"timereceived"` BipReplaceable string `json:"bip125-replaceable"` Hex dex.Bytes `json:"hex"` Details []*WalletTxDetails `json:"details"` }
GetTransactionResult models the data from the gettransaction command.
type GetWalletInfoResult ¶
type GetWalletInfoResult struct { WalletName string `json:"walletname"` WalletVersion uint32 `json:"walletversion"` Format string `json:"format"` Balance float64 `json:"balance"` UnconfirmedBalance float64 `json:"unconfirmed_balance"` ImmatureBalance float64 `json:"immature_balance"` TxCount uint32 `json:"txcount"` KeyPoolOldest uint64 `json:"keypoololdest"` KeyPoolSize uint32 `json:"keypoolsize"` KeyPoolSizeHDInternal uint32 `json:"keypoolsize_hd_internal"` PayTxFee float64 `json:"paytxfee"` HdSeedID string `json:"hdseedid"` // UnlockedUntil is a pointer because for encrypted locked wallets, it will // be zero, but for unencrypted wallets the field won't be present in the // response. UnlockedUntil *int64 `json:"unlocked_until"` // HDMasterKeyID is dropped in Bitcoin Core 0.18 HdMasterKeyID string `json:"hdmasterkeyid"` PriveyKeysEnabled bool `json:"private_keys_enabled"` // AvoidReuse and Scanning were added in Bitcoin Core 0.19 AvoidReuse bool `json:"avoid_reuse"` // Scanning is either a struct or boolean false, and since we're not using // it, commenting avoids having to deal with marshaling for now. // Scanning struct { // Duration uint32 `json:"duration"` // Progress float32 `json:"progress"` // } `json:"scanning"` Descriptors bool `json:"descriptors"` // Descriptor wallets that do not support dumpprivkey }
GetWalletInfoResult models the data from the getwalletinfo command.
type ListUnspentResult ¶
type ListUnspentResult struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` Address string `json:"address"` Label string `json:"label"` ScriptPubKey dex.Bytes `json:"scriptPubKey"` Amount float64 `json:"amount"` Confirmations uint32 `json:"confirmations"` RedeemScript dex.Bytes `json:"redeemScript"` Spendable bool `json:"spendable"` Solvable bool `json:"solvable"` SafePtr *bool `json:"safe"` }
ListUnspentResult models a successful response from the listunspent request.
func (*ListUnspentResult) Safe ¶
func (l *ListUnspentResult) Safe() bool
type RPCOutpoint ¶
RPCOutpoint is used to specify outputs to lock in calls to lockunspent.
type RPCWalletConfig ¶ added in v0.4.0
type RPCWalletConfig struct { dexbtc.RPCConfig WalletConfig }
RPCWalletConfig is a combination of RPCConfig and WalletConfig. Used for a wallet based on a bitcoind-like RPC API.
type RawRequester ¶ added in v0.2.0
type RawRequester interface {
RawRequest(string, []json.RawMessage) (json.RawMessage, error)
}
RawRequester defines decred's rpcclient RawRequest func where all RPC requests sent through. For testing, it can be satisfied by a stub.
type RawRequesterWithContext ¶ added in v0.4.0
type RawRequesterWithContext interface {
RawRequest(context.Context, string, []json.RawMessage) (json.RawMessage, error)
}
RawRequesterWithContext defines decred's rpcclient RawRequest func where all RPC requests sent through. For testing, it can be satisfied by a stub.
type SignTxError ¶
type SignTxError struct { TxID string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig dex.Bytes `json:"scriptSig"` Sequence uint64 `json:"sequence"` Error string `json:"error"` }
SignTxError models the data that contains script verification errors from the signrawtransaction request
type SignTxResult ¶
type SignTxResult struct { Hex dex.Bytes `json:"hex"` Complete bool `json:"complete"` Errors []*SignTxError `json:"errors"` }
SignTxResult models the data from the signrawtransaction command.
type TxInSigner ¶ added in v0.2.0
type TxInSigner func(tx *wire.MsgTx, idx int, subScript []byte, hashType txscript.SigHashType, key *btcec.PrivateKey, val uint64) ([]byte, error)
TxInSigner is a transaction input signer.
type Wallet ¶ added in v0.4.0
type Wallet interface { RawRequester // contains filtered or unexported methods }
type WalletConfig ¶ added in v0.4.0
type WalletConfig struct { UseSplitTx bool `ini:"txsplit"` FallbackFeeRate float64 `ini:"fallbackfee"` FeeRateLimit float64 `ini:"feeratelimit"` RedeemConfTarget uint64 `ini:"redeemconftarget"` WalletName string `ini:"walletname"` // RPC Peer string `ini:"peer"` // SPV }
WalletConfig are wallet-level configuration settings.
type WalletTxCategory ¶
type WalletTxCategory string
WalletTxCategory is the tx output category set in WalletTxDetails.
const ( TxCatSend WalletTxCategory = "send" TxCatReceive WalletTxCategory = "receive" TxCatGenerate WalletTxCategory = "generate" TxCatImmature WalletTxCategory = "immature" TxCatOrphan WalletTxCategory = "orphan" )
type WalletTxDetails ¶
type WalletTxDetails struct { Address string `json:"address"` Category WalletTxCategory `json:"category"` Amount float64 `json:"amount"` Label string `json:"label"` Vout uint32 `json:"vout"` Fee float64 `json:"fee"` Abandoned bool `json:"abandoned"` }
WalletTxDetails models the details data from the gettransaction command.