OSDN Git Service

add fed path fed_path
authorHAOYUatHZ <haoyu@protonmail.com>
Mon, 15 Jul 2019 13:03:37 +0000 (21:03 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Mon, 15 Jul 2019 13:03:37 +0000 (21:03 +0800)
blockchain/txbuilder/actions.go
config/genesis.go

index ff83650..545f92c 100644 (file)
@@ -293,7 +293,7 @@ func (a *crossInAction) Build(ctx context.Context, builder *TemplateBuilder) err
        txin := types.NewCrossChainInput(nil, a.SourceID, *a.AssetId, a.Amount, a.SourcePos, a.VMVersion, a.RawDefinitionByte, a.IssuanceProgram)
        tplIn := &SigningInstruction{}
        fed := cfg.CommonConfig.Federation
-       tplIn.AddRawWitnessKeys(fed.Xpubs, nil, fed.Quorum)
+       tplIn.AddRawWitnessKeys(fed.Xpubs, cfg.FedPath, fed.Quorum)
        tplIn.AddDataWitness(cfg.FederationPMultiSigScript(cfg.CommonConfig))
        return builder.AddInput(txin, tplIn)
 }
index aabb430..bef5a27 100644 (file)
@@ -13,9 +13,18 @@ import (
        "github.com/vapor/protocol/vm/vmutil"
 )
 
+var FedPath = [][]byte{
+       []byte{0x2C, 0x00, 0x00, 0x00},
+       []byte{0x99, 0x00, 0x00, 0x00},
+       []byte{0x01, 0x00, 0x00, 0x00},
+       []byte{0x00, 0x00, 0x00, 0x00},
+       []byte{0x01, 0x00, 0x00, 0x00},
+}
+
 func FederationPMultiSigScript(c *Config) []byte {
        xpubs := c.Federation.Xpubs
-       program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(xpubs), c.Federation.Quorum)
+       derivedXPubs := chainkd.DeriveXPubs(xpubs, FedPath)
+       program, err := vmutil.P2SPMultiSigProgram(chainkd.XPubKeys(derivedXPubs), c.Federation.Quorum)
        if err != nil {
                log.Panicf("fail to generate federation scirpt for federation: %v", err)
        }