mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-25 04:59:33 +00:00
additional nano fixes
This commit is contained in:
parent
541e0f23bd
commit
2ac3587ec7
1 changed files with 13 additions and 5 deletions
|
@ -294,7 +294,6 @@ class NanoClient {
|
||||||
|
|
||||||
Future<void> receiveBlock({
|
Future<void> receiveBlock({
|
||||||
required String blockHash,
|
required String blockHash,
|
||||||
required String source,
|
|
||||||
required String amountRaw,
|
required String amountRaw,
|
||||||
required String destinationAddress,
|
required String destinationAddress,
|
||||||
required String privateKey,
|
required String privateKey,
|
||||||
|
@ -319,9 +318,15 @@ class NanoClient {
|
||||||
representative = infoData.representative;
|
representative = infoData.representative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((BigInt.tryParse(amountRaw) ?? BigInt.zero) <= BigInt.zero) {
|
||||||
|
throw Exception("amountRaw must be greater than zero");
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockContentsResponse? frontierContents;
|
||||||
|
|
||||||
if (!openBlock) {
|
if (!openBlock) {
|
||||||
// get the block info of the frontier block:
|
// get the block info of the frontier block:
|
||||||
BlockContentsResponse? frontierContents = await getBlockContents(frontier);
|
frontierContents = await getBlockContents(frontier);
|
||||||
|
|
||||||
if (frontierContents == null) {
|
if (frontierContents == null) {
|
||||||
throw Exception("error while getting frontier block info");
|
throw Exception("error while getting frontier block info");
|
||||||
|
@ -349,7 +354,12 @@ class NanoClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
// first get the account balance:
|
// first get the account balance:
|
||||||
final BigInt currentBalance = (await getBalance(destinationAddress)).currentBalance;
|
late BigInt currentBalance;
|
||||||
|
if (!openBlock) {
|
||||||
|
currentBalance = BigInt.parse(frontierContents!.balance);
|
||||||
|
} else {
|
||||||
|
currentBalance = BigInt.zero;
|
||||||
|
}
|
||||||
final BigInt txAmount = BigInt.parse(amountRaw);
|
final BigInt txAmount = BigInt.parse(amountRaw);
|
||||||
final BigInt balanceAfterTx = currentBalance + txAmount;
|
final BigInt balanceAfterTx = currentBalance + txAmount;
|
||||||
|
|
||||||
|
@ -448,10 +458,8 @@ class NanoClient {
|
||||||
for (final blockHash in blocks.keys) {
|
for (final blockHash in blocks.keys) {
|
||||||
final block = blocks[blockHash];
|
final block = blocks[blockHash];
|
||||||
final String amountRaw = block["amount"] as String;
|
final String amountRaw = block["amount"] as String;
|
||||||
final String source = block["source"] as String;
|
|
||||||
await receiveBlock(
|
await receiveBlock(
|
||||||
blockHash: blockHash,
|
blockHash: blockHash,
|
||||||
source: source,
|
|
||||||
amountRaw: amountRaw,
|
amountRaw: amountRaw,
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
destinationAddress: destinationAddress,
|
destinationAddress: destinationAddress,
|
||||||
|
|
Loading…
Reference in a new issue