Skip to content

Commit 97acb9b

Browse files
committed
sign_psbt: update input amounts when additional_info is present
1 parent f4bda12 commit 97acb9b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

main/process/sign_psbt.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,25 @@ int sign_psbt(jade_process_t* process, CborValue* params, const network_t networ
755755

756756
// Found our key - we are signing this input
757757
JADE_LOGD("Key %u belongs to this signer, so we will need to sign input %u", iter.key_index, index);
758+
759+
if (for_liquid && in_sums) {
760+
uint8_t asset_id[32];
761+
size_t written = 0;
762+
if (!input->has_amount
763+
|| wally_psbt_input_get_asset(input, asset_id, sizeof(asset_id), &written) != WALLY_OK
764+
|| written != sizeof(asset_id)) {
765+
// If additional_info is present, the caller must provide explicit
766+
// value/asset along with their proofs (checked during parsing)
767+
*errmsg = "Missing input explicit asset or value";
768+
retval = CBOR_RPC_BAD_PARAMETERS;
769+
goto cleanup;
770+
}
771+
// TODO: additional_info should store asset_ids in binary order,
772+
// so we shouldn't have to reverse_in_place() here
773+
reverse_in_place(asset_id, sizeof(asset_id));
774+
asset_summary_update(in_sums, num_in_sums, asset_id, sizeof(asset_id), input->amount);
775+
}
776+
758777
uint32_t sig_type;
759778
JADE_WALLY_VERIFY(wally_psbt_get_input_signature_type(psbt, index, &sig_type));
760779
JADE_ASSERT(sig_type);

0 commit comments

Comments
 (0)