Browse Source

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.
travis-debug
Christian Decker 5 years ago
committed by neil saitug
parent
commit
be49a599bc
  1. 17
      bitcoin/tx.c

17
bitcoin/tx.c

@ -204,6 +204,8 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
return res;
}
/* FIXME(cdecker) Make the caller pass in a reference to amount_asset, and
* return false if unintelligible/encrypted. (WARN UNUSED). */
struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
int outnum)
{
@ -216,13 +218,18 @@ struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
output = &tx->wtx->outputs[outnum];
if (chainparams->is_elements) {
/* We currently only support v1 asset tags */
assert(output->asset_len == sizeof(amount.asset) &&
output->asset[0] == 0x01);
assert(output->asset_len == sizeof(amount.asset));
memcpy(&amount.asset, output->asset, sizeof(amount.asset));
memcpy(&raw, output->value + 1, sizeof(raw));
amount.value = be64_to_cpu(raw);
/* We currently only support explicit value asset tags, others
* are confidential, so don't even try to assign a value to
* it. */
if (output->asset[0] == 0x01) {
memcpy(&raw, output->value + 1, sizeof(raw));
amount.value = be64_to_cpu(raw);
} else {
amount.value = 0;
}
} else {
/* Do not assign amount.asset, we should never touch it in
* non-elements scenarios. */

Loading…
Cancel
Save