Skip to content

Commit

Permalink
src: maybe add taproot support
Browse files Browse the repository at this point in the history
  • Loading branch information
octobocto committed Nov 23, 2023
1 parent 39cbc70 commit eb07f23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/no/bb/deskriptor/service/Service.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.bitcoindevkit.*
class Service(private val network: Network) : DeskriptorServiceGrpcKt.DeskriptorServiceCoroutineImplBase() {
private fun innerDerive(scriptType: ScriptType, input: String, index: Int): Pair<AddressInfo, String> {
var descriptor = "${Script(scriptType)}($input/$index)"
if (scriptType == ScriptType.SCRIPT_TYPE_WPKH_NESTED) {
if (scriptType == ScriptType.SCRIPT_TYPE_WPKH_NESTED || scriptType == ScriptType.SCRIPT_TYPE_P2TR) {
descriptor += ")"
}

Expand Down Expand Up @@ -95,6 +95,7 @@ data class Script(private val script: ScriptType) {
// operators, and replace this `when` block with something that returns
// a list of operators. For another day.
ScriptType.SCRIPT_TYPE_WPKH_NESTED -> "sh(wpkh"
ScriptType.SCRIPT_TYPE_P2TR -> "sh(p2tr"
ScriptType.SCRIPT_TYPE_UNSPECIFIED -> throw newStatus(Code.INVALID_ARGUMENT, "unspecified")
ScriptType.UNRECOGNIZED -> throw newStatus(Code.INVALID_ARGUMENT, "unrecognized script type: $script")
}
Expand Down
24 changes: 24 additions & 0 deletions src/test/kotlin/no/bb/deskriptor/service/ServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ class ServiceTest : FunSpec({
) { it.assert() }
}

context("bos sparrow wallet") {
withData(
DeriveInput(
SCRIPT_TYPE_P2TR,
0,
"xpub68wbshdUKfMu3LVp329fG7JbZPZsquCb5vNAbYi9LQPUeKQmyQrnsZF8Tachg6wqyue8srM8tVBbHaHJMZuxu8RRXtubaMVZL19nsC7NAts",
"bc1pzzr5kkz5rtxw733tst7yxex8kgy2hanq0jchtt0xvp7cajqz9dkqj4pxev",
),
DeriveInput(
SCRIPT_TYPE_P2TR,
1,
"xpub68wbshdUKfMu3LVp329fG7JbZPZsquCb5vNAbYi9LQPUeKQmyQrnsZF8Tachg6wqyue8srM8tVBbHaHJMZuxu8RRXtubaMVZL19nsC7NAts",
"bc1psxyyfk9e4lykx7ghq4g44hunn75rmh3zvuxc5mud2tuae63yk3gqq2msra",
),
DeriveInput(
SCRIPT_TYPE_P2TR,
2,
"xpub68wbshdUKfMu3LVp329fG7JbZPZsquCb5vNAbYi9LQPUeKQmyQrnsZF8Tachg6wqyue8srM8tVBbHaHJMZuxu8RRXtubaMVZL19nsC7NAts",
"bc1pfmkr97h8dy50srk4p5c9c3fxg8m2uum4mrrfears2c7pt2ljx2xqu4ddwk",
),
) { it.assert() }
}


// generated with https://iancoleman.io/bip39/
context("iancoleman data") {

Expand Down

0 comments on commit eb07f23

Please sign in to comment.