feat(core): support pure watch-only address import

Adds a WalletDocument.WatchAddresses field and WalletLoader.NewFromAddresses
to build an ImportedKeyAccount with no private key at all (unlike xpub/WIF
imports, which can still derive/hold key material). ScriptKind is inferred
from the address itself via a new DerivationPaths.KindFor helper. Signing
already refuses to run for any IsWatchOnly account (TransactionFactory), so
this only had to wire up construction/reload of the new account shape.
This commit is contained in:
2026-07-19 12:37:18 +02:00
parent b6440484c1
commit 214abd2892
6 changed files with 192 additions and 1 deletions
+13
View File
@@ -52,6 +52,19 @@ public static class DerivationPaths
_ => throw new ArgumentOutOfRangeException(nameof(kind)),
};
/// <summary>
/// Best-effort reverse mapping from an already-known address to a ScriptKind, used to
/// label pure address imports (no derivation involved, so this is informational only).
/// </summary>
public static ScriptKind KindFor(BitcoinAddress address) => address switch
{
BitcoinWitPubKeyAddress => ScriptKind.NativeSegwit,
TaprootAddress => ScriptKind.Taproot,
BitcoinWitScriptAddress => ScriptKind.NativeSegwitMultisig,
BitcoinScriptAddress => ScriptKind.WrappedSegwit,
_ => ScriptKind.Legacy,
};
/// <summary>
/// Account path relative to the root: purpose'/coin'/account' (§4.2).
/// coin_type is taken from the profile (746 mainnet, 1 testnet).