Multiple hardware wallets: per-wallet devices, wallets page, Poinbase custodial account, PLEDGER item with supply-chain poisoning

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Opus 5.5 committed 2026-11-03 22:58:24 +08:00
1 parent add61a6b5e
commit 783f73989d
19 files changed
+557 -199

No files matched your search

+25 -1
View File
@@ -23,7 +23,29 @@ namespace Decentralized
public Market Market;
public Stablecoins Stable = new Stablecoins();
public Network Network = new Network();
public Wallet Hot = new Wallet { Address = "hot" };
/// <summary>链上钱包(硬件钱包,第一个是主钱包),各自的余额、污点、成本、冻结独立。</summary>
public List<Wallet> Wallets = new List<Wallet>();
/// <summary>终端当前连接的钱包:Web3 页的交易、黑市、混币器都用它,用币付款的顾客、挖矿收益也进它。</summary>
public int Current;
/// <summary>Poinbase 托管账户:银行存取、Poinbase 交易、出金审查都在这里。</summary>
public Wallet Poinbase = new Wallet { Address = "poinbase" };
[JsonIgnore] public Wallet Hot => Wallets[Math.Max(0, Math.Min(Wallets.Count - 1, Current))];
/// <summary>按地址找自己的钱包;找不到(钱包没了)退回当前钱包。</summary>
public Wallet WalletAt(string address) => Wallets.Find(w => ChainAddress.Same(w.Address, address)) ?? Hot;
public Wallet Own(string address) => Wallets.Find(w => ChainAddress.Same(w.Address, address));
public Wallet AddWallet(bool poisoned)
{
var w = new Wallet { Address = ChainAddress.Make(Rng.NextUInt()), Poisoned = poisoned };
Wallets.Add(w);
return w;
}
/// <summary>链上资产合计(全部钱包)。</summary>
public double ChainValue(Func<string, double> price) { double v = 0; foreach (var w in Wallets) v += w.Value(price); return v; }
public Exchange Exchange = new Exchange();
public Mixer Mixer = new Mixer();
public BlackMarket Black = new BlackMarket();
@@ -58,6 +80,7 @@ namespace Decentralized
public static void Load()
{
Data = null;
WalletWindow.Reset();
try
{
string json = ModHelper.GetModData(ModInfo.Id, Key);
@@ -68,6 +91,7 @@ namespace Decentralized
if (Data.Market == null) Data.Market = Market.CreateDefault(StoreStation.GetDayCounter());
// 旧存档里的商家地址没有校验位:换成合法地址
foreach (var s in Data.Black.Sellers) if (!ChainAddress.Valid(s.Name)) s.Name = ChainAddress.Make(Data.Rng.NextUInt());
if (Data.Wallets.Count == 0) Data.AddWallet(false);
Log.Info($"状态已载入(第 {Data.Day} 天,PSC {Data.Market.Price:0.00})");
}