package integration
import (
- "encoding/hex"
"encoding/json"
- "fmt"
"io/ioutil"
"os"
- "reflect"
"testing"
"github.com/vapor/account"
if err != nil {
t.Fatal(err)
}
- fmt.Println("TestP2SH1 hsm", hsm)
xpub1, _, err := hsm.XCreate("TestP2SH1", "password", "en")
if err != nil {
t.Fatal(err)
}
- // xpubers := make([]vcrypto.XPubKeyer, 2)
- // xpubers[0] = xpub1.XPub
- // xpubers[1] = xpub2.XPub
- fmt.Println("TestP2SH xpub1.XPub", xpub1.XPub)
- fmt.Println("TestP2SH xpub2.XPub", xpub2.XPub)
-
testAccount, err := accountManager.Create([]vcrypto.XPubKeyer{xpub1.XPub, xpub2.XPub}, 2, "testAccount", signers.BIP0044)
- // testAccount, err := accountManager.Create(xpubers, 2, "testAccount", signers.BIP0044)
if err != nil {
t.Fatal(err)
}
- fmt.Println("TestP2SH testAccount:", testAccount)
- fmt.Println("TestP2SH testAccount.XPubs:", testAccount.XPubs)
- fmt.Println("TestP2SH testAccount.XPubs[0]:", testAccount.XPubs[0])
- // fmt.Println("TestP2SH testAccount.XPubs[1] type:", reflect.TypeOf(testAccount.XPubs[1]))
controlProg, err := accountManager.CreateAddress(testAccount.ID, false)
if err != nil {
t.Fatal(err)
}
- fmt.Println("TestP2SH controlProg:", controlProg)
- fmt.Println("TestP2SH controlProg:", hex.EncodeToString(controlProg.ControlProgram))
utxo := test.MockUTXO(controlProg)
tpl, tx, err := test.MockTx(utxo, testAccount)
t.Fatal(err)
}
- fmt.Println("TestP2SH no.1")
// the number of sign transaction is equal to the count of xpub for account
if _, err := test.MockSign(tpl, hsm, "password"); err != nil {
t.Fatal(err)
}
- fmt.Println("TestP2SH no.2")
if _, err := test.MockSign(tpl, hsm, "password"); err != nil {
t.Fatal(err)
}
t.Fatal(err)
}
- fmt.Println("TestMutilNodeSign xpub1 type:", reflect.TypeOf(*xpub1))
- // xpubers := make([]vcrypto.XPubKeyer, 2)
- // xpubers[0] = xpub1.XPub
- // xpubers[1] = xpub2.XPub
-
testAccount, err := accountManager.Create([]vcrypto.XPubKeyer{xpub1.XPub, xpub2.XPub}, 2, "testAccount", signers.BIP0044)
- // testAccount, err := accountManager.Create(xpubers, 2, "testAccount", signers.BIP0044)
if err != nil {
t.Fatal(err)
}
package wallet
import (
- "encoding/hex"
"encoding/json"
- "fmt"
"io/ioutil"
"os"
"reflect"
"github.com/vapor/config"
"github.com/vapor/consensus"
vcrypto "github.com/vapor/crypto"
- edchainkd "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/database"
dbm "github.com/vapor/database/leveldb"
"github.com/vapor/event"
if err != nil {
t.Fatal(err)
}
- fmt.Println("TestMemPoolTxQueryLoop xpub1 is:", xpub1)
- edXPub := edchainkd.XPub{}
- edXPubKey, _ := hex.DecodeString("e0072a38408cfe4b70d322f8ed2d8acecab41615d2f091ddcd0d0622a8003de915569bd3e316d7e3c44ebebd21bfcc84f6428e60dbf17bef34f2e04a62f6cd2b")
- copy(edXPub[:], edXPubKey[:])
- xpub2 := pseudohsm.XPub{
- Alias: "",
- XPub: edXPub,
- File: "",
- }
+ // edXPub := edchainkd.XPub{}
+ // edXPubKey, _ := hex.DecodeString("e0072a38408cfe4b70d322f8ed2d8acecab41615d2f091ddcd0d0622a8003de915569bd3e316d7e3c44ebebd21bfcc84f6428e60dbf17bef34f2e04a62f6cd2b")
+ // copy(edXPub[:], edXPubKey[:])
+ // xpub2 := pseudohsm.XPub{
+ // Alias: "",
+ // XPub: edXPub,
+ // File: "",
+ // }
xpubers := make([]vcrypto.XPubKeyer, 1)
- xpubers[0] = xpub2.XPub
+ xpubers[0] = xpub1.XPub
testAccount, err := accountManager.Create(xpubers, 1, "testAccount", signers.BIP0044)
if err != nil {
t.Fatal(err)
}
- fmt.Println("TestMemPoolTxQueryLoop testAccount is:", testAccount)
- fmt.Println("TestMemPoolTxQueryLoop testAccount xpubs is:", testAccount.XPubs[0])
- fmt.Println("TestMemPoolTxQueryLoop testAccount xpubs type is:", reflect.TypeOf(testAccount.XPubs[0]))
controlProg, err := accountManager.CreateAddress(testAccount.ID, false)
if err != nil {