mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
tx_parts: as a convenience, copy over the value as the 'satoshi'
Reporting coin movements was crashing for liquid-regtest tests because we were using an un-initialized field (the tx_part output's satoshi field). We fill this in 'as a convenience' for other wally_tx_outputs that are on liquid elsewhere, here we do the same for tx_parts sent over the wire to onchaind.
This commit is contained in:
@@ -94,6 +94,19 @@ struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
|
||||
if (output != -1 && output != i)
|
||||
continue;
|
||||
txp->outputs[i] = clone_output(&wtx->outputs[i]);
|
||||
|
||||
/* Cheat a bit by also setting the numeric satoshi
|
||||
* value, otherwise we end up converting a
|
||||
* number of times */
|
||||
if (chainparams->is_elements) {
|
||||
struct amount_asset asset;
|
||||
struct amount_sat sats;
|
||||
asset = wally_tx_output_get_amount(txp->outputs[i]);
|
||||
/* FIXME: non l-btc assets */
|
||||
assert(amount_asset_is_main(&asset));
|
||||
sats = amount_asset_to_sat(&asset);
|
||||
txp->outputs[i]->satoshi = sats.satoshis; /* Raw: wally conversion */
|
||||
}
|
||||
}
|
||||
tal_wally_end(txp);
|
||||
|
||||
@@ -281,6 +294,9 @@ static struct wally_tx_output *fromwire_wally_tx_output(const tal_t *ctx,
|
||||
surjectionproof, tal_bytelen(surjectionproof),
|
||||
rangeproof, tal_bytelen(rangeproof),
|
||||
&out);
|
||||
|
||||
/* As a convenience, we sent the value over as satoshis */
|
||||
out->satoshi = fromwire_u64(cursor, max);
|
||||
} else {
|
||||
u64 satoshi;
|
||||
satoshi = fromwire_u64(cursor, max);
|
||||
@@ -348,6 +364,8 @@ static void towire_wally_tx_output(u8 **pptr, const struct wally_tx_output *out)
|
||||
out->surjectionproof_len);
|
||||
towire_u32(pptr, out->rangeproof_len);
|
||||
towire_u8_array(pptr, out->rangeproof, out->rangeproof_len);
|
||||
/* Copy the value over, as a convenience */
|
||||
towire_u64(pptr, out->satoshi);
|
||||
} else {
|
||||
towire_u64(pptr, out->satoshi);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user