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:
Torakushi
2023-02-17 18:06:19 +01:00
parent dd5ed71669
commit 77d3f00c3b
4 changed files with 70 additions and 0 deletions

View File

@@ -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(