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
@@ -148,6 +148,21 @@ public class StorageTests
Assert.True(WalletDocument.FromJson(doc.ToJson()).IsWatchOnly);
}
[Fact]
public void WatchAddresses_fa_roundtrip_json_ed_e_watch_only()
{
var doc = new WalletDocument
{
Network = "mainnet",
ScriptKind = "NativeSegwit",
WatchAddresses = ["bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"],
};
var restored = WalletDocument.FromJson(doc.ToJson());
Assert.Equal(doc.WatchAddresses, restored.WatchAddresses);
Assert.True(restored.IsWatchOnly);
}
[Fact]
public void Json_corrotto_lancia_eccezione()
{