Add Beneficiary fix for Bitcoin Wallet
diff --git a/pkg/bitcoinplugin/helpers.go b/pkg/bitcoinplugin/helpers.go
index c7b5e20..eb65167 100644
--- a/pkg/bitcoinplugin/helpers.go
+++ b/pkg/bitcoinplugin/helpers.go
@@ -53,10 +53,10 @@
//we are using the beneficiary specified in the order part 1
privateKeyPart2of2 := order.OrderDocument.OrderPart4.Secret
- if order.OrderDocument.BeneficiaryCID != nodeID {
- //need to forward this data to the beneficiary to complete redemption
- return "", errors.New("Currently beneficiary must be the same as the Principal")
- }
+ // if order.OrderDocument.BeneficiaryCID != nodeID {
+ // //need to forward this data to the beneficiary to complete redemption
+ // return "", errors.New("Currently beneficiary must be the same as the Principal")
+ // }
//restore the Seed
_, _, ecAddPrivateKey, err := cryptowallet.Bip44Address(beneficiariesSeed, cryptowallet.CoinTypeBitcoinMain, 0, 0, 0)
if err != nil {
diff --git a/pkg/defaultservice/order.go b/pkg/defaultservice/order.go
index d712618..4326ba0 100644
--- a/pkg/defaultservice/order.go
+++ b/pkg/defaultservice/order.go
@@ -208,7 +208,7 @@
return nil, err
}
- _, seed, blsSK, sikeSK, err := common.RetrieveIdentitySecrets(s.Store, nodeID)
+ _, _, blsSK, sikeSK, err := common.RetrieveIdentitySecrets(s.Store, nodeID)
if err != nil {
return nil, err
}
@@ -219,6 +219,20 @@
return nil, errors.Wrap(err, "Fail to retrieve Order from IPFS")
}
+ var beneficiariesSikeSK []byte
+ var beneficiaryCID string
+
+ if req.BeneficiaryIDDocumentCID != "" {
+ beneficiaryCID = req.BeneficiaryIDDocumentCID
+ } else {
+ beneficiaryCID = order.BeneficiaryCID
+ }
+
+ _, beneficiariesSeed, _, beneficiariesSikeSK, err := common.RetrieveIdentitySecrets(s.Store, beneficiaryCID)
+ if err != nil {
+ return nil, err
+ }
+
if err := s.Plugin.ValidateOrderSecretRequest(req, *order); err != nil {
return nil, err
}
@@ -253,7 +267,7 @@
return nil, err
}
- finalPrivateKey, finalPublicKey, ext, err := s.Plugin.ProduceFinalSecret(seed, sikeSK, order, orderPart4, req, response)
+ finalPrivateKey, finalPublicKey, ext, err := s.Plugin.ProduceFinalSecret(beneficiariesSeed, beneficiariesSikeSK, order, orderPart4, req, response)
if err != nil {
return nil, err
}