Skip to content

Commit

Permalink
Merge pull request #136 from LtbLightning/bdk-payjoin-integration-fix
Browse files Browse the repository at this point in the history
Bdk payjoin integration fix
  • Loading branch information
BitcoinZavior authored Jun 21, 2024
2 parents 3ecadf0 + b71c23c commit 9aad04e
Show file tree
Hide file tree
Showing 36 changed files with 1,638 additions and 672 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/precompile_binaries.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [v0.31.2-dev.1, master, main]
branches: [v0.31.2-dev.2, master, main]

name: Precompile Binaries

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [0.31.2-dev.2]
#### Fixed
- Thread `frb_workerpool` panicked on invalid `Fingerprint`.
- `SignOptions` issue to accept `witness-utxo` while signing.

#### Changed
- Removed `multiSig` variable from `SignOptions`.
- Updated example app to support `mutinynet`.
- Mapped `Hex`, `Address`, `Descriptor` & `Consensus` exceptions.

## [0.31.2-dev.1]
#### Fixed
- Invalid `Bip49Public`, `Bip84Public` & `Bip86Public`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ To use the `bdk_flutter` package in your project, add it as a dependency in your

```dart
dependencies:
bdk_flutter: ^0.31.2-dev.1
bdk_flutter: ^0.31.2-dev.2
```

### Examples
Expand Down
28 changes: 7 additions & 21 deletions example/lib/bdk_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,21 @@ class BdkLibrary {

Future<Descriptor> createDescriptor(Mnemonic mnemonic) async {
final descriptorSecretKey = await DescriptorSecretKey.create(
network: Network.testnet,
network: Network.signet,
mnemonic: mnemonic,
);
final descriptor = await Descriptor.newBip84(
secretKey: descriptorSecretKey,
network: Network.testnet,
network: Network.signet,
keychain: KeychainKind.externalChain);
return descriptor;
}

Future<Blockchain> initializeBlockchain(bool isElectrumBlockchain) async {
if (isElectrumBlockchain) {
final blockchain = await Blockchain.create(
config: const BlockchainConfig.esplora(
config: EsploraConfig(
baseUrl: 'https://blockstream.info/testnet/api',
stopGap: 10)));
return blockchain;
} else {
final blockchain = await Blockchain.create(
config: const BlockchainConfig.electrum(
config: ElectrumConfig(
stopGap: 10,
timeout: 5,
retry: 5,
url: "ssl://electrum.blockstream.info:60002",
validateDomain: true)));
return blockchain;
}
Future<Blockchain> initializeBlockchain() async {
return await Blockchain.create(
config: const BlockchainConfig.esplora(
config: EsploraConfig(
baseUrl: 'https://mutinynet.com/api', stopGap: 10)));
}

Future<Wallet> restoreWallet(Descriptor descriptor) async {
Expand Down
1 change: 0 additions & 1 deletion example/lib/multi_sig_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class MultiSigWallet {
await aliceWallet.sign(
psbt: psbt,
signOptions: const SignOptions(
multiSig: true,
trustWitnessUtxo: false,
allowAllSighashes: true,
removePartialSigs: true,
Expand Down
26 changes: 10 additions & 16 deletions example/lib/simple_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,25 @@ class _SimpleWalletState extends State<SimpleWallet> {

restoreWallet() async {
final aliceMnemonic = await Mnemonic.fromString(
'certain sense kiss guide crumble hint transfer crime much stereo warm coral');
'give rate trigger race embrace dream wish column upon steel wrist rice');
final aliceDescriptor = await lib.createDescriptor(aliceMnemonic);
aliceWallet = await lib.restoreWallet(aliceDescriptor);
setState(() {
displayText = "Wallets restored";
});
}

initBlockchain(bool isElectrumBlockchain) async {
blockchain = await lib.initializeBlockchain(isElectrumBlockchain);
}

sync() async {
if (blockchain == null) {
await initBlockchain(false);
}
blockchain ??= await lib.initializeBlockchain();
await lib.sync(blockchain!, aliceWallet);
}

getNewAddress() async {
final res = (await lib.getAddress(aliceWallet));
debugPrint(await res.address.asString());
setState(() async {
displayText =
"Address: ${await res.address.asString()} \n Index: ${res.index}";
final res = (await (await lib.getAddress(aliceWallet)).address.asString());
debugPrint(res);

setState(() {
displayText = "Address: $res";
});
}

Expand Down Expand Up @@ -93,13 +87,13 @@ class _SimpleWalletState extends State<SimpleWallet> {
print(" confirmationTime Height: ${e.confirmationTime?.height}");
final txIn = await e.transaction!.input();
final txOut = await e.transaction!.output();
print(" =============TxIn==============");
print("=============TxIn==============");
for (var e in txIn) {
print(" previousOutout Txid: ${e.previousOutput.txid}");
print(" previousOutout vout: ${e.previousOutput.vout}");
print(" witness: ${e.witness}");
}
print(" =============TxOut==============");
print("=============TxOut==============");
for (var e in txOut) {
print(" script: ${e.scriptPubkey.bytes}");
print(" value: ${e.value}");
Expand Down Expand Up @@ -160,7 +154,7 @@ class _SimpleWalletState extends State<SimpleWallet> {

sendBit() async {
await lib.sendBitcoin(
blockchain!, aliceWallet, "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB");
blockchain!, aliceWallet, "tb1qyhssajdx5vfxuatt082m9tsfmxrxludgqwe52f");
}

@override
Expand Down
4 changes: 2 additions & 2 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- bdk_flutter (0.31.2-dev):
- bdk_flutter (0.31.2-dev.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)

Expand All @@ -14,7 +14,7 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral

SPEC CHECKSUMS:
bdk_flutter: 8280f582b6b9b49deb843763027d4864b231c1d2
bdk_flutter: 57988518b9d8823b481055a894d9e3769bdfdf39
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24

PODFILE CHECKSUM: 6acf97521436d16fc31cd5e1a02000905acdb3ae
Expand Down
30 changes: 15 additions & 15 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.31.2-dev.1"
version: "0.31.2-dev.2"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -238,26 +238,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -294,10 +294,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mockito:
dependency: transitive
description:
Expand Down Expand Up @@ -395,10 +395,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -427,10 +427,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
watcher:
dependency: transitive
description:
Expand All @@ -448,5 +448,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0-0 <4.0.0"
flutter: ">=3.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
6 changes: 5 additions & 1 deletion ios/Classes/frb_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ typedef struct wire_cst_database_config {
} wire_cst_database_config;

typedef struct wire_cst_sign_options {
bool multi_sig;
bool trust_witness_utxo;
uint32_t *assume_height;
bool allow_all_sighashes;
Expand Down Expand Up @@ -506,6 +505,10 @@ typedef struct wire_cst_BdkError_Consensus {
struct wire_cst_consensus_error *field0;
} wire_cst_BdkError_Consensus;

typedef struct wire_cst_BdkError_VerifyTransaction {
struct wire_cst_list_prim_u_8_strict *field0;
} wire_cst_BdkError_VerifyTransaction;

typedef struct wire_cst_BdkError_Address {
struct wire_cst_address_error *field0;
} wire_cst_BdkError_Address;
Expand Down Expand Up @@ -644,6 +647,7 @@ typedef struct wire_cst_BdkError_InvalidTransaction {
typedef union BdkErrorKind {
struct wire_cst_BdkError_Hex Hex;
struct wire_cst_BdkError_Consensus Consensus;
struct wire_cst_BdkError_VerifyTransaction VerifyTransaction;
struct wire_cst_BdkError_Address Address;
struct wire_cst_BdkError_Descriptor Descriptor;
struct wire_cst_BdkError_InvalidU32Bytes InvalidU32Bytes;
Expand Down
2 changes: 1 addition & 1 deletion ios/bdk_flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'bdk_flutter'
s.version = "0.31.2-dev.1"
s.version = "0.31.2-dev.2"
s.summary = 'A Flutter library for the Bitcoin Development Kit (https://bitcoindevkit.org/)'
s.description = <<-DESC
A new Flutter plugin project.
Expand Down
2 changes: 1 addition & 1 deletion lib/bdk_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ export './src/generated/api/wallet.dart'
finishBumpFeeTxBuilder,
txBuilderFinish;
export './src/root.dart';
export 'src/utils/exceptions.dart' hide mapToException, BdkFfiException;
export 'src/utils/exceptions.dart' hide mapBdkError, BdkFfiException;
3 changes: 3 additions & 0 deletions lib/src/generated/api/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ sealed class BdkError with _$BdkError implements FrbException {
const factory BdkError.consensus(
ConsensusError field0,
) = BdkError_Consensus;
const factory BdkError.verifyTransaction(
String field0,
) = BdkError_VerifyTransaction;

/// Address error.
const factory BdkError.address(
Expand Down
Loading

0 comments on commit 9aad04e

Please sign in to comment.