mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 21:51:27 +02:00
walletrpc+btcwallet: no custom account with various key scopes
Currently, a user can create a custom account with various key scopes. This is not a desired behaviour.
This commit is contained in:
@@ -2,6 +2,7 @@ package itest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -468,6 +469,10 @@ func testWalletImportAccount(ht *lntest.HarnessTest) {
|
||||
name string
|
||||
addrType walletrpc.AddressType
|
||||
}{
|
||||
{
|
||||
name: "standard BIP-0044",
|
||||
addrType: walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||
},
|
||||
{
|
||||
name: "standard BIP-0049",
|
||||
addrType: walletrpc.
|
||||
@@ -550,6 +555,34 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,
|
||||
}
|
||||
dave.RPC.ImportAccount(importReq)
|
||||
|
||||
// Try to import an account with the same name but with a different
|
||||
// key scope. It should return an error.
|
||||
otherAddrType := walletrpc.AddressType_TAPROOT_PUBKEY
|
||||
if addrType == walletrpc.AddressType_TAPROOT_PUBKEY {
|
||||
otherAddrType--
|
||||
}
|
||||
|
||||
listReq = &walletrpc.ListAccountsRequest{
|
||||
Name: "default",
|
||||
AddressType: otherAddrType,
|
||||
}
|
||||
listResp = carol.RPC.ListAccounts(listReq)
|
||||
require.Len(ht, listResp.Accounts, 1)
|
||||
|
||||
carolAccountOtherAddrType := listResp.Accounts[0]
|
||||
|
||||
errAccountExists := fmt.Sprintf(
|
||||
"account '%s' already exists", importedAccount,
|
||||
)
|
||||
|
||||
importReq = &walletrpc.ImportAccountRequest{
|
||||
Name: importedAccount,
|
||||
ExtendedPublicKey: carolAccountOtherAddrType.ExtendedPublicKey,
|
||||
AddressType: otherAddrType,
|
||||
}
|
||||
err := dave.RPC.ImportAccountAssertErr(importReq)
|
||||
require.ErrorContains(ht, err, errAccountExists)
|
||||
|
||||
// We'll generate an address for Carol from Dave's node to receive some
|
||||
// funds.
|
||||
externalAddr := newExternalAddr(
|
||||
|
Reference in New Issue
Block a user