Add support for taproot keyspend PSBTs (#4462)

This commit is contained in:
benthecarman 2022-07-08 09:08:19 -05:00 committed by GitHub
parent 211339f344
commit 5df5bf6741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -588,9 +588,8 @@ class PSBTUnitTest extends BitcoinSUnitTest {
val finalizedT = psbt.finalizePSBT
assert(finalizedT.isSuccess)
// todo can't verify taproot yet
// val finalized = finalizedT.get
// assert(finalized.extractTransactionAndValidate.isSuccess)
val finalized = finalizedT.get
assert(finalized.extractTransactionAndValidate.isSuccess)
}
it must "PSBT with one P2TR key only output with internal key and its derivation path" in {

View file

@ -78,11 +78,8 @@ object TxSigComponent {
case Some(scriptWitness) =>
unsignedWtx.updateWitness(idx, scriptWitness)
}
case _: ScriptWitnessV0 =>
unsignedWtx
case t: TaprootWitness =>
throw new UnsupportedOperationException(
s"Taproot not supported, got=$t")
case _: ScriptWitnessV0 => unsignedWtx
case _: TaprootWitness => unsignedWtx
}
}

View file

@ -164,9 +164,13 @@ object InputInfo {
getPreImagesAndCondPath(p2wsh.scriptSignature)
case EmptyScriptWitness =>
getPreImagesAndCondPath(txIn.scriptSignature)
case taprootWitness: TaprootWitness =>
case _: TaprootKeyPath =>
// No hashes in taproot key path
(Vector.empty, Vector.empty)
case taprootWitness @ (_: TaprootScriptPath |
_: TaprootUnknownPath) =>
throw new UnsupportedOperationException(
s"Taproot not supported, got=$taprootWitness")
s"Taproot script path not yet supported, got=$taprootWitness")
}
}
@ -287,7 +291,7 @@ object InputInfo {
"Script Witness must be defined for (nested) Segwit input")
case Some(_: ScriptWitness) =>
throw new UnsupportedOperationException(
"Only v0 Segwit is currently supported")
"Only v0 Segwit is supported for wrapped segwit")
}
P2SHNestedSegwitV0InputInfo(outPoint,
output.value,
@ -304,7 +308,7 @@ object InputInfo {
throw new IllegalArgumentException("Cannot have nested P2SH")
case _: TaprootScriptPubKey =>
throw new UnsupportedOperationException(
s"Unsupported Taproot ScriptPubKey ${output.scriptPubKey}")
s"Taproot cannot be used as a nested P2SH")
case _: UnassignedWitnessScriptPubKey =>
throw new UnsupportedOperationException(
s"Unsupported ScriptPubKey ${output.scriptPubKey}")