@ -1629,21 +1629,32 @@ var cnUtil = function(currencyConfig)
var inputs _money = JSBigInt . ZERO ;
var i , j ;
console . log ( 'Sources: ' ) ;
//run the for loop twice to sort ins by key image
//first generate key image and other construction data to sort it all in one go
for ( i = 0 ; i < sources . length ; i ++ ) {
console . log ( i + ': ' + this . formatMoneyFull ( sources [ i ] . amount ) ) ;
if ( sources [ i ] . real _out >= sources [ i ] . outputs . length ) {
throw "real index >= outputs.length" ;
}
inputs _money = inputs _money . add ( sources [ i ] . amount ) ;
var res = this . generate _key _image _helper _rct ( keys , sources [ i ] . real _out _tx _key , sources [ i ] . real _out _in _tx , sources [ i ] . mask ) ; //mask will be undefined for non-rct
in _contexts . push ( res . in _ephemeral ) ;
if ( res . in _ephemeral . pub !== sources [ i ] . outputs [ sources [ i ] . real _out ] . key ) {
throw "in_ephemeral.pub != source.real_out.key" ;
}
sources [ i ] . key _image = res . image ;
sources [ i ] . in _ephemeral = res . in _ephemeral ;
}
//sort ins
sources . sort ( function ( a , b ) {
return JSBigInt . parse ( a . key _image , 16 ) . compare ( JSBigInt . parse ( b . key _image , 16 ) ) < 0
} ) ;
//copy the sorted sources data to tx
for ( i = 0 ; i < sources . length ; i ++ ) {
inputs _money = inputs _money . add ( sources [ i ] . amount ) ;
in _contexts . push ( sources [ i ] . in _ephemeral ) ;
var input _to _key = { } ;
input _to _key . type = "input_to_key" ;
input _to _key . amount = sources [ i ] . amount ;
input _to _key . k _image = res . image ;
input _to _key . k _image = sou rc es[i ] .key_ image;
input _to _key . key _offsets = [ ] ;
for ( j = 0 ; j < sources [ i ] . outputs . length ; ++ j ) {
input _to _key . key _offsets . push ( sources [ i ] . outputs [ j ] . index ) ;