Skip to content

Commit 77e5d63

Browse files
DuddinoDuddino Gatto
andauthored
Improve error when staking balance doesn't have enough PIVs to cover for the change (#625)
* Improve error when staking balance doesn't have enough PIVs to cover the change * Fix typos --------- Co-authored-by: Duddino Gatto <duddinogatto@pm.me>
1 parent 1e358c5 commit 77e5d63

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/wallet.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,15 @@ export class Wallet {
12661266
if (!subtractFeeFromAmt) {
12671267
throw new Error('Not enough balance');
12681268
}
1269+
if (isDelegation && transactionBuilder.valueOut - fee < COIN) {
1270+
throw new Error(
1271+
`You can't stake less than one PIV, you need ${
1272+
fee / COIN
1273+
} more ${
1274+
cChainParams.current.TICKER
1275+
}s to cover for the change`
1276+
);
1277+
}
12691278
transactionBuilder.equallySubtractAmt(Math.abs(changeValue));
12701279
} else if (changeValue > 0) {
12711280
// TransactionBuilder will internally add the change only if it is not dust

0 commit comments

Comments
 (0)