Skip to content

Commit

Permalink
Return redeem scripts and do not require option args
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Jul 5, 2023
1 parent 9ee90f4 commit 24178c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 12 additions & 2 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,12 @@ func (w *ETHWallet) FundMultiOrder(ord *asset.MultiOrder, maxLock uint64) ([]ass
return nil, nil, 0, err
}

return allCoins, nil, 0, nil
redeemScripts := make([][]dex.Bytes, len(ord.Values))
for i := range redeemScripts {
redeemScripts[i] = []dex.Bytes{nil}
}

return allCoins, redeemScripts, 0, nil
}

// FundMultiOrder funds multiple orders in one shot. No special handling is
Expand Down Expand Up @@ -1561,8 +1566,13 @@ func (w *TokenWallet) FundMultiOrder(ord *asset.MultiOrder, maxLock uint64) ([]a
return nil, nil, 0, err
}

redeemScripts := make([][]dex.Bytes, len(ord.Values))
for i := range redeemScripts {
redeemScripts[i] = []dex.Bytes{nil}
}

success = true
return allCoins, nil, 0, nil
return allCoins, redeemScripts, 0, nil
}

// gasEstimates are estimates of gas required for operations involving a swap
Expand Down
5 changes: 4 additions & 1 deletion client/asset/eth/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ func testFundMultiOrder(t *testing.T, assetID uint32) {
eth.lockedFunds.initiateReserves = 0
eth.baseWallet.wallets[BipID].lockedFunds.initiateReserves = 0

allCoins, _, _, err := multiFunder.FundMultiOrder(test.multiOrder, test.maxLock)
allCoins, redeemScripts, _, err := multiFunder.FundMultiOrder(test.multiOrder, test.maxLock)
if test.expectErr {
if err == nil {
t.Fatalf("%s: expected error but did not get one", test.name)
Expand All @@ -1705,6 +1705,9 @@ func testFundMultiOrder(t *testing.T, assetID uint32) {
if len(allCoins) != len(test.multiOrder.Values) {
t.Fatalf("%s: expected %d coins but got %d", test.name, len(test.multiOrder.Values), len(allCoins))
}
if len(redeemScripts) != len(test.multiOrder.Values) {
t.Fatalf("%s: expected %d redeem scripts but got %d", test.name, len(test.multiOrder.Values), len(redeemScripts))
}
for i, coins := range allCoins {
if len(coins) != 1 {
t.Fatalf("%s: expected 1 coin but got %d", test.name, len(coins))
Expand Down
11 changes: 7 additions & 4 deletions client/rpcserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func parseTradeArgs(params *RawParams) (*tradeForm, error) {
}

func parseMultiTradeArgs(params *RawParams) (*multiTradeForm, error) {
if err := checkNArgs(params, []int{1}, []int{7}); err != nil {
if err := checkNArgs(params, []int{1}, []int{6, 7}); err != nil {
return nil, err
}

Expand Down Expand Up @@ -621,9 +621,12 @@ func parseMultiTradeArgs(params *RawParams) (*multiTradeForm, error) {
})
}

options, err := checkMapArg(params.Args[6], "options")
if err != nil {
return nil, err
options := make(map[string]string)
if len(params.Args) == 7 {
options, err = checkMapArg(params.Args[6], "options")
if err != nil {
return nil, err
}
}

return &multiTradeForm{
Expand Down

0 comments on commit 24178c7

Please sign in to comment.