Skip to content

Commit 405a5f6

Browse files
chore(utxo-lib): changed deprecated comments and param type
TICKET: BTC-2183
1 parent 4502d21 commit 405a5f6

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

modules/utxo-lib/src/bitgo/ProprietaryKeyValUtils.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { KeyValue } from 'bip174/src/lib/interfaces';
1+
import { PsbtInput, PsbtOutput } from 'bip174/src/lib/interfaces';
22
import { decodeProprietaryKey, encodeProprietaryKey, ProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal';
33
import { UtxoPsbt } from './UtxoPsbt';
44

@@ -22,12 +22,8 @@ export interface ProprietaryKeyValue {
2222
value: Buffer;
2323
}
2424

25-
export interface WithUnknownKeyValues {
26-
unknownKeyVals?: KeyValue[];
27-
}
28-
2925
export function getProprietaryKeyValuesFromUnknownKeyValues(
30-
psbtField: WithUnknownKeyValues,
26+
psbtField: PsbtInput | PsbtOutput,
3127
keySearch?: ProprietaryKeySearch
3228
): ProprietaryKeyValue[] {
3329
if (!psbtField.unknownKeyVals?.length) {
@@ -52,7 +48,7 @@ export function getProprietaryKeyValuesFromUnknownKeyValues(
5248
}
5349

5450
export function deleteProprietaryKeyValuesFromUnknownKeyValues(
55-
psbtField: WithUnknownKeyValues,
51+
psbtField: PsbtInput | PsbtOutput,
5652
keysToDelete?: ProprietaryKeySearch
5753
): void {
5854
if (!psbtField.unknownKeyVals?.length) {
@@ -74,9 +70,9 @@ export function deleteProprietaryKeyValuesFromUnknownKeyValues(
7470
});
7571
}
7672

77-
export function updateProprietaryKeyValuesToUnknownKeyValues(
73+
export function updateProprietaryKeyValuesFromUnknownKeyValues(
7874
keyValueData: ProprietaryKeyValue,
79-
psbtField: WithUnknownKeyValues
75+
psbtField: PsbtInput | PsbtOutput
8076
): void {
8177
if (!psbtField.unknownKeyVals?.length) {
8278
return;
@@ -91,7 +87,7 @@ export function updateProprietaryKeyValuesToUnknownKeyValues(
9187
psbtField.unknownKeyVals[ukvIndex] = { key, value };
9288
}
9389

94-
export function addProprietaryKeyValuesToUnknownKeyValues(
90+
export function addProprietaryKeyValuesFromUnknownKeyValues(
9591
psbt: UtxoPsbt,
9692
entry: string,
9793
index: number,

modules/utxo-lib/src/bitgo/UtxoPsbt.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ export class UtxoPsbt<Tx extends UtxoTransaction<bigint> = UtxoTransaction<bigin
10751075
}
10761076

10771077
/**
1078-
* @deprecated Please use the new method addProprietaryKeyVals(type, index, keyValueData)
1078+
* @deprecated Please use the new method addProprietaryKeyVals(psbt, entry, index, keyValueData)
10791079
*
10801080
* Adds proprietary key value pair to PSBT input.
10811081
* Default identifierEncoding is utf-8 for identifier.
@@ -1088,7 +1088,8 @@ export class UtxoPsbt<Tx extends UtxoTransaction<bigint> = UtxoTransaction<bigin
10881088
}
10891089

10901090
/**
1091-
* @deprecated Please use the new method addOrUpdateProprietaryKeyVal(type, index, keyValueData)
1091+
* @deprecated Please use the new method addProprietaryKeyValuesToUnknownKeyValues(psbt, entry, index, keyValueData)
1092+
* or updateProprietaryKeyValuesToUnknownKeyValues(keyValueData)
10921093
*
10931094
* Adds or updates (if exists) proprietary key value pair to PSBT input.
10941095
* Default identifierEncoding is utf-8 for identifier.
@@ -1112,7 +1113,7 @@ export class UtxoPsbt<Tx extends UtxoTransaction<bigint> = UtxoTransaction<bigin
11121113
}
11131114

11141115
/**
1115-
* @deprecated Please use getProprietaryKeyValues(type, index, keySearch). The new method
1116+
* @deprecated Please use getProprietaryKeyValuesFromUnknownKeyValues(psbtField, keySearch). The new method
11161117
* allows for the retrieval of either input or output proprietary key values.
11171118
*
11181119
* To search any data from proprietary key value against keydata in the inputs.

modules/utxo-lib/test/bitgo/psbt/ProprietaryKeyVals.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { bip32, BIP32Interface, networks, testutil } from '../../../src';
44
import { RootWalletKeys, PSBT_PROPRIETARY_IDENTIFIER } from '../../../src/bitgo';
55
import { checkForInput, checkForOutput } from 'bip174/src/lib/utils';
66
import {
7-
addProprietaryKeyValuesToUnknownKeyValues,
7+
addProprietaryKeyValuesFromUnknownKeyValues,
88
deleteProprietaryKeyValuesFromUnknownKeyValues,
99
getProprietaryKeyValuesFromUnknownKeyValues,
10-
updateProprietaryKeyValuesToUnknownKeyValues,
10+
updateProprietaryKeyValuesFromUnknownKeyValues,
1111
} from '../../../src/bitgo/ProprietaryKeyValUtils';
1212

1313
const network = networks.bitcoin;
@@ -36,7 +36,7 @@ describe('Proprietary key value helper functions', () => {
3636
keydata: dummyTapOutputKey,
3737
};
3838
const input = checkForInput(psbt.data.inputs, 0);
39-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
39+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
4040
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(input);
4141
assert.strictEqual(keyVal[0].key.identifier, 'DUMMY');
4242
});
@@ -49,7 +49,7 @@ describe('Proprietary key value helper functions', () => {
4949
keydata: dummyTapOutputKey,
5050
};
5151
const output = checkForOutput(psbt.data.outputs, 0);
52-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
52+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
5353
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(output);
5454
assert.strictEqual(keyVal[0].key.identifier, 'DUMMY');
5555
});
@@ -62,8 +62,8 @@ describe('Proprietary key value helper functions', () => {
6262
keydata: dummyTapOutputKey,
6363
};
6464
const input = checkForInput(psbt.data.inputs, 0);
65-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
66-
updateProprietaryKeyValuesToUnknownKeyValues({ key, value: invalidTapOutputKey }, input);
65+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
66+
updateProprietaryKeyValuesFromUnknownKeyValues({ key, value: invalidTapOutputKey }, input);
6767
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(input);
6868
assert.strictEqual(keyVal[0].value, invalidTapOutputKey);
6969
});
@@ -76,8 +76,8 @@ describe('Proprietary key value helper functions', () => {
7676
keydata: dummyTapOutputKey,
7777
};
7878
const output = checkForOutput(psbt.data.outputs, 0);
79-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
80-
updateProprietaryKeyValuesToUnknownKeyValues({ key, value: invalidTapOutputKey }, output);
79+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
80+
updateProprietaryKeyValuesFromUnknownKeyValues({ key, value: invalidTapOutputKey }, output);
8181
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(output);
8282
assert.strictEqual(keyVal[0].value, invalidTapOutputKey);
8383
});
@@ -90,7 +90,7 @@ describe('Proprietary key value helper functions', () => {
9090
keydata: dummyTapOutputKey,
9191
};
9292
const input = checkForInput(psbt.data.inputs, 0);
93-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
93+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'input', 0, { key, value: dummyTapInternalKey });
9494
deleteProprietaryKeyValuesFromUnknownKeyValues(input, { identifier: PSBT_PROPRIETARY_IDENTIFIER });
9595
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(input);
9696
assert.strictEqual(keyVal[0].key.identifier, 'DUMMY');
@@ -109,8 +109,8 @@ describe('Proprietary key value helper functions', () => {
109109
keydata: dummyTapOutputKey,
110110
};
111111
const output = checkForOutput(psbt.data.outputs, 0);
112-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
113-
addProprietaryKeyValuesToUnknownKeyValues(psbt, 'output', 0, { key: key2, value: dummyTapInternalKey });
112+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'output', 0, { key, value: dummyTapInternalKey });
113+
addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'output', 0, { key: key2, value: dummyTapInternalKey });
114114
deleteProprietaryKeyValuesFromUnknownKeyValues(output, { identifier: 'DUMMY' });
115115
const keyVal = getProprietaryKeyValuesFromUnknownKeyValues(output);
116116
assert.strictEqual(keyVal[0].key.identifier, 'OTHER_DUMMY');

0 commit comments

Comments
 (0)