@@ -30,7 +30,7 @@ import {
30
30
import { BaseCoin as CoinConfig } from '@bitgo/statics' ;
31
31
import { Buffer as BufferAvax } from 'avalanche' ;
32
32
import BigNumber from 'bignumber.js' ;
33
- import { DecodedUtxoObj , SECP256K1_Transfer_Output , Tx } from './iface' ;
33
+ import { DecodedUtxoObj , SECP256K1_STAKEABLE_LOCK_OUT , SECP256K1_Transfer_Output , Tx } from './iface' ;
34
34
import { KeyPair } from './keyPair' ;
35
35
import { Transaction } from './transaction' ;
36
36
import { TransactionBuilder } from './transactionBuilder' ;
@@ -291,9 +291,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
291
291
this . transaction . _stakeAmount = permissionlessValidatorTx . stake [ 0 ] . output . amount ( ) ;
292
292
this . stakeAmount ( this . transaction . _stakeAmount ) ;
293
293
this . transaction . _utxos = recoverUtxos ( permissionlessValidatorTx . getInputs ( ) ) ;
294
- // TODO(CR-1073): remove log
295
- console . log ( 'utxos: ' , this . transaction . _utxos ) ;
296
- console . log ( 'fromAddresses: ' , this . transaction . fromAddresses ) ;
297
294
return this ;
298
295
}
299
296
@@ -338,8 +335,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
338
335
const bitgoAddresses = this . transaction . _fromAddresses . map ( ( b ) =>
339
336
avaxUtils . format ( this . transaction . _network . alias , this . transaction . _network . hrp , b )
340
337
) ;
341
- // TODO(CR-1073): remove log
342
- console . log ( `bitgoAddress: ${ bitgoAddresses } ` ) ;
343
338
344
339
// if we are in OVC, none of the utxos will have addresses since they come from
345
340
// deserialized inputs (which don't have addresses), not the IMS
@@ -371,12 +366,12 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
371
366
utxo . addresses . forEach ( ( a ) => {
372
367
bitgoIndexToOnChainIndex . set ( bitgoAddresses . indexOf ( a ) , utxo . addresses . indexOf ( a ) ) ;
373
368
} ) ;
374
- // TODO(CR-1073): remove log
375
- console . log ( `utxo.addresses: ${ utxo . addresses } ` ) ;
376
- console . log ( `bitgoIndexToOnChainIndex: ${ Array . from ( bitgoIndexToOnChainIndex ) } ` ) ;
377
369
// in OVC, output.addressesIndex is defined correctly from the previous iteration
378
370
379
- if ( utxo . outputID === SECP256K1_Transfer_Output ) {
371
+ if (
372
+ utxo . outputID === SECP256K1_Transfer_Output ||
373
+ ( utxo . outputID === SECP256K1_STAKEABLE_LOCK_OUT && utxo . locktime === '0' )
374
+ ) {
380
375
const utxoAmount = BigInt ( utxo . amount ) ;
381
376
// either user (0) or recovery (2)
382
377
// On regular mode: [user, bitgo] (i.e. [0, 1])
@@ -400,8 +395,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
400
395
new BigIntPr ( utxoAmount ) ,
401
396
new Input ( [ ...addressesIndex ] . sort ( ) . map ( ( num ) => new Int ( num ) ) )
402
397
) ;
403
- // TODO(CR-1073): remove log
404
- console . log ( `using addressesIndex sorted: ${ [ ...addressesIndex ] . sort ( ) } ` ) ;
405
398
406
399
const input = new avaxSerial . TransferableInput ( utxoId , assetId , transferInputs ) ;
407
400
utxos . push ( new Utxo ( utxoId , assetId , transferInputs ) ) ;
@@ -413,12 +406,7 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
413
406
// For the user/backup signature we store the address that matches the key
414
407
// if bitgo address comes before < user/backup address
415
408
416
- // TODO(CR-1073): remove log
417
- console . log ( `bitgo index on chain: ${ utxo . addressesIndex [ bitgoIndex ] } ` ) ;
418
- console . log ( `user Or Backup Index: ${ utxo . addressesIndex [ userOrBackupIndex ] } ` ) ;
419
409
if ( utxo . addressesIndex [ bitgoIndex ] < utxo . addressesIndex [ userOrBackupIndex ] ) {
420
- // TODO(CR-1073): remove log
421
- console . log ( `user or backup credentials after bitgo` ) ;
422
410
credentials . push (
423
411
new Credential ( [
424
412
utils . createNewSig ( BufferAvax . from ( '' ) . toString ( 'hex' ) ) ,
@@ -428,8 +416,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
428
416
] )
429
417
) ;
430
418
} else {
431
- // TODO(CR-1073): remove log
432
- console . log ( `user or backup credentials before bitgo` ) ;
433
419
credentials . push (
434
420
new Credential ( [
435
421
utils . createNewSig (
@@ -440,7 +426,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
440
426
) ;
441
427
}
442
428
} else {
443
- // TODO(CR-1073): verify this else case for OVC
444
429
credentials . push (
445
430
new Credential (
446
431
addressesIndex . map ( ( i ) =>
@@ -449,9 +434,6 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
449
434
)
450
435
) ;
451
436
}
452
- } else {
453
- // TODO(CR-1073): remove log
454
- console . log ( `reusing credentials from transaction` ) ;
455
437
}
456
438
}
457
439
} ) ;
@@ -542,9 +524,8 @@ export class PermissionlessValidatorTxBuilder extends TransactionBuilder {
542
524
. map ( ( a ) => Address . fromBytes ( a ) [ 0 ] )
543
525
) ;
544
526
545
- // TODO(CR-1073): check this value
546
- // Shares 10,000 times percentage of reward taken from delegators
547
- // https://docs.avax.network/reference/avalanchego/p-chain/txn-format#unsigned-add-validator-tx
527
+ // Shares 10,000 times percentage of reward taken from delegators
528
+ // https://docs.avax.network/reference/avalanchego/p-chain/txn-format#unsigned-add-validator-tx
548
529
const shares = new Int ( 1e4 * 2 ) ;
549
530
550
531
const addressMaps = [ ...this . transaction . _fromAddresses ]
0 commit comments