Merge pull request #2203 from BlueWallet/ops-payjoin-bump

OPS: updated payjoin dep
This commit is contained in:
GLaDOS 2020-11-25 13:56:21 +00:00 committed by GitHub
commit d127ef86ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

5
package-lock.json generated
View file

@ -17998,8 +17998,9 @@
} }
}, },
"payjoin-client": { "payjoin-client": {
"version": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5", "version": "1.0.0",
"from": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5", "resolved": "https://registry.npmjs.org/payjoin-client/-/payjoin-client-1.0.0.tgz",
"integrity": "sha512-3LLfpP9xaSkEeBZnNkjTDAANy5y7iIv+q5E36WTUnjz0tw1Jet8CfRzMnknunSlepXl9FV7sbrp4/s3P8zewnA==",
"requires": { "requires": {
"bitcoinjs-lib": "^5.2.0" "bitcoinjs-lib": "^5.2.0"
} }

View file

@ -110,7 +110,7 @@
"lottie-react-native": "3.5.0", "lottie-react-native": "3.5.0",
"metro-react-native-babel-preset": "0.63.0", "metro-react-native-babel-preset": "0.63.0",
"path-browserify": "1.0.1", "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", "pbkdf2": "3.1.1",
"prettier": "2.1.2", "prettier": "2.1.2",
"process": "0.11.10", "process": "0.11.10",

View file

@ -46,6 +46,18 @@ export default class Confirm extends Component {
this.isBiometricUseCapableAndEnabled = await Biometric.isBiometricUseCapableAndEnabled(); 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() { send() {
this.setState({ isLoading: true }, async () => { this.setState({ isLoading: true }, async () => {
try { try {
@ -54,7 +66,9 @@ export default class Confirm extends Component {
await this.broadcast(this.state.tx); await this.broadcast(this.state.tx);
} else { } else {
const wallet = new PayjoinTransaction(this.state.psbt, txHex => this.broadcast(txHex), this.state.fromWallet); const wallet = new PayjoinTransaction(this.state.psbt, txHex => this.broadcast(txHex), this.state.fromWallet);
const paymentScript = this.getPaymentScript();
const payjoinClient = new PayjoinClient({ const payjoinClient = new PayjoinClient({
paymentScript,
wallet, wallet,
payjoinUrl: this.state.payjoinUrl, payjoinUrl: this.state.payjoinUrl,
}); });

View file

@ -57,6 +57,7 @@ describe('PayjoinTransaction', () => {
}; };
const payjoinClient = new PayjoinClient({ const payjoinClient = new PayjoinClient({
paymentScript: bitcoin.address.toOutputScript('bc1qyvdzueznsh0rsyfqzdtj9ce7nlx4rlg2v93lcl'),
wallet, wallet,
payjoinRequester: payjoinRequesterMock, payjoinRequester: payjoinRequesterMock,
}); });
@ -110,6 +111,7 @@ describe('PayjoinTransaction', () => {
}; };
const payjoinClient = new PayjoinClient({ const payjoinClient = new PayjoinClient({
paymentScript: bitcoin.address.toOutputScript('bc1qy0ydthpa35m37pvwl5tu76j0srcmcwtmaur3aw'),
wallet, wallet,
payjoinRequester: payjoinRequesterMock, payjoinRequester: payjoinRequesterMock,
}); });