diff --git a/package-lock.json b/package-lock.json index 2a1b650cd..e6c3b24e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17998,8 +17998,9 @@ } }, "payjoin-client": { - "version": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5", - "from": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/payjoin-client/-/payjoin-client-1.0.0.tgz", + "integrity": "sha512-3LLfpP9xaSkEeBZnNkjTDAANy5y7iIv+q5E36WTUnjz0tw1Jet8CfRzMnknunSlepXl9FV7sbrp4/s3P8zewnA==", "requires": { "bitcoinjs-lib": "^5.2.0" } diff --git a/package.json b/package.json index af5e87221..1e7f03ef1 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "lottie-react-native": "3.5.0", "metro-react-native-babel-preset": "0.63.0", "path-browserify": "1.0.1", - "payjoin-client": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5", + "payjoin-client": "1.0.0", "pbkdf2": "3.1.1", "prettier": "2.1.2", "process": "0.11.10", diff --git a/screen/send/confirm.js b/screen/send/confirm.js index 219bcbb64..e7404ddcf 100644 --- a/screen/send/confirm.js +++ b/screen/send/confirm.js @@ -46,6 +46,18 @@ export default class Confirm extends Component { this.isBiometricUseCapableAndEnabled = await Biometric.isBiometricUseCapableAndEnabled(); } + /** + * we need to look into `recipients`, find destination address and return its outputScript + * (needed for payjoin) + * + * @return {string} + */ + getPaymentScript() { + for (const recipient of this.state.recipients) { + return bitcoin.address.toOutputScript(recipient.address); + } + } + send() { this.setState({ isLoading: true }, async () => { try { @@ -54,7 +66,9 @@ export default class Confirm extends Component { await this.broadcast(this.state.tx); } else { const wallet = new PayjoinTransaction(this.state.psbt, txHex => this.broadcast(txHex), this.state.fromWallet); + const paymentScript = this.getPaymentScript(); const payjoinClient = new PayjoinClient({ + paymentScript, wallet, payjoinUrl: this.state.payjoinUrl, }); diff --git a/tests/unit/payjoin-transaction.test.js b/tests/unit/payjoin-transaction.test.js index d4ab83456..a717fa81d 100644 --- a/tests/unit/payjoin-transaction.test.js +++ b/tests/unit/payjoin-transaction.test.js @@ -57,6 +57,7 @@ describe('PayjoinTransaction', () => { }; const payjoinClient = new PayjoinClient({ + paymentScript: bitcoin.address.toOutputScript('bc1qyvdzueznsh0rsyfqzdtj9ce7nlx4rlg2v93lcl'), wallet, payjoinRequester: payjoinRequesterMock, }); @@ -110,6 +111,7 @@ describe('PayjoinTransaction', () => { }; const payjoinClient = new PayjoinClient({ + paymentScript: bitcoin.address.toOutputScript('bc1qy0ydthpa35m37pvwl5tu76j0srcmcwtmaur3aw'), wallet, payjoinRequester: payjoinRequesterMock, });