Skip to content

Commit

Permalink
Don't allow big txs on ledger (#488)
Browse files Browse the repository at this point in the history
* Don't allow big txs on ledger

* Add error checking

* Fix duplicated code

* Remove more duplicated keys

* Fix build

* Idk where commets went but here they are again
  • Loading branch information
Duddino authored Jan 23, 2025
1 parent 05d5883 commit 552cca6
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions locale/cnr/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/de/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
5 changes: 3 additions & 2 deletions locale/en/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ WALLET_UNLOCKED = "Wallet successfully Unlocked!" # Wallet successfully Unlocked
CONFIRM_LEDGER_TX = "Confirm this transaction matches the one on your {hardwareWallet}" # Confirm this transaction matches the one on your {hardwareWallet}
CONFIRM_LEDGER_TX_OUT = "You will send {value} {ticker} to <div class=\"inline-address\">{address}</div>" # You will send {value} {ticker} to <div class="inline-address">{address}</div>
MISSING_SHIELD = "Shield is not enabled in this wallet!" # Shield is not enabled in this wallet!
MN_START_FAILED = "<b>Masternode failed to start!</b>" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "<b>Masternode failed to restart!</b>" # <b>Masternode failed to restart!</b>
MN_START_FAILED = " <b>Masternode failed to start!</b>" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = " <b>Masternode failed to restart!</b>" # <b>Masternode failed to restart!</b>
LEDGER_TX_TOO_BIG = "Transaction length exceeds 9000 bytes" # Transaction length exceeds 9000 bytes
MISSING_FUNDS = "<b>Balance is too small!</b> <br> Missing {sats} sats!" # <b>Balance is too small!</b> <br> Missing {sats} sats!
1 change: 1 addition & 0 deletions locale/es-mx/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/fr/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/hi/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_FUNDS = "बैलेंस बहुत कम है! {sats} सैट
MISSING_SHIELD = "इस वॉलेट में शील्ड सक्षम नहीं है!" # Shield is not enabled in this wallet!
WALLET_HARDWARE_USB_UNSUPPORTED = "" # <b>Firefox doesn't support this!</b><br>Unfortunately, Firefox does not support hardware wallets
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/it/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "Lo Shield non è abilitato nel wallet!" # Shield is not enable
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/nl/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/ph/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/pl/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/pt-br/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/pt-pt/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
1 change: 1 addition & 0 deletions locale/template/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,6 @@ CONFIRM_POPUP_DELETE_ACCOUNT = 'This will delete all your data, including master
CONFIRM_POPUP_DELETE_ACCOUNT_TITLE = 'Are you sure?'
CONFIRM_LEDGER_TX = 'Confirm this transaction matches the one on your {hardwareWallet}'
CONFIRM_LEDGER_TX_OUT = 'You will send {value} {ticker} to <div class="inline-address">{address}</div>'
LEDGER_TX_TOO_BIG = 'Transaction length exceeds 9000 bytes'
MISSING_FUNDS = '<b>Balance is too small!</b> <br> Missing {sats} sats!'
MISSING_SHIELD = "Shield is not enabled in this wallet!"
1 change: 1 addition & 0 deletions locale/uwu/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ MISSING_SHIELD = "" # Shield is not enabled in this wallet!
MN_START_FAILED = "" # <b>Masternode failed to start!</b>
MN_RESTART_FAILED = "" # <b>Masternode failed to restart!</b>
MN_UNLOCK_WALLET = "" # Please import your <b> COLLATERAL WALLET</b> first.
LEDGER_TX_TOO_BIG = "" # Transaction length exceeds 9000 bytes
7 changes: 6 additions & 1 deletion scripts/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export async function getHardwareWalletKeys(path, xpub = false, verify = true) {
*/
export async function ledgerSignTransaction(wallet, transaction) {
await setupConnection();
const ledgerTx = cHardwareWallet.splitTransaction(transaction.serialize());
const txHex = transaction.serialize();
if (txHex.length / 2 > 9000) {
createAlert('warning', ALERTS.LEDGER_TX_TOO_BIG, 10_000);
return false;
}
const ledgerTx = cHardwareWallet.splitTransaction(txHex);
const outputs = transaction.vout.map((o) => {
const { addresses, type } = wallet.getAddressesFromScript(o.script);
if (type !== 'p2pkh') {
Expand Down
3 changes: 2 additions & 1 deletion scripts/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export async function createAndSendTransaction({
});
if (!wallet.isHardwareWallet()) await wallet.sign(tx);
else {
await ledgerSignTransaction(wallet, tx);
const res = await ledgerSignTransaction(wallet, tx);
if (!res) return;
}
const res = await getNetwork().sendTransaction(tx.serialize());
if (res) {
Expand Down

0 comments on commit 552cca6

Please sign in to comment.