Skip to content

corepc-types: ListUnspentItem's amount should be an Amount instead of SignedAmount #436

@storopoli

Description

@storopoli

The amount field in ListUnspentItem (returned by the listunspent RPC) is typed as SignedAmount, but UTXO amounts are always non-negative per the Bitcoin protocol.

/// The transaction amount.
#[serde(default, with = "bitcoin::amount::serde::as_btc")]
pub amount: SignedAmount,

Bitcoin Core's own RPC documentation does not indicate that this field can be signed/negative.
See https://bitcoincore.org/en/doc/29.0.0/rpc/wallet/listunspent/:

Image

In contrast, signed amounts are appropriate for other RPCs (e.g., listtransactions) where negative values indicate outflows/sends/fees.
See https://bitcoincore.org/en/doc/29.0.0/rpc/wallet/listtransactions/:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions