• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版e0345b2822a742f6713360ab2b82dc83bdca2aa9 (tree)
时间2020-01-20 16:39:25
作者shenao78 <shenao.78@163....>
Commitershenao78

Log Message

fix_open_federation_issue_asset

更改概述

差异

--- a/protocol/bc/types/map.go
+++ b/protocol/bc/types/map.go
@@ -144,7 +144,7 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
144144 vetoInputs = append(vetoInputs, vetoInput)
145145
146146 case *CrossChainInput:
147- prog := &bc.Program{VmVersion: inp.VMVersion, Code: inp.ControlProgram}
147+ prog := &bc.Program{VmVersion: inp.VMVersion, Code: inp.IssuanceProgram}
148148 src := &bc.ValueSource{
149149 Ref: &inp.SourceID,
150150 Value: &inp.AssetAmount,
--- a/protocol/validation/tx_test.go
+++ b/protocol/validation/tx_test.go
@@ -7,6 +7,7 @@ import (
77 "github.com/davecgh/go-spew/spew"
88
99 "github.com/bytom/vapor/consensus"
10+ "github.com/bytom/vapor/crypto/ed25519/chainkd"
1011 "github.com/bytom/vapor/crypto/sha3pool"
1112 "github.com/bytom/vapor/errors"
1213 "github.com/bytom/vapor/protocol/bc"
@@ -1156,6 +1157,50 @@ func TestRingMagneticContractTx(t *testing.T) {
11561157 }
11571158 }
11581159
1160+func TestValidateOpenFederationIssueAsset(t *testing.T) {
1161+ tx := &types.Tx{TxData: types.TxData{Version: 1}}
1162+ tx.Inputs = append(tx.Inputs, types.NewCrossChainInput(nil,
1163+ testutil.MustDecodeHash("449143cb95389d19a1939879681168f78cc62614f4e0fb41f17b3232528a709d"),
1164+ testutil.MustDecodeAsset("ed9d55880b4c88d8579e6c542b0e714eb8c05226ae84b6794a18aad2e1124f70"),
1165+ 100000000,
1166+ 0,
1167+ 1,
1168+ testutil.MustDecodeHexString("7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b0a202020202269737375655f61737365745f616374696f6e223a202263726f73735f636861696e220a20207d2c0a2020226e616d65223a2022454f53222c0a20202271756f72756d223a20312c0a20202272656973737565223a202274727565222c0a20202273796d626f6c223a2022454f53220a7d"),
1169+ testutil.MustDecodeHexString("ae20d827c281d47f5de93f98544b20468feaac046bf8b89bd51102f6e971f09d215920be43bb856fe337b37f5f09040c2b6cdbe23eaf5aa4770b16ea51fdfc45514c295152ad"),
1170+ ))
1171+
1172+ tx.Outputs = append(tx.Outputs, types.NewIntraChainOutput(
1173+ testutil.MustDecodeAsset("ed9d55880b4c88d8579e6c542b0e714eb8c05226ae84b6794a18aad2e1124f70"),
1174+ 100000000,
1175+ testutil.MustDecodeHexString("0014d8dd58f374f58cffb1b1a7cc1e18a712b4fe67b5"),
1176+ ))
1177+
1178+ byteData, err := tx.MarshalText()
1179+ if err != nil {
1180+ t.Fatal(err)
1181+ }
1182+
1183+ tx.SerializedSize = uint64(len(byteData))
1184+ tx = types.NewTx(tx.TxData)
1185+
1186+ xPrv := chainkd.XPrv(toByte64("f0293101b509a0e919b4775d849372f97c688af8bd85a9d369fc1a4528baa94c0d74dd09aa6eaeed582df47d391c816b916a0537302291b09743903b730333f9"))
1187+ signature := xPrv.Sign(tx.SigHash(0).Bytes())
1188+ tx.Inputs[0].SetArguments([][]byte{signature})
1189+ tx = types.NewTx(tx.TxData)
1190+
1191+ if _, err := ValidateTx(tx.Tx, &bc.Block{BlockHeader: &bc.BlockHeader{Version: 1}}); err != nil {
1192+ t.Fatal(err)
1193+ }
1194+}
1195+
1196+func toByte64(str string) [64]byte{
1197+ var result [64]byte
1198+ bytes := testutil.MustDecodeHexString(str)
1199+ for i := range bytes {
1200+ result[i] = bytes[i]
1201+ }
1202+ return result
1203+}
11591204 // A txFixture is returned by sample (below) to produce a sample
11601205 // transaction, which takes a separate, optional _input_ txFixture to
11611206 // affect the transaction that's built. The components of the
Show on old repository browser