mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 03:15:50 +00:00
sol: fee set fix and sent to self fix
This commit is contained in:
parent
bf3667da85
commit
87a96b9b09
1 changed files with 11 additions and 6 deletions
|
@ -64,8 +64,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
fundingAccount: pubKey,
|
fundingAccount: pubKey,
|
||||||
recipientAccount: pubKey,
|
recipientAccount: pubKey,
|
||||||
lamports: transferAmount.raw.toInt(),
|
lamports: transferAmount.raw.toInt(),
|
||||||
),
|
)
|
||||||
ComputeBudgetInstruction.setComputeUnitPrice(microLamports: 6000),
|
|
||||||
]).compile(recentBlockhash: latestBlockhash!.value.blockhash, feePayer: (await _getKeyPair()).publicKey);
|
]).compile(recentBlockhash: latestBlockhash!.value.blockhash, feePayer: (await _getKeyPair()).publicKey);
|
||||||
|
|
||||||
return await _rpcClient?.getFeeForMessage(
|
return await _rpcClient?.getFeeForMessage(
|
||||||
|
@ -167,7 +166,12 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
recipientAccount: recipientPubKey,
|
recipientAccount: recipientPubKey,
|
||||||
lamports: txData.amount!.raw.toInt()),
|
lamports: txData.amount!.raw.toInt()),
|
||||||
ComputeBudgetInstruction.setComputeUnitPrice(
|
ComputeBudgetInstruction.setComputeUnitPrice(
|
||||||
microLamports: txData.fee!.raw.toInt()),
|
microLamports: txData.fee!.raw.toInt() - 5000),
|
||||||
|
// 5000 lamports is the base fee for a transaction. This instruction adds the necessary fee on top of base fee if it is needed.
|
||||||
|
ComputeBudgetInstruction.setComputeUnitLimit(units: 1000000),
|
||||||
|
// 1000000 is the multiplication number to turn the compute unit price of microLamports to lamports.
|
||||||
|
// These instructions also help the user to not pay more than the shown fee.
|
||||||
|
// See: https://solanacookbook.com/references/basic-transactions.html#how-to-change-compute-budget-fee-priority-for-a-transaction
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -367,7 +371,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
for (final tx in transactionsList!) {
|
for (final tx in transactionsList!) {
|
||||||
final senderAddress =
|
final senderAddress =
|
||||||
(tx.transaction as ParsedTransaction).message.accountKeys[0].pubkey;
|
(tx.transaction as ParsedTransaction).message.accountKeys[0].pubkey;
|
||||||
final receiverAddress =
|
var receiverAddress =
|
||||||
(tx.transaction as ParsedTransaction).message.accountKeys[1].pubkey;
|
(tx.transaction as ParsedTransaction).message.accountKeys[1].pubkey;
|
||||||
var txType = isar.TransactionType.unknown;
|
var txType = isar.TransactionType.unknown;
|
||||||
final txAmount = Amount(
|
final txAmount = Amount(
|
||||||
|
@ -376,9 +380,10 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
fractionDigits: cryptoCurrency.fractionDigits,
|
fractionDigits: cryptoCurrency.fractionDigits,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((senderAddress == (await _getKeyPair()).address) &&
|
if ((senderAddress == (await _getKeyPair()).address) && (receiverAddress == "11111111111111111111111111111111")) {
|
||||||
(receiverAddress == (await _getKeyPair()).address)) {
|
// The account that is only 1's are System Program accounts which means there is no receiver except the sender, see: https://explorer.solana.com/address/11111111111111111111111111111111
|
||||||
txType = isar.TransactionType.sentToSelf;
|
txType = isar.TransactionType.sentToSelf;
|
||||||
|
receiverAddress = senderAddress;
|
||||||
} else if (senderAddress == (await _getKeyPair()).address) {
|
} else if (senderAddress == (await _getKeyPair()).address) {
|
||||||
txType = isar.TransactionType.outgoing;
|
txType = isar.TransactionType.outgoing;
|
||||||
} else if (receiverAddress == (await _getKeyPair()).address) {
|
} else if (receiverAddress == (await _getKeyPair()).address) {
|
||||||
|
|
Loading…
Reference in a new issue