dcrwallet icon indicating copy to clipboard operation
dcrwallet copied to clipboard

trusted/safe output identification in listunspent and getbalance

Open chappjc opened this issue 5 years ago • 0 comments

What outputs should be considered safe to spend depends on several factors including confirmations, funding source, expiry, and sequence if the txn is not final. When computing balance, spendable should be broken down into trusted + untrusted/pending. When listing unspent outputs, each output should have a flag indicating if it is safe to spend according to these criteria.

This is based on the recently added BC getbalances RPC that has the following fields:

"trusted": trusted balance (outputs created by the wallet or confirmed outputs)
"untrusted_pending": outputs created by others that are in the mempool

The language "created by" is a little vague, but the listunspent documentation of the "safe" field clarifies this somewhat:

 Whether this output is considered safe to spend. Unconfirmed transactions
  from outside keys and unconfirmed replacement transactions are considered unsafe
  and are not eligible for spending by fundrawtransaction and sendtoaddress.

So safe in Decred would mean:

  1. 1+ confirms, maybe even 2 if we consider stake validation
  2. 0-confirms if ALL: a. The output is funded by a transaction spending prevouts using keys from the wallet b. no txn expiry c. sequence is not max value, or lock time not passed?

chappjc avatar Jun 18 '20 14:06 chappjc