Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Fix inputs selection, locktime encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
BTChip github committed May 12, 2017
1 parent 326d1dc commit 1d1d85b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions samples/signTransaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ int main(int argc, char **argv) {
for (j=0; j<txInputs; j++) {
unsigned char in[260];
unsigned char out[260];
unsigned int lockTime;
int sw;
int apduSize;
int result;
bitcoinInput *currentInput = rawTx->inputs;

// Initialize the signature request

Expand All @@ -264,8 +266,7 @@ int main(int argc, char **argv) {

// Process each input, scriptSig containing the redeem script

for (i=0; i<txInputs; i++) {
bitcoinInput *currentInput = rawTx->inputs;
for (i=0; i<txInputs; i++) {
int scriptLength;
int scriptOffset = 0;
apduSize = 0;
Expand Down Expand Up @@ -455,8 +456,9 @@ int main(int argc, char **argv) {
apduSize += 4;
}
in[apduSize++] = 0x00; // no 2FA on new platform
memcpy(in + apduSize, rawTx->lockTime, sizeof(rawTx->lockTime));
apduSize += sizeof(rawTx->lockTime);
lockTime = readUint32LE(rawTx->lockTime);
writeUint32BE(in + apduSize, lockTime);
apduSize += 4;
in[apduSize++] = SIGHASH_ALL;
in[OFFSET_CDATA] = (apduSize - 5);
result = sendApduDongle(dongle, in, apduSize, out, sizeof(out), &sw);
Expand Down

0 comments on commit 1d1d85b

Please sign in to comment.