SN-2844 已核对来源,附原文与上下文。
正如你想明白的那样,根本问题在于:交易没有至少 1 个确认之前,我们并不该计数、也不该花费。0/unconfirmed 交易就是彻头彻尾的二等公民。它们至多是「收到了什么东西」的提示,把它们计入余额或花出去都为时过早。
As you figured out, the root problem is we shouldn't be counting or spending transactions until they have at least 1 confirmation. 0/unconfirmed transactions are very much second class citizens. At most, they are advice that something has been received, but counting them as balance or spending them is premature.
我做了改动,让它们以浅色显示,金额放在方括号里如 [+1.23],不计入余额、不可用于花费。这并不适用于你发出的交易——你无条件地信任它们,因是你写的。
I made changes so they show up in lighter print, with the credit amount in square brackets like [+1.23], and the amount not counted towards your balance and not available for spending. This doesn't apply to transactions you sent, which you implicitly trust, since you wrote them.
我并未用 (+1.23),因会计里圆括号表示负数。我希望方括号的区分足够明显,让人明白是什么意思。
I didn't make it (+1.23) because parenthesis in accounting means negative. I hope square brackets is different enough to be clear what is meant.
JSON-RPC 接口如果需要,仍能通过指定 0 个确认看到 0/unconfirmed。
The JSON-RPC interface can still see 0/unconfirmed if it wants by specifying 0 confirmations.
我已把改动上传到 SVN rev 158。我很快会发 0.3.13 RC。
I uploaded the changes to SVN rev 158. I will post a 0.3.13 RC shortly.
如果你的钱包里有这类交易,在升级到 0.3.13(很快会来)之前,不要发出任何支付。
If you have any of these transactions in your wallet, do not send any payments until you've upgraded to 0.3.13, which will be coming soon.
如果你已经发出过这类交易,或者你就是它们的创建者,那么用 theymos 的补丁,或者做下面这个改动,从而用它把你的干净交易发到一个新钱包,清理干净。
If you've already sent any of these transactions, or you're the creator of them, then use theymos' patch or make the following change and use it to send your clean transactions to a new wallet to clean things up.
把:
change:
if (pcoin->GetDepthInMainChain() < 1 && pcoin->GetDebit() <= 0)
if (pcoin->GetDepthInMainChain() < 1 && pcoin->GetDebit() <= 0)
continue;
continue;
改成:
to:
if (pcoin->GetDepthInMainChain() < 1)
if (pcoin->GetDepthInMainChain() < 1)
continue;
continue;