• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版99cb9c581628c22999734eb04a711c852cd86a48 (tree)
时间2019-11-13 12:20:33
作者Paladz <yzhu101@uott...>
CommiterGitHub

Log Message

Merge branch 'mov' into fix_sync_status

更改概述

差异

--- a/blockchain/txbuilder/actions.go
+++ b/blockchain/txbuilder/actions.go
@@ -150,7 +150,8 @@ func DecodeCrossOutAction(data []byte) (Action, error) {
150150
151151 type crossOutAction struct {
152152 bc.AssetAmount
153- Address string `json:"address"`
153+ Address string `json:"address"`
154+ Program json.HexBytes `json:"control_program"`
154155 }
155156
156157 func (a *crossOutAction) Build(ctx context.Context, b *TemplateBuilder) error {
@@ -168,23 +169,25 @@ func (a *crossOutAction) Build(ctx context.Context, b *TemplateBuilder) error {
168169 return MissingFieldsError(missing...)
169170 }
170171
171- address, err := common.DecodeAddress(a.Address, consensus.BytomMainNetParams(&consensus.ActiveNetParams))
172- if err != nil {
173- return err
174- }
175-
176- redeemContract := address.ScriptAddress()
177- program := []byte{}
178- switch address.(type) {
179- case *common.AddressWitnessPubKeyHash:
180- program, err = vmutil.P2WPKHProgram(redeemContract)
181- case *common.AddressWitnessScriptHash:
182- program, err = vmutil.P2WSHProgram(redeemContract)
183- default:
184- return errors.New("unsupport address type")
185- }
186- if err != nil {
187- return err
172+ program := a.Program
173+ if a.Address != "" {
174+ address, err := common.DecodeAddress(a.Address, consensus.BytomMainNetParams(&consensus.ActiveNetParams))
175+ if err != nil {
176+ return err
177+ }
178+
179+ redeemContract := address.ScriptAddress()
180+ switch address.(type) {
181+ case *common.AddressWitnessPubKeyHash:
182+ program, err = vmutil.P2WPKHProgram(redeemContract)
183+ case *common.AddressWitnessScriptHash:
184+ program, err = vmutil.P2WSHProgram(redeemContract)
185+ default:
186+ return errors.New("unsupport address type")
187+ }
188+ if err != nil {
189+ return err
190+ }
188191 }
189192
190193 out := types.NewCrossChainOutput(*a.AssetId, a.Amount, program)
Show on old repository browser