Closed roylee17 closed 2 years ago
Root cause: Currently, all imported keys/addresses are assumed watch-only, and were skipped from adding into transaction inputs.
// Assume the default imported account has no private keys.
//
// TODO: Actually check whether it does.
if account == ImportedAddrAccount {
return true, nil
}
if !watchOnly {
err = tx.AddAllInputScripts(
secretSource{w.Manager, addrmgrNs},
)
if err != nil {
return err
}
err = validateMsgTx(
tx.Tx, tx.PrevScripts, tx.PrevInputValues,
)
if err != nil {
return err
}
}
An easy solution is to check the existence of the private key for each address. But it makes the code flow unnecessarily convoluted.
I'm leaning toward reserving a"imported-watchonly"
account (2^32-2) dedicated for imported public keys and addresses. Leave the "imported"
account for those imported using importprivkey
The current master includes a hotfix, which sacrifices watch-only address support in favor of imported addresses.
Earlier we have PR #23 to address the issue by implementing a watch-only account to house all watch-only addresses. However, using fixed dedicated accounts to house import keys can be awkward, and have many places to handle those accounts as corner cases.
We decided to implement proper multi-account support first. Later, we can allow users to decide which account(s) will be used for imported keys.