Documentation ¶
Index ¶
- Constants
- Variables
- type AccountInfo
- type AccountService
- func (as *AccountService) CreateAccountBIP44(ctx context.Context, label string, unconf bool) (*AccountInfo, error)
- func (as *AccountService) DeleteAccount(ctx context.Context, accountName string) (err error)
- func (as *AccountService) DeriveAddressesForAccount(ctx context.Context, accountName string, numOfAddresses uint64) (AddressesInfo, error)
- func (as *AccountService) DeriveChangeAddressesForAccount(ctx context.Context, accountName string, numOfAddresses uint64) (AddressesInfo, error)
- func (as *AccountService) GetBalanceForAccount(ctx context.Context, accountName string) (BalanceInfo, error)
- func (as *AccountService) ListAddressesForAccount(ctx context.Context, accountName string) (AddressesInfo, error)
- func (as *AccountService) ListUtxosForAccount(ctx context.Context, accountName string) (*UtxoInfo, error)
- func (as *AccountService) SetAccountLabel(ctx context.Context, accountName, label string) (*AccountInfo, error)
- type AddressesInfo
- type BalanceInfo
- type BlockInfo
- type BuildInfo
- type CoinSelectorFactory
- type Input
- type Inputs
- type NotificationService
- func (ns *NotificationService) GetTxChannel(ctx context.Context) (chan domain.TransactionEvent, error)
- func (ns *NotificationService) GetUtxoChannel(ctx context.Context) (chan domain.UtxoEvent, error)
- func (ns *NotificationService) StopWatchingScript(ctx context.Context, label string) error
- func (ns *NotificationService) WatchScript(ctx context.Context, scriptHex, blindingKey string) (string, error)
- type Output
- type Outputs
- type TransactionInfo
- type TransactionService
- func (ts *TransactionService) BlindPset(ctx context.Context, ptx string, extraUnblindedInputs []UnblindedInput, ...) (string, error)
- func (ts *TransactionService) BroadcastTransaction(ctx context.Context, txHex string) (string, error)
- func (ts *TransactionService) CreatePset(ctx context.Context, inputs Inputs, outputs Outputs) (string, error)
- func (ts *TransactionService) EstimateFees(ctx context.Context, ins Inputs, outs Outputs, millisatsPerByte uint64) (uint64, error)
- func (ts *TransactionService) GetTransactionInfo(ctx context.Context, txid string) (*TransactionInfo, error)
- func (ts *TransactionService) LockUtxos(ctx context.Context, accountName string, ins Inputs) (int64, error)
- func (ts *TransactionService) SelectUtxos(ctx context.Context, accountName, targetAsset string, targetAmount uint64, ...) (Utxos, uint64, int64, error)
- func (ts *TransactionService) SignPset(ctx context.Context, ptx string, sighashType uint32) (string, error)
- func (ts *TransactionService) SignPsetWithSchnorrKey(ctx context.Context, tx string, sighashType uint32) (string, error)
- func (ts *TransactionService) SignTransaction(ctx context.Context, txHex string, sighashType uint32) (string, error)
- func (ts *TransactionService) Transfer(ctx context.Context, accountName string, outputs Outputs, ...) (string, error)
- func (ts *TransactionService) UpdatePset(ctx context.Context, ptx string, inputs Inputs, outputs Outputs) (string, error)
- type UnblindedInput
- type UtxoInfo
- type UtxoKeys
- type Utxos
- type UtxosInfo
- type WalletInfo
- type WalletRestoreMessage
- type WalletService
- func (ws *WalletService) Auth(ctx context.Context, password string) (bool, error)
- func (ws *WalletService) ChangePassword(ctx context.Context, currentPassword, newPassword string) error
- func (ws *WalletService) CreateWallet(ctx context.Context, mnemonic []string, passphrase string) (err error)
- func (ws *WalletService) GenSeed(ctx context.Context) ([]string, error)
- func (ws *WalletService) GetInfo(ctx context.Context) (*WalletInfo, error)
- func (ws *WalletService) GetStatus(_ context.Context) WalletStatus
- func (ws *WalletService) Lock(ctx context.Context, password string) (err error)
- func (ws *WalletService) RegisterHandlerForWalletEvent(eventType domain.WalletEventType, handler ports.WalletEventHandler)
- func (ws *WalletService) RestoreWallet(ctx context.Context, chMessages chan WalletRestoreMessage, mnemonic []string, ...)
- func (ws *WalletService) Unlock(ctx context.Context, password string) (err error)
- type WalletStatus
Constants ¶
const (
CoinSelectionStrategySmallestSubset = iota
)
Variables ¶
var ( DefaultCoinSelector = ss_selector.NewSmallestSubsetCoinSelector() MinMillisatsPerByte = uint64(100) )
var (
ErrForbiddenUnlockedInputs = fmt.Errorf(
"the utxos used within 'external' transactions must be coming from a " +
"wallet's coin selection so that they can be temporary locked and " +
"prevent to accidentally double spending them",
)
)
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct {
domain.AccountInfo
}
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService is responsible for operations related to wallet accounts:
- Create a new account.
- Derive addresses for an existing account.
- List derived addresses for an existing account.
- Get balance of an existing account.
- List utxos of an existing account.
- Delete an existing account.
The service registers 3 handlers related to the following wallet events:
- domain.WalletAccountCreated - whenever an account is created, the service initializes a dedicated blockchain scanner and starts listening for its reports.
- domain.WalletAccountAddressesDerived - whenever one or more addresses are derived for an account, they are added to the list of those watched by the account's scanner.
- domain.WalletAccountDeleted - whenever an account is deleted, the relative scanner is stopped and removed.
The service guarantees to be always listening to notifications coming from each of its blockchain scanners in order to keep updated the utxo set of the relative accounts, ie. at startup it takes care of initializing a scanner for any existing account in case the wallet is already initialized and was just restarted.
func NewAccountService ¶
func NewAccountService( repoManager ports.RepoManager, bcScanner ports.BlockchainScanner, ) *AccountService
func (*AccountService) CreateAccountBIP44 ¶
func (as *AccountService) CreateAccountBIP44( ctx context.Context, label string, unconf bool, ) (*AccountInfo, error)
func (*AccountService) DeleteAccount ¶
func (as *AccountService) DeleteAccount( ctx context.Context, accountName string, ) (err error)
func (*AccountService) DeriveAddressesForAccount ¶ added in v0.1.3
func (as *AccountService) DeriveAddressesForAccount( ctx context.Context, accountName string, numOfAddresses uint64, ) (AddressesInfo, error)
func (*AccountService) DeriveChangeAddressesForAccount ¶ added in v0.1.3
func (as *AccountService) DeriveChangeAddressesForAccount( ctx context.Context, accountName string, numOfAddresses uint64, ) (AddressesInfo, error)
func (*AccountService) GetBalanceForAccount ¶
func (as *AccountService) GetBalanceForAccount( ctx context.Context, accountName string, ) (BalanceInfo, error)
func (*AccountService) ListAddressesForAccount ¶
func (as *AccountService) ListAddressesForAccount( ctx context.Context, accountName string, ) (AddressesInfo, error)
func (*AccountService) ListUtxosForAccount ¶
func (*AccountService) SetAccountLabel ¶ added in v0.1.16
func (as *AccountService) SetAccountLabel( ctx context.Context, accountName, label string, ) (*AccountInfo, error)
type AddressesInfo ¶
type AddressesInfo []domain.AddressInfo
func (AddressesInfo) Addresses ¶
func (info AddressesInfo) Addresses() []string
type BalanceInfo ¶
type CoinSelectorFactory ¶
type CoinSelectorFactory func() ports.CoinSelector
type NotificationService ¶
type NotificationService struct {
// contains filtered or unexported fields
}
Notification service has the very simple task of making the event channels of the used domain.TransactionRepository and domain.UtxoRepository accessible by external clients so that they can get real-time updates on the status of the internal wallet.
func NewNotificationService ¶
func NewNotificationService( repoManager ports.RepoManager, bcScanner ports.BlockchainScanner, ) *NotificationService
func (*NotificationService) GetTxChannel ¶
func (ns *NotificationService) GetTxChannel( ctx context.Context, ) (chan domain.TransactionEvent, error)
func (*NotificationService) GetUtxoChannel ¶
func (*NotificationService) StopWatchingScript ¶ added in v0.2.0
func (ns *NotificationService) StopWatchingScript( ctx context.Context, label string, ) error
func (*NotificationService) WatchScript ¶ added in v0.2.0
type Output ¶
type TransactionInfo ¶
type TransactionInfo domain.Transaction
type TransactionService ¶
type TransactionService struct {
// contains filtered or unexported fields
}
TransactionService is responsible for operations related to one or more accounts:
- Get info about a wallet-related transaction.
- Select a subset of the utxos of an existing account to cover a target amount. The selected utxos will be temporary locked to prevent double spending them.
- Estimate the fee amount for a transation composed by X inputs and Y outputs. It is required that the inputs owned by the wallet are locked utxos.
- Sign a raw transaction (in hex format). It is required that the inputs of the tx owned by the wallet are locked utxos.
- Broadcast a raw transaction (in hex format). It is required that the inputs of the tx owned by the wallet are locked utxos.
- Create a partial transaction (v2) given a list of inputs and outputs. It is required that the inputs of the tx owned by the wallet are locked utxos.
- Add inputs or outputs to partial transaction (v2). It is required that the inputs of the tx owned by the wallet are locked utxos.
- Blind a partial transaction (v2) either as non-last or last blinder. It is required that the inputs of the tx owned by the wallet are locked utxos.
- Sign a partial transaction (v2). It is required that the inputs of the tx owned by the wallet are locked utxos.
- Craft a finalized transaction to transfer some funds from an existing account to somewhere else, given a list of outputs.
The service registers 1 handler for the following utxo event:
- domain.UtxoLocked - whenever one or more utxos are locked, the service spawns a so-called unlocker, a goroutine wating for X seconds before unlocking them if necessary. The operation is just skipped if the utxos have been spent meanwhile.
The service guarantees that any locked utxo is eventually unlocked ASAP after the waiting time expires. Therefore, at startup, it makes sure to unlock any still-locked utxo that can be unlocked, and to spawn the required numnber of unlockers for those whose waiting time didn't expire yet.
func NewTransactionService ¶
func NewTransactionService( repoManager ports.RepoManager, bcScanner ports.BlockchainScanner, net *network.Network, utxoExpiryDuration time.Duration, dustAmount uint64, ) *TransactionService
func (*TransactionService) BlindPset ¶
func (ts *TransactionService) BlindPset( ctx context.Context, ptx string, extraUnblindedInputs []UnblindedInput, lastBlinder bool, ) (string, error)
func (*TransactionService) BroadcastTransaction ¶
func (*TransactionService) CreatePset ¶
func (*TransactionService) EstimateFees ¶
func (*TransactionService) GetTransactionInfo ¶
func (ts *TransactionService) GetTransactionInfo( ctx context.Context, txid string, ) (*TransactionInfo, error)
func (*TransactionService) SelectUtxos ¶
func (*TransactionService) SignPsetWithSchnorrKey ¶ added in v0.2.2
func (*TransactionService) SignTransaction ¶
func (*TransactionService) UpdatePset ¶
type UnblindedInput ¶ added in v0.1.3
type WalletInfo ¶
type WalletRestoreMessage ¶ added in v0.1.16
type WalletService ¶
type WalletService struct {
// contains filtered or unexported fields
}
WalletService is responsible for operations related to the managment of the wallet:
- Generate a new random 24-words mnemonic.
- Create a new wallet from scratch with given mnemonic and locked with the given password.
- Unlock the wallet with a password.
- Change the wallet password. It requires the wallet to be locked.
- Get the status of the wallet (initialized, unlocked, inSync).
- Get non-sensiive (network, native asset) and possibly sensitive info (root path, master blinding key and basic accounts' info) about the wallet. Sensitive info are returned only if the wallet is unlocked.
This service doesn't register any handler for wallet events, rather it allows its users to register their handler to manage situations like the unlocking of the wallet (for example, check how the grpc service uses this feature).
func NewWalletService ¶
func NewWalletService( repoManager ports.RepoManager, bcScanner ports.BlockchainScanner, rootPath string, net *network.Network, buildInfo BuildInfo, ) *WalletService
func (*WalletService) ChangePassword ¶
func (ws *WalletService) ChangePassword( ctx context.Context, currentPassword, newPassword string, ) error
func (*WalletService) CreateWallet ¶
func (*WalletService) GenSeed ¶
func (ws *WalletService) GenSeed(ctx context.Context) ([]string, error)
func (*WalletService) GetInfo ¶
func (ws *WalletService) GetInfo(ctx context.Context) (*WalletInfo, error)
func (*WalletService) GetStatus ¶
func (ws *WalletService) GetStatus(_ context.Context) WalletStatus
func (*WalletService) Lock ¶
func (ws *WalletService) Lock( ctx context.Context, password string, ) (err error)
func (*WalletService) RegisterHandlerForWalletEvent ¶
func (ws *WalletService) RegisterHandlerForWalletEvent( eventType domain.WalletEventType, handler ports.WalletEventHandler, )
func (*WalletService) RestoreWallet ¶
func (ws *WalletService) RestoreWallet( ctx context.Context, chMessages chan WalletRestoreMessage, mnemonic []string, rootPath, passpharse string, birthdayBlockHeight, emptyAccountsThreshold, unusedAddressesThreshold uint32, )