Browse Source

Allocate buffer for Sapling outputs dynamically. Thx Decker.

blackjok3r
Artem Pikulin 6 years ago
parent
commit
a4ff8b4d90
  1. 9
      iguana/exchanges/LP_bitcoin.c

9
iguana/exchanges/LP_bitcoin.c

@ -3494,8 +3494,13 @@ bits256 bitcoin_sigtxid(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2sht
memcpy(&for_sig_hash[len], sequence_hash, 32);
len += 32;
uint8_t outputs[1000], hash_outputs[32];
uint8_t *outputs, hash_outputs[32];
int32_t outputs_len = 0;
for (i = 0; i < dest.tx_out; i++) { // calc size for outputs buffer
outputs_len += sizeof(dest.vouts[i].value); outputs_len++; outputs_len += dest.vouts[i].pk_scriptlen;
}
outputs = malloc(outputs_len);
outputs_len = 0;
for (i = 0; i < dest.tx_out; i++) {
outputs_len += iguana_rwnum(1, &outputs[outputs_len], sizeof(dest.vouts[i].value), &dest.vouts[i].value);
outputs[outputs_len++] = (uint8_t) dest.vouts[i].pk_scriptlen;
@ -3516,6 +3521,8 @@ bits256 bitcoin_sigtxid(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2sht
memcpy(&for_sig_hash[len], hash_outputs, 32);
len += 32;
free(outputs);
// no join splits, fill the hashJoinSplits with 32 zeros
memset(&for_sig_hash[len], 0, 32);
len += 32;

Loading…
Cancel
Save