@@ -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). */
207209struct 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