1+ import { Output } from '@bitgo/utxo-core' ;
12import { Descriptor } from '@bitgo/wasm-miniscript' ;
23
34import { createCoreDaoOpReturnOutputScript , OpReturnParams } from './opReturn' ;
45
6+ type StakingParams = {
7+ amount : bigint ;
8+ descriptor : Descriptor ;
9+ index ?: number ;
10+ } ;
11+
512/**
613 * Create the staking outputs for a CoreDAO staking transaction. This is the ordering
714 * in which to add into the transaction.
@@ -10,14 +17,10 @@ import { createCoreDaoOpReturnOutputScript, OpReturnParams } from './opReturn';
1017 * If stakingParams.index is provided, then this is assumed to be a `derivable` descriptor.
1118 * @param opReturnParams to create the OP_RETURN output
1219 */
13- export function createStakingOutputs (
14- stakingParams : {
15- amount : bigint ;
16- descriptor : Descriptor ;
17- index ?: number ;
18- } ,
20+ export function createStakingOutputsCore (
21+ stakingParams : StakingParams ,
1922 opReturnParams : OpReturnParams
20- ) : { script : Buffer ; amount : bigint } [ ] {
23+ ) : Output < bigint > [ ] {
2124 if ( stakingParams . descriptor . hasWildcard ( ) && stakingParams . index === undefined ) {
2225 throw new Error ( 'Cannot create staking outputs with a wildcard descriptor and no derivation index' ) ;
2326 }
@@ -30,7 +33,20 @@ export function createStakingOutputs(
3033 const opReturnScript = createCoreDaoOpReturnOutputScript ( opReturnParams ) ;
3134
3235 return [
33- { script : outputScript , amount : stakingParams . amount } ,
34- { script : opReturnScript , amount : BigInt ( 0 ) } ,
36+ { script : outputScript , value : stakingParams . amount } ,
37+ { script : opReturnScript , value : BigInt ( 0 ) } ,
3538 ] ;
3639}
40+
41+ type LegacyOutput = {
42+ script : Buffer ;
43+ amount : bigint ;
44+ } ;
45+
46+ /**
47+ * @see createStakingOutputsCore
48+ * @deprecated - use createStakingOutputsCore instead
49+ */
50+ export function createStakingOutputs ( stakingParams : StakingParams , opReturnParams : OpReturnParams ) : LegacyOutput [ ] {
51+ return createStakingOutputsCore ( stakingParams , opReturnParams ) . map ( ( { value, ...o } ) => ( { ...o , amount : value } ) ) ;
52+ }
0 commit comments