Display all data parameters
This commit is contained in:
parent
37f33677c8
commit
f763a60d66
17
signTx.py
17
signTx.py
|
@ -71,10 +71,23 @@ tx = Transaction(
|
|||
encodedTx = encode(tx, UnsignedTransaction)
|
||||
|
||||
donglePath = parse_bip32_path(args.path)
|
||||
apdu = "e0040000".decode('hex') + chr(len(donglePath) + 1 + len(encodedTx)) + chr(len(donglePath) / 4) + donglePath + encodedTx
|
||||
data = chr(len(donglePath) / 4) + donglePath + encodedTx
|
||||
|
||||
dongle = getDongle(True)
|
||||
result = dongle.exchange(bytes(apdu))
|
||||
|
||||
offset = 0
|
||||
while offset != len(data):
|
||||
if (offset + 255) > len(data):
|
||||
blockSize = len(data) - offset
|
||||
else:
|
||||
blockSize = 255
|
||||
if offset == 0:
|
||||
p1 = "00"
|
||||
else:
|
||||
p1 = "80"
|
||||
apdu = ("e004" + p1 + "00").decode('hex') + chr(blockSize) + data[offset : offset + blockSize]
|
||||
result = dongle.exchange(bytes(apdu))
|
||||
offset = offset + blockSize
|
||||
|
||||
v = result[0]
|
||||
r = int(str(result[1:1 + 32]).encode('hex'), 16)
|
||||
|
|
|
@ -255,7 +255,7 @@ static void processV(txContext_t *context) {
|
|||
|
||||
static parserStatus_e processTxInternal(txContext_t *context) {
|
||||
for (;;) {
|
||||
bool processedCustom = false;
|
||||
customStatus_e customStatus = CUSTOM_NOT_HANDLED;
|
||||
// EIP 155 style transasction
|
||||
if (context->currentField == TX_RLP_DONE) {
|
||||
return USTREAM_FINISHED;
|
||||
|
@ -317,9 +317,22 @@ static parserStatus_e processTxInternal(txContext_t *context) {
|
|||
context->processingField = true;
|
||||
}
|
||||
if (context->customProcessor != NULL) {
|
||||
processedCustom = context->customProcessor(context);
|
||||
customStatus = context->customProcessor(context);
|
||||
switch(customStatus) {
|
||||
case CUSTOM_NOT_HANDLED:
|
||||
case CUSTOM_HANDLED:
|
||||
break;
|
||||
case CUSTOM_FAULT:
|
||||
PRINTF("Custom processor aborted\n");
|
||||
return USTREAM_FAULT;
|
||||
case CUSTOM_SUSPENDED:
|
||||
return USTREAM_SUSPENDED;
|
||||
default:
|
||||
PRINTF("Unhandled custom processor status\n");
|
||||
return USTREAM_FAULT;
|
||||
}
|
||||
}
|
||||
if (!processedCustom) {
|
||||
if (customStatus == CUSTOM_NOT_HANDLED) {
|
||||
switch (context->currentField) {
|
||||
case TX_RLP_CONTENT:
|
||||
processContent(context);
|
||||
|
@ -373,3 +386,19 @@ parserStatus_e processTx(txContext_t *context, uint8_t *buffer,
|
|||
END_TRY;
|
||||
return result;
|
||||
}
|
||||
|
||||
parserStatus_e continueTx(txContext_t *context) {
|
||||
parserStatus_e result;
|
||||
BEGIN_TRY {
|
||||
TRY {
|
||||
result = processTxInternal(context);
|
||||
}
|
||||
CATCH_OTHER(e) {
|
||||
result = USTREAM_FAULT;
|
||||
}
|
||||
FINALLY {
|
||||
}
|
||||
}
|
||||
END_TRY;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
struct txContext_t;
|
||||
|
||||
typedef bool (*ustreamProcess_t)(struct txContext_t *context);
|
||||
|
||||
typedef enum rlpTxField_e {
|
||||
TX_RLP_NONE = 0,
|
||||
TX_RLP_CONTENT,
|
||||
|
@ -40,10 +38,20 @@ typedef enum rlpTxField_e {
|
|||
|
||||
typedef enum parserStatus_e {
|
||||
USTREAM_PROCESSING,
|
||||
USTREAM_SUSPENDED,
|
||||
USTREAM_FINISHED,
|
||||
USTREAM_FAULT
|
||||
} parserStatus_e;
|
||||
|
||||
typedef enum customStatus_e {
|
||||
CUSTOM_NOT_HANDLED,
|
||||
CUSTOM_HANDLED,
|
||||
CUSTOM_SUSPENDED,
|
||||
CUSTOM_FAULT
|
||||
} customStatus_e;
|
||||
|
||||
typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
|
||||
|
||||
typedef struct txInt256_t {
|
||||
uint8_t value[32];
|
||||
uint8_t length;
|
||||
|
@ -81,5 +89,6 @@ void initTx(txContext_t *context, cx_sha3_t *sha3, txContent_t *content,
|
|||
ustreamProcess_t customProcessor, void *extra);
|
||||
parserStatus_e processTx(txContext_t *context, uint8_t *buffer,
|
||||
uint32_t length);
|
||||
parserStatus_e continueTx(txContext_t *context);
|
||||
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
|
||||
uint8_t readTxByte(txContext_t *context);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue