Skip to content

Commit 57a34d5

Browse files
committed
fix merge conflicts + clean code
2 parents af6ceb0 + 821fe90 commit 57a34d5

39 files changed

+1722
-759
lines changed

.github/workflows/precompile_binaries.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
push:
3-
branches: [v0.31.2-dev.1, master, main]
3+
branches: [v0.31.2-dev.2, master, main]
44

55
name: Precompile Binaries
66

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [0.31.2-dev.2]
2+
#### Fixed
3+
- Thread `frb_workerpool` panicked on invalid `Fingerprint`.
4+
- `SignOptions` issue to accept `witness-utxo` while signing.
5+
6+
#### Changed
7+
- Removed `multiSig` variable from `SignOptions`.
8+
- Updated example app to support `mutinynet`.
9+
- Mapped `Hex`, `Address`, `Descriptor` & `Consensus` exceptions.
10+
111
## [0.31.2-dev.1]
212
#### Fixed
313
- Invalid `Bip49Public`, `Bip84Public` & `Bip86Public`.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To use the `bdk_flutter` package in your project, add it as a dependency in your
3939

4040
```dart
4141
dependencies:
42-
bdk_flutter: ^0.31.2-dev.1
42+
bdk_flutter: ^0.31.2-dev.2
4343
```
4444

4545
### Examples

example/lib/bdk_library.dart

+10-32
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,18 @@ class BdkLibrary {
99

1010
Future<Descriptor> createDescriptor(Mnemonic mnemonic) async {
1111
final descriptorSecretKey = await DescriptorSecretKey.create(
12-
network: Network.testnet,
12+
network: Network.signet,
1313
mnemonic: mnemonic,
1414
);
1515
final descriptor = await Descriptor.newBip84(
1616
secretKey: descriptorSecretKey,
17-
network: Network.testnet,
17+
network: Network.signet,
1818
keychain: KeychainKind.externalChain);
1919
return descriptor;
2020
}
2121

22-
Future<Blockchain> initializeBlockchain({
23-
bool isElectrumBlockchain = false,
24-
bool useTestnetDefaults = false,
25-
}) async {
26-
if (useTestnetDefaults) {
27-
return await Blockchain.createWithTestnetDefaults();
28-
} else if (isElectrumBlockchain) {
29-
return await Blockchain.create(
30-
config: const BlockchainConfig.electrum(
31-
config: ElectrumConfig(
32-
stopGap: 10,
33-
timeout: 5,
34-
retry: 5,
35-
url: "ssl://electrum.blockstream.info:60002",
36-
validateDomain: true,
37-
),
38-
),
39-
);
40-
} else {
41-
return await Blockchain.create(
42-
config: const BlockchainConfig.esplora(
43-
config: EsploraConfig(
44-
baseUrl: 'https://blockstream.info/testnet/api',
45-
stopGap: 10,
46-
),
47-
),
48-
);
49-
}
22+
Future<Blockchain> initializeBlockchain() async {
23+
return Blockchain.createMutinynet();
5024
}
5125

5226
Future<Wallet> restoreWallet(Descriptor descriptor) async {
@@ -118,7 +92,11 @@ class BdkLibrary {
11892
}
11993

12094
sendBitcoin(
121-
Blockchain blockchain, Wallet aliceWallet, String addressStr) async {
95+
Blockchain blockchain,
96+
Wallet aliceWallet,
97+
String addressStr,
98+
int amountSat,
99+
) async {
122100
try {
123101
final txBuilder = TxBuilder();
124102
final address = await Address.fromString(
@@ -127,7 +105,7 @@ class BdkLibrary {
127105
final script = await address.scriptPubkey();
128106
final feeRate = await estimateFeeRate(25, blockchain);
129107
final (psbt, _) = await txBuilder
130-
.addRecipient(script, 750)
108+
.addRecipient(script, amountSat)
131109
.feeRate(feeRate.satPerVb)
132110
.finish(aliceWallet);
133111
final isFinalized = await aliceWallet.sign(psbt: psbt);

example/lib/multi_sig_wallet.dart

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class MultiSigWallet {
6969
await aliceWallet.sign(
7070
psbt: psbt,
7171
signOptions: const SignOptions(
72-
multiSig: true,
7372
trustWitnessUtxo: false,
7473
allowAllSighashes: true,
7574
removePartialSigs: true,

example/lib/simple_wallet.dart

+21-27
Original file line numberDiff line numberDiff line change
@@ -25,48 +25,38 @@ class _SimpleWalletState extends State<SimpleWallet> {
2525

2626
generateMnemonicKeys() async {
2727
final res = await lib.createMnemonic();
28+
final mnemonic = await res.asString();
2829
setState(() {
29-
displayText = res.toString();
30+
displayText = mnemonic;
3031
});
3132
if (kDebugMode) {
32-
print(await res.asString());
33+
print(mnemonic);
3334
}
3435
}
3536

3637
restoreWallet() async {
3738
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');
3940
final aliceDescriptor = await lib.createDescriptor(aliceMnemonic);
4041
aliceWallet = await lib.restoreWallet(aliceDescriptor);
4142
setState(() {
4243
displayText = "Wallets restored";
4344
});
4445
}
4546

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-
5647
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();
6149
await lib.sync(blockchain!, aliceWallet);
6250
}
6351

6452
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+
6858
setState(() {
69-
displayText = "Address: $address \n Index: ${res.index}";
59+
displayText = "Address: $address \n Index: ${addressInfo.index}";
7060
});
7161
}
7262

@@ -100,13 +90,13 @@ class _SimpleWalletState extends State<SimpleWallet> {
10090
print(" confirmationTime Height: ${e.confirmationTime?.height}");
10191
final txIn = await e.transaction!.input();
10292
final txOut = await e.transaction!.output();
103-
print(" =============TxIn==============");
93+
print("=============TxIn==============");
10494
for (var e in txIn) {
10595
print(" previousOutout Txid: ${e.previousOutput.txid}");
10696
print(" previousOutout vout: ${e.previousOutput.vout}");
10797
print(" witness: ${e.witness}");
10898
}
109-
print(" =============TxOut==============");
99+
print("=============TxOut==============");
110100
for (var e in txOut) {
111101
print(" script: ${e.scriptPubkey.bytes}");
112102
print(" value: ${e.value}");
@@ -165,9 +155,13 @@ class _SimpleWalletState extends State<SimpleWallet> {
165155
}
166156
}
167157

168-
sendBit() async {
158+
sendBit(int amountSat) async {
169159
await lib.sendBitcoin(
170-
blockchain!, aliceWallet, "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB");
160+
blockchain!,
161+
aliceWallet,
162+
"tb1qyhssajdx5vfxuatt082m9tsfmxrxludgqwe52f",
163+
amountSat,
164+
);
171165
}
172166

173167
@override
@@ -299,9 +293,9 @@ class _SimpleWalletState extends State<SimpleWallet> {
299293
fontWeight: FontWeight.w800),
300294
)),
301295
TextButton(
302-
onPressed: () => sendBit(),
296+
onPressed: () => sendBit(100000),
303297
child: const Text(
304-
'Press to send 1200 satoshi',
298+
'Press to send 100k sats',
305299
style: TextStyle(
306300
color: Colors.indigoAccent,
307301
fontSize: 12,

example/macos/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- bdk_flutter (0.31.2-dev):
2+
- bdk_flutter (0.31.2-dev.2):
33
- FlutterMacOS
44
- FlutterMacOS (1.0.0)
55

@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
1414
:path: Flutter/ephemeral
1515

1616
SPEC CHECKSUMS:
17-
bdk_flutter: 8280f582b6b9b49deb843763027d4864b231c1d2
17+
bdk_flutter: 5135d700e746fe36b8fb7e3e4dac539652aa3a2b
1818
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
1919

2020
PODFILE CHECKSUM: 6acf97521436d16fc31cd5e1a02000905acdb3ae

0 commit comments

Comments
 (0)