Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to v0.20 #33

Merged
merged 11 commits into from
Aug 21, 2024
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [0.20.0]
#### APIs added
- Make backwards-compatible `v2` to `v1` sends possible.
#### APIs changed
- Removed `contributeNonWitnessInput` from `v1` & `v2`.
- Allow receivers to make `payjoins` out of sweep transactions ([#259](https://github.com/payjoin/rust-payjoin/pull/259)).
- Encode &ohttp= and &exp= parameters in the &pj= URL as a fragment instead of as URI params ([#298](https://github.com/payjoin/rust-payjoin/pull/298))

## [0.18.0]
Updated `flutter_rust_bridge` to `2.0.0`.
#### APIs added
Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To use the `payjoin_flutter` package in your project, add it as a dependency in

```dart
dependencies:
payjoin_flutter: 0.18.0
payjoin_flutter: 0.20.0
```
### Requirements

Expand All @@ -26,15 +26,6 @@ this [link](https://github.com/vulpemventures/nigiri), to install it on your loc
Once the nigiri bitcoin starts running, you need to mine a few blocks. Please refer to the following [link](https://developer.bitcoin.org/reference/rpc/generatetoaddress.html?highlight=generate)
on how to mine blocks.

Before running the integration tests, please replace following snippet in `example/integration_test/bitcoin_core_full_cycle_test.dart` with your
nigiri bitcoin core credentials.

```dart
// Bitcoin core credentials
String rpcUser = "admin1";
String rpcPassword = "123";
int rpcPort = 18443;
```

## Running the integration tests
Once we have set up the Bitcoin core properly in the `Regtest` network,
Expand All @@ -47,8 +38,13 @@ cd example
#Run integration tests with bitcoin_core and bdk_flutter
flutter test integration_test
```
## Release status and readiness
## References

[Payjoin Dev Kit](https://payjoindevkit.org/)

[mozilla/uniffi-rs](https://github.com/mozilla/uniffi-rs)

Caution, this package is an Alpha at this stage Please consider reviewing, experimenting and contributing
## Release Status and Disclaimer

Please review and carry out testing to ensure security and safety of funds before using in production.
This project is in active development and currently in its Alpha stage. **Please proceed with caution**, particularly when using real funds.
We encourage thorough review, testing, and contributions to help improve its stability and security before considering production use.
4 changes: 2 additions & 2 deletions example/integration_test/bdk_full_cycle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ void main() {
final btcClient = BtcClient("sender");
await btcClient.loadWallet();
final sender = BdkClient(
"wpkh(tprv8ZgxMBicQKsPfNH1PykMg16TAvrZgoxDnxr3eorcbhvZxyZzStwFkvqCJegr8Gbwj3GQum8QpXQPh7DGkoobpTB7YbcnUeUSKRDyX2cNN9h/84'/1'/0'/0/*)#ey7hlgpn",
"wpkh(tprv8ZgxMBicQKsPemPN83fE95XY5PRnDJZ6YcTHbFACvme5Rwi2RRoivdksZzrP3M61Vz13pva5LjaY1TA9JezqgzLoaNG5SXpCAcyY5w2ursV)",
Network.regtest);
final receiver = BdkClient(
"wpkh(tprv8ZgxMBicQKsPczV7D2zfMr7oUzHDhNPEuBUgrwRoWM3ijLRvhG87xYiqh9JFLPqojuhmqwMdo1oJzbe5GUpxCbDHnqyGhQa5Jg1Wt6rc9di/84'/1'/0'/0/*)#kdnuw5lq",
"wpkh(tprv8ZgxMBicQKsPdD2rdKcJCtGop4vqW3cmvikhzVy42iCev4E9JpeJgnHXdMKLnmAyXatvhXPi8KomgWMa316mwyirBiLXi3MMPhRV1ikfNTJ)",
Network.regtest);
await sender.restoreWallet();
await receiver.restoreWallet();
Expand Down
10 changes: 5 additions & 5 deletions example/integration_test/bitcoin_core_full_cycle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void main() {
// Sender create a funded PSBT (not broadcast) to address with amount given in the pjUri
debugPrint("Sender Balance: ${(await sender.getBalance()).toString()}");
final uri = await pay_join_uri.Uri.fromStr(pjUri);
final address = await uri.address();
final amount = await uri.amount();
final address = uri.address();
final amount = uri.amount();
final senderPsbt =
(await sender.walletCreateFundedPsbt(amount, address, 2000))["psbt"];
debugPrint(
Expand All @@ -41,9 +41,9 @@ void main() {
final (provisionalProposal, ctx) =
await payJoinLib.handlePjRequest(senderPsbt, pjUri, (e) async {
final script = ScriptBuf(bytes: e);
final address = await (await Address.fromScript(
script: script, network: Network.regtest))
.asString();
final address =
(await Address.fromScript(script: script, network: Network.regtest))
.asString();
return (await receiver.getAddressInfo(address))["ismine"];
});
final availableInputs = await receiver.listUnspent([]);
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- payjoin_flutter (0.18.0)
- payjoin_flutter (0.20.0)

DEPENDENCIES:
- bdk_flutter (from `.symlinks/plugins/bdk_flutter/ios`)
Expand All @@ -33,8 +33,8 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
payjoin_flutter: 845f79d3e51d45e67842ee5df33ab492a1fd03cb
payjoin_flutter: 6397d7b698cdad6453be4949ab6aca1863f6c5e5

PODFILE CHECKSUM: a57f30d18f102dd3ce366b1d62a55ecbef2158e5

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
17 changes: 8 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _PayJoinState extends State<PayJoin> {
displayText = "sync complete";
});
debugPrint(
"sender balance: ${(await sender.getBalance()).toString()}");
"sender balance: ${(sender.getBalance()).toString()}");
},
child: Text(
"Sync wallets",
Expand All @@ -126,9 +126,9 @@ class _PayJoinState extends State<PayJoin> {
)),
TextButton(
onPressed: () async {
final address = (await receiver.getNewAddress()).address;
final address = (receiver.getNewAddress()).address;
final res = await payJoinLibrary.buildPjUri(
0.0083285, await address.toQrUri());
0.0083285, address.toQrUri());
setState(() {
pjUri = res;
displayText = res;
Expand All @@ -143,12 +143,11 @@ class _PayJoinState extends State<PayJoin> {
)),
TextButton(
onPressed: () async {
final balance = await sender.getBalance();
final balance = sender.getBalance();
debugPrint("Sender Balance: ${balance.toString()}");
final uri = await pay_join_uri.Uri.fromStr(pjUri);
final address = await uri.address();
int amount =
(((await uri.amount()) ?? 0) * 100000000).toInt();
final address = uri.address();
int amount = (((uri.amount()) ?? 0) * 100000000).toInt();
final psbt = (await sender.createPsbt(address, amount, 2000));
debugPrint(
"\nOriginal sender psbt: ${psbt.toString()}",
Expand All @@ -170,9 +169,9 @@ class _PayJoinState extends State<PayJoin> {
.handlePjRequest(senderPsbt.toString(), pjUri, (e) async {
final script = ScriptBuf(bytes: e);

return (await receiver.getAddressInfo(script));
return (receiver.getAddressInfo(script));
});
final unspent = await receiver.listUnspent();
final unspent = receiver.listUnspent();
// Select receiver payjoin inputs.
Map<BigInt, common.OutPoint> candidateInputs = {
for (var input in unspent)
Expand Down
4 changes: 1 addition & 3 deletions example/lib/payjoin_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class PayJoinLibrary {
'content-length': req.body.length.toString(),
});
final unchecked = await v1.UncheckedProposal.fromRequest(
body: req.body.toList(),
query: (await req.url.query())!,
headers: headers);
body: req.body.toList(), query: (req.url.query())!, headers: headers);
final provisionalProposal = await handleUnckedProposal(unchecked, isOwned);
return (provisionalProposal, cxt);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.18.0"
version: "0.20.0"
platform:
dependency: transitive
description:
Expand Down
22 changes: 5 additions & 17 deletions ios/Classes/frb_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ typedef struct wire_cst_list_prim_u_8_strict {
int32_t len;
} wire_cst_list_prim_u_8_strict;

typedef struct wire_cst_out_point {
struct wire_cst_list_prim_u_8_strict *txid;
uint32_t vout;
} wire_cst_out_point;

typedef struct wire_cst_tx_out {
uint64_t value;
struct wire_cst_list_prim_u_8_strict *script_pubkey;
} wire_cst_tx_out;

typedef struct wire_cst_out_point {
struct wire_cst_list_prim_u_8_strict *txid;
uint32_t vout;
} wire_cst_out_point;

typedef struct wire_cst_record_u_64_out_point {
uint64_t field0;
struct wire_cst_out_point field1;
Expand Down Expand Up @@ -336,11 +336,6 @@ void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_payjoin_proposal_psbt
void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_payjoin_proposal_utxos_to_be_locked(int64_t port_,
struct wire_cst_ffi_payjoin_proposal *that);

void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_contribute_non_witness_input(int64_t port_,
struct wire_cst_ffi_provisional_proposal *that,
struct wire_cst_list_prim_u_8_loose *tx,
struct wire_cst_out_point *outpoint);

void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_contribute_witness_input(int64_t port_,
struct wire_cst_ffi_provisional_proposal *that,
struct wire_cst_tx_out *txo,
Expand Down Expand Up @@ -429,11 +424,6 @@ void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_payjoin_proposal_
void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_payjoin_proposal_utxos_to_be_locked(int64_t port_,
struct wire_cst_ffi_v_2_payjoin_proposal *that);

void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_contribute_non_witness_input(int64_t port_,
struct wire_cst_ffi_v_2_provisional_proposal *that,
struct wire_cst_list_prim_u_8_loose *tx,
struct wire_cst_out_point *outpoint);

void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_contribute_witness_input(int64_t port_,
struct wire_cst_ffi_v_2_provisional_proposal *that,
struct wire_cst_tx_out *txo,
Expand Down Expand Up @@ -834,7 +824,6 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_payjoin_proposal_owned_vouts);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_payjoin_proposal_psbt);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_payjoin_proposal_utxos_to_be_locked);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_contribute_non_witness_input);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_contribute_witness_input);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_finalize_proposal);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_provisional_proposal_try_preserving_privacy);
Expand All @@ -857,7 +846,6 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_payjoin_proposal_process_res);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_payjoin_proposal_psbt);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_payjoin_proposal_utxos_to_be_locked);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_contribute_non_witness_input);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_contribute_witness_input);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_finalize_proposal);
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__receive__ffi_v_2_provisional_proposal_is_output_substitution_disabled);
Expand Down
2 changes: 1 addition & 1 deletion ios/payjoin_flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'payjoin_flutter'
s.version = '0.18.0'
s.version = '0.20.0'
s.summary = 'A new Flutter FFI plugin project.'
s.description = <<-DESC
A new Flutter FFI plugin project.
Expand Down
10 changes: 0 additions & 10 deletions lib/receive/v1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,6 @@ class ProvisionalProposal extends FfiProvisionalProposal {
}
}

@override
Future<void> contributeNonWitnessInput(
{required List<int> tx, required common.OutPoint outpoint, hint}) {
try {
return super.contributeNonWitnessInput(tx: tx, outpoint: outpoint);
} on error.PayjoinError catch (e) {
throw mapPayjoinError(e);
}
}

@override
Future<void> contributeWitnessInput(
{required common.TxOut txo, required common.OutPoint outpoint, hint}) {
Expand Down
10 changes: 0 additions & 10 deletions lib/receive/v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,6 @@ class ProvisionalProposal extends FfiV2ProvisionalProposal {
}
}

@override
Future<void> contributeNonWitnessInput(
{required List<int> tx, required OutPoint outpoint, hint}) {
try {
return super.contributeNonWitnessInput(tx: tx, outpoint: outpoint);
} on error.PayjoinError catch (e) {
throw mapPayjoinError(e);
}
}

@override
Future<void> contributeWitnessInput(
{required TxOut txo, required OutPoint outpoint, hint}) {
Expand Down
12 changes: 0 additions & 12 deletions lib/src/generated/api/receive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ class FfiProvisionalProposal {
required this.field0,
});

Future<void> contributeNonWitnessInput(
{required List<int> tx, required OutPoint outpoint}) =>
core.instance.api
.crateApiReceiveFfiProvisionalProposalContributeNonWitnessInput(
that: this, tx: tx, outpoint: outpoint);

Future<void> contributeWitnessInput(
{required TxOut txo, required OutPoint outpoint}) =>
core.instance.api
Expand Down Expand Up @@ -500,12 +494,6 @@ class FfiV2ProvisionalProposal {
required this.field0,
});

Future<void> contributeNonWitnessInput(
{required List<int> tx, required OutPoint outpoint}) =>
core.instance.api
.crateApiReceiveFfiV2ProvisionalProposalContributeNonWitnessInput(
that: this, tx: tx, outpoint: outpoint);

Future<void> contributeWitnessInput(
{required TxOut txo, required OutPoint outpoint}) =>
core.instance.api
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generated/api/uri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../lib.dart';
import '../utils/error.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`

class FfiOhttpKeys {
final OhttpKeys field0;
Expand Down
Loading