Skip to content

Commit

Permalink
P2PKH anyonecanpay SINGLE -> ALL.
Browse files Browse the repository at this point in the history
  • Loading branch information
msinkec committed Aug 25, 2023
1 parent f6c41d5 commit cca1e9f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/p2pkh-anyonecanpay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ async function main() {
)

// Construct the call tx locally (notice the "pratiallySigned" flag).
// Use the ANYONECANPAY_SINGLE sighash flag to sign the first input.
const sigHashType = bsv.crypto.Signature.ANYONECANPAY_SINGLE
// Use the ANYONECANPAY_ALL sighash flag to sign the first input.
const sigHashType = bsv.crypto.Signature.ANYONECANPAY_ALL
const { tx: callTx } = await p2pkh.methods.unlock(
// pass signature, the first parameter, to `unlock`
// after the signer signs the transaction, the signatures are returned in `SignatureResponse[]`
Expand Down Expand Up @@ -95,7 +95,7 @@ async function main() {
callTx.change(address)

// Finally, sign the newly added inputs and broadcast the modified transaction.
// Notice, that if the main singer wouldn't use the ANYONECANPAY_SINGLE sighash flag,
// Notice, that if the main singer wouldn't use the ANYONECANPAY sighash flag,
// Then the call to the "unlock" method (first input) wouldn't successfully evaluate anymore.
await feeSigner.signAndsendTransaction(callTx, { address })

Expand Down Expand Up @@ -158,8 +158,8 @@ async function main2() {
)

// Construct the call tx locally (notice the "pratiallySigned" flag).
// Use the ANYONECANPAY_SINGLE sighash flag to sign the first input.
const sigHashType = bsv.crypto.Signature.ANYONECANPAY_SINGLE
// Use the ANYONECANPAY_ALL sighash flag to sign the first input.
const sigHashType = bsv.crypto.Signature.ANYONECANPAY_ALL
const { tx: callTx } = await p2pkh.methods.unlock(
// pass signature, the first parameter, to `unlock`
// after the signer signs the transaction, the signatures are returned in `SignatureResponse[]`
Expand Down Expand Up @@ -187,15 +187,15 @@ async function main2() {
callTx.change(address)

// Finally, sign the newly added inputs and broadcast the modified transaction.
// Notice, that if the main singer wouldn't use the ANYONECANPAY_SINGLE sighash flag,
// Notice, that if the main singer wouldn't use the ANYONECANPAY sighash flag,
// Then the call to the "unlock" method (first input) wouldn't successfully evaluate anymore.

await feeSigner.signAndsendTransaction(callTx, { address })

console.log('main2 P2PKH contract called: ', callTx.id)
}

describe('Test SmartContract `P2PKH` with ANYONECANPAY_SINGLE', () => {
describe('Test SmartContract `P2PKH` with ANYONECANPAY', () => {
it('should succeed', async () => {
await P2PKH.compile()
// contract at first inputIndex
Expand Down

0 comments on commit cca1e9f

Please sign in to comment.