mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
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.
This commit is contained in:
parent
d35ec902f4
commit
be49a599bc
15
bitcoin/tx.c
15
bitcoin/tx.c
@ -204,6 +204,8 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
|
|||||||
return res;
|
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,
|
struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
|
||||||
int outnum)
|
int outnum)
|
||||||
{
|
{
|
||||||
@ -216,13 +218,18 @@ struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
|
|||||||
output = &tx->wtx->outputs[outnum];
|
output = &tx->wtx->outputs[outnum];
|
||||||
|
|
||||||
if (chainparams->is_elements) {
|
if (chainparams->is_elements) {
|
||||||
/* We currently only support v1 asset tags */
|
assert(output->asset_len == sizeof(amount.asset));
|
||||||
assert(output->asset_len == sizeof(amount.asset) &&
|
|
||||||
output->asset[0] == 0x01);
|
|
||||||
memcpy(&amount.asset, output->asset, sizeof(amount.asset));
|
memcpy(&amount.asset, output->asset, sizeof(amount.asset));
|
||||||
|
|
||||||
|
/* 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));
|
memcpy(&raw, output->value + 1, sizeof(raw));
|
||||||
amount.value = be64_to_cpu(raw);
|
amount.value = be64_to_cpu(raw);
|
||||||
|
} else {
|
||||||
|
amount.value = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Do not assign amount.asset, we should never touch it in
|
/* Do not assign amount.asset, we should never touch it in
|
||||||
* non-elements scenarios. */
|
* non-elements scenarios. */
|
||||||
|
Loading…
Reference in New Issue
Block a user