Skip to content

Commit

Permalink
Merge pull request #147 from LtbLightning/0.31.2-policy-patch
Browse files Browse the repository at this point in the history
0.31.2 policy patch
  • Loading branch information
BitcoinZavior authored Nov 25, 2024
2 parents 6c62a20 + 4ddc0c9 commit 8d7d89b
Show file tree
Hide file tree
Showing 23 changed files with 9,277 additions and 249 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
Updated `flutter_rust_bridge` to `2.0.0`.
#### APIs added
- Exposed `createTestnet` & `createMutinynet` to `Blockchain`.
- Exposed `policies` in `Wallet`.
- Exposed `policyPath` in `TxBuilder`.
- Exposed `id`, `requiresPath`, `item`, `satisfaction`, `contribution` in `Policy` class.
- Overrode `toString()` for `Address`, `DerivationPath`, `Descriptor`, `DescriptorPublicKey` , `DescriptorSecretKey`, `Mnemonic`,
- `PartiallySignedTransaction`, `ScriptBuf` & `Transaction`.
- `PartiallySignedTransaction`, `ScriptBuf` & `Transaction`.
#### Changed
- `partiallySignedTransaction.serialize()` serialize the data as raw binary.
#### Fixed
- Thread `frb_workerpool` panicked on Sql database access.


## [0.31.2-dev.2]
#### Fixed
- Thread `frb_workerpool` panicked on invalid `Fingerprint`.
Expand Down
1 change: 0 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 31
namespace "io.bdk.f.bdk_flutter"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="io.bdk.f.bdk_flutter"></manifest>
<manifest></manifest>
63 changes: 63 additions & 0 deletions example/integration_test /full_cycle_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'dart:typed_data';

import 'package:bdk_flutter/bdk_flutter.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Descriptor & Wallet', () {
setUp(() async {});
testWidgets('generating psbt using a muti-sig wallet', (_) async {
final externalDescriptor = await Descriptor.create(
descriptor:
"wsh(thresh(2,pk(tpubD6NzVbkrYhZ4XJBfEJ6gt9DiVdfWJijsQTCE3jtXByW3Tk6AVGQ3vL1NNxg3SjB7QkJAuutACCQjrXD8zdZSM1ZmBENszCqy49ECEHmD6rf/0/*),sj:and_v(v:pk(tpubD6NzVbkrYhZ4YfAr3jCBRk4SpqB9L1Hh442y83njwfMaker7EqZd7fHMqyTWrfRYJ1e5t2ue6BYjW5i5yQnmwqbzY1a3kfqNxog1AFcD1aE/0/*),n:older(6)),snj:and_v(v:pk(tprv8ZgxMBicQKsPeitVUz3s6cfyCECovNP7t82FaKPa4UKqV1kssWcXgLkMDjzDbgG9GWoza4pL7z727QitfzkiwX99E1Has3T3a1MKHvYWmQZ/0/*),after(630000))))",
network: Network.signet);
final internalDescriptor = await Descriptor.create(
descriptor:
"wsh(thresh(2,pk(tpubD6NzVbkrYhZ4XJBfEJ6gt9DiVdfWJijsQTCE3jtXByW3Tk6AVGQ3vL1NNxg3SjB7QkJAuutACCQjrXD8zdZSM1ZmBENszCqy49ECEHmD6rf/1/*),sj:and_v(v:pk(tpubD6NzVbkrYhZ4YfAr3jCBRk4SpqB9L1Hh442y83njwfMaker7EqZd7fHMqyTWrfRYJ1e5t2ue6BYjW5i5yQnmwqbzY1a3kfqNxog1AFcD1aE/1/*),n:older(6)),snj:and_v(v:pk(tprv8ZgxMBicQKsPeitVUz3s6cfyCECovNP7t82FaKPa4UKqV1kssWcXgLkMDjzDbgG9GWoza4pL7z727QitfzkiwX99E1Has3T3a1MKHvYWmQZ/1/*),after(630000))))",
network: Network.signet);

final wallet = await Wallet.create(
descriptor: externalDescriptor,
changeDescriptor: internalDescriptor,
network: Network.signet,
databaseConfig: const DatabaseConfig.memory());
final blockchain = await Blockchain.createMutinynet();
wallet.sync(blockchain: blockchain);
debugPrint("Wallet balance: ${wallet.getBalance().total}");
final toAddress = wallet
.getAddress(addressIndex: const AddressIndex.increase())
.address;
debugPrint("Wallet address: ${toAddress.toString()}");
final externalWalletPolicy = wallet.policies(KeychainKind.externalChain);
final ineternalWalletPolicy = wallet.policies(KeychainKind.internalChain);
if (externalWalletPolicy != null && ineternalWalletPolicy != null) {
// Construct external and internal policy paths
final extPath = {
ineternalWalletPolicy.id(): Uint32List.fromList([0, 1])
};
debugPrint("External Policy path: $extPath\n");

final intPath = {
ineternalWalletPolicy.id(): Uint32List.fromList([0, 1])
};
debugPrint("Internal Policy Path: $intPath\n");

// Build the transaction
final txBuilder = TxBuilder()
.addRecipient(
toAddress.scriptPubkey(),
BigInt.from(1000),
)
.doNotSpendChange()
.policyPath(KeychainKind.internalChain, intPath)
.policyPath(KeychainKind.externalChain, extPath);

final (psbt, _) = await txBuilder.finish(wallet);
debugPrint("Transaction serialized: ${psbt.toString()}\n");
}
});
});
}
47 changes: 47 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_driver:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -210,6 +215,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.2"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
Expand All @@ -218,6 +228,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -314,6 +329,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.0"
platform:
dependency: transitive
description:
name: platform
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
url: "https://pub.dev"
source: hosted
version: "3.1.5"
process:
dependency: transitive
description:
name: process
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
pub_semver:
dependency: transitive
description:
Expand Down Expand Up @@ -375,6 +406,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
sync_http:
dependency: transitive
description:
name: sync_http
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
term_glyph:
dependency: transitive
description:
Expand Down Expand Up @@ -439,6 +478,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
yaml:
dependency: transitive
description:
Expand Down
5 changes: 4 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter

integration_test:
sdk: flutter
flutter_driver:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
Expand Down
Loading

0 comments on commit 8d7d89b

Please sign in to comment.