-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add alby support to send bulk #67
feat: add alby support to send bulk #67
Conversation
86b40ee
to
1395328
Compare
0e58fa3
to
eb89e35
Compare
a711010
to
e1fd335
Compare
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.
Lookin good! Just want to be able to see the txn before signing
So we show estimated fee first, user hits confirm, then signs stuff, then views the final tx before hitting "send"?
.filter((x) => x.status.confirmed) | ||
.filter((x) => x.value > 10000) | ||
.filter(utxo => !utxo.inscriptionId) | ||
.sort((a, b) => b.value - a.value); |
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.
nit: maybe actually better to do smallest to largest
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.
ignore this, nevermind. You are trying to use the largest spendable UTXO as a cardinal if you need to add one
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.
we should select and use the largest first
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.
Yeah, it uses the biggest first.
e1fd335
to
f5f3f14
Compare
78f8255
to
5d32717
Compare
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.
Amazingggg
@@ -331,6 +338,183 @@ const Psbt = function (config) { | |||
return psbtModule.broadcastPsbt(psbt); | |||
}, | |||
|
|||
preparePsbtForMultipleSend: async ({ |
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.
nit: maybe add comment to describe general flow:
preparePsbtForMultipleSend allows safe bulk UTXO transfers, with appropriate fees.
1. Any input UTXOs with an inscription will be created as a distinct output UTXO of the same size, and appear before any non-inscription UTXOs in the resultant PSBT
2. Any input UTXOs without an inscription will have their amounts consolidated into a single output UTXO
3. A check is run to ensure that enough cardinal funds are available to perform the transfer. If step 2 does not contain enough cardinal funds, cardinal funds will be appended to the PSBT, and another change output will be created
throw new Error('Signing not supported.'); | ||
} | ||
|
||
const cardinalUtxos = ownedUtxos.filter(utxo => !selectedUtxos.some(ownedUtxo => ownedUtxo.txid === utxo.txid)) |
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.
nit: maybe add comment
// only used if selectedCardinalAmount is not large enough to cover fees
} | ||
inputs.push(utxo); | ||
totalCardinalAmount += utxo.value; | ||
isCardinalAdded = true; |
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.
love it
address, | ||
value: changeAmount, | ||
}); | ||
metadata.outputs.push({ type: 'Change' }); |
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.
excellent
a6a1347
to
463167e
Compare
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.
nice optimization
No description provided.