multi: create and list all default internal accounts
This commit is contained in:
5 files changed
+108
-57
No files matched your search
@@ -310,6 +310,14 @@ func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispat
|
||||
return subServer, macPermissions, nil
|
||||
}
|
||||
|
||||
// internalScope returns the internal key scope.
|
||||
func (w *WalletKit) internalScope() waddrmgr.KeyScope {
|
||||
return waddrmgr.KeyScope{
|
||||
Purpose: keychain.BIP0043Purpose,
|
||||
Coin: w.cfg.ChainParams.HDCoinType,
|
||||
}
|
||||
}
|
||||
|
||||
// ListUnspent returns useful information about each unspent output owned by the
|
||||
// wallet, as reported by the underlying `ListUnspentWitness`; the information
|
||||
// returned is: outpoint, amount in satoshis, address, address type,
|
||||
@@ -1245,7 +1253,9 @@ func (w *WalletKit) FinalizePsbt(_ context.Context,
|
||||
|
||||
// marshalWalletAccount converts the properties of an account into its RPC
|
||||
// representation.
|
||||
func marshalWalletAccount(account *waddrmgr.AccountProperties) (*Account, error) {
|
||||
func marshalWalletAccount(internalScope waddrmgr.KeyScope,
|
||||
account *waddrmgr.AccountProperties) (*Account, error) {
|
||||
|
||||
var addrType AddressType
|
||||
switch account.KeyScope {
|
||||
case waddrmgr.KeyScopeBIP0049Plus:
|
||||
@@ -1259,6 +1269,10 @@ func marshalWalletAccount(account *waddrmgr.AccountProperties) (*Account, error)
|
||||
switch *account.AddrSchema {
|
||||
case waddrmgr.KeyScopeBIP0049AddrSchema:
|
||||
addrType = AddressType_NESTED_WITNESS_PUBKEY_HASH
|
||||
|
||||
case waddrmgr.ScopeAddrMap[waddrmgr.KeyScopeBIP0049Plus]:
|
||||
addrType = AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported address schema %v",
|
||||
*account.AddrSchema)
|
||||
@@ -1267,6 +1281,9 @@ func marshalWalletAccount(account *waddrmgr.AccountProperties) (*Account, error)
|
||||
case waddrmgr.KeyScopeBIP0084:
|
||||
addrType = AddressType_WITNESS_PUBKEY_HASH
|
||||
|
||||
case internalScope:
|
||||
addrType = AddressType_WITNESS_PUBKEY_HASH
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("account %v has unsupported "+
|
||||
"key scope %v", account.AccountName, account.KeyScope)
|
||||
@@ -1340,7 +1357,9 @@ func (w *WalletKit) ListAccounts(ctx context.Context,
|
||||
continue
|
||||
}
|
||||
|
||||
rpcAccount, err := marshalWalletAccount(account)
|
||||
rpcAccount, err := marshalWalletAccount(
|
||||
w.internalScope(), account,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1431,7 +1450,7 @@ func (w *WalletKit) ImportAccount(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcAccount, err := marshalWalletAccount(accountProps)
|
||||
rpcAccount, err := marshalWalletAccount(w.internalScope(), accountProps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user