|
@ -1664,25 +1664,27 @@ void wallet_confirm_tx(struct wallet *w, |
|
|
db_exec_prepared_v2(take(stmt)); |
|
|
db_exec_prepared_v2(take(stmt)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, |
|
|
int wallet_extract_owned_outputs(struct wallet *w, const struct wally_tx *wtx, |
|
|
const u32 *blockheight, |
|
|
const u32 *blockheight, |
|
|
struct amount_sat *total) |
|
|
struct amount_sat *total) |
|
|
{ |
|
|
{ |
|
|
int num_utxos = 0; |
|
|
int num_utxos = 0; |
|
|
|
|
|
|
|
|
*total = AMOUNT_SAT(0); |
|
|
*total = AMOUNT_SAT(0); |
|
|
for (size_t output = 0; output < tx->wtx->num_outputs; output++) { |
|
|
for (size_t output = 0; output < wtx->num_outputs; output++) { |
|
|
struct utxo *utxo; |
|
|
struct utxo *utxo; |
|
|
u32 index; |
|
|
u32 index; |
|
|
bool is_p2sh; |
|
|
bool is_p2sh; |
|
|
const u8 *script; |
|
|
const u8 *script; |
|
|
struct amount_asset asset = bitcoin_tx_output_get_amount(tx, output); |
|
|
struct amount_asset asset = |
|
|
|
|
|
wally_tx_output_get_amount(&wtx->outputs[output]); |
|
|
struct chain_coin_mvt *mvt; |
|
|
struct chain_coin_mvt *mvt; |
|
|
|
|
|
|
|
|
if (!amount_asset_is_main(&asset)) |
|
|
if (!amount_asset_is_main(&asset)) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
script = bitcoin_tx_output_get_script(tmpctx, tx, output); |
|
|
script = wally_tx_output_get_script(tmpctx, |
|
|
|
|
|
&wtx->outputs[output]); |
|
|
if (!script) |
|
|
if (!script) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
@ -1694,7 +1696,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, |
|
|
utxo->is_p2sh = is_p2sh; |
|
|
utxo->is_p2sh = is_p2sh; |
|
|
utxo->amount = amount_asset_to_sat(&asset); |
|
|
utxo->amount = amount_asset_to_sat(&asset); |
|
|
utxo->status = output_state_available; |
|
|
utxo->status = output_state_available; |
|
|
bitcoin_txid(tx, &utxo->txid); |
|
|
wally_txid(wtx, &utxo->txid); |
|
|
utxo->outnum = output; |
|
|
utxo->outnum = output; |
|
|
utxo->close_info = NULL; |
|
|
utxo->close_info = NULL; |
|
|
|
|
|
|
|
@ -1738,7 +1740,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, |
|
|
|
|
|
|
|
|
if (!amount_sat_add(total, *total, utxo->amount)) |
|
|
if (!amount_sat_add(total, *total, utxo->amount)) |
|
|
fatal("Cannot add utxo output %zu/%zu %s + %s", |
|
|
fatal("Cannot add utxo output %zu/%zu %s + %s", |
|
|
output, tx->wtx->num_outputs, |
|
|
output, wtx->num_outputs, |
|
|
type_to_string(tmpctx, struct amount_sat, total), |
|
|
type_to_string(tmpctx, struct amount_sat, total), |
|
|
type_to_string(tmpctx, struct amount_sat, |
|
|
type_to_string(tmpctx, struct amount_sat, |
|
|
&utxo->amount)); |
|
|
&utxo->amount)); |
|
|