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

Zero-Confirmation Escrows #11838

Merged
merged 6 commits into from
Sep 22, 2021
Merged

Conversation

msalcala11
Copy link
Collaborator

@msalcala11 msalcala11 commented Aug 23, 2021

This PR enables BitPay Wallet to make ZCE-secured payments to JSON Payment Protocol accepting merchants and requires Bitcore Wallet Service to be running the following Bitcore PR: bitpay/bitcore#3240. Bitcore Wallet Client and Bitcore Lib Cash must also be upgraded to the commit in the aforementioned Bitcore PR, which can be done by pulling the Bitcore PR and using npm link.

ZCEs enable instant, incentive-secure payments on Bitcoin Cash. ZCE-secured payments can be accepted by merchants immediately upon receipt (without the need for a 5-10 second delay to monitor the network for double-spends) and with the same finality as a 1-confirmation transaction.

Testing a ZCE-secured payment end-to-end

  1. Clone the bitcore repo and pull the zero-conf-escrows branch from this PR: Zero-Confirmation Escrows bitcore#3240
  2. Start an instance of Bitcore Wallet Service locally using the branch above
  3. Navigate to the packages/bitcore-wallet-client directory, and run npm link
  4. Navigate to the packages/bitcore-lib-cash directory, and run npm link
  5. Clone this repository (wallet), and pull this PR
  6. Run npm link bitcore-wallet-client && npm link bitcore-lib-cash inside the wallet directory
  7. Run npm start
  8. Create a testnet BCH Wallet, and in advanced settings, change the Wallet Service URL to http://localhost:3232/bws/api
  9. Send at least $2.10 of testnet BCH to your newly created wallet
  10. Create a $1 invoice on https://test.bitpay.com
  11. Pay the invoice with your testnet BCH wallet

If everything is working properly, you'll see that the payment is instantly accepted by payment protocol. On the other hand, if you don't have at least 2x the invoice amount in your wallet, the broadcast step will not be instant and will instead take ~8 seconds.

@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #11838 (46a01c5) into master (6c42fc8) will decrease coverage by 0.05%.
The diff coverage is 16.39%.

❗ Current head 46a01c5 differs from pull request most recent head 9baa566. Consider uploading reports for the commit 9baa566 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11838      +/-   ##
==========================================
- Coverage   28.63%   28.58%   -0.06%     
==========================================
  Files         244      245       +1     
  Lines       21977    22066      +89     
  Branches     3551     3566      +15     
==========================================
+ Hits         6293     6307      +14     
- Misses      15137    15207      +70     
- Partials      547      552       +5     
Impacted Files Coverage Δ
...rds/confirm-card-purchase/confirm-card-purchase.ts 8.20% <0.00%> (-0.24%) ⬇️
src/pages/send/confirm/confirm.ts 22.93% <0.00%> (-0.20%) ⬇️
src/providers/providers.module.ts 100.00% <ø> (ø)
src/providers/zce/zce.ts 13.33% <13.33%> (ø)
src/providers/wallet/wallet.ts 57.31% <41.93%> (-0.94%) ⬇️
src/providers/index.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c42fc8...9baa566. Read the comment docs.

gabrielbazan7
gabrielbazan7 previously approved these changes Sep 8, 2021
Copy link
Collaborator

@gabrielbazan7 gabrielbazan7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome Job!! 🚀 I was able to make an end-to-end ZCE-secured payment successfully.
txid: 9c2d5e3b867273299bb56ef5c82e845f1847092afea86f1d1a8a58e7517ad8b9

I also paid an invoice without sufficient funds for the instantAcceptanceEscrow amount without issues.

@gabrielbazan7 gabrielbazan7 merged commit 0f77a5f into bitpay:master Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants