LedgerHQ/ledgerjs

support for new transaction format in peercoin

backpacker69 opened this issue · 0 comments

Recently peercoin has been updated to new transaction format, from version 3 onwards serialized transaction does not have a separate timestamp field, that was originally there after version. as a result, signing input from these new transactions fails, as deserialisation expects timestamp to be present:

packages/hw-app-btc/src/splitTransaction.ts:

 38   if (hasTimestamp) {
 39     timestamp = transaction.slice(offset, 4 + offset);
 40     offset += 4;
 41   }

I propose to add handling of this to splitTransaction, by adding "peercoin" to additionals when calling createPaymentTransactionNew method and checking for transaction versions 1 and 2 before attempting to extract timestamp.

Also, communication part in app-bitcoin would have to be changed to something like this:

+++ b/src/btchip_transaction.c
@@ -268,8 +268,9 @@ void transaction_parse(unsigned char parseMode) {
                     }

                     if (G_coin_config->flags & FLAG_PEERCOIN_SUPPORT) {
-                        if ((G_coin_config->family ==
-                            BTCHIP_FAMILY_PEERCOIN) ||
+                        if (((G_coin_config->family ==
+                            BTCHIP_FAMILY_PEERCOIN) &&
+                            (btchip_context_D.transactionVersion[0] < 3)) ||
                             ((G_coin_config->family == BTCHIP_FAMILY_STEALTH) &&
                             (btchip_context_D.transactionVersion[0] < 2))) {
                             // Timestamp