Skip to content

Commit be49a59

Browse files
cdeckerniftynei
authored andcommitted
elements: Do not get upset if we see a confidential asset or value
I made some assumptions that turn out not to be true, mea culpa.
1 parent d35ec90 commit be49a59

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

bitcoin/tx.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
204204
return res;
205205
}
206206

207+
/* FIXME(cdecker) Make the caller pass in a reference to amount_asset, and
208+
* return false if unintelligible/encrypted. (WARN UNUSED). */
207209
struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
208210
int outnum)
209211
{
@@ -216,13 +218,18 @@ struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
216218
output = &tx->wtx->outputs[outnum];
217219

218220
if (chainparams->is_elements) {
219-
/* We currently only support v1 asset tags */
220-
assert(output->asset_len == sizeof(amount.asset) &&
221-
output->asset[0] == 0x01);
221+
assert(output->asset_len == sizeof(amount.asset));
222222
memcpy(&amount.asset, output->asset, sizeof(amount.asset));
223-
memcpy(&raw, output->value + 1, sizeof(raw));
224-
amount.value = be64_to_cpu(raw);
225223

224+
/* We currently only support explicit value asset tags, others
225+
* are confidential, so don't even try to assign a value to
226+
* it. */
227+
if (output->asset[0] == 0x01) {
228+
memcpy(&raw, output->value + 1, sizeof(raw));
229+
amount.value = be64_to_cpu(raw);
230+
} else {
231+
amount.value = 0;
232+
}
226233
} else {
227234
/* Do not assign amount.asset, we should never touch it in
228235
* non-elements scenarios. */

0 commit comments

Comments
 (0)