• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision0b60020f164f36f8d98e4f011fd52476a2c91970 (tree)
Time2019-07-15 23:16:13
AuthorHAOYUatHZ <37070449+HAOYUatHZ@user...>
CommiterPaladz

Log Message

refactor: use derived xpubs for federation (#289)

* add fed path

* refactor: rename FedPath

* clean

Change Summary

Incremental Difference

--- a/blockchain/txbuilder/actions.go
+++ b/blockchain/txbuilder/actions.go
@@ -293,7 +293,7 @@ func (a *crossInAction) Build(ctx context.Context, builder *TemplateBuilder) err
293293 txin := types.NewCrossChainInput(nil, a.SourceID, *a.AssetId, a.Amount, a.SourcePos, a.VMVersion, a.RawDefinitionByte, a.IssuanceProgram)
294294 tplIn := &SigningInstruction{}
295295 fed := cfg.CommonConfig.Federation
296- tplIn.AddRawWitnessKeys(fed.Xpubs, nil, fed.Quorum)
296+ tplIn.AddRawWitnessKeys(fed.Xpubs, cfg.FedAddressPath, fed.Quorum)
297297 tplIn.AddDataWitness(cfg.FederationPMultiSigScript(cfg.CommonConfig))
298298 return builder.AddInput(txin, tplIn)
299299 }
--- a/config/genesis.go
+++ b/config/genesis.go
@@ -13,9 +13,18 @@ import (
1313 "github.com/vapor/protocol/vm/vmutil"
1414 )
1515
16+var FedAddressPath = [][]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+
1624 func FederationPMultiSigScript(c *Config) []byte {
1725 xpubs := c.Federation.Xpubs
18- program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(xpubs), c.Federation.Quorum)
26+ derivedXPubs := chainkd.DeriveXPubs(xpubs, FedAddressPath)
27+ program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(derivedXPubs), c.Federation.Quorum)
1928 if err != nil {
2029 log.Panicf("fail to generate federation scirpt for federation: %v", err)
2130 }
Show on old repository browser