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

feat(abstract-utxo): add psbt support backup recovery #3755

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

saravanan7mani
Copy link
Contributor

No description provided.

@saravanan7mani saravanan7mani force-pushed the psbtBackupkeyRecovery branch 3 times, most recently from 493a951 to 7cb08ff Compare July 27, 2023 16:01
@saravanan7mani saravanan7mani changed the title wip feat(abstract-utxo): add psbt support backup recovery Jul 27, 2023
Copy link
Contributor

@davidkaplanbitgo davidkaplanbitgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were all of the fixtures changed because you changed the mocking? Was there a reason why that was needed?

@@ -62,16 +55,17 @@ export interface FormattedOfflineVaultTxInfo {
* @param txHex
* @returns {{txHex: *, txInfo: {unspents: *}, feeInfo: {}, coin: void}}
*/
function formatForOfflineVault<TNumber extends number | bigint = number>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you take away TNumber here?

Copy link
Contributor Author

@saravanan7mani saravanan7mani Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per new change, OfflineVaultTxInfo uses valueString to carry large values. value is always number. So no need to for Generics.

Comment on lines +477 to +481
const safeRootWalletKeys = new RootWalletKeys(
rootWalletKeys.triple.map((bip32) => bip32.neutered()) as Triple<BIP32Interface>,
rootWalletKeys.derivationPrefixes
);
const xPubs = safeRootWalletKeys.triple.map(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need RootWalletPublicKeys

@saravanan7mani
Copy link
Contributor Author

were all of the fixtures changed because you changed the mocking? Was there a reason why that was needed?

Primarily what you mentioned (prevTx id change changes txHex) and also few cases returns PSBT hex instread transaction hex, new response fields recoveryAmountString.

Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits mostly

@@ -1,42 +0,0 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could have been a separate commit

export interface OfflineVaultTxInfo<TNumber extends number | bigint = number> {
inputs: WalletUnspent<TNumber>[];
export interface OfflineVaultTxInfo {
inputs: WalletUnspent<number>[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose OfflineVault always takes number? Probably would have been a good separate commit as well.

* Builds a funds recovery transaction without BitGo
* Builds a funds recovery transaction without BitGo.
*
* Returns transaction hex for unsigned sweep transaction, half signed backup recovery transaction with KRS provider (only keyternal),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns transaction hex for unsigned sweep transaction, half signed backup recovery transaction with KRS provider (only keyternal),
* Returns transaction hex in legacy format for unsigned sweep transaction, half signed backup recovery transaction with KRS provider (only keyternal),

@@ -276,6 +283,7 @@ export async function backupKeyRecovery<TNumber extends number | bigint = number

const isKrsRecovery = getIsKrsRecovery(params);
const isUnsignedSweep = getIsUnsignedSweep(params);
const respondWithTx = isUnsignedSweep || !isKrsRecovery || params.krsProvider === 'keyternal';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const respondWithTx = isUnsignedSweep || !isKrsRecovery || params.krsProvider === 'keyternal';
const responseFormat = (isUnsignedSweep || !isKrsRecovery || params.krsProvider === 'keyternal') ? 'legacy' : 'psbt';


// Construct a transaction
txInfo.inputs = unspents;
txInfo.inputs = respondWithTx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
txInfo.inputs = respondWithTx
txInfo.inputs = responseFormat === 'legacy' ?

@@ -203,32 +237,38 @@ function run(

if (params.hasUserSignature && params.hasBackupSignature) {
it('has no placeholder signatures', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('has no placeholder signatures', function () {
it('has no placeholder signatures', function (this: mocha.Context) {

then you can get rid of the @ts-expect-error further down

Comment on lines +477 to +481
const safeRootWalletKeys = new RootWalletKeys(
rootWalletKeys.triple.map((bip32) => bip32.neutered()) as Triple<BIP32Interface>,
rootWalletKeys.derivationPrefixes
);
const xPubs = safeRootWalletKeys.triple.map(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need RootWalletPublicKeys

PSBT is used to build and sign backup recovery and unsigned sweep

Ticket: BTC-317
@saravanan7mani saravanan7mani marked this pull request as ready for review July 31, 2023 08:58
@saravanan7mani saravanan7mani requested review from a team as code owners July 31, 2023 08:58
@saravanan7mani saravanan7mani merged commit e16c18d into master Jul 31, 2023
5 checks passed
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

Successfully merging this pull request may close these issues.

4 participants