Amount: 10,
ControlProgram: MustCreateP2WMCProgram(ETH, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251"), 50, 1),
},
+ BlockHeight: 100,
+ TxIndex: 1,
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251"),
},
{
FromAssetID: &BTC,
Amount: 20,
ControlProgram: MustCreateP2WMCProgram(ETH, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"), 53, 1),
},
+ BlockHeight: 100,
+ TxIndex: 2,
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"),
},
{
FromAssetID: &BTC,
Amount: 15,
ControlProgram: MustCreateP2WMCProgram(ETH, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"), 53, 1),
},
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"),
},
{
FromAssetID: &BTC,
Amount: 17,
ControlProgram: MustCreateP2WMCProgram(ETH, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"), 53, 1),
},
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19252"),
},
}
Amount: 510,
ControlProgram: MustCreateP2WMCProgram(BTC, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19253"), 1, 51.0),
},
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19253"),
},
{
FromAssetID: Ð,
Amount: 416,
ControlProgram: MustCreateP2WMCProgram(BTC, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19254"), 1, 52.0),
},
+ BlockHeight: 100,
+ TxIndex: 2,
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19254"),
},
{
FromAssetID: Ð,
Amount: 810,
ControlProgram: MustCreateP2WMCProgram(BTC, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255"), 1, 54.0),
},
+ BlockHeight: 101,
+ TxIndex: 1,
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255"),
},
{
FromAssetID: Ð,
Amount: 600,
ControlProgram: MustCreateP2WMCProgram(BTC, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256"), 1, 150.0),
},
+ BlockHeight: 101,
+ TxIndex: 3,
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256"),
},
}
Amount: 100,
ControlProgram: MustCreateP2WMCProgram(ETC, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255"), 1, 2.0),
},
+ SellerProgram: testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255"),
},
}
Amount: 50,
ControlProgram: MustCreateP2WMCProgram(EOS, testutil.MustDecodeHexString("0014df7a97e53bbe278e4e44810b0a760fb472daa9a3"), 2, 1.0),
},
+ SellerProgram: testutil.MustDecodeHexString("0014df7a97e53bbe278e4e44810b0a760fb472daa9a3"),
},
}
Amount: 500,
ControlProgram: MustCreateP2WMCProgram(EOS, testutil.MustDecodeHexString("0014e3178c0f294a9a8f4b304236406507913091df86"), 2, 1.0),
},
+ SellerProgram: testutil.MustDecodeHexString("0014e3178c0f294a9a8f4b304236406507913091df86"),
},
}
Amount: 1000,
ControlProgram: MustCreateP2WMCProgram(BTC, testutil.MustDecodeHexString("00144d0dfc8a0c5ce41d31d4f61d99aff70588bff8bc"), 1, 100.0),
},
+ SellerProgram: testutil.MustDecodeHexString("00144d0dfc8a0c5ce41d31d4f61d99aff70588bff8bc"),
},
}
// partial matched transaction from Btc2EthOrders[0], Eth2BtcOrders[1]
types.NewTx(types.TxData{
Inputs: []*types.TxInput{
+ // maker
types.NewSpendInput([][]byte{vm.Int64Bytes(416), vm.Int64Bytes(0), vm.Int64Bytes(0)}, *Btc2EthOrders[0].Utxo.SourceID, *Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, Btc2EthOrders[0].Utxo.SourcePos, Btc2EthOrders[0].Utxo.ControlProgram),
+ // taker
types.NewSpendInput([][]byte{vm.Int64Bytes(2), vm.Int64Bytes(1)}, *Eth2BtcOrders[1].Utxo.SourceID, *Eth2BtcOrders[1].FromAssetID, Eth2BtcOrders[1].Utxo.Amount, Eth2BtcOrders[1].Utxo.SourcePos, Eth2BtcOrders[1].Utxo.ControlProgram),
},
Outputs: []*types.TxOutput{
types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 499, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
types.NewIntraChainOutput(*Eth2BtcOrders[0].ToAssetID, 9, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19253")),
// fee
- types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 11, RewardProgram),
+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 2, RewardProgram),
types.NewIntraChainOutput(*Eth2BtcOrders[0].ToAssetID, 1, RewardProgram),
+ // refund to taker
+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 9, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
},
}),
// partial matched transaction from Btc2EthOrders[0], Eth2BtcOrders[2]
types.NewTx(types.TxData{
Inputs: []*types.TxInput{
+ // maker
types.NewSpendInput([][]byte{vm.Int64Bytes(0), vm.Int64Bytes(1)}, *Btc2EthOrders[0].Utxo.SourceID, *Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, Btc2EthOrders[0].Utxo.SourcePos, Btc2EthOrders[0].Utxo.ControlProgram),
+ // taker
types.NewSpendInput([][]byte{vm.Int64Bytes(10), vm.Int64Bytes(1), vm.Int64Bytes(0)}, *Eth2BtcOrders[2].Utxo.SourceID, *Eth2BtcOrders[2].FromAssetID, Eth2BtcOrders[2].Utxo.Amount, Eth2BtcOrders[2].Utxo.SourcePos, Eth2BtcOrders[2].Utxo.ControlProgram),
},
Outputs: []*types.TxOutput{
// re-order
types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, 270, Eth2BtcOrders[2].Utxo.ControlProgram),
// fee
- types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, 25, RewardProgram),
+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 1, RewardProgram),
types.NewIntraChainOutput(*Btc2EthOrders[0].FromAssetID, 1, RewardProgram),
- // refund
- types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, 8, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
- types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, 8, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255")),
+ // re-order
+ types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, 40, Eth2BtcOrders[2].SellerProgram),
},
}),
types.NewTx(types.TxData{
Inputs: []*types.TxInput{
+ // maker
types.NewSpendInput([][]byte{vm.Int64Bytes(0), vm.Int64Bytes(0)}, *Btc2EthOrders[1].Utxo.SourceID, *Btc2EthOrders[1].FromAssetID, Btc2EthOrders[1].Utxo.Amount, Btc2EthOrders[1].Utxo.SourcePos, Btc2EthOrders[1].Utxo.ControlProgram),
+ // taker
types.NewSpendInput([][]byte{vm.Int64Bytes(2), vm.Int64Bytes(1)}, testutil.MustDecodeHash("39bdb7058a0c31fb740af8e3c382bf608efff1b041cd4dd461332722ad24552a"), *Eth2BtcOrders[2].FromAssetID, 270, 2, Eth2BtcOrders[2].Utxo.ControlProgram),
},
Outputs: []*types.TxOutput{
types.NewSpendInput([][]byte{vm.Int64Bytes(2), vm.Int64Bytes(1)}, *Eos2BtcOrders[0].Utxo.SourceID, *Eos2BtcOrders[0].FromAssetID, Eos2BtcOrders[0].Utxo.Amount, Eos2BtcOrders[0].Utxo.SourcePos, Eos2BtcOrders[0].Utxo.ControlProgram),
},
Outputs: []*types.TxOutput{
- types.NewIntraChainOutput(ETH, 499, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
- types.NewIntraChainOutput(EOS, 999, testutil.MustDecodeHexString("0014e3178c0f294a9a8f4b304236406507913091df86")),
- types.NewIntraChainOutput(BTC, 9, testutil.MustDecodeHexString("00144d0dfc8a0c5ce41d31d4f61d99aff70588bff8bc")),
+ types.NewIntraChainOutput(ETH, 499, Btc2EthOrders[0].SellerProgram),
+ types.NewIntraChainOutput(EOS, 999, Eth2EosOrders[0].SellerProgram),
+ types.NewIntraChainOutput(BTC, 9, Eos2BtcOrders[0].SellerProgram),
// fee
types.NewIntraChainOutput(ETH, 1, RewardProgram),
types.NewIntraChainOutput(EOS, 1, RewardProgram),
// full matched transaction from Btc2EthOrders[0] Eth2BtcOrders[3]
types.NewTx(types.TxData{
Inputs: []*types.TxInput{
+ // maker
types.NewSpendInput([][]byte{vm.Int64Bytes(0), vm.Int64Bytes(1)}, *Btc2EthOrders[0].Utxo.SourceID, *Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, Btc2EthOrders[0].Utxo.SourcePos, Btc2EthOrders[0].Utxo.ControlProgram),
+ // taker
types.NewSpendInput([][]byte{vm.Int64Bytes(1), vm.Int64Bytes(1)}, *Eth2BtcOrders[3].Utxo.SourceID, *Eth2BtcOrders[3].FromAssetID, Eth2BtcOrders[3].Utxo.Amount, Eth2BtcOrders[3].Utxo.SourcePos, Eth2BtcOrders[3].Utxo.ControlProgram),
},
Outputs: []*types.TxOutput{
types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 499, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 3, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256")),
// fee
- types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 25, RewardProgram),
- types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 1, RewardProgram),
+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 1, RewardProgram),
+ types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 2, RewardProgram),
// refund
- types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 3, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
- types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 3, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256")),
- types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 38, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
- types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 38, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256")),
+ types.NewIntraChainOutput(*Eth2BtcOrders[3].ToAssetID, 5, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256")),
+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 100, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19256")),
},
}),
}
)
func MustCreateP2WMCProgram(requestAsset bc.AssetID, sellerProgram []byte, ratioNumerator, ratioDenominator int64) []byte {
- contractArgs := vmutil.MagneticContractArgs{
+ contractArgs := createContractArgs(requestAsset, sellerProgram, ratioNumerator, ratioDenominator)
+ program, err := vmutil.P2WMCProgram(*contractArgs)
+ if err != nil {
+ panic(err)
+ }
+ return program
+}
+
+func createContractArgs(requestAsset bc.AssetID, sellerProgram []byte, ratioNumerator, ratioDenominator int64) *vmutil.MagneticContractArgs {
+ return &vmutil.MagneticContractArgs{
RequestedAsset: requestAsset,
RatioNumerator: ratioNumerator,
RatioDenominator: ratioDenominator,
SellerProgram: sellerProgram,
SellerKey: testutil.MustDecodeHexString("ad79ec6bd3a6d6dbe4d0ee902afc99a12b9702fb63edce5f651db3081d868b75"),
}
- program, err := vmutil.P2WMCProgram(contractArgs)
- if err != nil {
- panic(err)
- }
- return program
}
-func MustNewOrderFromOutput(tx *types.Tx, outputIndex int) *common.Order {
- order, err := common.NewOrderFromOutput(tx, outputIndex)
+func MustNewOrderFromOutputV2(tx *types.Tx, outputIndex int, blockHeight, txIndex uint64) *common.Order {
+ order, err := common.NewOrderFromOutput(tx, outputIndex, blockHeight, txIndex)
if err != nil {
panic(err)
}
return order
}
+func MustNewOrderFromOutput(tx *types.Tx, outputIndex int) *common.Order {
+ return MustNewOrderFromOutputV2(tx, outputIndex, 0, 0)
+}
+
func hashPtr(hash bc.Hash) *bc.Hash {
return &hash
}