mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
bitcoin_tx: add helper for extracting output amount
This commit is contained in:
committed by
Rusty Russell
parent
d8c9e70c0c
commit
c110f3662c
10
bitcoin/tx.c
10
bitcoin/tx.c
@@ -263,6 +263,16 @@ struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
|
||||
return amount;
|
||||
}
|
||||
|
||||
void bitcoin_tx_output_get_amount_sat(struct bitcoin_tx *tx, int outnum,
|
||||
struct amount_sat *amount)
|
||||
{
|
||||
struct amount_asset asset_amt;
|
||||
asset_amt = bitcoin_tx_output_get_amount(tx, outnum);
|
||||
assert(amount_asset_is_main(&asset_amt));
|
||||
*amount = amount_asset_to_sat(&asset_amt);
|
||||
}
|
||||
|
||||
|
||||
void bitcoin_tx_input_set_witness(struct bitcoin_tx *tx, int innum,
|
||||
u8 **witness)
|
||||
{
|
||||
|
||||
@@ -115,6 +115,13 @@ void bitcoin_tx_output_set_amount(struct bitcoin_tx *tx, int outnum,
|
||||
*/
|
||||
const u8 *bitcoin_tx_output_get_script(const tal_t *ctx, const struct bitcoin_tx *tx, int outnum);
|
||||
|
||||
/** bitcoin_tx_output_get_amount_sat - Helper to get transaction output's amount
|
||||
*
|
||||
* Internally we use a `wally_tx` to represent the transaction. The
|
||||
* satoshi amount isn't a struct amount_sat, so we need a conversion
|
||||
*/
|
||||
void bitcoin_tx_output_get_amount_sat(struct bitcoin_tx *tx, int outnum,
|
||||
struct amount_sat *amount);
|
||||
/**
|
||||
* Helper to just get an amount_sat for the output amount.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user