Golang implemented sidechain for Bytom
Revision | 33f41e2906162f0606c177406b60108d3dc230a1 (tree) |
---|---|
Zeit | 2019-07-15 22:03:37 |
Autor | HAOYUatHZ <haoyu@prot...> |
Commiter | HAOYUatHZ |
add fed path
@@ -293,7 +293,7 @@ func (a *crossInAction) Build(ctx context.Context, builder *TemplateBuilder) err | ||
293 | 293 | txin := types.NewCrossChainInput(nil, a.SourceID, *a.AssetId, a.Amount, a.SourcePos, a.VMVersion, a.RawDefinitionByte, a.IssuanceProgram) |
294 | 294 | tplIn := &SigningInstruction{} |
295 | 295 | fed := cfg.CommonConfig.Federation |
296 | - tplIn.AddRawWitnessKeys(fed.Xpubs, nil, fed.Quorum) | |
296 | + tplIn.AddRawWitnessKeys(fed.Xpubs, cfg.FedPath, fed.Quorum) | |
297 | 297 | tplIn.AddDataWitness(cfg.FederationPMultiSigScript(cfg.CommonConfig)) |
298 | 298 | return builder.AddInput(txin, tplIn) |
299 | 299 | } |
@@ -13,9 +13,18 @@ import ( | ||
13 | 13 | "github.com/vapor/protocol/vm/vmutil" |
14 | 14 | ) |
15 | 15 | |
16 | +var FedPath = [][]byte{ | |
17 | + []byte{0x2C, 0x00, 0x00, 0x00}, | |
18 | + []byte{0x99, 0x00, 0x00, 0x00}, | |
19 | + []byte{0x01, 0x00, 0x00, 0x00}, | |
20 | + []byte{0x00, 0x00, 0x00, 0x00}, | |
21 | + []byte{0x01, 0x00, 0x00, 0x00}, | |
22 | +} | |
23 | + | |
16 | 24 | func FederationPMultiSigScript(c *Config) []byte { |
17 | 25 | xpubs := c.Federation.Xpubs |
18 | - program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(xpubs), c.Federation.Quorum) | |
26 | + derivedXPubs := chainkd.DeriveXPubs(xpubs, FedPath) | |
27 | + program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(derivedXPubs), c.Federation.Quorum) | |
19 | 28 | if err != nil { |
20 | 29 | log.Panicf("fail to generate federation scirpt for federation: %v", err) |
21 | 30 | } |