-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
417512a
commit 31aa1ae
Showing
12 changed files
with
497 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "txn_wrapper.h" | ||
|
||
#include "txn.h" | ||
#include "v2txn.h" | ||
|
||
void txn_wrapper_init(txn_state_t *txn, uint16_t sigIndex, uint32_t changeIndex) { | ||
if (txn->v2) { | ||
v2txn_init(txn, sigIndex, changeIndex); | ||
} else { | ||
txn_init(txn, sigIndex, changeIndex); | ||
} | ||
} | ||
|
||
void txn_wrapper_update(txn_state_t *txn, uint8_t *in, uint8_t inlen) { | ||
if (txn->v2) { | ||
v2txn_update(txn, in, inlen); | ||
} else { | ||
txn_update(txn, in, inlen); | ||
} | ||
} | ||
|
||
txnDecoderState_e txn_wrapper_next_elem(txn_state_t *txn) { | ||
if (txn->v2) { | ||
return v2txn_next_elem(txn); | ||
} else { | ||
return txn_next_elem(txn); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef TXN_WRAPPER_H | ||
#define TXN_WRAPPER_H | ||
|
||
#include "txn.h" | ||
|
||
// Wrappers so that the appropriate function is called for updating | ||
// transaction state depending on if the transaction is v1 or v2. | ||
|
||
// txn_wrapper_init initializes a transaction decoder, preparing it to calculate the | ||
// requested SigHash. It will call txn_init if given a transaction with v2=false and | ||
// v2txn_init if given a transaction where v2=true. | ||
void txn_wrapper_init(txn_state_t *txn, uint16_t sigIndex, uint32_t changeIndex); | ||
|
||
// txn_wrapper_update adds data to a transaction decoder. It will call txn_update if given a transaction with v2=false and | ||
// v2txn_update if given a transaction where v2=true. | ||
void txn_wrapper_update(txn_state_t *txn, uint8_t *in, uint8_t inlen); | ||
|
||
// txn_wrapper_next_elem decodes the next element of the transaction. If the | ||
// element is ready for display, txn_next_elem returns TXN_STATE_READY. If more | ||
// data is required, it returns TXN_STATE_PARTIAL. If a decoding error is | ||
// encountered, it returns TXN_STATE_ERR. If the transaction has been fully | ||
// decoded, it returns TXN_STATE_FINISHED. | ||
txnDecoderState_e txn_wrapper_next_elem(txn_state_t *txn); | ||
|
||
|
||
#endif /* TXN_WRAPPER_H */ |
Oops, something went wrong.