-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
val xpub = DeterministicWallet.ExtendedPublicKey.decode(
"xpub6CEAyB6zF8bLzi1tNqg4zEfWSBBXtieA4hm3EstWsgSJCgMQS1UrfAFAZHYH1o7tfgFuNWzJhsDHg1EhoF4G5gzXUpQNkt1RzSTyFeAUv4S"
).second
println(xpub)
// สร้างธุรกรรม
val unsignedTx = Transaction(
version = 2,
txIn = listOf(
TxIn(
OutPoint(
TxId("c95039b1ce6152a20ecab1759e924c15e25f4d980673bd64c07a43d2fb501acb"),
0
),
signatureScript = listOf(),
sequence = 0xfdffffff
)
),
txOut = listOf(
TxOut(
12_000.toSatoshi(),
ByteVector("0014d85c2b71d0060b09c9886aeb815e50991dda124d")
)
),
lockTime = 1423787
)
val psbt = Psbt(unsignedTx)
// ดึงข้อมูล public key, fingerprint, และ key path จาก xpub
val publicKey = xpub.publicKey
val fingerprint = xpub.parent
val keyPath = xpub.path
// สร้าง mapping ของ public key และ key path
val pubkeyData = mapOf(
publicKey to KeyPathWithMaster(fingerprint, keyPath)
)
// ระบุ redeem script
val redeemScript = listOf(
)
// อัปเดต PSBT : https://github.com/ACINQ/bitcoin-kmp/blob/master/src%2FcommonMain%2Fkotlin%2Ffr%2Facinq%2Fbitcoin%2Fpsbt%2FPsbt.kt#L172-L172
val firstPSBT = psbt.updateNonWitnessInput(
inputTx = unsignedTx,
outputIndex = 0,
redeemScript = redeemScript,
sighashType = 1,
derivationPaths = pubkeyData
)Metadata
Metadata
Assignees
Labels
No labels