mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
lnwallet+lnrpc: add address index to ListAddresses
For the itest in the next commit we'll need to be able to fetch the input information for an address over RPC. The only piece missing is the address' index, which we add in this commit. Everything else should be derivable from the ListAddresses and ListAccounts calls.
This commit is contained in:
@@ -815,17 +815,35 @@ func (b *BtcWallet) ListAddresses(name string,
|
||||
|
||||
// Hex-encode the compressed public key for custom lnd
|
||||
// keys, addresses don't make a lot of sense.
|
||||
pubKey, ok := managedAddr.(waddrmgr.ManagedPubKeyAddress)
|
||||
if ok && isLndCustom {
|
||||
var (
|
||||
pubKey *btcec.PublicKey
|
||||
derivationPath string
|
||||
)
|
||||
pka, ok := managedAddr.(waddrmgr.ManagedPubKeyAddress)
|
||||
if ok {
|
||||
pubKey = pka.PubKey()
|
||||
|
||||
// There can be an error in two cases: Either
|
||||
// the address isn't a managed pubkey address,
|
||||
// which we already checked above, or the
|
||||
// address is imported in which case we don't
|
||||
// know the derivation path, and it will just be
|
||||
// empty anyway.
|
||||
_, _, derivationPath, _ =
|
||||
Bip32DerivationFromAddress(pka)
|
||||
}
|
||||
if pubKey != nil && isLndCustom {
|
||||
addressString = hex.EncodeToString(
|
||||
pubKey.PubKey().SerializeCompressed(),
|
||||
pubKey.SerializeCompressed(),
|
||||
)
|
||||
}
|
||||
|
||||
addressProperties[idx] = lnwallet.AddressProperty{
|
||||
Address: addressString,
|
||||
Internal: managedAddr.Internal(),
|
||||
Balance: addressBalance[addressString],
|
||||
Address: addressString,
|
||||
Internal: managedAddr.Internal(),
|
||||
Balance: addressBalance[addressString],
|
||||
PublicKey: pubKey,
|
||||
DerivationPath: derivationPath,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user