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

feat: recover pending escrow links #875

Closed
wants to merge 50 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2770a86
initial escrow upd
justinenerio Feb 17, 2023
3532a29
upd
justinenerio Feb 21, 2023
057b32a
Merge commit 'a3ff0c889a7dbd50db3e6ee433ffaca42c637d3b' into feat/lin…
justinenerio Feb 21, 2023
2bdca41
test upd
justinenerio Feb 21, 2023
4be5262
Merge commit '3d1ec4dad956396349877d6f3dcbcbf7d775ac73' into feat/lin…
justinenerio Feb 22, 2023
36deb2a
upd
justinenerio Feb 22, 2023
d2bf344
analyzer fixes
justinenerio Feb 22, 2023
fa30b12
fix
justinenerio Feb 22, 2023
41b3f33
Merge commit '907c6903fd104c5f8717f5684d1c9f3cf5fa2da7' into feat/lin…
justinenerio Mar 2, 2023
808fa74
upd ci
justinenerio Mar 2, 2023
bfc93ec
fix
justinenerio Mar 2, 2023
8103068
Merge branch 'master' into feat/links-escrow
justinenerio Mar 3, 2023
027e969
test updates
justinenerio Mar 15, 2023
a55679d
init: recover watcher
justinenerio Mar 17, 2023
8bb8644
upd cancel oksp
justinenerio Mar 17, 2023
a105a4c
upd
justinenerio Mar 17, 2023
f0c9903
added comments
justinenerio Mar 17, 2023
e3d4850
Merge commit '6332451987b179ffcac4b2fc3de82f19ae2c29dc' into feat/rec…
justinenerio Mar 20, 2023
d4c8ac3
Merge commit 'aad6d9411ee401a89689e2d1e36856966ca70caa' into feat/rec…
justinenerio Apr 4, 2023
788ab4f
upd
justinenerio Apr 4, 2023
a3ad905
Merge commit '46fb09255b1ae3c3bfe657829bd03a2dfd373de5' into feat/rec…
justinenerio Apr 8, 2023
72d8605
Merge commit '19579a9ac02400c59df2b7ac3885548d2e64e8a6' into feat/rec…
justinenerio Apr 24, 2023
c4c9ccf
revert
justinenerio Apr 24, 2023
0638407
revert
justinenerio Apr 24, 2023
8c7496c
upd
justinenerio Apr 24, 2023
e78aaf7
upd address
justinenerio Apr 24, 2023
372638e
dump schema
justinenerio Apr 24, 2023
29aad72
fix error
justinenerio Apr 24, 2023
7eddd66
upd
justinenerio Apr 24, 2023
a8faffc
Merge branch 'master' into feat/recover-links
justinenerio Apr 25, 2023
f76892a
Merge branch 'master' into feat/recover-links
justinenerio Apr 26, 2023
f81c980
Merge branch 'master' into feat/recover-links
justinenerio Apr 27, 2023
288f670
Merge branch 'master' into feat/recover-links
justinenerio Apr 30, 2023
b5c603e
upd
justinenerio May 2, 2023
3a17327
Merge commit '2114d3e245b789dc5242353c0bb2916e9d3777a7' into feat/rec…
justinenerio May 2, 2023
ef8741b
Merge branch 'master' into feat/recover-links
justinenerio May 4, 2023
e6a251a
Merge branch 'master' into feat/recover-links
justinenerio May 8, 2023
3777321
Merge branch 'master' into feat/recover-links
justinenerio May 19, 2023
d3b4a1f
Merge branch 'master' into feat/recover-links
justinenerio Jun 2, 2023
ece1c3b
Merge branch 'master' into feat/recover-links
justinenerio Jun 9, 2023
17f2bf4
Merge branch 'master' into feat/recover-links
justinenerio Jun 13, 2023
3b0c896
Merge commit '9a58f908af99157fb517abd40bae3fe030a26cb4' into feat/rec…
justinenerio Jun 18, 2023
e2b3642
Merge branch 'feat/recover-links' of https://github.com/espresso-cash…
justinenerio Jun 18, 2023
90099fd
Merge branch 'master' into feat/recover-links
justinenerio Jun 21, 2023
f7cd9ac
Merge branch 'master' into feat/recover-links
justinenerio Jul 27, 2023
c4d16ca
upd code style
justinenerio Aug 3, 2023
f25e54d
Merge branch 'feat/recover-links' of https://github.com/espresso-cash…
justinenerio Aug 3, 2023
10982fb
Merge branch 'master' into feat/recover-links
justinenerio Aug 20, 2023
354597e
Merge branch 'master' into feat/recover-links
justinenerio Aug 29, 2023
6bdd1c8
Merge branch 'master' into feat/recover-links
justinenerio Sep 22, 2023
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
Prev Previous commit
Next Next commit
upd
  • Loading branch information
justinenerio committed Feb 21, 2023
commit 3532a29ce505be0c81aab121869975a5317099ad
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@ import '../accounts/bl/ec_wallet.dart';
extension ResignTx on SignedTx {
Future<SignedTx> resign(ECWallet wallet) async => SignedTx(
signatures: signatures.toList()
..removeLast()
..add(await wallet.sign(compiledMessage.toByteArray())),
..setAll(
signatures.indexWhere((it) => it.publicKey == wallet.publicKey), [
await wallet.sign(compiledMessage.toByteArray()),
]),
compiledMessage: compiledMessage,
);
}
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ class OSKPService {

Future<OutgoingSplitKeyPayment> cancel(
OutgoingSplitKeyPayment payment, {
required Ed25519HDPublicKey account,
required ECWallet account,
}) async {
final status = payment.status;

@@ -105,7 +105,8 @@ class OSKPService {
final response = await _client.createPayment(dto);
final tx = await response.transaction
.let(SignedTx.decode)
.let((it) => it.resign(account));
.let((it) => it.resign(account))
.letAsync((it) => it.resign(LocalWallet(escrowAccount)));

return OSKPStatus.txCreated(tx, escrow: privateKey, slot: response.slot);
} on Exception {
@@ -117,22 +118,22 @@ class OSKPService {

Future<OSKPStatus> _createCancelTx({
required Ed25519HDKeyPair escrow,
required Ed25519HDPublicKey account,
required ECWallet account,
}) async {
final privateKey = await EscrowPrivateKey.fromKeyPair(escrow);

try {
final dto = ReceivePaymentRequestDto(
receiverAccount: account.toBase58(),
final dto = CancelPaymentRequestDto(
senderAccount: account.address,
escrowAccount: escrow.address,
cluster: apiCluster,
);

final response = await _client.receivePayment(dto);
final response = await _client.cancelPayment(dto);
final tx = await response
.let((it) => it.transaction)
.let(SignedTx.decode)
.let((it) => it.resign(LocalWallet(escrow)));
.let((it) => it.resign(account));

return OSKPStatus.cancelTxCreated(
tx,
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ extension BuildContextExt on BuildContext {
runWithLoader<void>(this, () async {
await sl<OSKPService>().cancel(
payment,
account: read<MyAccount>().publicKey,
account: read<MyAccount>().wallet,
);
sl<AnalyticsManager>().linksCreated();
});
Original file line number Diff line number Diff line change
@@ -24,6 +24,11 @@ abstract class CryptopleaseClient {
@Body() ReceivePaymentRequestDto request,
);

@POST('/cancelPayment')
Future<CancelPaymentResponseDto> cancelPayment(
@Body() CancelPaymentRequestDto request,
);

@POST('/createDirectPayment')
Future<CreateDirectPaymentResponseDto> createDirectPayment(
@Body() CreateDirectPaymentRequestDto request,

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -50,6 +50,29 @@ class ReceivePaymentResponseDto with _$ReceivePaymentResponseDto {
_$ReceivePaymentResponseDtoFromJson(json);
}

@freezed
class CancelPaymentRequestDto with _$CancelPaymentRequestDto {
const factory CancelPaymentRequestDto({
required String senderAccount,
required String escrowAccount,
required Cluster cluster,
}) = _CancelPaymentRequestDto;

factory CancelPaymentRequestDto.fromJson(Map<String, dynamic> json) =>
_$CancelPaymentRequestDtoFromJson(json);
}

@freezed
class CancelPaymentResponseDto with _$CancelPaymentResponseDto {
const factory CancelPaymentResponseDto({
required String transaction,
required BigInt slot,
}) = _CancelPaymentResponseDto;

factory CancelPaymentResponseDto.fromJson(Map<String, dynamic> json) =>
_$CancelPaymentResponseDtoFromJson(json);
}

@freezed
class CreateDirectPaymentRequestDto with _$CreateDirectPaymentRequestDto {
const factory CreateDirectPaymentRequestDto({
Loading