Skip to content

Commit

Permalink
fix sendall receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Jan 18, 2021
1 parent 80519c9 commit cb6c2af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/api/ergo/lib/transactions/utxoTransaction.js
Expand Up @@ -201,7 +201,7 @@ export function sendAllUnsignedTxFromUtxo(request: {|
RustModule.SigmaRust.I64.from_str(request.txFee.toString())
),
RustModule.SigmaRust.Address.from_bytes(
Buffer.from(request.protocolParams.FeeAddress, 'hex')
Buffer.from(request.receiver.address, 'hex')
),
RustModule.SigmaRust.BoxValue.from_i64(
RustModule.SigmaRust.I64.from_str(request.protocolParams.MinimumBoxValue.toString())
Expand Down
27 changes: 26 additions & 1 deletion app/api/ergo/lib/transactions/utxoTransaction.test.js
Expand Up @@ -508,9 +508,10 @@ describe('Create sendAll unsigned TX from UTXO', () => {
it('Create a transaction involving all input with no change', () => {
const sampleUtxos = genSampleUtxos();
const utxos: Array<RemoteUnspentOutput> = [sampleUtxos[1], sampleUtxos[3]];
const receiver = decode('9egNKTzQDH658qcdiPEoQfVM1SBxQNxnyF8BCw57aNWerRhhHBQ').toString('hex');
const sendAllResponse = sendAllUnsignedTxFromUtxo({
receiver: {
address: decode('9egNKTzQDH658qcdiPEoQfVM1SBxQNxnyF8BCw57aNWerRhhHBQ').toString('hex')
address: receiver
},
utxos,
currentHeight: 100,
Expand All @@ -530,13 +531,37 @@ describe('Create sendAll unsigned TX from UTXO', () => {
.value().as_i64()
.to_str()
).toEqual('20950001'); // output
expect(Buffer.from(
unsignedTx
.outputs()
.get(0)
.ergo_tree().to_bytes()
).toString('hex')).toEqual(
Buffer.from(
RustModule.SigmaRust.NetworkAddress.from_bytes(
Buffer.from(receiver, 'hex')
).address().to_ergo_tree().to_bytes()
).toString('hex')
); // output
expect(
unsignedTx
.outputs()
.get(1)
.value().as_i64()
.to_str()
).toEqual('50000'); // fee
expect(Buffer.from(
unsignedTx
.outputs()
.get(1)
.ergo_tree().to_bytes()
).toString('hex')).toEqual(
Buffer.from(
RustModule.SigmaRust.NetworkAddress.from_bytes(
Buffer.from(parameterSubset.FeeAddress, 'hex')
).address().to_ergo_tree().to_bytes()
).toString('hex')
); // fee
// make sure the assets are also sent
expect(
unsignedTx
Expand Down

0 comments on commit cb6c2af

Please sign in to comment.