-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose more of the Transaction type #307
Merged
notmandatory
merged 17 commits into
bitcoindevkit:master
from
thunderbiscuit:feat/transaction-methods
Mar 23, 2023
Merged
Expose more of the Transaction type #307
notmandatory
merged 17 commits into
bitcoindevkit:master
from
thunderbiscuit:feat/transaction-methods
Mar 23, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89db3ae
to
150c26e
Compare
I added the new methods. You can test the PR by building bdk-jvm with a custom name and publishing to local maven, and then running the following script: @file:Repository("file:///~/.m2/repository/")
@file:DependsOn("org.bitcoindevkit:bdk-jvm:0.28.0-PR307")
import org.bitcoindevkit.*
val memoryDatabaseConfig = DatabaseConfig.Memory
val blockchainConfig = BlockchainConfig.Electrum(
ElectrumConfig(
"ssl://electrum.blockstream.info:60002",
null,
5u,
null,
100u,
true,
)
)
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET)
val wallet = Wallet(descriptor, null, Network.TESTNET, memoryDatabaseConfig)
val blockchain = Blockchain(blockchainConfig)
wallet.sync(blockchain, null)
val balance = wallet.getBalance()
check(balance.total > 0uL) {
"Wallet balance is 0, please add funds!"
}
@OptIn(ExperimentalUnsignedTypes::class)
val faucetAddress = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"
val (psbt, txDetails) = TxBuilder()
.addRecipient(Address(faucetAddress).scriptPubkey(), 10000u)
.feeRate(2.0f)
.enableRbf()
.finish(wallet)
val tx = psbt.extractTx()
println("Transaction info is:")
println("Coinbase: ${tx.isCoinBase()}")
println("Explicitly signals RBF: ${tx.isExplicitlyRbf()}")
println("Locktime is enabled: ${tx.isLockTimeEnabled()}")
println("Txid: ${tx.txid()}")
println("Weight: ${tx.weight()}")
println("Size: ${tx.size()}")
println("Virtual size: ${tx.vsize()}")
println("Tx version: ${tx.version()}")
println("Tx locktime: ${tx.lockTime()}")
println("Tx inputs: ${tx.inputs()}")
println("Tx outputs: ${tx.outputs()}") |
This PR adds the txid(), is_coin_base(), is_explicitly_rbf(), and is_lock_time_enabled() methods. Fixes bitcoindevkit#303
500c560
to
1199f3f
Compare
1199f3f
to
7557e21
Compare
9dfebbd
to
40263b4
Compare
This was referenced Mar 14, 2023
48f94ca
to
b143b2b
Compare
b143b2b
to
e86909a
Compare
thunderbiscuit
commented
Mar 20, 2023
@notmandatory this is now ready for review. |
65e875e
to
82ad557
Compare
ad43275
to
6c56122
Compare
1063e98
to
cba69e6
Compare
notmandatory
approved these changes
Mar 23, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK cba69e6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We've recently exposed the
Transaction
type, and I think a few methods on it would be useful.This is a draft PR with the first 3:Edit: it's now much more. I think there might be other methods we might want to expose as well. Take a look at the docs to see them all.weight()
,size()
, andvsize()
Other candidates have now been added:
This PR is growing in size but I decided to add all 4 fields on the
Transaction
type. This is useful because it means we can now add thetransaction
field on theTransactionDetails
type (also added in this PR).I still have a few questions regarding all the translation between the ffi and bdk/rust types, some of the traits I had to remove (Eq and PartialEq on the TransactionDetails type) as well as the usage of
Option<Arc<T>>
vsArc<Option<T>>
. Will outline those tomorrow.Closes #303
Closes #187
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: