@@ -25,48 +25,38 @@ class _SimpleWalletState extends State<SimpleWallet> {
25
25
26
26
generateMnemonicKeys () async {
27
27
final res = await lib.createMnemonic ();
28
+ final mnemonic = await res.asString ();
28
29
setState (() {
29
- displayText = res. toString () ;
30
+ displayText = mnemonic ;
30
31
});
31
32
if (kDebugMode) {
32
- print (await res. asString () );
33
+ print (mnemonic );
33
34
}
34
35
}
35
36
36
37
restoreWallet () async {
37
38
final aliceMnemonic = await Mnemonic .fromString (
38
- 'certain sense kiss guide crumble hint transfer crime much stereo warm coral ' );
39
+ 'give rate trigger race embrace dream wish column upon steel wrist rice ' );
39
40
final aliceDescriptor = await lib.createDescriptor (aliceMnemonic);
40
41
aliceWallet = await lib.restoreWallet (aliceDescriptor);
41
42
setState (() {
42
43
displayText = "Wallets restored" ;
43
44
});
44
45
}
45
46
46
- initBlockchain ({
47
- bool isElectrumBlockchain = false ,
48
- bool useTestnetDefaults = false ,
49
- }) async {
50
- blockchain = await lib.initializeBlockchain (
51
- isElectrumBlockchain: isElectrumBlockchain,
52
- useTestnetDefaults: useTestnetDefaults,
53
- );
54
- }
55
-
56
47
sync () async {
57
- if (blockchain == null ) {
58
- // Initialize blockchain with default testnet values and esplora server
59
- await initBlockchain (useTestnetDefaults: true );
60
- }
48
+ blockchain ?? = await lib.initializeBlockchain ();
61
49
await lib.sync (blockchain! , aliceWallet);
62
50
}
63
51
64
52
getNewAddress () async {
65
- final res = (await lib.getAddress (aliceWallet));
66
- debugPrint (await res.address.asString ());
67
- final address = await res.address.asString ();
53
+ final addressInfo = await lib.getAddress (aliceWallet);
54
+ final address = await addressInfo.address.asString ();
55
+
56
+ debugPrint (address);
57
+
68
58
setState (() {
69
- displayText = "Address: $address \n Index: ${res .index }" ;
59
+ displayText = "Address: $address \n Index: ${addressInfo .index }" ;
70
60
});
71
61
}
72
62
@@ -100,13 +90,13 @@ class _SimpleWalletState extends State<SimpleWallet> {
100
90
print (" confirmationTime Height: ${e .confirmationTime ?.height }" );
101
91
final txIn = await e.transaction! .input ();
102
92
final txOut = await e.transaction! .output ();
103
- print (" =============TxIn==============" );
93
+ print ("=============TxIn==============" );
104
94
for (var e in txIn) {
105
95
print (" previousOutout Txid: ${e .previousOutput .txid }" );
106
96
print (" previousOutout vout: ${e .previousOutput .vout }" );
107
97
print (" witness: ${e .witness }" );
108
98
}
109
- print (" =============TxOut==============" );
99
+ print ("=============TxOut==============" );
110
100
for (var e in txOut) {
111
101
print (" script: ${e .scriptPubkey .bytes }" );
112
102
print (" value: ${e .value }" );
@@ -165,9 +155,13 @@ class _SimpleWalletState extends State<SimpleWallet> {
165
155
}
166
156
}
167
157
168
- sendBit () async {
158
+ sendBit (int amountSat ) async {
169
159
await lib.sendBitcoin (
170
- blockchain! , aliceWallet, "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB" );
160
+ blockchain! ,
161
+ aliceWallet,
162
+ "tb1qyhssajdx5vfxuatt082m9tsfmxrxludgqwe52f" ,
163
+ amountSat,
164
+ );
171
165
}
172
166
173
167
@override
@@ -299,9 +293,9 @@ class _SimpleWalletState extends State<SimpleWallet> {
299
293
fontWeight: FontWeight .w800),
300
294
)),
301
295
TextButton (
302
- onPressed: () => sendBit (),
296
+ onPressed: () => sendBit (100000 ),
303
297
child: const Text (
304
- 'Press to send 1200 satoshi ' ,
298
+ 'Press to send 100k sats ' ,
305
299
style: TextStyle (
306
300
color: Colors .indigoAccent,
307
301
fontSize: 12 ,
0 commit comments