Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Highlights include:
- [Dogecoin](https://dogecoin.com/)
- [Epic Cash](https://linktr.ee/epiccash)
- [MimbleWimbleCoin](https://mwc.mw)
- [Grin](https://grin.mw/)
- [Ethereum](https://ethereum.org/en/)
- [Ecash](https://e.cash/)
- [Fact0rn](https://www.fact0rn.io/)
Expand Down
Binary file modified asset_sources/default_themes/stack_duo/dark.zip
Binary file not shown.
Binary file modified asset_sources/default_themes/stack_duo/light.zip
Binary file not shown.
Binary file modified asset_sources/default_themes/stack_wallet/dark.zip
Binary file not shown.
Binary file modified asset_sources/default_themes/stack_wallet/light.zip
Binary file not shown.
93 changes: 49 additions & 44 deletions integration_test/grin/grin_test_chain_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/models/slatepack_models.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/utilities/logger.dart';
Expand Down Expand Up @@ -359,11 +360,11 @@ void main() {
expect(await alice.pendingSlatepackFor(slateId), s1);

final inspected = await bob.inspectSlatepack(s1);
expect(inspected.state, GrinSlateState.s1);
expect(inspected.amount, grin(50).raw);
expect(inspected.sender, aliceAddress);
final s2 = await bob.receiveSlatepack(s1);
expect(s2.state, GrinSlateState.s2);
expect(inspected.state, SlateState.s1);
expect(inspected.amount, grin(50));
expect(inspected.senderAddress, aliceAddress);
final s2 = await bob.receiveSlatepack(inspected);
expect(s2.state, SlateState.s2);
expect(s2.slateId, slateId);

await sync(bob);
Expand All @@ -378,7 +379,9 @@ void main() {
expect(bob.info.cachedBalance.total, grin(0));
expect(bob.info.cachedBalance.spendable, grin(0));

final s3 = await alice.finalizeSlatepack(s2.armoredSlatepack);
final s3 = await alice.finalizeSlatepack(
await alice.inspectSlatepack(s2.slatepack!),
);
expect(s3.posted, isTrue);
expect(s3.kernelExcess, hasLength(66));
// Posting mined height 16; ten more give it 11 confirmations.
Expand All @@ -397,7 +400,7 @@ void main() {
expect(data[TxV2OdKeys.grinPaymentProofLogId], isA<int>());
expect(a.hash, s3.kernelExcess);
expect(sent(a), grin(50));
expect(fee(a), nano(s3.fee));
expect(fee(a), confirmed.fee);

b = await row(bob, slateId);
expect(b.height, 16);
Expand All @@ -418,27 +421,21 @@ void main() {
amount: grin(30),
payerAddress: aliceAddress,
);
expect(i1.state, GrinSlateState.i1);
expect(i1.state, SlateState.i1);
await sync(bob);
var b = await row(bob, i1.slateId);
var b = await row(bob, i1.slateId!);
expect(b.type, TransactionType.incoming);
expect(label(bob, b), 'Invoice issued (waiting for payer)');
expect(otherData(b)[TxV2OdKeys.grinSlateState], 'I1');

// An amount other than the invoice's is refused before the library is
// asked to pay, and nothing is recorded or locked.
await expectLater(
alice.processInvoice(
i1.armoredSlatepack,
confirmedAmount: nano(grin(30).raw - BigInt.one),
),
throwsA(
predicate(
(e) => e.toString().contains('does not match'),
'amount mismatch',
),
),
final refused = await alice.processInvoice(
i1.slatepack!,
confirmedAmount: nano(grin(30).raw - BigInt.one),
);
expect(refused.success, isFalse);
expect(refused.error, contains('does not match'));
expect(
chain.backend.calls.where((c) => c.startsWith('processInvoice')),
isEmpty,
Expand All @@ -447,47 +444,47 @@ void main() {
expect(
await MainDB.instance.isar.transactionV2s
.where()
.txidWalletIdEqualTo(i1.slateId, alice.walletId)
.txidWalletIdEqualTo(i1.slateId!, alice.walletId)
.findFirst(),
isNull,
);
expect(alice.info.cachedBalance.spendable, before);

final i2 = await alice.processInvoice(
i1.armoredSlatepack,
i1.slatepack!,
confirmedAmount: grin(30),
);
expect(i2.state, GrinSlateState.i2);
expect(i2.state, SlateState.i2);
expect(
chain.backend.calls.where((c) => c.startsWith('processInvoice')),
hasLength(1),
);
await sync(alice);
var a = await row(alice, i1.slateId);
var a = await row(alice, i1.slateId!);
expect(a.type, TransactionType.outgoing);
expect(label(alice, a), 'Paying invoice (waiting for invoicer)');
expect(otherData(a)[TxV2OdKeys.grinSlateState], 'I2');
expect(alice.info.cachedBalance.spendable < before, isTrue);

final i3 = await bob.finalizeInvoice(i2.armoredSlatepack);
final i3 = await bob.finalizeInvoice(i2.slatepack!);
expect(i3.posted, isTrue);
// Posting mined height 16, to Bob.
expect(await chain.mine(alice, 10), 26);
await sync(alice);
await sync(bob);

b = await row(bob, i1.slateId);
b = await row(bob, i1.slateId!);
expect(b.height, 16);
expect(label(bob, b), 'Received');
expect(received(b), grin(30));
expect(otherData(b)[TxV2OdKeys.grinKernelExcess], i3.kernelExcess);
a = await row(alice, i1.slateId);
a = await row(alice, i1.slateId!);
expect(a.height, 16);
expect(label(alice, a), 'Sent');
expect(sent(a), grin(30));
expect(fee(a), nano(i2.fee));
expect(fee(a), i2.fee!);
// Bob also got the block 16 coinbase and the fee.
expect(bob.info.cachedBalance.total, grin(30 + reward) + nano(i2.fee));
expect(bob.info.cachedBalance.total, grin(30 + reward) + i2.fee!);
}, timeout: _timeout);

testWidgets('a send whose funds changed after review is refused', (
Expand Down Expand Up @@ -558,13 +555,13 @@ void main() {
await sync(alice);
expect(alice.info.cachedBalance.spendable < before.spendable, isTrue);
expect(
label(alice, await row(alice, slate.slateId)),
label(alice, await row(alice, slate.slateId!)),
'Sending (waiting for response)',
);

expect(await alice.cancelPendingTransactionAndPost(slate.slateId), '');
expect(await alice.cancelPendingTransactionAndPost(slate.slateId!), '');
await sync(alice);
final tx = await row(alice, slate.slateId);
final tx = await row(alice, slate.slateId!);
expect(tx.isCancelled, isTrue);
expect(label(alice, tx), 'Cancelled');
expect(tx.height, isNull);
Expand All @@ -573,7 +570,7 @@ void main() {

// A second cancel is reported, not thrown.
expect(
await alice.cancelPendingTransactionAndPost(slate.slateId),
await alice.cancelPendingTransactionAndPost(slate.slateId!),
isNotEmpty,
);
}, timeout: _timeout);
Expand All @@ -589,20 +586,24 @@ void main() {

// Nothing is stored to post yet.
await sync(alice);
await expectLater(alice.repost(slate.slateId), throwsA(anything));
await expectLater(alice.repost(slate.slateId!), throwsA(anything));
expect(chain.backend.calls.where((c) => c.startsWith('repost')), isEmpty);

final s2 = await bob.receiveSlatepack(slate.armoredSlatepack);
final s2 = await bob.receiveSlatepack(
await bob.inspectSlatepack(slate.slatepack!),
);
(await chain.api(alice)).skipNextBroadcast = true;
final s3 = await alice.finalizeSlatepack(s2.armoredSlatepack);
final s3 = await alice.finalizeSlatepack(
await alice.inspectSlatepack(s2.slatepack!),
);
expect(s3.posted, isFalse);
await sync(alice);
var tx = await row(alice, slate.slateId);
var tx = await row(alice, slate.slateId!);
expect(otherData(tx)[TxV2OdKeys.grinHasStoredTx], isTrue);
expect(tx.height, isNull);
expect(alice.info.cachedChainHeight, 15);

await alice.repost(slate.slateId);
await alice.repost(slate.slateId!);
expect(
chain.backend.calls.where((c) => c.startsWith('repost')),
hasLength(1),
Expand All @@ -611,7 +612,7 @@ void main() {
expect(await chain.mine(alice, 10), 26);
await sync(alice);
await sync(bob);
tx = await row(alice, slate.slateId);
tx = await row(alice, slate.slateId!);
expect(tx.height, 16);
expect(label(alice, tx), 'Sent');
expect(otherData(tx)[TxV2OdKeys.grinKernelExcess], s3.kernelExcess);
Expand All @@ -624,13 +625,17 @@ void main() {
amount: grin(25),
recipientAddress: await bob.slatepackAddress(),
);
final s2 = await bob.receiveSlatepack(slate.armoredSlatepack);
final s3 = await alice.finalizeSlatepack(s2.armoredSlatepack);
final s2 = await bob.receiveSlatepack(
await bob.inspectSlatepack(slate.slatepack!),
);
final s3 = await alice.finalizeSlatepack(
await alice.inspectSlatepack(s2.slatepack!),
);
await chain.mine(alice, 1);
await sync(alice);
await sync(bob);

final json = await alice.exportPaymentProof(slate.slateId);
final json = await alice.exportPaymentProof(slate.slateId!);
final proof = GrinPaymentProof.fromJsonString(json);
expect(proof.amount, grin(25).raw);
expect(proof.excess, s3.kernelExcess);
Expand All @@ -654,11 +659,11 @@ void main() {
);
// The receiving side keeps no proof.
expect(
otherData(await row(bob, slate.slateId))[TxV2OdKeys.grinHasPaymentProof],
otherData(await row(bob, slate.slateId!))[TxV2OdKeys.grinHasPaymentProof],
isFalse,
);
await expectLater(
bob.exportPaymentProof(slate.slateId),
bob.exportPaymentProof(slate.slateId!),
throwsA(predicate((e) => e.toString().contains('no payment proof'))),
);
}, timeout: _timeout);
Expand Down
1 change: 1 addition & 0 deletions integration_test/wallet_creation/coin_matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const defaultWordCounts = <String, int>{
'ethereum': 12,
'fact0rn': 12,
'firo': 12,
'grin': 24,
'litecoin': 12,
'mimblewimblecoin': 12,
'monero': 16,
Expand Down
3 changes: 3 additions & 0 deletions integration_test/wallet_creation/seed_validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:stackwallet/services/wallets.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/impl/grin_wallet.dart';
import 'package:stackwallet/wallets/wallet/impl/mimblewimblecoin_wallet.dart';
import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart';
import 'package:stackwallet/wallets/wallet/intermediate/lib_xelis_wallet.dart';
Expand All @@ -31,6 +32,8 @@ Future<void> verifyOpenNativeWallet(Wallet wallet, String expected) async {
0,
await wallet.getMwcMqsConfig(),
)).value;
} else if (wallet is GrinWallet) {
actual = await wallet.getNativeReceivingAddress();
} else if (wallet is LibXelisWallet) {
wallet.checkInitialized();
actual = wallet.xelis.getAddress(wallet.wallet!);
Expand Down
Loading
Loading