Comments (6)
I think you have the wrong idea with what you are doing with const tweakKey = Tap.tweak.getPubKey(pubkey)
.
For Tap.getPubKey
you should be using the internal pubkey
, and for the address you should be using the tpubkey
. For the pubkey in the script itself, it can be any keypair that you want, but it can be convenient to reuse the internal pubkey
for that as well.
The internal pubkey
is what gets tweaked by the taproot, creating the tpubkey
, which you then encode into an address. I hope that helps.
from tapscript.
from tapscript.
Maybe it's because taproot hash deletion
from tapscript.
i fix it. see
from tapscript.
hey am also facing same witness mismatch problem
`
// Here is my code
const inscriptions = async () => {
const marker = Buff.encode('ord')
const mimetype = Buff.encode('image/png')
const imgdata = Buff.from('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/Pv8hOAAAAABJRU5ErkJggg==', 'base64')
// const pubKey = "02f8a93684235245259faf189eb6b5787b03dbe8711a1262409cfcfd0ee015a483";
const pvt = "06e257ee24ce8ee772d78568da1e0c281b5b816c90fa77d.........";
const pvtKey = keys.get_seckey(pvt)
const pubkey = keys.get_pubkey(pvt,true);
// Basic format of an 'inscription' script.
const script = [pubkey.hex, 'OP_CHECKSIG', 'OP_0', 'OP_IF', marker, '01', mimetype, 'OP_0', imgdata, 'OP_ENDIF']
// const tapleaf = Tap.encodeScript(script)
const tapleaf = Tap.tree.getLeaf(Script.encode(script));
const [tpubkey, cblock] = Tap.getPubKey(pubkey, { target: tapleaf });
const address = Address.p2tr.fromPubKey(tpubkey, 'regtest')
console.log('Inscription address: ', address);
console.log('Tapkey:', tpubkey);
try {
const txdata = Tx.create({
vin: [{
// Use the txid of the funding transaction used to send the sats.
txid: "c404bc4ba89e9423ff772cb45268ba6fba8b713f809484c1216f1a657aafa088",
// Specify the index value of the output that you are going to spend from.
vout: 1,
// Also include the value and script of that ouput.
prevout: {
// Feel free to change this if you sent a different amount.
value: 1973787,
// This is what our address looks like in script form.
scriptPubKey: ['OP_1', tpubkey]
},
}],
vout: [{
// We are leaving behind 1000 sats as a fee to the miners.
value: 500,
// This is the new script that we are locking our funds to. sent
scriptPubKey: Address.toScriptPubKey('tb1q7gnys2cwhkm7r73px6nus0g9dcr8mjh6fe2ums')
// scriptPubKey: [ 'OP_1', tpubkey ]
}]
})
// let sig = await window.unisat.signMessage(pvtKey, txdata, 0, { extension: tapleaf });
const sig = Signer.taproot.sign(pvtKey, txdata, 0, { extension: tapleaf })
console.log("sig",sig)
txdata.vin[0].witness = [sig, script, cblock]
console.log(txdata.vin[0].witness)
console.log(script,cblock)
// const isValid = await Signer.taproot.verify(txdata, 0, { pubkey, throws: true })
console.log("txdata", txdata)
// encode
console.log('Your txhex:', Tx.encode(txdata).hex)
const isValid = Signer.taproot.verify(txdata, 0, { pubkey, throws: true })
console.log("valid",isValid)
// console.dir(txdata, { depth: null })
} catch (error) {
console.log("error", error)
}
}
`
from tapscript.
A witness hash mismatch
problem is usually because there is something wrong with the encoding of the script when you first encode it as a tapleaf.
Using Tap.encodeScript(script)
should make sure that the script is encoded properly, so that when the script is verified in the witness, the encoding during verification is the same as the encoding when you first create the tapleaf.
Let me know if that helps.
from tapscript.
Related Issues (20)
- crypto is not defined HOT 2
- Taptree Example sounds strange HOT 5
- PSBT support HOT 10
- Tap script inquiry HOT 3
- Witness program hash mismatch HOT 2
- Custom Address Prefix HOT 1
- Ordinal Provenance HOT 13
- ReferenceError: crypto is not defined HOT 2
- ReferenceError: crypto is not defined HOT 1
- Public key version reserved for soft-fork upgrades HOT 3
- Add Metadata to inscription HOT 1
- Error: Size greater than stream: 38133322 > 56518 HOT 16
- A test failure HOT 3
- In the examples, where is the scriptPubKey address comming from? HOT 1
- Add multiple parent to a child inscription HOT 2
- Runes HOT 1
- OP_RETURN in output HOT 6
- sponsors? HOT 1
- Invalid Schnorr Siganture - Example: Basic Pay-to-Pubkey Spending HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tapscript.