Skip to content
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

Wrappers, helpers, and syntactic sugar on BDK discussion #265

Closed
thunderbiscuit opened this issue Nov 29, 2022 · 2 comments
Closed

Wrappers, helpers, and syntactic sugar on BDK discussion #265

thunderbiscuit opened this issue Nov 29, 2022 · 2 comments

Comments

@thunderbiscuit
Copy link
Member

No description provided.

@thunderbiscuit
Copy link
Member Author

thunderbiscuit commented Dec 14, 2022

To move the discussion forward on this, I have started a "sugar" library that would work on bdk-android and bdk-jvm. The repo is here.

At the moment it does 2 things but I'd love to add more.

  1. Adding a .sat and .btc values on the common Int, Long, Float, Double units to provide simple checks for values and allow to express them in either satoshis or bitcoin, while inlining the actual ULong value.
  2. Adding an infix function called before that allows comparison between two transactions and returns a boolean.

Examples:

// example 1
TxBuilder()
    .addRecipient(Address(faucetAddress).scriptPubkey(), 1000.sat)
    .feeRate(1.2f)
    .finish(wallet)

TxBuilder()
    .addRecipient(Address(faucetAddress).scriptPubkey(), 0.004.btc)
    .feeRate(1.2f)
    .finish(wallet)

// example 2
val txList = wallet.listTransactions()
val tx1: TransactionDetails = txList[0]
val tx2: TransactionDetails = txList[1]

if (tx1 before tx2) {
    println("tx1 is older than tx2")
}

@thunderbiscuit
Copy link
Member Author

Closing this issue to combine the discussion with #266.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant