FIXME(cdecker) Make the caller pass in a reference to amount_asset, and * return false if unintelligible/encrypted. (WARN UNUSED). */
| 776 | /* FIXME(cdecker) Make the caller pass in a reference to amount_asset, and |
| 777 | * return false if unintelligible/encrypted. (WARN UNUSED). */ |
| 778 | struct amount_asset |
| 779 | wally_tx_output_get_amount(const struct wally_tx_output *output) |
| 780 | { |
| 781 | struct amount_asset amount; |
| 782 | be64 raw; |
| 783 | |
| 784 | if (chainparams->is_elements) { |
| 785 | assert(output->asset_len == sizeof(amount.asset)); |
| 786 | memcpy(&amount.asset, output->asset, sizeof(amount.asset)); |
| 787 | /* We currently only support explicit value |
| 788 | * asset tags, others are confidential, so |
| 789 | * don't even try to assign a value to it. */ |
| 790 | if (output->asset[0] == 0x01) { |
| 791 | memcpy(&raw, output->value + 1, sizeof(raw)); |
| 792 | amount.value = be64_to_cpu(raw); |
| 793 | } else { |
| 794 | amount.value = 0; |
| 795 | } |
| 796 | } else { |
| 797 | /* Do not assign amount.asset, we should never touch it in |
| 798 | * non-elements scenarios. */ |
| 799 | amount.value = output->satoshi; |
| 800 | } |
| 801 | |
| 802 | return amount; |
| 803 | } |
| 804 | |
| 805 | /* Various weights of transaction parts. */ |
| 806 | size_t bitcoin_tx_core_weight(size_t num_inputs, size_t num_outputs) |
no test coverage detected