From 42fd42cfd9f9b3fcd6d95b0038573fe72000f47d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 27 Jan 2018 02:02:17 -0500 Subject: [PATCH 001/399] [daemon] [gnet] refs #735 - Initial test for serialization of RJCT messages ... FAIL --- .gitignore | 3 ++ src/daemon/errors.go | 57 ++++++++++++++++++++++++++ src/daemon/gnet/dispatcher.go | 4 +- src/daemon/gnet/dispatcher_test.go | 8 ++-- src/daemon/messages.go | 47 +++++++++++++++++++++ src/daemon/messages_test.go | 65 ++++++++++++++++++++++++++++++ 6 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 src/daemon/errors.go diff --git a/.gitignore b/.gitignore index 2887d053a4..7dfa8771b2 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,9 @@ electron/.standalone_output .vscode/ +*.swp +*.swo + src/mesh/TODO .idea/ diff --git a/src/daemon/errors.go b/src/daemon/errors.go new file mode 100644 index 0000000000..1702abf3a4 --- /dev/null +++ b/src/daemon/errors.go @@ -0,0 +1,57 @@ +package daemon + +import ( + "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/daemon/pex" +) + +var errorByCode = [...]error{ + nil, + ErrDisconnectInvalidVersion, + ErrDisconnectIntroductionTimeout, + ErrDisconnectVersionSendFailed, + ErrDisconnectIsBlacklisted, + ErrDisconnectSelf, + ErrDisconnectConnectedTwice, + ErrDisconnectIdle, + ErrDisconnectNoIntroduction, + ErrDisconnectIPLimitReached, + ErrDisconnectOtherError, + gnet.ErrDisconnectReadFailed, + gnet.ErrDisconnectWriteFailed, + gnet.ErrDisconnectSetReadDeadlineFailed, + gnet.ErrDisconnectInvalidMessageLength, + gnet.ErrDisconnectMalformedMessage, + gnet.ErrDisconnectUnknownMessage, + gnet.ErrDisconnectWriteQueueFull, + gnet.ErrDisconnectUnexpectedError, + gnet.ErrConnectionPoolClosed, + pex.ErrPeerlistFull, + pex.ErrInvalidAddress, + pex.ErrNoLocalhost, + pex.ErrNotExternalIP, + pex.ErrPortTooLow, + pex.ErrBlacklistedAddress} + +var errorCodeByError map[error]uint8 + +var initErrorCodeMap = func() { + errorCodeByError = make(map[error]uint8) + for i, err := range errorByCode { + errorCodeByError[err] = uint8(i) + } +} + +const ErrorCodeNone = 0xFF + +func GetError(code uint8) error { + return errorByCode[code] +} + +func GetErrorCode(err error) uint8 { + if initErrorCodeMap != nil { + initErrorCodeMap() + initErrorCodeMap = nil + } + return errorCodeByError[err] +} diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index f1ac437fbb..57f303a93d 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -27,7 +27,7 @@ func newSendResult(addr string, m Message, err error) SendResult { // Serializes a Message over a net.Conn func sendMessage(conn net.Conn, msg Message, timeout time.Duration) error { - m := encodeMessage(msg) + m := EncodeMessage(msg) return sendByteMessage(conn, m, timeout) } @@ -90,7 +90,7 @@ func deserializeMessage(msg []byte, v reflect.Value) (n int, e error) { } // Packgs a Message into []byte containing length, id and data -var encodeMessage = func(msg Message) []byte { +var EncodeMessage = func(msg Message) []byte { t := reflect.ValueOf(msg).Elem().Type() msgID, succ := MessageIDMap[t] if !succ { diff --git a/src/daemon/gnet/dispatcher_test.go b/src/daemon/gnet/dispatcher_test.go index f882b36154..10d95f943a 100644 --- a/src/daemon/gnet/dispatcher_test.go +++ b/src/daemon/gnet/dispatcher_test.go @@ -13,12 +13,12 @@ import ( var ( _sendByteMessage = sendByteMessage - _encodeMessage = encodeMessage + _EncodeMessage = EncodeMessage ) func resetHandler() { sendByteMessage = _sendByteMessage - encodeMessage = _encodeMessage + EncodeMessage = _EncodeMessage } func TestConvertToMessage(t *testing.T) { @@ -113,14 +113,14 @@ func TestEncodeMessage(t *testing.T) { RegisterMessage(BytePrefix, ByteMessage{}) VerifyMessages() m := NewByteMessage(7) - b := encodeMessage(m) + b := EncodeMessage(m) assert.True(t, bytes.Equal(b, []byte{5, 0, 0, 0, 'B', 'Y', 'T', 'E', 7})) } func TestEncodeMessageUnknownMessage(t *testing.T) { resetHandler() EraseMessages() - assert.Panics(t, func() { encodeMessage(&DummyMessage{}) }) + assert.Panics(t, func() { EncodeMessage(&DummyMessage{}) }) } func TestSendByteMessage(t *testing.T) { diff --git a/src/daemon/messages.go b/src/daemon/messages.go index eac6f0a22f..e3696b777d 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" "net" + "reflect" "strings" "github.com/skycoin/skycoin/src/daemon/gnet" @@ -52,6 +53,7 @@ func getMessageConfigs() []MessageConfig { NewMessageConfig("GETT", GetTxnsMessage{}), NewMessageConfig("GIVT", GiveTxnsMessage{}), NewMessageConfig("ANNT", AnnounceTxnsMessage{}), + NewMessageConfig("RJCT", RejectMessage{}), } } @@ -379,3 +381,48 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err } return nil } + +// RejectMessage a RejectMessage is sent to inform peers of +// a protocol failure. Whenever possible the node should +// send back data useful for peer recovery, especially +// before disconnecting it +// +// Must never Reject a Reject message (infinite loop) +type RejectMessage struct { + // Prefix of the (previous) message that's been rejected + TargetPrefix gnet.MessagePrefix + // Error code + ErrorCode uint8 + // Reason message. Included only in very particular cases + Reason string + // Extra data + Data interface{} + + c *gnet.MessageContext `enc:"-"` +} + +func NewRejectMessage(msg interface{}, err error, reason string, data interface{}) *RejectMessage { + t := reflect.TypeOf(msg) + prefix, exists := gnet.MessageIDMap[t] + if !exists { + logger.Panicf("Rejecting unknown message type %s", t) + } + + // TODO: Return RejectMessage instance + return &RejectMessage{ + TargetPrefix: prefix, + ErrorCode: 0, + Reason: "", + Data: make([]byte, 0)} +} + +// Process an event queued by Handle() +func (msg *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { + msg.c = mc + return daemon.(*Daemon).recordMessageEvent(msg, mc) +} + +// Process Recover from message rejection state +func (msg *RejectMessage) Process(d *Daemon) { + // TODO: Implement +} diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 9d3072094b..241f6e2906 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -1 +1,66 @@ package daemon + +import ( + "fmt" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/skycoin/skycoin/src/cipher/encoder" + "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/daemon/pex" +) + +func TestSerializeRejectMessageReplyingIntroduction(t *testing.T) { + // TODO: Test fixture + msgcfg := []MessageConfig{ + NewMessageConfig("INTR", &IntroductionMessage{}), + NewMessageConfig("RJCT", &RejectMessage{})} + for i, _ := range msgcfg { + to := reflect.TypeOf(msgcfg[i].Message) + _, succ := gnet.MessageIDMap[to] + if !succ { + gnet.RegisterMessage(msgcfg[i].Prefix, msgcfg[i].Message) + fmt.Println("Register %v", msgcfg[i].Prefix) + } + } + + originalMessage := NewIntroductionMessage(1234, 2, 6000) + + peers := make([]IPAddr, 0) + addr, _ := NewIPAddr("192.168.1.1:6001") + peers = append(peers, addr) + addr, _ = NewIPAddr("192.168.1.2:6002") + peers = append(peers, addr) + addr, _ = NewIPAddr("192.168.1.3:6003") + peers = append(peers, addr) + addr, _ = NewIPAddr("192.168.1.4:6004") + peers = append(peers, addr) + + // TODO: Expected message length + bLen := encoder.SerializeAtomic(uint32(0)) + errCode := GetErrorCode(pex.ErrPeerlistFull) + prefix := gnet.MessagePrefixFromString("RJCT") + + b := make([]byte, 0) + // Expected message length + b = append(b, bLen...) + // Message prefix + b = append(b, prefix[:]...) + // Rejected message prefix + prefix = gnet.MessagePrefixFromString("INTR") + b = append(b, prefix[:]...) + // Error code for peer list overflow + b = append(b, encoder.SerializeAtomic(errCode)...) + // Reason length + b = append(b, encoder.SerializeAtomic(uint32(0))...) + // Reason string + // Addresses + b = append(b, encoder.Serialize(peers)...) + + msg := NewRejectMessage(originalMessage, pex.ErrPeerlistFull, "", peers) + realBytes := gnet.EncodeMessage(msg) + + require.Equal(t, b, realBytes) +} From ff583501bc415b3381e0ca71f9b25d3ff1bdbd3c Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 31 May 2018 13:46:00 -0400 Subject: [PATCH 002/399] [daemon] refs #735 - ExampleRejectWithPeersMessage test case for binary RJCP messages Fix error when serializing empty slices. --- src/daemon/messages.go | 60 +++++++++++++------- src/daemon/messages_test.go | 106 ++++++++++++++++-------------------- 2 files changed, 88 insertions(+), 78 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 33774e1dc8..b0a743bd4c 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -17,6 +17,11 @@ import ( "github.com/skycoin/skycoin/src/util/utc" ) +var ( + // Every rejection message prefix must start with "RJC" prefix + rejectPrefix = [...]byte{82, 74, 67} +) + // Message represent a packet to be serialized over the network by // the gnet encoder. // They must implement the gnet.Message interface @@ -56,7 +61,7 @@ func getMessageConfigs() []MessageConfig { NewMessageConfig("GETT", GetTxnsMessage{}), NewMessageConfig("GIVT", GiveTxnsMessage{}), NewMessageConfig("ANNT", AnnounceTxnsMessage{}), - NewMessageConfig("RJCT", RejectMessage{}), + NewMessageConfig("RJCP", RejectWithPeersMessage{}), } } @@ -400,48 +405,65 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err return nil } -// RejectMessage a RejectMessage is sent to inform peers of -// a protocol failure. Whenever possible the node should -// send back data useful for peer recovery, especially -// before disconnecting it +// Metadata describing message rejection // -// Must never Reject a Reject message (infinite loop) -type RejectMessage struct { +// Should be at the beginning of every RJC? message +type RejectHeader struct { // Prefix of the (previous) message that's been rejected TargetPrefix gnet.MessagePrefix // Error code ErrorCode uint8 // Reason message. Included only in very particular cases Reason string - // Extra data - Data interface{} +} + +// RejectWithPeersMessage a RejectWithPeersMessage is sent to inform peers of +// a protocol failure. Whenever possible the node should +// send back data useful for peer recovery, especially +// before disconnecting it +// +// Must never Reject a Reject message (infinite loop) +type RejectWithPeersMessage struct { + // Reject message header + RejectHeader + // Peers list + Peers []IPAddr + // Reserved for future use + Reserved []byte c *gnet.MessageContext `enc:"-"` } -func NewRejectMessage(msg interface{}, err error, reason string, data interface{}) *RejectMessage { - t := reflect.TypeOf(msg) +func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers []IPAddr) *RejectWithPeersMessage { + t := reflect.Indirect(reflect.ValueOf(msg)).Type() prefix, exists := gnet.MessageIDMap[t] if !exists { logger.Panicf("Rejecting unknown message type %s", t) } + if reflect.DeepEqual(prefix[:3], rejectPrefix[:]) { + logger.Panicf("Message type %s (prefix = %s) may not be rejected", t, prefix) + } - // TODO: Return RejectMessage instance - return &RejectMessage{ - TargetPrefix: prefix, - ErrorCode: 0, - Reason: "", - Data: make([]byte, 0)} + return &RejectWithPeersMessage{ + RejectHeader: RejectHeader{ + TargetPrefix: prefix, + // TODO: Return error code + ErrorCode: 0, + Reason: reason, + }, + Peers: peers, + Reserved: nil, + } } // Process an event queued by Handle() -func (msg *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { +func (msg *RejectWithPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { msg.c = mc return daemon.(*Daemon).recordMessageEvent(msg, mc) } // Process Recover from message rejection state -func (msg *RejectMessage) Process(d *Daemon) { +func (msg *RejectWithPeersMessage) Process(d *Daemon) { // TODO: Implement } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 4c3e92343a..414dae968b 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -6,9 +6,6 @@ import ( "os" "reflect" "strconv" - "testing" - - "github.com/stretchr/testify/require" "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/encoder" @@ -84,16 +81,23 @@ func (mai *MessagesAnnotationsIterator) Next() (util.Annotation, bool) { mai.CurrentIndex = 0 return util.Annotation{Size: 4, Name: f.Name + " length"}, true } + sliceLen := v.Field(i).Len() mai.CurrentIndex++ - if mai.CurrentIndex != v.Field(i).Len() { + if mai.CurrentIndex < sliceLen { - //mai.CurrentField++ - return util.Annotation{Size: len(encoder.Serialize(v.Field(i).Slice(j, j+1).Interface())[4:]), Name: f.Name + "#" + strconv.Itoa(j)}, true + // Emit annotation for slice item + return util.Annotation{Size: len(encoder.Serialize(v.Field(i).Slice(j, j+1).Interface())[4:]), Name: f.Name + "[" + strconv.Itoa(j) + "]"}, true } + // No more annotation tokens for current slice field mai.CurrentIndex = -1 mai.CurrentField++ - return util.Annotation{Size: len(encoder.Serialize(v.Field(i).Slice(j, j+1).Interface())[4:]), Name: f.Name + "#" + strconv.Itoa(j)}, true - + if sliceLen > 0 { + // Emit annotation for last item + return util.Annotation{Size: len(encoder.Serialize(v.Field(i).Slice(j, j+1).Interface())[4:]), Name: f.Name + "[" + strconv.Itoa(j) + "]"}, true + } else { + // Zero length slice. Start over + return mai.Next() + } } mai.CurrentField++ @@ -192,9 +196,9 @@ func ExampleGivePeersMessage() { // 0x0000 | 1a 00 00 00 ....................................... Length // 0x0004 | 47 49 56 50 ....................................... Prefix // 0x0008 | 03 00 00 00 ....................................... Peers length - // 0x000c | 5d 87 b2 76 70 17 ................................. Peers#0 - // 0x0012 | 9c 21 58 2f 70 17 ................................. Peers#1 - // 0x0018 | 94 67 29 79 70 17 ................................. Peers#2 + // 0x000c | 5d 87 b2 76 70 17 ................................. Peers[0] + // 0x0012 | 9c 21 58 2f 70 17 ................................. Peers[1] + // 0x0018 | 94 67 29 79 70 17 ................................. Peers[2] // 0x001e | } @@ -260,7 +264,7 @@ func ExampleGiveBlocksMessage() { // 0x009c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 0x00ac | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 0x00bc | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x00cc | 00 ................................................ Blocks#0 + // 0x00cc | 00 ................................................ Blocks[0] // 0x00cd | 02 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 // 0x00dd | 00 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 // 0x00ed | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -273,7 +277,7 @@ func ExampleGiveBlocksMessage() { // 0x015d | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 0x016d | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 0x017d | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x018d | 00 ................................................ Blocks#1 + // 0x018d | 00 ................................................ Blocks[1] // 0x018e | } @@ -310,9 +314,9 @@ func ExampleGetTxnsMessage() { // 0x0004 | 47 45 54 54 ....................................... Prefix // 0x0008 | 02 00 00 00 ....................................... Txns length // 0x000c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x001c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns#0 + // 0x001c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns[0] // 0x002c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x003c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns#1 + // 0x003c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns[1] // 0x004c | } @@ -396,7 +400,7 @@ func ExampleGiveTxnsMessage() { // 0x010c | a9 ee fe 91 f2 0b a0 74 0c 00 00 00 00 00 00 00 // 0x011c | 22 00 00 00 00 00 00 00 00 e9 cb 47 35 e3 95 cf // 0x012c | 36 b0 d1 a6 f2 21 bb 23 b3 f7 bf b1 f9 38 00 00 - // 0x013c | 00 00 00 00 00 4e 00 00 00 00 00 00 00 ............ Txns#0 + // 0x013c | 00 00 00 00 00 4e 00 00 00 00 00 00 00 ............ Txns[0] // 0x0149 | 88 13 00 00 7b 00 00 00 00 00 00 00 00 00 00 00 // 0x0159 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 0x0169 | 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 @@ -416,7 +420,7 @@ func ExampleGiveTxnsMessage() { // 0x0249 | e9 f4 f0 88 7b 08 4b 43 09 00 00 00 00 00 00 00 // 0x0259 | 0c 00 00 00 00 00 00 00 00 83 f1 96 59 16 14 99 // 0x0269 | 2f a6 03 13 38 6f 72 88 ac 40 14 c8 bc 22 00 00 - // 0x0279 | 00 00 00 00 00 38 00 00 00 00 00 00 00 ............ Txns#1 + // 0x0279 | 00 00 00 00 00 38 00 00 00 00 00 00 00 ............ Txns[1] // 0x0286 | } @@ -434,27 +438,15 @@ func ExampleAnnounceTxnsMessage() { // 0x0004 | 41 4e 4e 54 ....................................... Prefix // 0x0008 | 02 00 00 00 ....................................... Txns length // 0x000c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x001c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns#0 + // 0x001c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns[0] // 0x002c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - // 0x003c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns#1 + // 0x003c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns[1] // 0x004c | } -func TestSerializeRejectMessageReplyingIntroduction(t *testing.T) { - // TODO: Test fixture - msgcfg := []MessageConfig{ - NewMessageConfig("INTR", &IntroductionMessage{}), - NewMessageConfig("RJCT", &RejectMessage{})} - for i, _ := range msgcfg { - to := reflect.TypeOf(msgcfg[i].Message) - _, succ := gnet.MessageIDMap[to] - if !succ { - gnet.RegisterMessage(msgcfg[i].Prefix, msgcfg[i].Message) - fmt.Printf("Register %v\n", msgcfg[i].Prefix) - } - } - - originalMessage := NewIntroductionMessage(1234, 2, 6000) +func ExampleRejectWithPeersMessage() { + defer gnet.EraseMessages() + setupMsgEncoding() peers := make([]IPAddr, 0) addr, _ := NewIPAddr("192.168.1.1:6001") @@ -466,29 +458,25 @@ func TestSerializeRejectMessageReplyingIntroduction(t *testing.T) { addr, _ = NewIPAddr("192.168.1.4:6004") peers = append(peers, addr) - // TODO: Expected message length - bLen := encoder.SerializeAtomic(uint32(0)) - errCode := GetErrorCode(pex.ErrPeerlistFull) - prefix := gnet.MessagePrefixFromString("RJCT") - - b := make([]byte, 0) - // Expected message length - b = append(b, bLen...) - // Message prefix - b = append(b, prefix[:]...) - // Rejected message prefix - prefix = gnet.MessagePrefixFromString("INTR") - b = append(b, prefix[:]...) - // Error code for peer list overflow - b = append(b, encoder.SerializeAtomic(errCode)...) - // Reason length - b = append(b, encoder.SerializeAtomic(uint32(0))...) - // Reason string - // Addresses - b = append(b, encoder.Serialize(peers)...) - - msg := NewRejectMessage(originalMessage, pex.ErrPeerlistFull, "", peers) - realBytes := gnet.EncodeMessage(msg) - - require.Equal(t, b, realBytes) + rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000) + message := NewRejectWithPeersMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, + "ExampleRejectWithPeersMessage", peers) + fmt.Println("RejectWithPeersMessage:") + var mai = NewMessagesAnnotationsIterator(message) + w := bufio.NewWriter(os.Stdout) + util.HexDumpFromIterator(gnet.EncodeMessage(message), &mai, w) + // Output: + // RejectWithPeersMessage: + // 0x0000 | 4a 00 00 00 ....................................... Length + // 0x0004 | 52 4a 43 50 ....................................... Prefix + // 0x0008 | 49 4e 54 52 00 1d 00 00 00 45 78 61 6d 70 6c 65 + // 0x0018 | 52 65 6a 65 63 74 57 69 74 68 50 65 65 72 73 4d + // 0x0028 | 65 73 73 61 67 65 ................................. RejectHeader + // 0x002e | 04 00 00 00 ....................................... Peers length + // 0x0032 | 01 01 a8 c0 71 17 ................................. Peers[0] + // 0x0038 | 02 01 a8 c0 72 17 ................................. Peers[1] + // 0x003e | 03 01 a8 c0 73 17 ................................. Peers[2] + // 0x0044 | 04 01 a8 c0 74 17 ................................. Peers[3] + // 0x004a | 00 00 00 00 ....................................... Reserved length + // 0x004e | } From e61fd0de5c2db71b96d353fdb1e51e890d456da6 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 1 Jun 2018 17:39:23 -0400 Subject: [PATCH 003/399] [daemon] refs #735 - Error codes in RJCP messages --- src/daemon/errors.go | 8 +++++++- src/daemon/messages.go | 7 ++++--- src/daemon/messages_test.go | 7 +++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 00733a8967..bc9b089a09 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -42,12 +42,18 @@ var initErrorCodeMap = func() { } } -const ErrorCodeNone = 0xFF +// Unexpected error condition detected +const ErrorCodeUnknown = 0xFF +// Success error code +const Success = 0 + +// Retrieve error object by corresponding error code func GetError(code uint8) error { return errorByCode[code] } +// Retrieve error code representing corresponding error object func GetErrorCode(err error) uint8 { if initErrorCodeMap != nil { initErrorCodeMap() diff --git a/src/daemon/messages.go b/src/daemon/messages.go index b0a743bd4c..b65ecb661a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -412,7 +412,7 @@ type RejectHeader struct { // Prefix of the (previous) message that's been rejected TargetPrefix gnet.MessagePrefix // Error code - ErrorCode uint8 + ErrorCode uint16 // Reason message. Included only in very particular cases Reason string } @@ -434,6 +434,7 @@ type RejectWithPeersMessage struct { c *gnet.MessageContext `enc:"-"` } +// Create message sent to reject previously received message func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers []IPAddr) *RejectWithPeersMessage { t := reflect.Indirect(reflect.ValueOf(msg)).Type() prefix, exists := gnet.MessageIDMap[t] @@ -448,7 +449,7 @@ func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers RejectHeader: RejectHeader{ TargetPrefix: prefix, // TODO: Return error code - ErrorCode: 0, + ErrorCode: GetErrorCode(err), Reason: reason, }, Peers: peers, @@ -456,7 +457,7 @@ func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers } } -// Process an event queued by Handle() +// Handle an event queued by Handle() func (msg *RejectWithPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { msg.c = mc return daemon.(*Daemon).recordMessageEvent(msg, mc) diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 414dae968b..50f44918bc 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -94,10 +94,9 @@ func (mai *MessagesAnnotationsIterator) Next() (util.Annotation, bool) { if sliceLen > 0 { // Emit annotation for last item return util.Annotation{Size: len(encoder.Serialize(v.Field(i).Slice(j, j+1).Interface())[4:]), Name: f.Name + "[" + strconv.Itoa(j) + "]"}, true - } else { - // Zero length slice. Start over - return mai.Next() } + // Zero length slice. Start over + return mai.Next() } mai.CurrentField++ @@ -469,7 +468,7 @@ func ExampleRejectWithPeersMessage() { // RejectWithPeersMessage: // 0x0000 | 4a 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 50 ....................................... Prefix - // 0x0008 | 49 4e 54 52 00 1d 00 00 00 45 78 61 6d 70 6c 65 + // 0x0008 | 49 4e 54 52 0c 1d 00 00 00 45 78 61 6d 70 6c 65 // 0x0018 | 52 65 6a 65 63 74 57 69 74 68 50 65 65 72 73 4d // 0x0028 | 65 73 73 61 67 65 ................................. RejectHeader // 0x002e | 04 00 00 00 ....................................... Peers length From ae1f4efa82bd58e943a2041260bbf9112628b53d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 1 Jun 2018 17:47:25 -0400 Subject: [PATCH 004/399] [daemon] refs #735 - 16 bit error codes --- src/daemon/errors.go | 12 ++++++------ src/daemon/messages_test.go | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index bc9b089a09..51f396762b 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -33,28 +33,28 @@ var errorByCode = [...]error{ pex.ErrPortTooLow, pex.ErrBlacklistedAddress} -var errorCodeByError map[error]uint8 +var errorCodeByError map[error]uint16 var initErrorCodeMap = func() { - errorCodeByError = make(map[error]uint8) + errorCodeByError = make(map[error]uint16) for i, err := range errorByCode { - errorCodeByError[err] = uint8(i) + errorCodeByError[err] = uint16(i) } } // Unexpected error condition detected -const ErrorCodeUnknown = 0xFF +const ErrorCodeUnknown = 0xFFFF // Success error code const Success = 0 // Retrieve error object by corresponding error code -func GetError(code uint8) error { +func GetError(code uint16) error { return errorByCode[code] } // Retrieve error code representing corresponding error object -func GetErrorCode(err error) uint8 { +func GetErrorCode(err error) uint16 { if initErrorCodeMap != nil { initErrorCodeMap() initErrorCodeMap = nil diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 50f44918bc..1e2eacb72f 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -466,16 +466,16 @@ func ExampleRejectWithPeersMessage() { util.HexDumpFromIterator(gnet.EncodeMessage(message), &mai, w) // Output: // RejectWithPeersMessage: - // 0x0000 | 4a 00 00 00 ....................................... Length + // 0x0000 | 4b 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 50 ....................................... Prefix - // 0x0008 | 49 4e 54 52 0c 1d 00 00 00 45 78 61 6d 70 6c 65 - // 0x0018 | 52 65 6a 65 63 74 57 69 74 68 50 65 65 72 73 4d - // 0x0028 | 65 73 73 61 67 65 ................................. RejectHeader - // 0x002e | 04 00 00 00 ....................................... Peers length - // 0x0032 | 01 01 a8 c0 71 17 ................................. Peers[0] - // 0x0038 | 02 01 a8 c0 72 17 ................................. Peers[1] - // 0x003e | 03 01 a8 c0 73 17 ................................. Peers[2] - // 0x0044 | 04 01 a8 c0 74 17 ................................. Peers[3] - // 0x004a | 00 00 00 00 ....................................... Reserved length - // 0x004e | + // 0x0008 | 49 4e 54 52 0c 00 1d 00 00 00 45 78 61 6d 70 6c + // 0x0018 | 65 52 65 6a 65 63 74 57 69 74 68 50 65 65 72 73 + // 0x0028 | 4d 65 73 73 61 67 65 .............................. RejectHeader + // 0x002f | 04 00 00 00 ....................................... Peers length + // 0x0033 | 01 01 a8 c0 71 17 ................................. Peers[0] + // 0x0039 | 02 01 a8 c0 72 17 ................................. Peers[1] + // 0x003f | 03 01 a8 c0 73 17 ................................. Peers[2] + // 0x0045 | 04 01 a8 c0 74 17 ................................. Peers[3] + // 0x004b | 00 00 00 00 ....................................... Reserved length + // 0x004f | } From 90e4e93c1c2ae4542f181427f71d6db25ef7a07d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 2 Jun 2018 02:27:52 -0400 Subject: [PATCH 005/399] [daemon] refs #735 - Fix linting errors --- src/daemon/errors.go | 6 +++--- src/daemon/messages.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 51f396762b..9967efa526 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -42,18 +42,18 @@ var initErrorCodeMap = func() { } } -// Unexpected error condition detected +// ErrorCodeUnknown is used on unexpected error condition detected const ErrorCodeUnknown = 0xFFFF // Success error code const Success = 0 -// Retrieve error object by corresponding error code +// GetError Retrieve error object by corresponding error code func GetError(code uint16) error { return errorByCode[code] } -// Retrieve error code representing corresponding error object +// GetErrorCode Retrieve error code representing corresponding error object func GetErrorCode(err error) uint16 { if initErrorCodeMap != nil { initErrorCodeMap() diff --git a/src/daemon/messages.go b/src/daemon/messages.go index b65ecb661a..8db6a0bcf5 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -405,7 +405,7 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err return nil } -// Metadata describing message rejection +// RejectHeader contains metadata describing message rejection // // Should be at the beginning of every RJC? message type RejectHeader struct { @@ -434,7 +434,7 @@ type RejectWithPeersMessage struct { c *gnet.MessageContext `enc:"-"` } -// Create message sent to reject previously received message +// NewRejectWithPeersMessage creates message sent to reject previously received message func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers []IPAddr) *RejectWithPeersMessage { t := reflect.Indirect(reflect.ValueOf(msg)).Type() prefix, exists := gnet.MessageIDMap[t] From a243fe89ab627e07670cf9609bcddde76c3a5f74 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Wed, 6 Jun 2018 11:58:55 -0400 Subject: [PATCH 006/399] [libc] ref #1191 finish test cipher [====] Synthesis: Tested: 88 | Passing: 88 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.crypto.c | 4 +- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 188 +++++ .../tests/check_cipher.encrypt.sha256xor.c | 311 ++++++++ lib/cgo/tests/check_cipher.scrypt.c | 164 ++++ .../tests/check_cipher.secp256k1.secp256.c | 170 +++++ .../tests/check_cipher.secp256k1.secp256_2.c | 702 ++++++++++++++++++ .../check_cipher.secp256k1.secp256k1-go2.ec.c | 143 ++++ ...eck_cipher.secp256k1.secp256k1-go2.field.c | 41 + ...check_cipher.secp256k1.secp256k1-go2.sig.c | 101 +++ ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 63 ++ lib/cgo/tests/cipher.testsuite.c | 22 +- 11 files changed, 1896 insertions(+), 13 deletions(-) create mode 100644 lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c create mode 100644 lib/cgo/tests/check_cipher.encrypt.sha256xor.c create mode 100644 lib/cgo/tests/check_cipher.scrypt.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256_2.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 97d1735b2e..2bcbcea8a0 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -161,7 +161,7 @@ Test(cipher_crypto, TestPubKeyVerifyDefault2) { Test(cipher_crypto, TestPubKeyToAddressHash) { cipher__PubKey p; cipher__SecKey s; - cipher__Ripemd160 h; + Ripemd160 h; SKY_cipher_GenerateKeyPair(&p, &s); SKY_cipher_PubKey_ToAddressHash(&p, &h); @@ -181,7 +181,7 @@ Test(cipher_crypto, TestPubKeyToAddress) { cipher__PubKey p; cipher__SecKey s; cipher__Address addr; - cipher__Ripemd160 h; + Ripemd160 h; int errcode; SKY_cipher_GenerateKeyPair(&p, &s); diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c new file mode 100644 index 0000000000..3cc4dd4258 --- /dev/null +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -0,0 +1,188 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define PLAINTEXT "plaintext" +#define PASSWORD "password" +#define PASSWORD2 "pwd" +#define WRONG_PASSWORD "wrong password" +#define ENCRYPTED "dQB7Im4iOjUyNDI4OCwiciI6OCwicCI6MSwia2V5TGVuIjozMiwic2FsdCI6ImpiejUrSFNjTFFLWkI5T0tYblNNRmt2WDBPY3JxVGZ0ZFpDNm9KUFpaeHc9Iiwibm9uY2UiOiJLTlhOQmRQa1ZUWHZYNHdoIn3PQFmOot0ETxTuv//skTG7Q57UVamGCgG5" +#define BUFFER_SIZE 1024 +#define SCRYPTCHACHA20METALENGTHSIZE 2 + +TestSuite(cipher_encrypt_scrypt_chacha20poly1305, .init = setup, .fini = teardown); + +void parseJsonMetaData(char* metadata, int* n, int* r, int* p, int* keyLen){ + *n = *r = *p = *keyLen = 0; + int length = strlen(metadata); + int openingQuote = -1; + const char* keys[] = {"n", "r", "p", "keyLen"}; + int keysCount = 4; + int keyIndex = -1; + int startNumber = -1; + for(int i = 0; i < length; i++){ + if( metadata[i] == '\"'){ + startNumber = -1; + if(openingQuote >= 0){ + keyIndex = -1; + metadata[i] = 0; + for(int k = 0; k < keysCount; k++){ + if(strcmp(metadata + openingQuote + 1, keys[k]) == 0){ + keyIndex = k; + } + } + openingQuote = -1; + } else { + openingQuote = i; + } + } else if( metadata[i] >= '0' && metadata[i] <= '9' ){ + if(startNumber < 0) + startNumber = i; + } else if( metadata[i] == ',' ){ + if(startNumber >= 0){ + metadata[i] = 0; + int number = atoi(metadata + startNumber); + startNumber = -1; + if(keyIndex == 0) *n = number; + else if(keyIndex == 1) *r = number; + else if(keyIndex == 2) *p = number; + else if(keyIndex == 3) *keyLen = number; + } + } else { + startNumber = -1; + } + } +} + +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + char str[BUFFER_SIZE]; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; + + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(str, 0, BUFFER_SIZE); + + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; + + GoUint32 errcode; + unsigned int metalength; + encrypt__ScryptChacha20poly1305 encrypt = {1, 8, 1, 32}; + for(int i = 1; i <= 20; i++) { + memset(&result, 0, sizeof(GoSlice)); + encrypt.N = 1 << i; + errcode = SKY_encrypt_ScryptChacha20poly1305_Encrypt( + &encrypt, text, password, (coin__UxArray*)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed"); + registerMemCleanup( (void*) result.data ); + cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); + int decode_len = b64_decode((const unsigned char*)result.data, + result.len, str); + cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); + cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); + metalength = (unsigned int) str[0]; + for(int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++){ + if(str[m] > 0){ + metalength += (((unsigned int)str[m]) << (m * 8)); + } + } + cr_assert(metalength + SCRYPTCHACHA20METALENGTHSIZE < decode_len, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata length greater than result lentgh."); + char* meta = str + SCRYPTCHACHA20METALENGTHSIZE; + meta[metalength] = 0; + int n, r, p, keyLen; + parseJsonMetaData(meta, &n, &r, &p, &keyLen); + + cr_assert(n == encrypt.N, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value N incorrect."); + cr_assert(r == encrypt.R, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value R incorrect."); + cr_assert(p == encrypt.P, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value P incorrect."); + cr_assert(keyLen == encrypt.KeyLen, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value KeyLen incorrect."); + } +} + +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; + + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(&result, 0, sizeof(coin__UxArray)); + + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; + + GoUint32 errcode; + encrypt__ScryptChacha20poly1305 encrypt = {0, 0, 0, 0}; + + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (coin__UxArray*)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt failed"); + registerMemCleanup( (void*) result.data ); + cr_assert( eq(type(GoSlice), text, result) ); + + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, nullData, password2, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null encrypted data."); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); +} diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c new file mode 100644 index 0000000000..3359696175 --- /dev/null +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -0,0 +1,311 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define BUFFER_SIZE 1024 +#define PASSWORD1 "pwd" +#define PASSWORD2 "key" +#define PASSWORD3 "9JMkCPphe73NQvGhmab" +#define WRONGPASSWORD "wrongpassword" +#define SHA256XORDATALENGTHSIZE 4 +#define SHA256XORBLOCKSIZE 32 +#define SHA256XORCHECKSUMSIZE 32 +#define SHA256XORNONCESIZE 32 + +TestSuite(cipher_encrypt_sha256xor, .init = setup, .fini = teardown); + +typedef struct{ + int dataLength; + GoSlice* pwd; + GoSlice* decryptPwd; + int success; + int tampered; +} TEST_DATA; + +int putUvarint(GoSlice* buf , GoUint64 x){ + int i = 0; + while( x >= 0x80 && i < buf->cap) { + ((unsigned char*)buf->data)[i] = ((GoUint8)x) | 0x80; + x >>= 7; + i++; + } + if( i < buf->cap ){ + ((unsigned char*)buf->data)[i] = (GoUint8)(x); + buf->len = i + 1; + } else { + buf->len = i; + } + return buf->len; +} + +int putVarint(GoSlice* buf , GoInt64 x){ + GoUint64 ux = (GoUint64)x << 1; + if ( x < 0 ) { + ux = ~ux; + } + return putUvarint(buf, ux); +} + +void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, + cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ + GoUint32 errcode; + int length = 32 + sizeof(cipher__SHA256); + unsigned char buff[length]; + GoSlice slice = {buff, 0, length}; + memset(buff, 0, length * sizeof(char)); + putVarint( &slice, index ); + memcpy(buff + 32, *nonceHash, sizeof(cipher__SHA256)); + slice.len = length; + cipher__SHA256 indexNonceHash; + errcode = SKY_cipher_SumSHA256(slice, &indexNonceHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + SKY_cipher_AddSHA256(key.data, &indexNonceHash, resultHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_AddSHA256 failed. Error adding hashes"); +} + +void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxArray* encrypted){ + GoUint32 fullLength = dataLength + SHA256XORDATALENGTHSIZE; + GoUint32 n = fullLength / SHA256XORBLOCKSIZE; + GoUint32 m = fullLength % SHA256XORBLOCKSIZE; + GoUint32 errcode; + + if( m > 0 ){ + fullLength += SHA256XORBLOCKSIZE - m; + } + cr_assert(SHA256XORBLOCKSIZE == sizeof(cipher__SHA256), "Size of SHA256 block size different that cipher.SHA256 struct"); + fullLength += SHA256XORBLOCKSIZE; + char* buffer = malloc(fullLength); + cr_assert(buffer != NULL, "Couldn\'t allocate buffer"); + //Add data length to the beginning, saving space for the checksum + for(int i = 0; i < SHA256XORDATALENGTHSIZE; i++){ + int shift = i * 8; + buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; + } + //Add the data + memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, + data.data, dataLength); + /*for(int i = 0; i < dataLength; i++){ + buffer[i + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE] = ((char*)data.data)[i]; + }*/ + //Add padding + for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ + buffer[i] = 0; + } + //Buffer with space for the checksum, then data length, then data, and then padding + GoSlice _data = {buffer + SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE}; + //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; + errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + char bufferNonce[SHA256XORNONCESIZE]; + GoSlice sliceNonce = {bufferNonce, 0, SHA256XORNONCESIZE}; + randBytes(&sliceNonce, SHA256XORNONCESIZE); + cipher__SHA256 hashNonce; + errcode = SKY_cipher_SumSHA256(sliceNonce, &hashNonce); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash for nonce"); + char bufferHash[BUFFER_SIZE]; + coin__UxArray hashPassword = {bufferHash, 0, BUFFER_SIZE}; + errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); + cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); + cipher__SHA256 h; + + + int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + unsigned char* dest_buffer = malloc(fullDestLength); + cr_assert(dest_buffer != NULL, "Couldn\'t allocate result buffer"); + for(int i = 0; i < n; i++){ + hashKeyIndexNonce(hashPassword, i, &hashNonce, &h); + cipher__SHA256* pBuffer = (cipher__SHA256*)(buffer + i *SHA256XORBLOCKSIZE); + cipher__SHA256* xorResult = (cipher__SHA256*)(dest_buffer + destBufferStart + i *SHA256XORBLOCKSIZE); + SKY_cipher_SHA256_Xor(pBuffer, &h, xorResult); + } + // Prefix the nonce + memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); + // Calculates the checksum + GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), + fullLength + SHA256XORNONCESIZE, + fullLength + SHA256XORNONCESIZE + }; + cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; + errcode = SKY_cipher_SumSHA256(nonceAndDataBytes, checksum); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating final checksum"); + unsigned char bufferb64[BUFFER_SIZE]; + unsigned int size = b64_encode((const unsigned char*)dest_buffer, fullDestLength, encrypted->data); + encrypted->len = size; +} + +Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ + unsigned char buff[BUFFER_SIZE]; + unsigned char encryptedBuffer[BUFFER_SIZE]; + unsigned char encryptedText[BUFFER_SIZE]; + GoSlice data = { buff, 0, BUFFER_SIZE }; + coin__UxArray encrypted = { encryptedBuffer, 0, BUFFER_SIZE }; + GoSlice pwd1 = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice pwd2 = { PASSWORD2, strlen(PASSWORD2), strlen(PASSWORD2) }; + GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; + + TEST_DATA test_data[] = { + {1, &nullPwd, &nullPwd, 0, 0}, + {1, &pwd2, &nullPwd, 1, 0}, + {2, &pwd1, &nullPwd, 1, 0}, + {32, &pwd1, &nullPwd, 1, 0}, + {64, &pwd3, &nullPwd, 1, 0}, + {65, &pwd3, &nullPwd, 1, 0}, + }; + + encrypt__Sha256Xor encryptSettings = {}; + + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, test_data[i].dataLength); + errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, *(test_data[i].pwd), &encrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + } else { + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); + } + if( errcode == SKY_OK ){ + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; + + int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } + + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert(decode_length >= 0, "base64_decode_string failed."); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + } + } + + for(int i = 33; i <= 64; i++){ + randBytes(&data, i); + errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd1, &encrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; + + int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } + + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert( decode_length >= 0, "base64_decode failed" ); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + + } +} + +Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ + unsigned char buff[BUFFER_SIZE]; + unsigned char encrypted_buffer[BUFFER_SIZE]; + unsigned char decrypted_buffer[BUFFER_SIZE]; + GoSlice data = {buff, 0, BUFFER_SIZE}; + GoSlice pwd = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice wrong_pwd = { WRONGPASSWORD, strlen(WRONGPASSWORD), strlen(WRONGPASSWORD) }; + coin__UxArray encrypted = {encrypted_buffer, 0, BUFFER_SIZE}; + coin__UxArray decrypted = {decrypted_buffer, 0, BUFFER_SIZE}; + GoSlice emptyPwd = {"", 1, 1}; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; + + TEST_DATA test_data[] = { + {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum + {32, &pwd, &emptyPwd, 0, 0}, //Empty password + {32, &pwd, &nullPwd, 0, 0}, //Null password + {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password + }; + encrypt__Sha256Xor encryptSettings = {}; + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, 32); + makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); + //SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + if( test_data[i].tampered ){ + ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; + } + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + *(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + } else { + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); + } + } + + for(int i = 0; i <= 64; i++){ + randBytes(&data, i); + //makeEncryptedData(data, i, pwd, &encrypted); + SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + *(GoSlice*)&encrypted, pwd, &decrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); + int equal = 1; + for(int j = 0; j < data.len; j++){ + if( ((unsigned char*)data.data)[j] != ((unsigned char*)decrypted.data)[j] ) + equal = 0; + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); + } +} + diff --git a/lib/cgo/tests/check_cipher.scrypt.c b/lib/cgo/tests/check_cipher.scrypt.c new file mode 100644 index 0000000000..7863fab99a --- /dev/null +++ b/lib/cgo/tests/check_cipher.scrypt.c @@ -0,0 +1,164 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define BUFFER_SIZE 1024 + +TestSuite(cipher_scrypt, .init = setup, .fini = teardown); + +typedef struct { + char* password; + char* salt; + GoInt N, r, p; + GoUint8* output; + GoInt keyLength; + GoInt passwordLength; + GoInt saltLength; +} TESTVECTOR; + +Test(cipher_scrypt, TestKey){ + GoUint8 g1[] = { + 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f, + 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb, + 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a, + 0xc5, 0xe5, 0xa, 0xa1, 0x5f, + }; + GoUint8 g2[] = { + 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18, + 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e, + 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5, + 0x7f, 0x91, 0x96, 0x3c, 0x37, + }; + GoUint8 g3[] = { + 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70, + 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09, + 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f, + 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98, + 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50, + 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa, + 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11, + 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40, + 0x18, 0x79, 0xe6, 0x41, 0xae, + }; + GoUint8 g4[] = { + 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98, + 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52, + }; + GoUint8 g5[] = { + 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b, + 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b, + 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa, + 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d, + 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f, + 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d, + 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89, + 0x06, + }; + GoUint8 g6[] = { + 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78, + 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a, + 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76, + 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9, + 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d, + 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, + 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, + 0x40, + }; + GoUint8 g7[] = { + 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46, + 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8, + 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43, + 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55, + 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24, + 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65, + 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58, + 0x87, + }; + TESTVECTOR good_ones[] = { + {"password", "salt", 2, 10, 10, g1, sizeof(g1) / sizeof(GoUint8), -1, -1}, + {"password", "salt", 16, 100, 100, g2, sizeof(g2) / sizeof(GoUint8), -1, -1}, + {"this is a long \000 password", + "and this is a long \000 salt", + 16384, 8, 1, g3, sizeof(g3) / sizeof(GoUint8), 25, 25}, + {"p", "s", 2, 1, 1, g4, sizeof(g4) / sizeof(GoUint8), -1, -1}, + {"", "", 16, 1, 1, g5, sizeof(g5) / sizeof(GoUint8), -1, -1}, + {"password", "NaCl", 1024, 8, 16, g6, sizeof(g6) / sizeof(GoUint8), -1, -1}, + {"pleaseletmein", "SodiumChloride", 16384, 8, 1, g7, sizeof(g7) / sizeof(GoUint8), -1, -1}, + }; + + GoInt32 maxInt = (GoInt32)(~((GoUint32)0) >> 1); + + TESTVECTOR bad_ones[] = { + {"p", "s", 0, 1, 1, NULL, -1, -1}, // N == 0 + {"p", "s", 1, 1, 1, NULL, -1, -1}, // N == 1 + {"p", "s", 7, 8, 1, NULL, -1, -1}, // N is not power of 2 + {"p", "s", 16, maxInt / 2, maxInt / 2, NULL, -1, -1}, // p * r too large + }; + + GoUint32 errcode; + GoSlice password; + GoSlice salt; + GoUint8 buffer[BUFFER_SIZE]; + coin__UxArray key = {buffer, 0, BUFFER_SIZE}; + + int good_ones_count = sizeof(good_ones) / sizeof(good_ones[0]); + int bad_ones_count = sizeof(bad_ones) / sizeof(bad_ones[0]); + for(int i = 0; i < good_ones_count; i++){ + password.data = good_ones[i].password; + if( good_ones[i].passwordLength < 0) + password.len = strlen(good_ones[i].password); + else + password.len = good_ones[i].passwordLength; + password.cap = password.len; + + salt.data = good_ones[i].salt; + if( good_ones[i].saltLength < 0) + salt.len = strlen(good_ones[i].salt); + else + salt.len = good_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + good_ones[i].N, good_ones[i].r, good_ones[i].p, + good_ones[i].keyLength, &key); + cr_assert(errcode == SKY_OK, "SKY_scrypt_Key failed"); + cr_assert(good_ones[i].keyLength == key.len, "SKY_scrypt_Key failed, incorrect generated key length."); + int equal = 1; + for(int j = 0; j < key.len; j++){ + if( ((GoUint8*)key.data)[j] != good_ones[i].output[j]){ + equal = 0; + } + } + cr_assert(equal == 1, "SKY_scrypt_Key failed. Invalid key generated."); + } + + for(int i = 0; i < bad_ones_count; i++){ + password.data = bad_ones[i].password; + if( bad_ones[i].passwordLength < 0) + password.len = strlen(bad_ones[i].password); + else + password.len = bad_ones[i].passwordLength; + password.cap = password.len; + + salt.data = bad_ones[i].salt; + if( bad_ones[i].saltLength < 0) + salt.len = strlen(bad_ones[i].salt); + else + salt.len = bad_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, + bad_ones[i].keyLength, &key); + cr_assert(errcode != SKY_OK, "SKY_scrypt_Key didn\'t failed"); + } +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c new file mode 100644 index 0000000000..c9bb5b178a --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -0,0 +1,170 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +#define BUFFER_SIZE 128 +#define TESTS 1 +#define SigSize 65 + +TestSuite(cipher_secp256k1, .init = setup, .fini = teardown); + +Test(cipher_secp256k1,Test_Secp256_00){ + unsigned char buff[SigSize]; + visor__ReadableOutputs nonce = {buff,0,64}; + SKY_secp256k1_RandByte(32,&nonce); + if (nonce.len != 32) cr_fatal(); +} + + +Test(cipher_secp256k1,Test_Secp256_01){ + + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; + SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); + if (!errorSecKey) cr_fatal(); + + GoInt errorPubKey; + GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); + if (!errorPubKey) cr_fatal(); +} + +Test(cipher_secp256k1, TestPubkeyFromSeckey) { + + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char* hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; + + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + + GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; + GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; + + + visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; + + GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey,&pubkey); + if(errocode) cr_fatal(); + + cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + +} + +Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) { + + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char* hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; + + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + + GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; + GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; + + + visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; + + GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey,&pubkey); + if(errocode) cr_fatal(); + + cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + +} + +Test(cipher_secp256k1, Test_SignatureVerifyPubkey){ + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoInt result = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&recoveredPubKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); +} + +Test(cipher_secp256k1, Test_verify_functions){ + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoInt result = 0; + + error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySeckey failed"); + cr_assert(result == 1, "Sec key not verified"); + + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + + error_code = SKY_secp256k1_VerifySignature(msg, sig, pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result == 1, "Signature not verified"); +} + +Test(cipher_secp256k1,Test_SignatureVerifySecKey ){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; + SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); + cr_assert(errorSecKey != SKY_OK); + GoInt errorPubKey; + GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); + cr_assert(errorPubKey != SKY_OK); +} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c new file mode 100644 index 0000000000..3e2fadf77b --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c @@ -0,0 +1,702 @@ + +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +#define BUFFER_SIZE 128 +#define TESTS 1 +#define SigSize 65 + +int keys_count = 4; +const char* test_keys[] = { + "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", + "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", + "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", + "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", +}; + +//test size of messages +Test(cipher_secp256k1, Test_Secp256_02s){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); + cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char*) sig.data)[64]; + cr_assert( last <= 4 ); +} + +//test signing message +Test(cipher_secp256k1, Test_Secp256_02){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); +} + +//test pubkey recovery +Test(cipher_secp256k1, Test_Secp256_02a){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); +} + +//test random messages for the same pub/private key +Test(cipher_secp256k1, Test_Secp256_03){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for( int i = 0; i < TESTS; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + } +} + +//test random messages for different pub/private keys +Test(cipher_secp256k1, Test_Secp256_04){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for( int i = 0; i < TESTS; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char*) sig.data)[64]; + cr_assert( last < 4 ); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + } +} + +Test(cipher_secp256k1, Test_Secp256_06a_alt0){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + GoInt result; + for(int i = 0; i < TESTS; i++){ + error_code = SKY_secp256k1_RandByte(65, (coin__UxArray*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char*)sig.data)[32] = ((unsigned char*)sig.data)[32] & 0x70; + ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); + SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Secp256_06b){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + + GoInt result; + for(int i = 0; i < TESTS; i++){ + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_00){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_01){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_02){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_03){ + int test_count = 16; + const char* testArray[] = { + "tQ93w5Aqcunm9SGUfnmF4fJv", "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", + "DC7qdQQtbWSSaekXnFmvQgse", "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", + "X8EkuUZC7Td7PAXeS7Duc7vR", "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", + "tVqPYHHNVPRWyEed62v7f23u", "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", + "kCy4R57HDfLqF3pVhBWxuMcg", "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", + "j8bjv86ZNjKqzafR6mtSUVCE", "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", + "qShryAzVY8EtsuD3dsAc7qnG", "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", + "5FGG7ZBa8wVMBJkmzpXj5ESX", "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", + "f46TZG4xJHXUGWx8ekbNqa9F", "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", + "XkZdQJ5LT96wshN8JBH8rvEt", "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", + "GFDqXU4zYymhJJ9UGqRgS8ty", "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", + "tmwZksH2XyvuamnddYxyJ5Lp", "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", + "EuqZFsbAV5amTzkhgAMgjr7W", "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", + "TW6j8rMffZfmhyDEt2JUCrLB", "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", + "8rvkBnygfhWP8kjX9aXq68CY", "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", + "phyRfPDuf9JMRFaWdGh7NXPX", "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", + }; + + GoInt32 error_code; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {NULL, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + seed.data = (void*)testArray[2 * i]; + seed.len = strlen(testArray[2 * i]); + seed.cap = seed.len; + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&s1, (coin__UxArray*)&s2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWallets1){ + int test_count = 16; + const char* testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", + }; + GoInt32 error_code; + char bufferSeed[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&s1, (coin__UxArray*)&s2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_Secp256k1_Hash){ + int test_count = 16; + const char* testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", + }; + GoInt32 error_code; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferHash3[BUFFER_SIZE]; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); + hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); + error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray*)&hash3); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); + } +} + + +Test(cipher_secp256k1, Test_Secp256k1_Equal){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for(int i = 0; i < 64; i++) { + error_code = SKY_secp256k1_RandByte( 128, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray*)&hash1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash2, + (coin__UxArray*)&public, + (coin__UxArray*)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWalletGeneration){ + const char* pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; + const char* pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; + const char* pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; + + char bufferSeed[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + char bufferNewSeed[BUFFER_SIZE]; + char bufferPrivateExpected[BUFFER_SIZE]; + char bufferPublicExpected[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; + GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; + GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; + + strcpy(bufferSeed, pSeed); + seed.len = strlen(pSeed); + + GoInt32 error_code; + + for( int i = 0; i < 1024; i++ ) { + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&newSeed, + (coin__UxArray*)&public, + (coin__UxArray*)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + memcpy( seed.data, newSeed.data, newSeed.len); + seed.len = newSeed.len; + } + + privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); + publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); + + cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); + cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); +} + +Test(cipher_secp256k1, Test_ECDH) { + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); +} + +Test(cipher_secp256k1, Test_ECDH2) { + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + + for( int i = 0; i < 32; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys) { + char seedBuffer[64]; + GoSlice seed = {seedBuffer, 0, 64}; + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; + GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for( int i = 0; i < 32; i++ ) { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&privatekey, (coin__UxArray*)& pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys2) { + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; + GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for(int i = 0; i < keys_count; i++){ + int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); + privatekey.len = sizePrivatekey; + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray*)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys3) { + unsigned char bufferPrivatekey1[BUFFER_SIZE]; + unsigned char bufferPubKey1[BUFFER_SIZE]; + unsigned char bufferPrivatekey2[BUFFER_SIZE]; + unsigned char bufferPubKey2[BUFFER_SIZE]; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + int sizePrivatekey1, sizePrivatekey2; + int sizePubKey1, sizePubKey2; + GoSlice privatekey1 = { bufferPrivatekey1, 0, BUFFER_SIZE }; + GoSlice privatekey2 = { bufferPrivatekey2, 0, BUFFER_SIZE }; + GoSlice pubKey1 = { bufferPubKey1, 0, BUFFER_SIZE }; + GoSlice pubKey2 = { bufferPubKey2, 0, BUFFER_SIZE }; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for(int i = 0; i < keys_count; i++){ + int randn = rand() % keys_count; + sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); + sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); + privatekey1.len = sizePrivatekey1; + privatekey2.len = sizePrivatekey2; + + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray*)&pubKey1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray*)&pubKey2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + + SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c new file mode 100644 index 0000000000..56a61280db --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c @@ -0,0 +1,143 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define AX "0EAEBCD1DF2DF853D66CE0E1B0FDA07F67D1CABEFDE98514AAD795B86A6EA66D" +#define AY "BEB26B67D7A00E2447BAECCC8A4CEF7CD3CAD67376AC1C5785AEEBB4F6441C16" +#define AZ "0000000000000000000000000000000000000000000000000000000000000001" + +#define EX "EB6752420B6BDB40A760AC26ADD7E7BBD080BF1DF6C0B009A0D310E4511BDF49" +#define EY "8E8CEB84E1502FC536FFE67967BC44314270A0B38C79865FFED5A85D138DCA6B" +#define EZ "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" + +#define U1 "B618EBA71EC03638693405C75FC1C9ABB1A74471BAAF1A3A8B9005821491C4B4" +#define U2 "8554470195DE4678B06EDE9F9286545B51FF2D9AA756CE35A39011783563EA60" + +#define NONCE "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E" + +#define E2X "02D1BF36D37ACD68E4DD00DB3A707FD176A37E42F81AEF9386924032D3428FF0" +#define E2Y "FD52E285D33EC835230EA69F89D9C38673BD5B995716A4063C893AF02F938454" +#define E2Z "4C6ACE7C8C062A1E046F66FD8E3981DC4E8E844ED856B5415C62047129268C1B" + +TestSuite(cipher_secp256k1_xyz, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_xyz, TestXYZECMult){ + + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number u1, u2, nonce; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&u1, 0, sizeof(Number)); + memset(&u2, 0, sizeof(Number)); + memset(&nonce, 0, sizeof(Number)); + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + GoString strU1 = {U1, strlen(U1)}; + GoString strU2 = {U2, strlen(U2)}; + + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Number_SetHex(&u1, strU1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + error_code = SKY_secp256k1go_Number_SetHex(&u2, strU2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, &u2, &u1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); +} + +Test(cipher_secp256k1_xyz, TestXYZECMultGen){ + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number u1, u2, nonce; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&u1, 0, sizeof(Number)); + memset(&u2, 0, sizeof(Number)); + memset(&nonce, 0, sizeof(Number)); + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strNonce = {NONCE, strlen(NONCE)}; + GoString strEx = {E2X, strlen(E2X)}; + GoString strEy = {E2Y, strlen(E2Y)}; + GoString strEz = {E2Z, strlen(E2Z)}; + + error_code = SKY_secp256k1go_Number_SetHex(&nonce, strNonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + + error_code = SKY_secp256k1go_ECmultGen(&pr, &nonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Y, &y, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Y is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Z, &z, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); +} + diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c new file mode 100644 index 0000000000..e271c36c42 --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c @@ -0,0 +1,41 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define INHEX "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" +#define EXPHEX "7F586430EA30F914965770F6098E492699C62EE1DF6CAFFA77681C179FDF3117" + +TestSuite(cipher_secp256k1_field, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_field, TestFieldInv){ + secp256k1go__Field in; + secp256k1go__Field out; + secp256k1go__Field expected; + + memset(&in, 0, sizeof(secp256k1go__Field)); + memset(&out, 0, sizeof(secp256k1go__Field)); + memset(&expected, 0, sizeof(secp256k1go__Field)); + + GoUint32 error_code; + GoInt8 equal = 0; + + GoString InStr = {INHEX, strlen(INHEX)}; + GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; + error_code = SKY_secp256k1go_Field_SetHex(&in, InStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected, ExpStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_Inv(&in, &out); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Inv failed"); + error_code = SKY_secp256k1go_Field_Equals(&out, &expected, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Field_Inv failed, result is different than expected."); +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c new file mode 100644 index 0000000000..cba38ac40a --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -0,0 +1,101 @@ + +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "skynumber.h" + +#define BUFFER_SIZE 1024 + +#define R1 "6028b9e3a31c9e725fcbd7d5d16736aaaafcc9bf157dfb4be62bcbcf0969d488" +#define S1 "036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a" +#define MSG1 "9cff3da1a4f86caf3683f865232c64992b5ed002af42b321b8d8a48420680487" +#define X1 "56dc5df245955302893d8dda0677cc9865d8011bc678c7803a18b5f6faafec08" +#define Y1 "54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6" + +#define R2 "b470e02f834a3aaafa27bd2b49e07269e962a51410f364e9e195c31351a05e50" +#define S2 "560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09" +#define MSG2 "9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6" +#define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" +#define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" + +TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_sig, TestSigRecover){ + GoUint32 error_code; + Signature sig; + Number msg; + secp256k1go__XY pubKey; + secp256k1go__XY expected; + + memset(&pubKey, 0, sizeof(secp256k1go__XY)); + memset(&expected, 0, sizeof(secp256k1go__XY)); + memset(&sig, 0, sizeof(Signature)); + memset(&msg, 0, sizeof(Number)); + + GoString R = {R1, strlen(R1)}; + GoString S = {S1, strlen(S1)}; + GoString MSG = {MSG1, strlen(MSG1)}; + GoString X = {X1, strlen(X1)}; + GoString Y = {Y1, strlen(Y1)}; + GoInt rid = 0; + GoInt8 result; + + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); + + R.p = R2; + R.n = strlen(R2); + S.p = S2; + S.n = strlen(S2); + MSG.p = MSG2; + MSG.n = strlen(MSG2); + X.p = X2; + X.n = strlen(X2); + Y.p = Y2; + Y.n = strlen(Y2); + rid = 1; + + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + GoInt8 equal; + error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); + SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c new file mode 100644 index 0000000000..31637a6da5 --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c @@ -0,0 +1,63 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define AX "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" +#define AY "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" +#define AZ "01" +#define EX "7D152C041EA8E1DC2191843D1FA9DB55B68F88FEF695E2C791D40444B365AFC2" +#define EY "56915849F52CC8F76F5FD7E4BF60DB4A43BF633E1B1383F85FE89164BFADCBDB" +#define EZ "9075B4EE4D4788CABB49F7F81C221151FA2F68914D0AA833388FA11FF621A970" + + + +Test(cipher_secp256k1_xyz, TestXYZDouble){ + GoInt32 error_code; + secp256k1go__XYZ a; //sample data + secp256k1go__XYZ r; //result of double + secp256k1go__XYZ e; //expected + + memset(&a, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&r, 0, sizeof(secp256k1go__XYZ)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + error_code = SKY_secp256k1go_Field_SetHex(&a.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_Double(&a, &r); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); +} + diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index a2ea72d9f5..d6f2003849 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -425,17 +425,17 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { "%d-th SKY_cipher_AddressFromPubKey and SKY_cipher_AddressFromSecKey must generate same addresses", i); // TODO : Translate once secp256k1 be part of libskycoin - /* - validSec := secp256k1.VerifySeckey(s[:]) - if validSec != 1 { - return errors.New("secp256k1.VerifySeckey failed") - } - - validPub := secp256k1.VerifyPubkey(p[:]) - if validPub != 1 { - return errors.New("secp256k1.VerifyPubkey failed") - } - */ + GoInt validSec; + char bufferSecKey[101]; + strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),65 }; + SKY_secp256k1_VerifySeckey(slseckey,&validSec); + cr_assert(validSec ==1 ,"SKY_secp256k1_VerifySeckey failed"); + + GoInt validPub; + GoSlice slpubkey = { &p,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&validPub); + cr_assert(validPub ==1 ,"SKY_secp256k1_VerifyPubkey failed"); // FIXME: without cond : 'not give a valid preprocessing token' bool cond = (!(inputData == NULL && expected->Signatures.len != 0)); From 7f180f16215e783c02d5d45d3c74d7d7fd4a40d9 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 7 Jun 2018 01:47:39 -0400 Subject: [PATCH 007/399] [libc] ref #1191 add test coin_transaction [====] Synthesis: Tested: 92 | Passing: 92 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transactions.c | 96 +++++++++++++++++++++++++ lib/cgo/tests/testutils/transutils.c | 2 + 2 files changed, 98 insertions(+) create mode 100644 lib/cgo/tests/check_coin.transactions.c diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c new file mode 100644 index 0000000000..e19071d30b --- /dev/null +++ b/lib/cgo/tests/check_coin.transactions.c @@ -0,0 +1,96 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +Test(coin_transaction, TestTransactionVerify) +{ + char bufferSHA[1024]; + char bufferSHA_[1024]; + int error; + + // Mismatch header hash + coin__Transaction tx; + makeTransaction(&tx); + memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); + GoUint32 errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Invalid header hash"); + + // No inputs + errcode = makeTransaction(&tx); + cr_assert(errcode == SKY_OK); + memset(&tx.In, 0, sizeof(GoSlice)); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert(errcode == SKY_OK); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "No inputs"); + + // No outputs + errcode = makeTransaction(&tx); + cr_assert(errcode == SKY_OK); + memset(&tx.Out, 0, sizeof(GoSlice)); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert(errcode == SKY_OK); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "No outputs"); + + // Invalid number of sigs + errcode = makeTransaction(&tx); + cr_assert(errcode == SKY_OK); + memset(&tx.Sigs, 0, sizeof(cipher__Sig)); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Invalid number of signatures"); + + errcode = makeTransaction(&tx); + cr_assert(errcode == SKY_OK); + GoSlice slice = { NULL, 20, 20 }; + memset(&tx.Sigs.data, 0, sizeof(slice)); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Invalid number of signatures"); + + errcode = makeTransaction(&tx); + cr_assert(errcode == SKY_OK); + GoSlice slice_sigs = { NULL, 32768, 32768 }; + GoSlice slice_in = { NULL, 32768, 32768 }; + memset(&tx.Sigs, 0, sizeof(slice_sigs)); + memset(&tx.In, 0, sizeof(slice_in)); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Too many signatures and inputs"); + + // Duplicate inputs + coin__UxOut* ux; + cipher__SecKey* s; + errcode = makeUxOutWithSecret(&ux, &s); + cr_assert(errcode == SKY_OK); + makeTransactionFromUxOut(&ux, &s, &tx); + cipher__SHA256 sha256; + SKY_coin_Transaction_Hash(&tx, &sha256); + SKY_coin_Transaction_PushInput(&tx, &sha256 , 0); + tx.Sigs.data = NULL; + GoSlice slice_duplicate; + copySlice( ((GoSlice*)&slice_duplicate.data), (GoSlice*)&tx.In.data,sizeof(cipher__SecKey) ); + SKY_coin_Transaction_SignInputs(&tx, slice_duplicate); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Duplicate spend"); + +} + +// Test(coin_transaction, TestTransactionPushInput) +// { + +// coin__Transaction tx; +// coin__UxOut ux; +// int errcode = makeUxOut(&ux); +// cr_assert(errcode == SKY_OK); +// } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 9f0b18391e..6c387b0ff9 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -17,6 +17,8 @@ int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey){ int result; memset( puxBody, 0, sizeof(coin__UxBody) ); + puxBody->Coins = 1000000; + puxBody->Hours = 100; result = SKY_cipher_GenerateKeyPair(&pubkey, pseckey); cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); From ba14a564b4e0352b53ec1d0db5a7d20c29f16c44 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 10:37:02 +0000 Subject: [PATCH 008/399] [libc] refs #1191. Added libc and tests for cipher. [====] Synthesis: Tested: 51 | Passing: 51 | Failing: 0 | Crashing: 0. --- include/api.blockchain.go.h | 0 include/api.client.go.h | 30 + include/api.csrf.go.h | 0 include/api.explorer.go.h | 23 + include/api.gateway.go.h | 0 include/api.health.go.h | 0 include/api.http.go.h | 6 + include/api.integration.empty.go.h | 0 include/api.network.go.h | 0 include/api.notes.go.h | 0 include/api.spend.go.h | 40 + include/api.transaction.go.h | 0 include/api.uxout.go.h | 0 include/api.wallet.go.h | 29 + include/api.webrpc.block.go.h | 0 include/api.webrpc.client.go.h | 5 + include/api.webrpc.gateway.go.h | 0 include/api.webrpc.outputs.go.h | 3 + include/api.webrpc.status.go.h | 6 + include/api.webrpc.transaction.go.h | 6 + include/api.webrpc.uxout.go.h | 4 + include/api.webrpc.webrpc.go.h | 5 + include/base64.h | 7 +- include/cipher.address.go.h | 19 +- include/cipher.base58.base58.go.h | 1 + ...her.chacha20poly1305.chacha20poly1305.go.h | 3 + ...acha20poly1305.chacha20poly1305_amd64.go.h | 0 ...ha20poly1305.chacha20poly1305_generic.go.h | 0 ...acha20poly1305.chacha20poly1305_noasm.go.h | 0 ...1305.internal.chacha20.chacha_generic.go.h | 0 include/cipher.crypto.go.h | 6 +- include/cipher.encoder.encoder.go.h | 5 + include/cipher.encoder.field.go.h | 6 + ...ipher.encrypt.scrypt_chacha20poly1305.go.h | 14 + include/cipher.encrypt.sha256xor.go.h | 2 + include/cipher.go-bip39.bip39.go.h | 0 include/cipher.go-bip39.wordlist.go.h | 0 include/cipher.hash.go.h | 4 +- include/cipher.pbkdf2.pbkdf2.go.h | 0 include/cipher.poly1305.poly1305.go.h | 0 include/cipher.poly1305.sum_amd64.go.h | 0 include/cipher.poly1305.sum_arm.go.h | 0 include/cipher.poly1305.sum_ref.go.h | 0 include/cipher.ripemd160.ripemd160block.go.h | 0 include/cipher.ripemd160.ripmd_160.go.h | 0 include/cipher.scrypt.scrypt.go.h | 0 include/cipher.secp256k1-go.secp256_rand.go.h | 0 .../cipher.secp256k1-go.secp256k1-go2.ec.go.h | 0 ...pher.secp256k1-go.secp256k1-go2.field.go.h | 3 + ...cipher.secp256k1-go.secp256k1-go2.num.go.h | 0 ....secp256k1-go.secp256k1-go2.secp256k1.go.h | 0 ...cipher.secp256k1-go.secp256k1-go2.sig.go.h | 0 .../cipher.secp256k1-go.secp256k1-go2.xy.go.h | 5 + ...cipher.secp256k1-go.secp256k1-go2.xyz.go.h | 6 + ...r.secp256k1-go.secp256k1-go2.z_consts.go.h | 0 ...her.secp256k1-go.secp256k1-go2.z_init.go.h | 0 include/cipher.secp256k1-go.secp256k1.go.h | 0 include/cli.add_private_key.go.h | 0 include/cli.address_gen.go.h | 0 include/cli.blocks.go.h | 0 include/cli.broadcast_rawtx.go.h | 0 include/cli.check_balance.go.h | 16 + include/cli.checkdb.go.h | 0 include/cli.cli.go.h | 17 + include/cli.decryptWallet.go.h | 0 include/cli.encrypt_wallet.go.h | 0 include/cli.generate_addrs.go.h | 0 include/cli.generate_wallet.go.h | 0 include/cli.integration.empty.go.h | 0 include/cli.last_blocks.go.h | 0 include/cli.list_addrs.go.h | 0 include/cli.list_wallets.go.h | 5 + include/cli.outputs.go.h | 0 include/cli.send.go.h | 0 include/cli.show_seed.go.h | 0 include/cli.status.go.h | 5 + include/cli.transaction.go.h | 0 include/cli.verify_address.go.h | 0 include/cli.version.go.h | 0 include/cli.wallet_dir.go.h | 0 include/cli.wallet_history.go.h | 1 + include/coin.block.go.h | 26 + include/coin.math.go.h | 0 include/coin.transactions.go.h | 27 +- include/consensus.blockstat.go.h | 4 + include/consensus.connection_manager.go.h | 0 include/consensus.consensus.go.h | 5 + include/consensus.example.example.go.h | 0 include/consensus.example.example_gnet.go.h | 3 + .../consensus.example.example_minimal.go.h | 0 include/consensus.participant.go.h | 0 ...cast_channel.public_broadcast_channel.go.h | 0 include/daemon.daemon.go.h | 12 + include/daemon.gateway.go.h | 13 + include/daemon.gnet.dispatcher.go.h | 0 include/daemon.gnet.message.go.h | 4 + include/daemon.gnet.pool.go.h | 1 + include/daemon.messages.go.h | 30 + include/daemon.pex.peerlist.go.h | 1 + include/daemon.pex.pex.go.h | 8 + include/daemon.pool.go.h | 0 include/daemon.rpc.go.h | 23 + include/daemon.storage.go.h | 0 include/daemon.strand.strand.go.h | 0 include/daemon.visor.go.h | 29 + include/skycriterion.h | 12 +- include/skynumber.h | 8 + include/skystring.h | 15 +- include/skytest.h | 51 +- include/skytypes.gen.h | 124 ++ include/skytypes.h | 121 +- include/testutil.assert.assertions.go.h | 0 include/testutil.require.require.go.h | 0 include/testutil.testutil.go.h | 0 include/util.apputil.apputil.go.h | 0 include/util.browser.browser.go.h | 0 include/util.cert.cert.go.h | 0 include/util.droplet.droplet.go.h | 0 include/util.elapse.elapser.go.h | 0 include/util.fee.fee.go.h | 0 include/util.file.file.go.h | 0 include/util.http.error.go.h | 0 include/util.http.handler.go.h | 0 include/util.http.json.go.h | 5 + include/util.http.log.go.h | 0 include/util.iputil.iputil.go.h | 0 include/util.logging.formatter.go.h | 12 + include/util.logging.hooks.go.h | 0 include/util.logging.logger.go.h | 0 include/util.logging.logging.go.h | 0 include/util.utc.utc.go.h | 0 include/visor.blockchain.go.h | 8 + include/visor.blockdb.block_tree.go.h | 2 + include/visor.blockdb.blockchain.go.h | 3 + include/visor.blockdb.blocksigs.go.h | 2 + include/visor.blockdb.chain_meta.go.h | 2 + include/visor.blockdb.unspent.go.h | 9 + include/visor.db.go.h | 3 + include/visor.dbutil.dbutil.go.h | 7 + include/visor.distribution.go.h | 0 include/visor.historydb.address_txn.go.h | 2 + include/visor.historydb.address_uxout.go.h | 2 + include/visor.historydb.history_meta.go.h | 2 + include/visor.historydb.historydb.go.h | 0 include/visor.historydb.output.go.h | 18 + include/visor.historydb.transaction.go.h | 6 + include/visor.readable.go.h | 90 ++ include/visor.richlist.go.h | 7 + include/visor.unconfirmed.go.h | 11 + include/visor.verify.go.h | 6 + include/visor.visor.go.h | 8 + include/wallet.addresses.go.h | 0 include/wallet.balance.go.h | 8 + include/wallet.crypto.go.h | 1 + include/wallet.entry.go.h | 1 + include/wallet.notes.go.h | 10 + include/wallet.readable.go.h | 6 + include/wallet.secrets.go.h | 0 include/wallet.service.go.h | 6 + include/wallet.wallet.go.h | 28 +- include/wallet.wallets.go.h | 0 lib/cgo/api.blockchain.go | 10 + lib/cgo/api.client.go | 1001 +++++++++++++++++ lib/cgo/api.csrf.go | 10 + lib/cgo/api.gateway.go | 10 + lib/cgo/api.health.go | 10 + lib/cgo/api.http.go | 10 + lib/cgo/api.integration.empty.go | 10 + lib/cgo/api.network.go | 10 + lib/cgo/api.notes.go | 10 + lib/cgo/api.spend.go | 97 ++ lib/cgo/api.transaction.go | 10 + lib/cgo/api.uxout.go | 10 + lib/cgo/api.wallet.go | 31 + lib/cgo/api.webrpc.block.go | 10 + lib/cgo/api.webrpc.client.go | 199 +++- lib/cgo/api.webrpc.gateway.go | 10 + lib/cgo/api.webrpc.outputs.go | 10 + lib/cgo/api.webrpc.status.go | 10 + lib/cgo/api.webrpc.transaction.go | 10 + lib/cgo/api.webrpc.uxout.go | 10 + lib/cgo/api.webrpc.webrpc.go | 28 + lib/cgo/cipher.address.go | 133 ++- lib/cgo/cipher.base58.base58.go | 152 +++ ...ipher.chacha20poly1305.chacha20poly1305.go | 10 + lib/cgo/cipher.crypto.go | 157 ++- lib/cgo/cipher.encoder.encoder.go | 10 + lib/cgo/cipher.encoder.field.go | 41 + .../cipher.encrypt.scrypt_chacha20poly1305.go | 51 + lib/cgo/cipher.encrypt.sha256xor.go | 51 + lib/cgo/cipher.go-bip39.bip39.go | 88 ++ lib/cgo/cipher.go-bip39.wordlist.go | 10 + lib/cgo/cipher.hash.go | 35 +- lib/cgo/cipher.pbkdf2.pbkdf2.go | 10 + lib/cgo/cipher.poly1305.poly1305.go | 30 + lib/cgo/cipher.ripemd160.ripemd160block.go | 10 + lib/cgo/cipher.ripemd160.ripmd_160.go | 10 + lib/cgo/cipher.scrypt.scrypt.go | 37 + lib/cgo/cipher.secp256k1-go.secp256_rand.go | 41 + .../cipher.secp256k1-go.secp256k1-go2.ec.go | 119 ++ ...cipher.secp256k1-go.secp256k1-go2.field.go | 246 ++++ .../cipher.secp256k1-go.secp256k1-go2.num.go | 52 + ...er.secp256k1-go.secp256k1-go2.secp256k1.go | 10 + .../cipher.secp256k1-go.secp256k1-go2.sig.go | 98 ++ .../cipher.secp256k1-go.secp256k1-go2.xy.go | 152 +++ .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 164 +++ ...her.secp256k1-go.secp256k1-go2.z_consts.go | 10 + ...ipher.secp256k1-go.secp256k1-go2.z_init.go | 10 + lib/cgo/cipher.secp256k1-go.secp256k1.go | 221 ++++ lib/cgo/cli.add_private_key.go | 53 + lib/cgo/cli.address_gen.go | 10 + lib/cgo/cli.blocks.go | 10 + lib/cgo/cli.broadcast_rawtx.go | 10 + lib/cgo/cli.check_balance.go | 56 + lib/cgo/cli.checkdb.go | 10 + lib/cgo/cli.cli.go | 154 +++ lib/cgo/cli.create_rawtx.go | 21 +- lib/cgo/cli.decryptWallet.go | 10 + lib/cgo/cli.encrypt_wallet.go | 10 + lib/cgo/cli.generate_addrs.go | 78 ++ lib/cgo/cli.generate_wallet.go | 47 + lib/cgo/cli.integration.empty.go | 10 + lib/cgo/cli.last_blocks.go | 10 + lib/cgo/cli.list_addrs.go | 10 + lib/cgo/cli.list_wallets.go | 10 + lib/cgo/cli.outputs.go | 60 + lib/cgo/cli.send.go | 10 + lib/cgo/cli.show_seed.go | 10 + lib/cgo/cli.status.go | 10 + lib/cgo/cli.transaction.go | 10 + lib/cgo/cli.verify_address.go | 10 + lib/cgo/cli.version.go | 10 + lib/cgo/cli.wallet_dir.go | 10 + lib/cgo/cli.wallet_history.go | 10 + lib/cgo/cli_helper.go | 106 ++ lib/cgo/coin.block.go | 266 +++++ lib/cgo/coin.math.go | 58 + lib/cgo/coin.outputs.go | 65 +- lib/cgo/coin.transactions.go | 355 ++++++ lib/cgo/libsky_handle.go | 151 ++- lib/cgo/libsky_handle_helper.go | 370 ++++++ lib/cgo/libsky_map.go | 52 + lib/cgo/libsky_mem.go | 78 +- lib/cgo/tests/libsky_string.c | 30 - lib/cgo/tests/libsky_testutil.c | 121 -- lib/cgo/tests/testutils/base64.c | 35 +- lib/cgo/tests/testutils/json.c | 1 - lib/cgo/tests/testutils/json_util.c | 41 +- .../tests/{ => testutils}/libsky_criterion.c | 240 ++-- lib/cgo/tests/testutils/libsky_number.c | 13 + lib/cgo/tests/testutils/libsky_string.c | 115 ++ lib/cgo/tests/testutils/libsky_testutil.c | 363 ++++++ lib/cgo/testutil.assert.assertions.go | 10 + lib/cgo/testutil.require.require.go | 10 + lib/cgo/testutil.testutil.go | 27 + lib/cgo/util.apputil.apputil.go | 42 + lib/cgo/util.browser.browser.go | 26 + lib/cgo/util.cert.cert.go | 29 + lib/cgo/util.droplet.droplet.go | 42 + lib/cgo/util.elapse.elapser.go | 10 + lib/cgo/util.fee.fee.go | 86 ++ lib/cgo/util.file.file.go | 67 ++ lib/cgo/util.http.error.go | 10 + lib/cgo/util.http.handler.go | 10 + lib/cgo/util.http.json.go | 131 +++ lib/cgo/util.http.log.go | 10 + lib/cgo/util.iputil.iputil.go | 54 + lib/cgo/util.logging.formatter.go | 10 + lib/cgo/util.logging.hooks.go | 10 + lib/cgo/util.logging.logger.go | 10 + lib/cgo/util.logging.logging.go | 42 + lib/cgo/util.utc.utc.go | 23 + lib/cgo/wallet.addresses.go | 61 + lib/cgo/wallet.balance.go | 100 ++ lib/cgo/wallet.crypto.go | 29 + lib/cgo/wallet.entry.go | 44 + lib/cgo/wallet.notes.go | 197 ++++ lib/cgo/wallet.readable.go | 142 +++ lib/cgo/wallet.secrets.go | 10 + lib/cgo/wallet.service.go | 10 + lib/cgo/wallet.wallet.go | 93 +- 281 files changed, 8469 insertions(+), 523 deletions(-) create mode 100644 include/api.blockchain.go.h create mode 100644 include/api.client.go.h create mode 100644 include/api.csrf.go.h create mode 100644 include/api.explorer.go.h create mode 100644 include/api.gateway.go.h create mode 100644 include/api.health.go.h create mode 100644 include/api.http.go.h create mode 100644 include/api.integration.empty.go.h create mode 100644 include/api.network.go.h create mode 100644 include/api.notes.go.h create mode 100644 include/api.spend.go.h create mode 100644 include/api.transaction.go.h create mode 100644 include/api.uxout.go.h create mode 100644 include/api.wallet.go.h create mode 100644 include/api.webrpc.block.go.h create mode 100644 include/api.webrpc.client.go.h create mode 100644 include/api.webrpc.gateway.go.h create mode 100644 include/api.webrpc.outputs.go.h create mode 100644 include/api.webrpc.status.go.h create mode 100644 include/api.webrpc.transaction.go.h create mode 100644 include/api.webrpc.uxout.go.h create mode 100644 include/api.webrpc.webrpc.go.h create mode 100644 include/cipher.base58.base58.go.h create mode 100644 include/cipher.chacha20poly1305.chacha20poly1305.go.h create mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h create mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h create mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h create mode 100644 include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h create mode 100644 include/cipher.encoder.encoder.go.h create mode 100644 include/cipher.encoder.field.go.h create mode 100644 include/cipher.encrypt.scrypt_chacha20poly1305.go.h create mode 100644 include/cipher.encrypt.sha256xor.go.h create mode 100644 include/cipher.go-bip39.bip39.go.h create mode 100644 include/cipher.go-bip39.wordlist.go.h create mode 100644 include/cipher.pbkdf2.pbkdf2.go.h create mode 100644 include/cipher.poly1305.poly1305.go.h create mode 100644 include/cipher.poly1305.sum_amd64.go.h create mode 100644 include/cipher.poly1305.sum_arm.go.h create mode 100644 include/cipher.poly1305.sum_ref.go.h create mode 100644 include/cipher.ripemd160.ripemd160block.go.h create mode 100644 include/cipher.ripemd160.ripmd_160.go.h create mode 100644 include/cipher.scrypt.scrypt.go.h create mode 100644 include/cipher.secp256k1-go.secp256_rand.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.ec.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.field.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.num.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.sig.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.xy.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h create mode 100644 include/cipher.secp256k1-go.secp256k1.go.h create mode 100644 include/cli.add_private_key.go.h create mode 100644 include/cli.address_gen.go.h create mode 100644 include/cli.blocks.go.h create mode 100644 include/cli.broadcast_rawtx.go.h create mode 100644 include/cli.check_balance.go.h create mode 100644 include/cli.checkdb.go.h create mode 100644 include/cli.cli.go.h create mode 100644 include/cli.decryptWallet.go.h create mode 100644 include/cli.encrypt_wallet.go.h create mode 100644 include/cli.generate_addrs.go.h create mode 100644 include/cli.generate_wallet.go.h create mode 100644 include/cli.integration.empty.go.h create mode 100644 include/cli.last_blocks.go.h create mode 100644 include/cli.list_addrs.go.h create mode 100644 include/cli.list_wallets.go.h create mode 100644 include/cli.outputs.go.h create mode 100644 include/cli.send.go.h create mode 100644 include/cli.show_seed.go.h create mode 100644 include/cli.status.go.h create mode 100644 include/cli.transaction.go.h create mode 100644 include/cli.verify_address.go.h create mode 100644 include/cli.version.go.h create mode 100644 include/cli.wallet_dir.go.h create mode 100644 include/cli.wallet_history.go.h create mode 100644 include/coin.block.go.h create mode 100644 include/coin.math.go.h create mode 100644 include/consensus.blockstat.go.h create mode 100644 include/consensus.connection_manager.go.h create mode 100644 include/consensus.consensus.go.h create mode 100644 include/consensus.example.example.go.h create mode 100644 include/consensus.example.example_gnet.go.h create mode 100644 include/consensus.example.example_minimal.go.h create mode 100644 include/consensus.participant.go.h create mode 100644 include/consensus.public_broadcast_channel.public_broadcast_channel.go.h create mode 100644 include/daemon.daemon.go.h create mode 100644 include/daemon.gateway.go.h create mode 100644 include/daemon.gnet.dispatcher.go.h create mode 100644 include/daemon.gnet.message.go.h create mode 100644 include/daemon.gnet.pool.go.h create mode 100644 include/daemon.messages.go.h create mode 100644 include/daemon.pex.peerlist.go.h create mode 100644 include/daemon.pex.pex.go.h create mode 100644 include/daemon.pool.go.h create mode 100644 include/daemon.rpc.go.h create mode 100644 include/daemon.storage.go.h create mode 100644 include/daemon.strand.strand.go.h create mode 100644 include/daemon.visor.go.h create mode 100644 include/skynumber.h create mode 100644 include/skytypes.gen.h create mode 100644 include/testutil.assert.assertions.go.h create mode 100644 include/testutil.require.require.go.h create mode 100644 include/testutil.testutil.go.h create mode 100644 include/util.apputil.apputil.go.h create mode 100644 include/util.browser.browser.go.h create mode 100644 include/util.cert.cert.go.h create mode 100644 include/util.droplet.droplet.go.h create mode 100644 include/util.elapse.elapser.go.h create mode 100644 include/util.fee.fee.go.h create mode 100644 include/util.file.file.go.h create mode 100644 include/util.http.error.go.h create mode 100644 include/util.http.handler.go.h create mode 100644 include/util.http.json.go.h create mode 100644 include/util.http.log.go.h create mode 100644 include/util.iputil.iputil.go.h create mode 100644 include/util.logging.formatter.go.h create mode 100644 include/util.logging.hooks.go.h create mode 100644 include/util.logging.logger.go.h create mode 100644 include/util.logging.logging.go.h create mode 100644 include/util.utc.utc.go.h create mode 100644 include/visor.blockchain.go.h create mode 100644 include/visor.blockdb.block_tree.go.h create mode 100644 include/visor.blockdb.blockchain.go.h create mode 100644 include/visor.blockdb.blocksigs.go.h create mode 100644 include/visor.blockdb.chain_meta.go.h create mode 100644 include/visor.blockdb.unspent.go.h create mode 100644 include/visor.db.go.h create mode 100644 include/visor.dbutil.dbutil.go.h create mode 100644 include/visor.distribution.go.h create mode 100644 include/visor.historydb.address_txn.go.h create mode 100644 include/visor.historydb.address_uxout.go.h create mode 100644 include/visor.historydb.history_meta.go.h create mode 100644 include/visor.historydb.historydb.go.h create mode 100644 include/visor.historydb.output.go.h create mode 100644 include/visor.historydb.transaction.go.h create mode 100644 include/visor.readable.go.h create mode 100644 include/visor.richlist.go.h create mode 100644 include/visor.unconfirmed.go.h create mode 100644 include/visor.verify.go.h create mode 100644 include/visor.visor.go.h create mode 100644 include/wallet.addresses.go.h create mode 100644 include/wallet.balance.go.h create mode 100644 include/wallet.crypto.go.h create mode 100644 include/wallet.notes.go.h create mode 100644 include/wallet.readable.go.h create mode 100644 include/wallet.secrets.go.h create mode 100644 include/wallet.service.go.h create mode 100644 include/wallet.wallets.go.h create mode 100644 lib/cgo/api.blockchain.go create mode 100644 lib/cgo/api.client.go create mode 100644 lib/cgo/api.csrf.go create mode 100644 lib/cgo/api.gateway.go create mode 100644 lib/cgo/api.health.go create mode 100644 lib/cgo/api.http.go create mode 100644 lib/cgo/api.integration.empty.go create mode 100644 lib/cgo/api.network.go create mode 100644 lib/cgo/api.notes.go create mode 100644 lib/cgo/api.spend.go create mode 100644 lib/cgo/api.transaction.go create mode 100644 lib/cgo/api.uxout.go create mode 100644 lib/cgo/api.wallet.go create mode 100644 lib/cgo/api.webrpc.block.go create mode 100644 lib/cgo/api.webrpc.gateway.go create mode 100644 lib/cgo/api.webrpc.outputs.go create mode 100644 lib/cgo/api.webrpc.status.go create mode 100644 lib/cgo/api.webrpc.transaction.go create mode 100644 lib/cgo/api.webrpc.uxout.go create mode 100644 lib/cgo/api.webrpc.webrpc.go create mode 100644 lib/cgo/cipher.base58.base58.go create mode 100644 lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go create mode 100644 lib/cgo/cipher.encoder.encoder.go create mode 100644 lib/cgo/cipher.encoder.field.go create mode 100644 lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go create mode 100644 lib/cgo/cipher.encrypt.sha256xor.go create mode 100644 lib/cgo/cipher.go-bip39.bip39.go create mode 100644 lib/cgo/cipher.go-bip39.wordlist.go create mode 100644 lib/cgo/cipher.pbkdf2.pbkdf2.go create mode 100644 lib/cgo/cipher.poly1305.poly1305.go create mode 100644 lib/cgo/cipher.ripemd160.ripemd160block.go create mode 100644 lib/cgo/cipher.ripemd160.ripmd_160.go create mode 100644 lib/cgo/cipher.scrypt.scrypt.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256_rand.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go create mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1.go create mode 100644 lib/cgo/cli.add_private_key.go create mode 100644 lib/cgo/cli.address_gen.go create mode 100644 lib/cgo/cli.blocks.go create mode 100644 lib/cgo/cli.broadcast_rawtx.go create mode 100644 lib/cgo/cli.check_balance.go create mode 100644 lib/cgo/cli.checkdb.go create mode 100644 lib/cgo/cli.cli.go create mode 100644 lib/cgo/cli.decryptWallet.go create mode 100644 lib/cgo/cli.encrypt_wallet.go create mode 100644 lib/cgo/cli.generate_addrs.go create mode 100644 lib/cgo/cli.generate_wallet.go create mode 100644 lib/cgo/cli.integration.empty.go create mode 100644 lib/cgo/cli.last_blocks.go create mode 100644 lib/cgo/cli.list_addrs.go create mode 100644 lib/cgo/cli.list_wallets.go create mode 100644 lib/cgo/cli.outputs.go create mode 100644 lib/cgo/cli.send.go create mode 100644 lib/cgo/cli.show_seed.go create mode 100644 lib/cgo/cli.status.go create mode 100644 lib/cgo/cli.transaction.go create mode 100644 lib/cgo/cli.verify_address.go create mode 100644 lib/cgo/cli.version.go create mode 100644 lib/cgo/cli.wallet_dir.go create mode 100644 lib/cgo/cli.wallet_history.go create mode 100644 lib/cgo/cli_helper.go create mode 100644 lib/cgo/coin.block.go create mode 100644 lib/cgo/coin.math.go create mode 100644 lib/cgo/coin.transactions.go create mode 100644 lib/cgo/libsky_handle_helper.go create mode 100644 lib/cgo/libsky_map.go delete mode 100644 lib/cgo/tests/libsky_string.c delete mode 100644 lib/cgo/tests/libsky_testutil.c rename lib/cgo/tests/{ => testutils}/libsky_criterion.c (58%) create mode 100644 lib/cgo/tests/testutils/libsky_number.c create mode 100644 lib/cgo/tests/testutils/libsky_string.c create mode 100644 lib/cgo/tests/testutils/libsky_testutil.c create mode 100644 lib/cgo/testutil.assert.assertions.go create mode 100644 lib/cgo/testutil.require.require.go create mode 100644 lib/cgo/testutil.testutil.go create mode 100644 lib/cgo/util.apputil.apputil.go create mode 100644 lib/cgo/util.browser.browser.go create mode 100644 lib/cgo/util.cert.cert.go create mode 100644 lib/cgo/util.droplet.droplet.go create mode 100644 lib/cgo/util.elapse.elapser.go create mode 100644 lib/cgo/util.fee.fee.go create mode 100644 lib/cgo/util.file.file.go create mode 100644 lib/cgo/util.http.error.go create mode 100644 lib/cgo/util.http.handler.go create mode 100644 lib/cgo/util.http.json.go create mode 100644 lib/cgo/util.http.log.go create mode 100644 lib/cgo/util.iputil.iputil.go create mode 100644 lib/cgo/util.logging.formatter.go create mode 100644 lib/cgo/util.logging.hooks.go create mode 100644 lib/cgo/util.logging.logger.go create mode 100644 lib/cgo/util.logging.logging.go create mode 100644 lib/cgo/util.utc.utc.go create mode 100644 lib/cgo/wallet.addresses.go create mode 100644 lib/cgo/wallet.balance.go create mode 100644 lib/cgo/wallet.crypto.go create mode 100644 lib/cgo/wallet.entry.go create mode 100644 lib/cgo/wallet.notes.go create mode 100644 lib/cgo/wallet.readable.go create mode 100644 lib/cgo/wallet.secrets.go create mode 100644 lib/cgo/wallet.service.go diff --git a/include/api.blockchain.go.h b/include/api.blockchain.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.client.go.h b/include/api.client.go.h new file mode 100644 index 0000000000..aecac9544a --- /dev/null +++ b/include/api.client.go.h @@ -0,0 +1,30 @@ +typedef struct{ + GoString_ Status; + GoInt_ StatusCode; + GoString_ Message; +} api__ClientError; +typedef struct{ + GoString_ ID; + GoSlice_ Addresses; + GoString_ Password; +} api__CreateTransactionRequestWallet; +typedef struct{ + GoString_ Type; + GoString_ Mode; + GoString_ ShareFactor; +} api__HoursSelection; +typedef struct{ + GoString_ Address; + GoString_ Coins; + GoString_ Hours; +} api__Receiver; +typedef struct{ + GoInt_ N; + BOOL IncludeDistribution; +} api__RichlistParams; +typedef struct{ + api__HoursSelection HoursSelection; + api__CreateTransactionRequestWallet Wallet; + GoString_ ChangeAddress; + GoSlice_ To; +} api__CreateTransactionRequest; diff --git a/include/api.csrf.go.h b/include/api.csrf.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h new file mode 100644 index 0000000000..6017b5acc0 --- /dev/null +++ b/include/api.explorer.go.h @@ -0,0 +1,23 @@ +typedef struct{ + GoString_ CurrentSupply; + GoString_ TotalSupply; + GoString_ MaxSupply; + GoString_ CurrentCoinHourSupply; + GoString_ TotalCoinHourSupply; + GoSlice_ UnlockedAddresses; + GoSlice_ LockedAddresses; +} api__CoinSupply; +typedef struct{ + visor__Richlist Richlist; +} api__Richlist; +typedef struct{ + visor__TransactionStatus Status; + GoUint32_ Length; + GoUint8_ Type; + GoString_ Hash; + GoString_ InnerHash; + GoUint64_ Timestamp; + GoSlice_ Sigs; + GoSlice_ In; + GoSlice_ Out; +} api__ReadableTransaction; diff --git a/include/api.gateway.go.h b/include/api.gateway.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.health.go.h b/include/api.health.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.http.go.h b/include/api.http.go.h new file mode 100644 index 0000000000..f31f3bb717 --- /dev/null +++ b/include/api.http.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoString_ host; + GoString_ appLoc; + BOOL enableGUI; + BOOL enableJSON20RPC; +} api__muxConfig; diff --git a/include/api.integration.empty.go.h b/include/api.integration.empty.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.network.go.h b/include/api.network.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.notes.go.h b/include/api.notes.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.spend.go.h b/include/api.spend.go.h new file mode 100644 index 0000000000..e884eee5aa --- /dev/null +++ b/include/api.spend.go.h @@ -0,0 +1,40 @@ +typedef struct{ + GoUint32_ Length; + GoUint8_ Type; + GoString_ TxID; + GoString_ InnerHash; + GoString_ Fee; + GoSlice_ Sigs; + GoSlice_ In; + GoSlice_ Out; +} api__CreatedTransaction; +typedef struct{ + GoString_ UxID; + GoString_ Address; + GoString_ Coins; + GoString_ Hours; +} api__CreatedTransactionOutput; +typedef struct{ + GoString_ UxID; + GoString_ Address; + GoString_ Coins; + GoString_ Hours; + GoString_ CalculatedHours; + GoUint64_ Time; + GoUint64_ Block; + GoString_ TxID; +} api__CreatedTransactionInput; +typedef struct{ + GoString_ ID; + GoSlice_ Addresses; + GoString_ Password; +} api__createTransactionRequestWallet; +typedef struct{ + api__CreatedTransaction Transaction; + GoString_ EncodedTransaction; +} api__CreateTransactionResponse; +typedef struct{ + httphelper__Address Address; + httphelper__Coins Coins; + httphelper__Hours * Hours; +} api__receiver; diff --git a/include/api.transaction.go.h b/include/api.transaction.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.uxout.go.h b/include/api.uxout.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.wallet.go.h b/include/api.wallet.go.h new file mode 100644 index 0000000000..a80d2c1ff4 --- /dev/null +++ b/include/api.wallet.go.h @@ -0,0 +1,29 @@ +typedef struct{ + GoSlice_ Transactions; +} api__UnconfirmedTxnsResponse; +typedef struct{ + GoString_ Address; + GoString_ Public; +} api__WalletEntry; +typedef struct{ + GoString_ Coin; + GoString_ Filename; + GoString_ Label; + GoString_ Type; + GoString_ Version; + GoString_ CryptoType; + GoInt64_ Timestamp; + BOOL Encrypted; +} api__WalletMeta; +typedef struct{ + api__WalletMeta Meta; + GoSlice_ Entries; +} api__WalletResponse; +typedef struct{ + GoString_ Address; +} api__WalletFolder; +typedef struct{ + wallet__BalancePair * Balance; + visor__ReadableTransaction * Transaction; + GoString_ Error; +} api__SpendResult; diff --git a/include/api.webrpc.block.go.h b/include/api.webrpc.block.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.webrpc.client.go.h b/include/api.webrpc.client.go.h new file mode 100644 index 0000000000..c367e9f68c --- /dev/null +++ b/include/api.webrpc.client.go.h @@ -0,0 +1,5 @@ +typedef struct{ + GoString_ Status; + GoInt_ StatusCode; + GoString_ Message; +} webrpc__ClientError; diff --git a/include/api.webrpc.gateway.go.h b/include/api.webrpc.gateway.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/api.webrpc.outputs.go.h b/include/api.webrpc.outputs.go.h new file mode 100644 index 0000000000..63833d4494 --- /dev/null +++ b/include/api.webrpc.outputs.go.h @@ -0,0 +1,3 @@ +typedef struct{ + visor__ReadableOutputSet Outputs; +} webrpc__OutputsResult; diff --git a/include/api.webrpc.status.go.h b/include/api.webrpc.status.go.h new file mode 100644 index 0000000000..35dcb38e55 --- /dev/null +++ b/include/api.webrpc.status.go.h @@ -0,0 +1,6 @@ +typedef struct{ + BOOL Running; + GoUint64_ BlockNum; + GoString_ LastBlockHash; + GoString_ TimeSinceLastBlock; +} webrpc__StatusResult; diff --git a/include/api.webrpc.transaction.go.h b/include/api.webrpc.transaction.go.h new file mode 100644 index 0000000000..5f542a6c66 --- /dev/null +++ b/include/api.webrpc.transaction.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoString_ Txid; +} webrpc__TxIDJson; +typedef struct{ + daemon__TransactionResult * Transaction; +} webrpc__TxnResult; diff --git a/include/api.webrpc.uxout.go.h b/include/api.webrpc.uxout.go.h new file mode 100644 index 0000000000..f5540e314e --- /dev/null +++ b/include/api.webrpc.uxout.go.h @@ -0,0 +1,4 @@ +typedef struct{ + GoString_ Address; + GoSlice_ UxOuts; +} webrpc__AddrUxoutResult; diff --git a/include/api.webrpc.webrpc.go.h b/include/api.webrpc.webrpc.go.h new file mode 100644 index 0000000000..b2307bfe08 --- /dev/null +++ b/include/api.webrpc.webrpc.go.h @@ -0,0 +1,5 @@ +typedef struct{ + GoInt_ Code; + GoString_ Message; + GoString_ Data; +} webrpc__RPCError; diff --git a/include/base64.h b/include/base64.h index 75211ccf4e..9dc9c4ecc7 100644 --- a/include/base64.h +++ b/include/base64.h @@ -11,7 +11,7 @@ Thank you for inspiration: #include //Base64 char table function - used internally for decoding -unsigned int b64_int(unsigned int ch); +int b64_int(unsigned int ch); // in_size : the number bytes to be encoded. // Returns the recommended memory size to be allocated for the output buffer excluding the null byte @@ -41,5 +41,6 @@ unsigned int b64_encodef(char *InFile, char *OutFile); // file-version b64_decode // Input : filenames // returns size of output -unsigned int b64_decodef(char *InFile, char *OutFile); - +int b64_decodef(char *InFile, char *OutFile); + +//unsigned int b64_encode_string(const unsigned char* in, unsigned int in_len, unsigned char* out); diff --git a/include/cipher.address.go.h b/include/cipher.address.go.h index 462feb9816..082ce600d8 100644 --- a/include/cipher.address.go.h +++ b/include/cipher.address.go.h @@ -1,14 +1,7 @@ -/** - * Integrity checksum, 4-bytes long. - */ -typedef unsigned char cipher__Checksum[4]; - -/** - * Addresses of SKY accounts - */ -typedef struct { - unsigned char Version; ///< Address version identifier. - ///< Used to differentiate testnet - ///< vs mainnet addresses, for instance. - cipher__Ripemd160 Key; ///< Address hash identifier. +typedef GoUint8_ cipher__Checksum[4]; +typedef struct{ + GoUint8_ Version; ///< Address version identifier. + ///< Used to differentiate testnet + ///< vs mainnet addresses, for ins + cipher__Ripemd160 Key; ///< Address hash identifier. } cipher__Address; diff --git a/include/cipher.base58.base58.go.h b/include/cipher.base58.base58.go.h new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/include/cipher.base58.base58.go.h @@ -0,0 +1 @@ + diff --git a/include/cipher.chacha20poly1305.chacha20poly1305.go.h b/include/cipher.chacha20poly1305.chacha20poly1305.go.h new file mode 100644 index 0000000000..22e4917781 --- /dev/null +++ b/include/cipher.chacha20poly1305.chacha20poly1305.go.h @@ -0,0 +1,3 @@ +typedef struct{ + GoUint8_ key[32]; +} chacha20poly1305__chacha20poly1305; diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h b/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.crypto.go.h b/include/cipher.crypto.go.h index 17f3923a8c..aaaf0378ed 100644 --- a/include/cipher.crypto.go.h +++ b/include/cipher.crypto.go.h @@ -1,12 +1,12 @@ /** * Hash signed using a secret key, 65 bytes long. */ -typedef unsigned char cipher__Sig[65]; +typedef GoUint8_ cipher__Sig[65]; /** * Public key, 33-bytes long. */ -typedef unsigned char cipher__PubKey[33]; +typedef GoUint8_ cipher__PubKey[33]; /** * Container type suitable for storing a variable number of @@ -17,4 +17,4 @@ typedef GoSlice_ cipher__PubKeySlice; /** * Secret key, 32 bytes long. */ -typedef unsigned char cipher__SecKey[32]; +typedef GoUint8_ cipher__SecKey[32]; diff --git a/include/cipher.encoder.encoder.go.h b/include/cipher.encoder.encoder.go.h new file mode 100644 index 0000000000..8b70d1b79e --- /dev/null +++ b/include/cipher.encoder.encoder.go.h @@ -0,0 +1,5 @@ +typedef struct{ + GoSlice_ buf; +} encoder__coder; +typedef encoder__coder encoder__decoder; +typedef encoder__coder encoder__encoder; diff --git a/include/cipher.encoder.field.go.h b/include/cipher.encoder.field.go.h new file mode 100644 index 0000000000..6e58de2c1e --- /dev/null +++ b/include/cipher.encoder.field.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoString_ Name; + GoUint32_ Kind; + GoString_ Type; + GoString_ Tag; +} encoder__StructField; diff --git a/include/cipher.encrypt.scrypt_chacha20poly1305.go.h b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h new file mode 100644 index 0000000000..8e728cea45 --- /dev/null +++ b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h @@ -0,0 +1,14 @@ +typedef struct{ + GoInt_ N; + GoInt_ R; + GoInt_ P; + GoInt_ KeyLen; +} encrypt__ScryptChacha20poly1305; +typedef struct{ + GoInt_ N; + GoInt_ R; + GoInt_ P; + GoInt_ KeyLen; + GoSlice_ Salt; + GoSlice_ Nonce; +} encrypt__meta; diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h new file mode 100644 index 0000000000..b306cba549 --- /dev/null +++ b/include/cipher.encrypt.sha256xor.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} encrypt__Sha256Xor; diff --git a/include/cipher.go-bip39.bip39.go.h b/include/cipher.go-bip39.bip39.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.go-bip39.wordlist.go.h b/include/cipher.go-bip39.wordlist.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.hash.go.h b/include/cipher.hash.go.h index 87465693c6..2b801ca668 100644 --- a/include/cipher.hash.go.h +++ b/include/cipher.hash.go.h @@ -1,9 +1,9 @@ /** * Hash obtained using SHA256 algorithm, 32 bytes long. */ -typedef unsigned char cipher__SHA256[32]; +typedef GoUint8_ cipher__SHA256[32]; /** * RIPEMD-160 hash. */ -typedef unsigned char cipher__Ripemd160[20]; +typedef GoUint8_ cipher__Ripemd160[20]; diff --git a/include/cipher.pbkdf2.pbkdf2.go.h b/include/cipher.pbkdf2.pbkdf2.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.poly1305.poly1305.go.h b/include/cipher.poly1305.poly1305.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.poly1305.sum_amd64.go.h b/include/cipher.poly1305.sum_amd64.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.poly1305.sum_arm.go.h b/include/cipher.poly1305.sum_arm.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.poly1305.sum_ref.go.h b/include/cipher.poly1305.sum_ref.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.ripemd160.ripemd160block.go.h b/include/cipher.ripemd160.ripemd160block.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.ripemd160.ripmd_160.go.h b/include/cipher.ripemd160.ripmd_160.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.scrypt.scrypt.go.h b/include/cipher.scrypt.scrypt.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256_rand.go.h b/include/cipher.secp256k1-go.secp256_rand.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h b/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.field.go.h b/include/cipher.secp256k1-go.secp256k1-go2.field.go.h new file mode 100644 index 0000000000..6345d5e4ac --- /dev/null +++ b/include/cipher.secp256k1-go.secp256k1-go2.field.go.h @@ -0,0 +1,3 @@ +typedef struct{ + GoUint32_ n[10]; +} secp256k1go__Field; diff --git a/include/cipher.secp256k1-go.secp256k1-go2.num.go.h b/include/cipher.secp256k1-go.secp256k1-go2.num.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h b/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.xy.go.h b/include/cipher.secp256k1-go.secp256k1-go2.xy.go.h new file mode 100644 index 0000000000..780f923486 --- /dev/null +++ b/include/cipher.secp256k1-go.secp256k1-go2.xy.go.h @@ -0,0 +1,5 @@ +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + BOOL Infinity; +} secp256k1go__XY; diff --git a/include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h b/include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h new file mode 100644 index 0000000000..bd16b90ab8 --- /dev/null +++ b/include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h @@ -0,0 +1,6 @@ +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + secp256k1go__Field Z; + BOOL Infinity; +} secp256k1go__XYZ; diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cipher.secp256k1-go.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.add_private_key.go.h b/include/cli.add_private_key.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.address_gen.go.h b/include/cli.address_gen.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.blocks.go.h b/include/cli.blocks.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.broadcast_rawtx.go.h b/include/cli.broadcast_rawtx.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.check_balance.go.h b/include/cli.check_balance.go.h new file mode 100644 index 0000000000..ad2218e8d7 --- /dev/null +++ b/include/cli.check_balance.go.h @@ -0,0 +1,16 @@ +typedef struct{ + GoString_ Coins; + GoString_ Hours; +} cli__Balance; +typedef struct{ + cli__Balance Confirmed; + cli__Balance Spendable; + cli__Balance Expected; + GoString_ Address; +} cli__AddressBalance; +typedef struct{ + cli__Balance Confirmed; + cli__Balance Spendable; + cli__Balance Expected; + GoSlice_ Addresses; +} cli__BalanceResult; diff --git a/include/cli.checkdb.go.h b/include/cli.checkdb.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h new file mode 100644 index 0000000000..a1c7775c4f --- /dev/null +++ b/include/cli.cli.go.h @@ -0,0 +1,17 @@ +typedef struct{ + GoString_ WalletDir; + GoString_ WalletName; + GoString_ DataDir; + GoString_ Coin; + GoString_ RPCAddress; + BOOL UseCSRF; +} cli__Config; +typedef struct{ + GoInt32_ _unnamed; +} cli__WalletLoadError; +typedef struct{ + GoInt32_ _unnamed; +} cli__WalletSaveError; +typedef GoSlice_ cli__PasswordFromBytes; +typedef struct{ +} cli__PasswordFromTerm; diff --git a/include/cli.decryptWallet.go.h b/include/cli.decryptWallet.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.encrypt_wallet.go.h b/include/cli.encrypt_wallet.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.generate_addrs.go.h b/include/cli.generate_addrs.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.generate_wallet.go.h b/include/cli.generate_wallet.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.integration.empty.go.h b/include/cli.integration.empty.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.last_blocks.go.h b/include/cli.last_blocks.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.list_addrs.go.h b/include/cli.list_addrs.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.list_wallets.go.h b/include/cli.list_wallets.go.h new file mode 100644 index 0000000000..2650079be5 --- /dev/null +++ b/include/cli.list_wallets.go.h @@ -0,0 +1,5 @@ +typedef struct{ + GoString_ Name; + GoString_ Label; + GoInt_ AddressNum; +} cli__WalletEntry; diff --git a/include/cli.outputs.go.h b/include/cli.outputs.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.send.go.h b/include/cli.send.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.show_seed.go.h b/include/cli.show_seed.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.status.go.h b/include/cli.status.go.h new file mode 100644 index 0000000000..6086d80849 --- /dev/null +++ b/include/cli.status.go.h @@ -0,0 +1,5 @@ +typedef struct{ + webrpc__StatusResult _unnamed; + GoString_ RPCAddress; + BOOL UseCSRF; +} cli__StatusResult; diff --git a/include/cli.transaction.go.h b/include/cli.transaction.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.verify_address.go.h b/include/cli.verify_address.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.version.go.h b/include/cli.version.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.wallet_dir.go.h b/include/cli.wallet_dir.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/cli.wallet_history.go.h b/include/cli.wallet_history.go.h new file mode 100644 index 0000000000..00d158f4a3 --- /dev/null +++ b/include/cli.wallet_history.go.h @@ -0,0 +1 @@ +typedef GoSlice_ cli__byTime; diff --git a/include/coin.block.go.h b/include/coin.block.go.h new file mode 100644 index 0000000000..25b72ee72e --- /dev/null +++ b/include/coin.block.go.h @@ -0,0 +1,26 @@ + +typedef struct{ + cipher__SHA256 Hash; + cipher__SHA256 PreHash; +} coin__HashPair; +typedef struct{ + GoUint32_ Version; + GoUint64_ Time; + GoUint64_ BkSeq; + GoUint64_ Fee; + cipher__SHA256 PrevHash; + cipher__SHA256 BodyHash; + cipher__SHA256 UxHash; +} coin__BlockHeader; +typedef struct{ + coin__Transactions Transactions; +} coin__BlockBody; +typedef struct{ + coin__BlockHeader Head; + coin__BlockBody Body; +} coin__Block; + +typedef struct{ + coin__Block _unnamed; + cipher__Sig Sig; +} coin__SignedBlock; diff --git a/include/coin.math.go.h b/include/coin.math.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/coin.transactions.go.h b/include/coin.transactions.go.h index 0fa66cac15..48efbba677 100644 --- a/include/coin.transactions.go.h +++ b/include/coin.transactions.go.h @@ -1,13 +1,9 @@ -/** - * Skycoin transaction output. - * - * Instances are integral part of transactions included in blocks. - */ -typedef struct { - cipher__Address Address; ///< Receipient address. - GoInt64_ Coins; ///< Amount sent to the receipient address. - GoInt64_ Hours; ///< Amount of Coin Hours sent to the receipient address. -} coin__TransactionOutput; +typedef GoSlice_ coin__Transactions; +typedef struct{ + coin__Transactions Txns; + GoSlice_ Fees; + GoSlice_ Hashes; +} coin__SortableTransactions; /** * Skycoin transaction. @@ -23,3 +19,14 @@ typedef struct { GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. } coin__Transaction; + +/** + * Skycoin transaction output. + * + * Instances are integral part of transactions included in blocks. + */ +typedef struct{ + cipher__Address Address; ///< Receipient address. + GoUint64_ Coins; ///< Amount sent to the receipient address. + GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. +} coin__TransactionOutput; diff --git a/include/consensus.blockstat.go.h b/include/consensus.blockstat.go.h new file mode 100644 index 0000000000..11a947abf9 --- /dev/null +++ b/include/consensus.blockstat.go.h @@ -0,0 +1,4 @@ +typedef GoSlice_ consensus__PriorityQueue; +typedef struct{ + consensus__PriorityQueue queue; +} consensus__BlockStatQueue; diff --git a/include/consensus.connection_manager.go.h b/include/consensus.connection_manager.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/consensus.consensus.go.h b/include/consensus.consensus.go.h new file mode 100644 index 0000000000..36b52554ea --- /dev/null +++ b/include/consensus.consensus.go.h @@ -0,0 +1,5 @@ +typedef struct{ + cipher__Sig Sig; + cipher__SHA256 Hash; + GoUint64_ Seqno; +} consensus__BlockBase; diff --git a/include/consensus.example.example.go.h b/include/consensus.example.example.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/consensus.example.example_gnet.go.h b/include/consensus.example.example_gnet.go.h new file mode 100644 index 0000000000..8413cbfb02 --- /dev/null +++ b/include/consensus.example.example_gnet.go.h @@ -0,0 +1,3 @@ +typedef struct{ + consensus__BlockBase _unnamed; +} main__BlockBaseWrapper; diff --git a/include/consensus.example.example_minimal.go.h b/include/consensus.example.example_minimal.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/consensus.participant.go.h b/include/consensus.participant.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h b/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/daemon.daemon.go.h b/include/daemon.daemon.go.h new file mode 100644 index 0000000000..45c1f89311 --- /dev/null +++ b/include/daemon.daemon.go.h @@ -0,0 +1,12 @@ +typedef struct{ + GoString_ Addr; + BOOL Solicited; +} daemon__ConnectEvent; +typedef struct{ + GoString_ Addr; + GoInt32_ Error; +} daemon__ConnectionError; +typedef struct{ + GoString_ Addr; + gnet__DisconnectReason Reason; +} daemon__DisconnectEvent; diff --git a/include/daemon.gateway.go.h b/include/daemon.gateway.go.h new file mode 100644 index 0000000000..ad2414ea30 --- /dev/null +++ b/include/daemon.gateway.go.h @@ -0,0 +1,13 @@ +typedef struct{ + GoInt_ BufferSize; + BOOL EnableWalletAPI; + BOOL EnableGUI; +} daemon__GatewayConfig; +typedef struct{ + GoSlice_ Txns; +} daemon__TransactionResults; +typedef struct{ + visor__TransactionStatus Status; + GoUint64_ Time; + visor__ReadableTransaction Transaction; +} daemon__TransactionResult; diff --git a/include/daemon.gnet.dispatcher.go.h b/include/daemon.gnet.dispatcher.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/daemon.gnet.message.go.h b/include/daemon.gnet.message.go.h new file mode 100644 index 0000000000..17d7861530 --- /dev/null +++ b/include/daemon.gnet.message.go.h @@ -0,0 +1,4 @@ +typedef struct{ + GoInt_ ConnID; + GoString_ Addr; +} gnet__MessageContext; diff --git a/include/daemon.gnet.pool.go.h b/include/daemon.gnet.pool.go.h new file mode 100644 index 0000000000..522c34ff4a --- /dev/null +++ b/include/daemon.gnet.pool.go.h @@ -0,0 +1 @@ +typedef GoInt32_ gnet__DisconnectReason; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h new file mode 100644 index 0000000000..f133742c8c --- /dev/null +++ b/include/daemon.messages.go.h @@ -0,0 +1,30 @@ +typedef struct{ + GoSlice_ Messages; +} daemon__MessagesConfig; +typedef struct{ + daemon__MessagesConfig Config; + GoUint32_ Mirror; +} daemon__Messages; +typedef struct{ + GoUint32_ IP; + GoUint16_ Port; +} daemon__IPAddr; +typedef struct{ + GoString_ addr; +} daemon__GetPeersMessage; +typedef struct{ +} daemon__PongMessage; +typedef struct{ + GoSlice_ Peers; + gnet__MessageContext * c; +} daemon__GivePeersMessage; +typedef struct{ + GoUint32_ Mirror; + GoUint16_ Port; + GoInt32_ Version; + gnet__MessageContext * c; + BOOL valid; +} daemon__IntroductionMessage; +typedef struct{ + gnet__MessageContext * c; +} daemon__PingMessage; diff --git a/include/daemon.pex.peerlist.go.h b/include/daemon.pex.peerlist.go.h new file mode 100644 index 0000000000..8d75a422bb --- /dev/null +++ b/include/daemon.pex.peerlist.go.h @@ -0,0 +1 @@ +typedef GoSlice_ pex__Peers; diff --git a/include/daemon.pex.pex.go.h b/include/daemon.pex.pex.go.h new file mode 100644 index 0000000000..e33ca25204 --- /dev/null +++ b/include/daemon.pex.pex.go.h @@ -0,0 +1,8 @@ +typedef struct{ + GoString_ Addr; + GoInt64_ LastSeen; + BOOL Private; + BOOL Trusted; + BOOL HasIncomingPort; + GoInt_ RetryTimes; +} pex__Peer; diff --git a/include/daemon.pool.go.h b/include/daemon.pool.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h new file mode 100644 index 0000000000..82c934991d --- /dev/null +++ b/include/daemon.rpc.go.h @@ -0,0 +1,23 @@ +typedef struct{ + GoInt_ ID; + GoString_ Addr; + GoInt64_ LastSent; + GoInt64_ LastReceived; + BOOL Outgoing; + BOOL Introduced; + GoUint32_ Mirror; + GoUint16_ ListenPort; +} daemon__Connection; +typedef struct{ + GoSlice_ Connections; +} daemon__Connections; +typedef struct{ + GoUint64_ Current; + GoUint64_ Highest; + GoSlice_ Peers; +} daemon__BlockchainProgress; +typedef struct{ + GoSlice_ Txids; +} daemon__ResendResult; +typedef struct{ +} daemon__RPC; diff --git a/include/daemon.storage.go.h b/include/daemon.storage.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/daemon.strand.strand.go.h b/include/daemon.strand.strand.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/daemon.visor.go.h b/include/daemon.visor.go.h new file mode 100644 index 0000000000..8ac65482a7 --- /dev/null +++ b/include/daemon.visor.go.h @@ -0,0 +1,29 @@ +typedef struct{ + GoString_ Address; + GoUint64_ Height; +} daemon__PeerBlockchainHeight; +typedef struct{ + GoUint64_ LastBlock; + GoUint64_ RequestedBlocks; + gnet__MessageContext * c; +} daemon__GetBlocksMessage; +typedef struct{ + GoSlice_ Blocks; + gnet__MessageContext * c; +} daemon__GiveBlocksMessage; +typedef struct{ + GoUint64_ MaxBkSeq; + gnet__MessageContext * c; +} daemon__AnnounceBlocksMessage; +typedef struct{ + GoSlice_ Txns; + gnet__MessageContext * c; +} daemon__AnnounceTxnsMessage; +typedef struct{ + GoSlice_ Txns; + gnet__MessageContext * c; +} daemon__GetTxnsMessage; +typedef struct{ + coin__Transactions Txns; + gnet__MessageContext * c; +} daemon__GiveTxnsMessage; diff --git a/include/skycriterion.h b/include/skycriterion.h index ecdf227c5c..fb36608b39 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -20,17 +20,23 @@ extern char *cr_user_GoString__tostr(GoString_ *string) ; extern int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2); extern char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1); -extern int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); -extern int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); -extern char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1); +extern int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2); +extern int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2); +extern char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1); extern int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2); extern char *cr_user_GoSlice_tostr(GoSlice *slice1); extern int cr_user_GoSlice_noteq(GoSlice *slice1, GoSlice *slice2); + +extern int cr_user_GoSlice__eq(GoSlice_ *slice1, GoSlice_ *slice2); +extern char *cr_user_GoSlice__tostr(GoSlice_ *slice1); +extern int cr_user_GoSlice__noteq(GoSlice_ *slice1, GoSlice_ *slice2); + extern int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2); extern int cr_user_cipher__SHA256_eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2); extern char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1); +extern int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2); #endif //LIBCRITERION_H diff --git a/include/skynumber.h b/include/skynumber.h new file mode 100644 index 0000000000..f3804d8fb1 --- /dev/null +++ b/include/skynumber.h @@ -0,0 +1,8 @@ +#ifndef LIBSKY_NUMBER_H +#define LIBSKY_NUMBER_H + +#include "skytypes.h" + +extern int number_eq(Number* n1, Number* n2); + +#endif \ No newline at end of file diff --git a/include/skystring.h b/include/skystring.h index b49114a80f..2d555b324a 100644 --- a/include/skystring.h +++ b/include/skystring.h @@ -9,7 +9,20 @@ extern void randBytes(GoSlice *bytes, size_t n); extern void strnhex(unsigned char* buf, char *str, int n); -extern void strhex(unsigned char* buf, char *str); +extern void strnhexlower(unsigned char* buf, char *str, int n); +extern int hexnstr(const char* hex, unsigned char* str, int n); + +extern void bin2hex(unsigned char* buf, char *str, int n); + +extern int cmpGoSlice_GoSlice(GoSlice *slice1, GoSlice_ *slice2); + +extern void bin2hex(unsigned char* buf, char *str, int n); + +extern int string_has_suffix(const char* str, const char* suffix); + +extern int string_has_prefix(const char* str, const char* prefix); + +extern int count_words(const char* str, int length); #endif //LIBSKY_STRING_H diff --git a/include/skytest.h b/include/skytest.h index ebd25d9bb1..6ca88a2396 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -1,48 +1,59 @@ #include - #include "json.h" +#include "skytypes.h" #include "skycriterion.h" #ifndef LIBSKY_TESTING_H #define LIBSKY_TESTING_H -/*---------------------------------------------------------------------- - * I/O - *---------------------------------------------------------------------- - */ +void * registerMemCleanup(void *p); + void fprintbuff(FILE *f, void *buff, size_t n); -json_value* loadJsonFile(const char* filename); -/*---------------------------------------------------------------------- - * Memory handling - *---------------------------------------------------------------------- - */ -void * registerMemCleanup(void *p); -extern void toGoString(GoString_ *s, GoString *r); +void redirectStdOut(); + +int getStdOut(char* str, unsigned int max_size); -/*---------------------------------------------------------------------- - * JSON helpers - *---------------------------------------------------------------------- - */ json_value* json_get_string(json_value* value, const char* key); + int json_set_string(json_value* value, const char* new_string_value); + int registerJsonFree(void *p); + void freeRegisteredJson(void *p); +int registerHandleClose(Handle handle); + +void closeRegisteredHandle(Handle handle); + +void freeRegisteredMemCleanup(void *p); + +int registerWalletClean(Client__Handle clientHandle, + WalletResponse__Handle walletHandle); + +void cleanRegisteredWallet( + Client__Handle client, + WalletResponse__Handle wallet); + json_value* loadJsonFile(const char* filename); + int compareJsonValues(json_value* value1, json_value* value2); + json_value* get_json_value(json_value* node, const char* path, json_type type); + json_value* get_json_value_not_strict(json_value* node, const char* path, json_type type, int allow_null); + +int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, const char* ignoreList); -/*---------------------------------------------------------------------- - * JSON helpers - *---------------------------------------------------------------------- - */ +int parseBoolean(const char* str, int length); + void setup(void); void teardown(void); + +extern void toGoString(GoString_ *s, GoString *r); #endif diff --git a/include/skytypes.gen.h b/include/skytypes.gen.h new file mode 100644 index 0000000000..1448d53d94 --- /dev/null +++ b/include/skytypes.gen.h @@ -0,0 +1,124 @@ +#include "cipher.hash.go.h" +#include "cipher.address.go.h" +#include "cipher.base58.base58.go.h" +#include "cipher.chacha20poly1305.chacha20poly1305.go.h" +#include "cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" +#include "cipher.chacha20poly1305.chacha20poly1305_generic.go.h" +#include "cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" +#include "cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" +#include "cipher.crypto.go.h" +#include "cipher.encoder.encoder.go.h" +#include "cipher.encoder.field.go.h" +#include "cipher.encrypt.scrypt_chacha20poly1305.go.h" +#include "cipher.encrypt.sha256xor.go.h" +#include "cipher.go-bip39.bip39.go.h" +#include "cipher.go-bip39.wordlist.go.h" + +#include "cipher.pbkdf2.pbkdf2.go.h" +#include "cipher.poly1305.poly1305.go.h" +#include "cipher.poly1305.sum_amd64.go.h" +#include "cipher.poly1305.sum_arm.go.h" +#include "cipher.poly1305.sum_ref.go.h" +#include "cipher.ripemd160.ripemd160block.go.h" +#include "cipher.ripemd160.ripmd_160.go.h" +#include "cipher.scrypt.scrypt.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.ec.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.field.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.num.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.sig.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" +#include "cipher.secp256k1-go.secp256k1-go2.z_init.go.h" +#include "cipher.secp256k1-go.secp256k1.go.h" +#include "cipher.secp256k1-go.secp256_rand.go.h" +#include "coin.transactions.go.h" +#include "coin.block.go.h" +#include "coin.outputs.go.h" + +#include "consensus.blockstat.go.h" +#include "consensus.connection_manager.go.h" +#include "consensus.consensus.go.h" +#include "consensus.participant.go.h" +#include "consensus.public_broadcast_channel.public_broadcast_channel.go.h" + + +#include "testutil.assert.assertions.go.h" +#include "testutil.require.require.go.h" +#include "util.browser.browser.go.h" +#include "util.cert.cert.go.h" +#include "util.droplet.droplet.go.h" +#include "util.elapse.elapser.go.h" +#include "util.fee.fee.go.h" +#include "util.file.file.go.h" +#include "util.http.error.go.h" +#include "util.http.handler.go.h" +#include "util.http.json.go.h" +#include "util.http.log.go.h" +#include "util.iputil.iputil.go.h" +#include "util.logging.formatter.go.h" +#include "util.logging.hooks.go.h" +#include "util.logging.logger.go.h" +#include "util.logging.logging.go.h" +#include "util.utc.utc.go.h" +#include "visor.blockchain.go.h" +#include "visor.visor.go.h" +#include "visor.blockdb.blockchain.go.h" +#include "visor.blockdb.blocksigs.go.h" +#include "visor.blockdb.block_tree.go.h" +#include "visor.blockdb.unspent.go.h" +#include "visor.db.go.h" +#include "visor.distribution.go.h" +#include "visor.historydb.address_txn.go.h" +#include "visor.historydb.address_uxout.go.h" +#include "visor.historydb.historydb.go.h" +#include "visor.historydb.history_meta.go.h" +#include "visor.historydb.output.go.h" +#include "visor.historydb.transaction.go.h" +#include "visor.readable.go.h" +#include "visor.richlist.go.h" +#include "visor.unconfirmed.go.h" +#include "visor.verify.go.h" + + +#include "daemon.gnet.pool.go.h" +#include "daemon.gnet.message.go.h" +#include "daemon.messages.go.h" +#include "daemon.daemon.go.h" +#include "daemon.gateway.go.h" +#include "daemon.gnet.dispatcher.go.h" +#include "daemon.pex.peerlist.go.h" +#include "daemon.pex.pex.go.h" +#include "daemon.pool.go.h" +#include "daemon.rpc.go.h" +#include "daemon.storage.go.h" +#include "daemon.strand.strand.go.h" +#include "daemon.visor.go.h" + +#include "api.webrpc.block.go.h" +#include "api.webrpc.client.go.h" +#include "api.webrpc.gateway.go.h" +#include "api.webrpc.outputs.go.h" +#include "api.webrpc.status.go.h" +#include "api.webrpc.transaction.go.h" +#include "api.webrpc.uxout.go.h" +#include "api.webrpc.webrpc.go.h" +#include "wallet.addresses.go.h" +#include "wallet.balance.go.h" +#include "wallet.crypto.go.h" +#include "wallet.entry.go.h" +#include "wallet.notes.go.h" +#include "wallet.readable.go.h" +#include "wallet.secrets.go.h" +#include "wallet.service.go.h" +#include "wallet.wallet.go.h" +#include "wallet.wallets.go.h" + +#include "api.client.go.h" +#include "api.explorer.go.h" +#include "api.spend.go.h" +#include "api.wallet.go.h" +#include "cli.check_balance.go.h" +#include "cli.cli.go.h" +#include "cli.create_rawtx.go.h" \ No newline at end of file diff --git a/include/skytypes.h b/include/skytypes.h index b15d8464ac..0929bd8455 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -59,11 +59,13 @@ typedef double GoFloat64_; /** * Instances of Go `complex` type. */ -typedef float _Complex GoComplex64_; +typedef struct{float real; float imaginary;} GoComplex64_; /** * Instances of Go `complex` type. */ -typedef double _Complex GoComplex128_; +typedef struct{double real; double imaginary;} GoComplex128_; +typedef unsigned int BOOL; +typedef unsigned int error; /* static assertion to make sure the file is being used on architecture @@ -83,17 +85,97 @@ typedef struct { * Instances of Go `map` type. */ typedef void *GoMap_; + /** * Instances of Go `chan` channel types. */ typedef void *GoChan_; + +/** + * Memory handles returned back to the caller and manipulated + * internally by API functions. Usually used to avoid type dependencies + * with internal implementation types. + */ +typedef GoInt64_ Handle; + +/** + * Webrpc Client Handle +*/ +typedef Handle WebRpcClient__Handle; + +/** + * Wallet Handle +*/ +typedef Handle Wallet__Handle; + +/** + * ReadableWallet Handle +*/ +typedef Handle ReadableWallet__Handle; + +/** + * ReadableEntry Handle +*/ +typedef Handle ReadableEntry__Handle; + +/** + * Options Handle +*/ +typedef Handle Options__Handle; + + +/** + * Config Handle +*/ +typedef Handle Config__Handle; + +/** + * App Handle +*/ +typedef Handle App__Handle; + +/** + * Gcli Context Handle +*/ +typedef Handle Context__Handle; + +/** + * API Client Handle +*/ +typedef Handle Client__Handle; + +/** + * Wallet Response Handle +*/ +typedef Handle WalletResponse__Handle; + +/** + * Create Transaction Request Handle +*/ +typedef Handle CreateTransactionRequest__Handle; + +/** + * String Slice Handle +*/ +typedef Handle Strings__Handle; + +/** + * Instances of Go `map` type, deal map[string] as handle + */ +typedef Handle GoStringMap_; + +/** + * Wallets Handle, slice of Wallet +*/ +typedef Handle Wallets__Handle; + /** * Instances of Go interface types. */ typedef struct { void *t; ///< Pointer to the information of the concrete Go type ///< bound to this interface reference. - void *v; ///< Pointer to the data corresponding to the value + void *v; ///< Pointer to the data corresponding to the value ///< bound to this interface type. } GoInterface_; /** @@ -107,13 +189,34 @@ typedef struct { ///< size. } GoSlice_; +typedef struct { + BOOL neg; + GoSlice_ nat; +} Number; /** - * Memory handles returned back to the caller and manipulated - * internally by API functions. Usually used to avoid type dependencies - * with internal implementation types. + * RIPEMD-160 hash. */ -typedef GoInt64_ Handle; +typedef unsigned char Ripemd160[20]; + +typedef struct { + //TODO: stdevEclipse Define Signature + Number R; + Number S; +} Signature; + +#include "skytypes.gen.h" + +/** + * Internal representation of a Skycoin wallet. + */ +typedef struct { + GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. + GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. +} Wallet; + +typedef GoUint8_ poly1305__Mac[16]; +typedef GoUint8_ poly1305__Key[32]; /** * Memory handle for internal object retrieving password to read @@ -141,7 +244,7 @@ typedef Handle Options__Handle; * Memory handle to access to Skycoin CLI configuration */ typedef Handle Config__Handle; - +/* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" #include "cipher.address.go.h" @@ -150,6 +253,6 @@ typedef Handle Config__Handle; #include "coin.transactions.go.h" #include "wallet.entry.go.h" #include "wallet.wallet.go.h" - +*/ #endif diff --git a/include/testutil.assert.assertions.go.h b/include/testutil.assert.assertions.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/testutil.require.require.go.h b/include/testutil.require.require.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/testutil.testutil.go.h b/include/testutil.testutil.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.apputil.apputil.go.h b/include/util.apputil.apputil.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.browser.browser.go.h b/include/util.browser.browser.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.cert.cert.go.h b/include/util.cert.cert.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.droplet.droplet.go.h b/include/util.droplet.droplet.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.elapse.elapser.go.h b/include/util.elapse.elapser.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.fee.fee.go.h b/include/util.fee.fee.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.file.file.go.h b/include/util.file.file.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.http.error.go.h b/include/util.http.error.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.http.handler.go.h b/include/util.http.handler.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.http.json.go.h b/include/util.http.json.go.h new file mode 100644 index 0000000000..84cb0e0361 --- /dev/null +++ b/include/util.http.json.go.h @@ -0,0 +1,5 @@ +typedef GoUint64_ httphelper__Coins; +typedef GoUint64_ httphelper__Hours; +typedef struct{ + cipher__Address _unnamed; +} httphelper__Address; diff --git a/include/util.http.log.go.h b/include/util.http.log.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.iputil.iputil.go.h b/include/util.iputil.iputil.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.logging.formatter.go.h b/include/util.logging.formatter.go.h new file mode 100644 index 0000000000..58f8dab875 --- /dev/null +++ b/include/util.logging.formatter.go.h @@ -0,0 +1,12 @@ +typedef struct{ + GoString_ InfoLevelStyle; + GoString_ WarnLevelStyle; + GoString_ ErrorLevelStyle; + GoString_ FatalLevelStyle; + GoString_ PanicLevelStyle; + GoString_ DebugLevelStyle; + GoString_ PrefixStyle; + GoString_ TimestampStyle; + GoString_ CallContextStyle; + GoString_ CriticalStyle; +} logging__ColorScheme; diff --git a/include/util.logging.hooks.go.h b/include/util.logging.hooks.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.logging.logger.go.h b/include/util.logging.logger.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.logging.logging.go.h b/include/util.logging.logging.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/util.utc.utc.go.h b/include/util.utc.utc.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/visor.blockchain.go.h b/include/visor.blockchain.go.h new file mode 100644 index 0000000000..33277ba6a8 --- /dev/null +++ b/include/visor.blockchain.go.h @@ -0,0 +1,8 @@ +typedef struct{ + BOOL Arbitrating; + cipher__PubKey Pubkey; +} visor__BlockchainConfig; +typedef struct{ + cipher__Sig sig; + cipher__SHA256 hash; +} visor__sigHash; diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h new file mode 100644 index 0000000000..deb16ea9ad --- /dev/null +++ b/include/visor.blockdb.block_tree.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} blockdb__blockTree; diff --git a/include/visor.blockdb.blockchain.go.h b/include/visor.blockdb.blockchain.go.h new file mode 100644 index 0000000000..ade4c24131 --- /dev/null +++ b/include/visor.blockdb.blockchain.go.h @@ -0,0 +1,3 @@ +typedef struct{ + coin__Block * b; +} blockdb__ErrMissingSignature; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h new file mode 100644 index 0000000000..29e49599d1 --- /dev/null +++ b/include/visor.blockdb.blocksigs.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} blockdb__blockSigs; diff --git a/include/visor.blockdb.chain_meta.go.h b/include/visor.blockdb.chain_meta.go.h new file mode 100644 index 0000000000..7d2cdc3053 --- /dev/null +++ b/include/visor.blockdb.chain_meta.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} blockdb__chainMeta; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h new file mode 100644 index 0000000000..4606d88f97 --- /dev/null +++ b/include/visor.blockdb.unspent.go.h @@ -0,0 +1,9 @@ +typedef struct{ + GoString_ UxID; +} blockdb__ErrUnspentNotExist; +typedef struct{ +} blockdb__unspentMeta; +typedef struct{ +} blockdb__pool; +typedef struct{ +} blockdb__poolAddrIndex; diff --git a/include/visor.db.go.h b/include/visor.db.go.h new file mode 100644 index 0000000000..caa2070624 --- /dev/null +++ b/include/visor.db.go.h @@ -0,0 +1,3 @@ +typedef struct{ + GoInt32_ _unnamed; +} visor__ErrCorruptDB; diff --git a/include/visor.dbutil.dbutil.go.h b/include/visor.dbutil.dbutil.go.h new file mode 100644 index 0000000000..c86978a042 --- /dev/null +++ b/include/visor.dbutil.dbutil.go.h @@ -0,0 +1,7 @@ +typedef struct{ + GoString_ Bucket; + GoInt32_ Err; +} dbutil__ErrCreateBucketFailed; +typedef struct{ + GoString_ Bucket; +} dbutil__ErrBucketNotExist; diff --git a/include/visor.distribution.go.h b/include/visor.distribution.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h new file mode 100644 index 0000000000..461204b534 --- /dev/null +++ b/include/visor.historydb.address_txn.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h new file mode 100644 index 0000000000..04a5acd6d4 --- /dev/null +++ b/include/visor.historydb.address_uxout.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h new file mode 100644 index 0000000000..be4cbdf596 --- /dev/null +++ b/include/visor.historydb.history_meta.go.h @@ -0,0 +1,2 @@ +typedef struct{ +} historydb__historyMeta; diff --git a/include/visor.historydb.historydb.go.h b/include/visor.historydb.historydb.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h new file mode 100644 index 0000000000..ab77b04b78 --- /dev/null +++ b/include/visor.historydb.output.go.h @@ -0,0 +1,18 @@ +typedef struct{ + GoString_ Uxid; + GoUint64_ Time; + GoUint64_ SrcBkSeq; + GoString_ SrcTx; + GoString_ OwnerAddress; + GoUint64_ Coins; + GoUint64_ Hours; + GoUint64_ SpentBlockSeq; + GoString_ SpentTxID; +} historydb__UxOutJSON; +typedef struct{ +} historydb__UxOuts; +typedef struct{ + coin__UxOut Out; + cipher__SHA256 SpentTxID; + GoUint64_ SpentBlockSeq; +} historydb__UxOut; diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h new file mode 100644 index 0000000000..75c6205bdf --- /dev/null +++ b/include/visor.historydb.transaction.go.h @@ -0,0 +1,6 @@ +typedef struct{ +} historydb__transactions; +typedef struct{ + coin__Transaction Tx; + GoUint64_ BlockSeq; +} historydb__Transaction; diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h new file mode 100644 index 0000000000..bac09f1429 --- /dev/null +++ b/include/visor.readable.go.h @@ -0,0 +1,90 @@ +typedef struct{ + BOOL Confirmed; + BOOL Unconfirmed; + GoUint64_ Height; + GoUint64_ BlockSeq; + BOOL Unknown; +} visor__TransactionStatus; +typedef struct{ + GoString_ Hash; + GoString_ Address; + GoString_ Coins; + GoUint64_ Hours; +} visor__ReadableTransactionOutput; +typedef struct{ + GoString_ Hash; + GoString_ Address; + GoString_ Coins; + GoUint64_ Hours; +} visor__ReadableTransactionInput; +typedef struct{ + GoString_ Hash; + GoUint64_ Time; + GoUint64_ BkSeq; + GoString_ SourceTransaction; + GoString_ Address; + GoString_ Coins; + GoUint64_ Hours; + GoUint64_ CalculatedHours; +} visor__ReadableOutput; +typedef GoSlice_ visor__ReadableOutputs; +typedef struct{ + GoUint32_ Length; + GoUint8_ Type; + GoString_ Hash; + GoString_ InnerHash; + GoUint64_ Timestamp; + GoSlice_ Sigs; + GoSlice_ In; + GoSlice_ Out; +} visor__ReadableTransaction; +typedef struct{ + GoUint64_ BkSeq; + GoString_ BlockHash; + GoString_ PreviousBlockHash; + GoUint64_ Time; + GoUint64_ Fee; + GoUint32_ Version; + GoString_ BodyHash; +} visor__ReadableBlockHeader; +typedef struct{ + GoSlice_ Transactions; +} visor__ReadableBlockBody; +typedef struct{ + visor__ReadableBlockHeader Head; + visor__ReadableBlockBody Body; + GoInt_ Size; +} visor__ReadableBlock; +typedef struct{ + GoSlice_ Blocks; +} visor__ReadableBlocks; +typedef struct{ + GoString_ Hash; + GoString_ SourceTransaction; + GoString_ Address; + GoString_ Coins; + GoUint64_ Hours; +} visor__TransactionOutputJSON; +typedef struct{ + GoString_ Hash; + GoString_ InnerHash; + GoSlice_ Sigs; + GoSlice_ In; + GoSlice_ Out; +} visor__TransactionJSON; +typedef struct{ + visor__ReadableBlockHeader Head; + GoUint64_ Unspents; + GoUint64_ Unconfirmed; +} visor__BlockchainMetadata; +typedef struct{ + visor__ReadableOutputs HeadOutputs; + visor__ReadableOutputs OutgoingOutputs; + visor__ReadableOutputs IncomingOutputs; +} visor__ReadableOutputSet; +typedef struct{ + coin__Transaction Txn; + visor__TransactionStatus Status; + GoUint64_ Time; + GoInt_ Size; +} visor__Transaction; diff --git a/include/visor.richlist.go.h b/include/visor.richlist.go.h new file mode 100644 index 0000000000..6ad0998e61 --- /dev/null +++ b/include/visor.richlist.go.h @@ -0,0 +1,7 @@ +typedef struct{ + GoString_ Address; + GoString_ Coins; + BOOL Locked; + GoUint64_ coins; +} visor__RichlistBalance; +typedef GoSlice_ visor__Richlist; diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h new file mode 100644 index 0000000000..7366404211 --- /dev/null +++ b/include/visor.unconfirmed.go.h @@ -0,0 +1,11 @@ +typedef struct{ +} visor__unconfirmedTxns; +typedef struct{ +} visor__txUnspents; +typedef struct{ + coin__Transaction Txn; + GoInt64_ Received; + GoInt64_ Checked; + GoInt64_ Announced; + GoInt8_ IsValid; +} visor__UnconfirmedTxn; diff --git a/include/visor.verify.go.h b/include/visor.verify.go.h new file mode 100644 index 0000000000..284d1638f1 --- /dev/null +++ b/include/visor.verify.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoInt32_ Err; +} visor__ErrTxnViolatesHardConstraint; +typedef struct{ + GoInt32_ Err; +} visor__ErrTxnViolatesSoftConstraint; diff --git a/include/visor.visor.go.h b/include/visor.visor.go.h new file mode 100644 index 0000000000..5bb3f2f9a0 --- /dev/null +++ b/include/visor.visor.go.h @@ -0,0 +1,8 @@ +typedef struct{ + GoString_ Version; + GoString_ Commit; + GoString_ Branch; +} visor__BuildInfo; +typedef struct{ + GoSlice_ Addrs; +} visor__addrsFilter; diff --git a/include/wallet.addresses.go.h b/include/wallet.addresses.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/wallet.balance.go.h b/include/wallet.balance.go.h new file mode 100644 index 0000000000..7c5fb1f493 --- /dev/null +++ b/include/wallet.balance.go.h @@ -0,0 +1,8 @@ +typedef struct{ + GoUint64_ Coins; + GoUint64_ Hours; +} wallet__Balance; +typedef struct{ + wallet__Balance Confirmed; + wallet__Balance Predicted; +} wallet__BalancePair; diff --git a/include/wallet.crypto.go.h b/include/wallet.crypto.go.h new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/include/wallet.crypto.go.h @@ -0,0 +1 @@ + diff --git a/include/wallet.entry.go.h b/include/wallet.entry.go.h index 362bb76494..7cf6a23377 100644 --- a/include/wallet.entry.go.h +++ b/include/wallet.entry.go.h @@ -1,3 +1,4 @@ + /** * Wallet entry. */ diff --git a/include/wallet.notes.go.h b/include/wallet.notes.go.h new file mode 100644 index 0000000000..7fdce9e75c --- /dev/null +++ b/include/wallet.notes.go.h @@ -0,0 +1,10 @@ +typedef GoSlice_ wallet__Notes; +typedef struct{ + GoString_ TxID; + GoString_ Value; +} wallet__Note; +typedef GoSlice_ wallet__ReadableNotes; +typedef struct{ + GoString_ TransactionID; + GoString_ ActualNote; +} wallet__ReadableNote; diff --git a/include/wallet.readable.go.h b/include/wallet.readable.go.h new file mode 100644 index 0000000000..69057bc363 --- /dev/null +++ b/include/wallet.readable.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoString_ Address; + GoString_ Public; + GoString_ Secret; +} wallet__ReadableEntry; +typedef GoSlice_ wallet__ReadableEntries; diff --git a/include/wallet.secrets.go.h b/include/wallet.secrets.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/wallet.service.go.h b/include/wallet.service.go.h new file mode 100644 index 0000000000..dae4d8cdce --- /dev/null +++ b/include/wallet.service.go.h @@ -0,0 +1,6 @@ +typedef struct{ + GoString_ WalletDir; + GoString_ CryptoType; + BOOL EnableWalletAPI; + BOOL EnableSeedAPI; +} wallet__Config; diff --git a/include/wallet.wallet.go.h b/include/wallet.wallet.go.h index 2605cde0f9..fb405c5741 100644 --- a/include/wallet.wallet.go.h +++ b/include/wallet.wallet.go.h @@ -1,3 +1,23 @@ + +/** + * Internal representation of a Skycoin wallet. + */ +typedef struct { + GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. + GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. +} wallet__Wallet; + +typedef GoInterface_ wallet__Validator; + +typedef struct{ + GoString_ Coin; + GoString_ Label; + GoString_ Seed; + BOOL Encrypt; + GoSlice_ Password; + GoString_ CryptoType; +} wallet__Options; + /** * Intermediate representation of a UxOut for sorting and spend choosing. */ @@ -9,11 +29,3 @@ typedef struct { GoInt64_ Coins; ///< Coins amount (e.g. in SKY). GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. } wallet__UxBalance; - -/** - * Internal representation of a Skycoin wallet. - */ -typedef struct { - GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. - GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. -} wallet__Wallet; diff --git a/include/wallet.wallets.go.h b/include/wallet.wallets.go.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/cgo/api.blockchain.go b/lib/cgo/api.blockchain.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.blockchain.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go new file mode 100644 index 0000000000..883184b2ed --- /dev/null +++ b/lib/cgo/api.client.go @@ -0,0 +1,1001 @@ +package main + +import ( + "unsafe" + + api "github.com/skycoin/skycoin/src/api" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_ClientError_Error +func SKY_api_ClientError_Error(_e *C.api__ClientError, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + e := *(*api.ClientError)(unsafe.Pointer(_e)) + __arg0 := e.Error() + copyString(__arg0, _arg0) + return +} + +//export SKY_api_NewClient +func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := _addr + __arg1 := api.NewClient(addr) + *_arg1 = registerClientHandle(__arg1) + return +} + +//export SKY_api_Client_CSRF +func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.CSRF() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_api_Client_Version +func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.Version() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_Outputs +func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.Outputs() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_OutputsForAddresses +func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.OutputsForAddresses(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_OutputsForHashes +func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + hashes := *(*[]string)(unsafe.Pointer(&_hashes)) + __arg1, ____return_err := c.OutputsForHashes(hashes) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_CoinSupply +func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.CoinSupply() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_BlockByHash +func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + hash := _hash + __arg1, ____return_err := c.BlockByHash(hash) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_BlockBySeq +func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + seq := _seq + __arg1, ____return_err := c.BlockBySeq(seq) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Blocks +func SKY_api_Client_Blocks(_c C.Client__Handle, _start, _end int, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + start := _start + end := _end + __arg1, ____return_err := c.Blocks(start, end) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_LastBlocks +func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n int, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + n := _n + __arg1, ____return_err := c.LastBlocks(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_BlockchainMetadata +func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.BlockchainMetadata() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_BlockchainProgress +func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.BlockchainProgress() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_Balance +func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.Balance(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__BalancePair)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_api_Client_UxOut +func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + uxID := _uxID + __arg1, ____return_err := c.UxOut(uxID) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_AddressUxOuts +func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addr := _addr + __arg1, ____return_err := c.AddressUxOuts(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Wallet +func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + __arg1, ____return_err := c.Wallet(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletResponseHandle(__arg1) + } + return +} + +//export SKY_api_Client_Wallets +func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.Wallets() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerWalletsHandle(__arg0) + } + return +} + +//export SKY_api_Client_CreateUnencryptedWallet +func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + seed := _seed + label := _label + scanN := _scanN + __arg2, ____return_err := c.CreateUnencryptedWallet(seed, label, scanN) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_CreateEncryptedWallet +func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _password string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + seed := _seed + label := _label + password := _password + scanN := _scanN + __arg2, ____return_err := c.CreateEncryptedWallet(seed, label, password, scanN) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_NewWalletAddress +func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _password string, _arg3 *C.Strings__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + n := _n + password := _password + __arg3, ____return_err := c.NewWalletAddress(id, n, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = (C.Strings__Handle)(registerHandle(__arg3)) + } + return +} + +//export SKY_api_Client_WalletBalance +func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + __arg1, ____return_err := c.WalletBalance(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__BalancePair)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_api_Client_Spend +func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.api__SpendResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + dst := _dst + coins := _coins + password := _password + __arg3, ____return_err := c.Spend(id, dst, coins, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = *(*C.api__SpendResult)(unsafe.Pointer(__arg3)) + } + return +} + +//export SKY_api_Client_CreateTransaction +func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.api__CreateTransactionResponse) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + req, okreq := lookupCreateTransactionRequestHandle(C.CreateTransactionRequest__Handle(*_req)) + if !okreq { + ____error_code = SKY_ERROR + return + } + __arg1, ____return_err := c.CreateTransaction(*req) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.api__CreateTransactionResponse)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_api_Client_WalletTransactions +func SKY_api_Client_WalletTransactions(_c C.Client__Handle, _id string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + __arg1, ____return_err := c.WalletTransactions(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_UpdateWallet +func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + label := _label + ____return_err := c.UpdateWallet(id, label) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_api_Client_WalletFolderName +func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.WalletFolderName() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NewSeed +func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + entropy := _entropy + __arg1, ____return_err := c.NewSeed(entropy) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_GetWalletSeed +func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + password := _password + __arg2, ____return_err := c.GetWalletSeed(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg2, _arg2) + } + return +} + +//export SKY_api_Client_NetworkConnection +func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addr := _addr + __arg1, ____return_err := c.NetworkConnection(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_NetworkConnections +func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.NetworkConnections() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NetworkDefaultConnections +func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.NetworkDefaultConnections() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NetworkTrustedConnections +func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.NetworkTrustedConnections() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NetworkExchangeableConnections +func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.NetworkExchangeableConnections() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_PendingTransactions +func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.PendingTransactions() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_Transaction +func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + txid := _txid + __arg1, ____return_err := c.Transaction(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Transactions +func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.Transactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_ConfirmedTransactions +func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.ConfirmedTransactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_UnconfirmedTransactions +func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.UnconfirmedTransactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_InjectTransaction +func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + rawTx := _rawTx + __arg1, ____return_err := c.InjectTransaction(rawTx) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_ResendUnconfirmedTransactions +func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.ResendUnconfirmedTransactions() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_RawTransaction +func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + txid := _txid + __arg1, ____return_err := c.RawTransaction(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_AddressTransactions +func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addr := _addr + __arg1, ____return_err := c.AddressTransactions(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Richlist +func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + params := (*api.RichlistParams)(unsafe.Pointer(_params)) + __arg1, ____return_err := c.Richlist(params) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_AddressCount +func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.AddressCount() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_api_Client_UnloadWallet +func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + ____return_err := c.UnloadWallet(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_api_Client_Health +func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.Health() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_EncryptWallet +func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + password := _password + __arg2, ____return_err := c.EncryptWallet(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_DecryptWallet +func SKY_api_Client_DecryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + id := _id + password := _password + __arg2, ____return_err := c.DecryptWallet(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} diff --git a/lib/cgo/api.csrf.go b/lib/cgo/api.csrf.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.csrf.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.gateway.go b/lib/cgo/api.gateway.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.gateway.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.health.go b/lib/cgo/api.health.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.health.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.http.go b/lib/cgo/api.http.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.http.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.integration.empty.go b/lib/cgo/api.integration.empty.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.integration.empty.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.network.go b/lib/cgo/api.network.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.network.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.notes.go b/lib/cgo/api.notes.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.notes.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go new file mode 100644 index 0000000000..a042e4a26a --- /dev/null +++ b/lib/cgo/api.spend.go @@ -0,0 +1,97 @@ +package main + +import ( + "unsafe" + + api "github.com/skycoin/skycoin/src/api" + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_NewCreateTransactionResponse +func SKY_api_NewCreateTransactionResponse(_txn *C.coin__Transaction, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreateTransactionResponse) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) + __arg2, ____return_err := api.NewCreateTransactionResponse(txn, inputs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.api__CreateTransactionResponse)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_api_NewCreatedTransaction +func SKY_api_NewCreatedTransaction(_txn *C.coin__Transaction, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreatedTransaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) + __arg2, ____return_err := api.NewCreatedTransaction(txn, inputs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.api__CreatedTransaction)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_api_CreatedTransaction_ToTransaction +func SKY_api_CreatedTransaction_ToTransaction(_r *C.api__CreatedTransaction, _arg0 *C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + r := (*api.CreatedTransaction)(unsafe.Pointer(_r)) + __arg0, ____return_err := r.ToTransaction() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = *(*C.coin__Transaction)(unsafe.Pointer(__arg0)) + } + return +} + +//export SKY_api_NewCreatedTransactionOutput +func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.api__CreatedTransactionOutput) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + out := *(*coin.TransactionOutput)(unsafe.Pointer(_out)) + txid := *(*cipher.SHA256)(unsafe.Pointer(_txid)) + __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.api__CreatedTransactionOutput)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_api_NewCreatedTransactionInput +func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.api__CreatedTransactionInput) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + out := *(*wallet.UxBalance)(unsafe.Pointer(_out)) + __arg1, ____return_err := api.NewCreatedTransactionInput(out) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.api__CreatedTransactionInput)(unsafe.Pointer(__arg1)) + } + return +} diff --git a/lib/cgo/api.transaction.go b/lib/cgo/api.transaction.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.transaction.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.uxout.go b/lib/cgo/api.uxout.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.uxout.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.wallet.go b/lib/cgo/api.wallet.go new file mode 100644 index 0000000000..8eb41e4e15 --- /dev/null +++ b/lib/cgo/api.wallet.go @@ -0,0 +1,31 @@ +package main + +import api "github.com/skycoin/skycoin/src/api" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_NewWalletResponse +func SKY_api_NewWalletResponse(_w C.Wallet__Handle, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_ERROR + return + } + __arg1, ____return_err := api.NewWalletResponse(w) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletResponseHandle(__arg1) + } + return +} diff --git a/lib/cgo/api.webrpc.block.go b/lib/cgo/api.webrpc.block.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.block.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index a185aa0ed1..a7da5e1f6c 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -1,17 +1,34 @@ package main import ( + "reflect" + "unsafe" + webrpc "github.com/skycoin/skycoin/src/api/webrpc" + coin "github.com/skycoin/skycoin/src/coin" ) /* + #include #include - #include "skytypes.h" + #include "skytypes.h" */ import "C" +//export SKY_webrpc_ClientError_Error +func SKY_webrpc_ClientError_Error(_e *C.webrpc__ClientError, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + e := *(*webrpc.ClientError)(unsafe.Pointer(_e)) + __arg0 := e.Error() + copyString(__arg0, _arg0) + return +} + //export SKY_webrpc_NewClient func SKY_webrpc_NewClient(_addr string, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { ____error_code = 0 @@ -45,3 +62,183 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ } return } + +//export SKY_webrpc_Client_GetUnspentOutputs +func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.webrpc__OutputsResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.GetUnspentOutputs(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_webrpc_Client_InjectTransactionString +func SKY_webrpc_Client_InjectTransactionString(_c C.WebRpcClient__Handle, _rawtx string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + rawtx := _rawtx + __arg1, ____return_err := c.InjectTransactionString(rawtx) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_webrpc_Client_InjectTransaction +func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx *C.coin__Transaction, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + __arg1, ____return_err := c.InjectTransaction(tx) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_webrpc_Client_GetStatus +func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__StatusResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg0, ____return_err := c.GetStatus() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = *(*C.webrpc__StatusResult)(unsafe.Pointer(__arg0)) + } + return +} + +//export SKY_webrpc_Client_GetTransactionByID +func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.webrpc__TxnResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + txid := _txid + __arg1, ____return_err := c.GetTransactionByID(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.webrpc__TxnResult)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_webrpc_Client_GetAddressUxOuts +func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.GetAddressUxOuts(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_webrpc_Client_GetBlocks +func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + start := _start + end := _end + __arg1, ____return_err := c.GetBlocks(start, end) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_webrpc_Client_GetBlocksBySeq +func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + ss := *(*[]uint64)(unsafe.Pointer(&_ss)) + __arg1, ____return_err := c.GetBlocksBySeq(ss) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_webrpc_Client_GetLastBlocks +func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + n := _n + __arg1, ____return_err := c.GetLastBlocks(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + } + return +} diff --git a/lib/cgo/api.webrpc.gateway.go b/lib/cgo/api.webrpc.gateway.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.gateway.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.outputs.go b/lib/cgo/api.webrpc.outputs.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.outputs.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.status.go b/lib/cgo/api.webrpc.status.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.status.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.transaction.go b/lib/cgo/api.webrpc.transaction.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.transaction.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.uxout.go b/lib/cgo/api.webrpc.uxout.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/api.webrpc.uxout.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/api.webrpc.webrpc.go b/lib/cgo/api.webrpc.webrpc.go new file mode 100644 index 0000000000..be2d44f87c --- /dev/null +++ b/lib/cgo/api.webrpc.webrpc.go @@ -0,0 +1,28 @@ +package main + +import ( + "unsafe" + + webrpc "github.com/skycoin/skycoin/src/api/webrpc" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_webrpc_RPCError_Error +func SKY_webrpc_RPCError_Error(_e *C.webrpc__RPCError, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + e := *(*webrpc.RPCError)(unsafe.Pointer(_e)) + __arg0 := e.Error() + copyString(__arg0, _arg0) + return +} diff --git a/lib/cgo/cipher.address.go b/lib/cgo/cipher.address.go index 8c1abeb3af..86e517dcc0 100644 --- a/lib/cgo/cipher.address.go +++ b/lib/cgo/cipher.address.go @@ -1,25 +1,22 @@ package main +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" +) + /* + #include #include - #include "skytypes.h" + #include "skytypes.h" */ import "C" -import ( - "reflect" - "unsafe" - - "github.com/skycoin/skycoin/src/cipher" -) - -/** - * Functions in github.com/skycoin/skycoin/src/cipher/address.go - */ - //export SKY_cipher_DecodeBase58Address func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) uint32 { addr, err := cipher.DecodeBase58Address(_addr) @@ -30,20 +27,61 @@ func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) uint return errcode } +//export SKY_cipher_MustDecodeBase58Address +func SKY_cipher_MustDecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := _addr + __arg1 := cipher.MustDecodeBase58Address(addr) + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_cipher_BitcoinMustDecodeBase58Address +func SKY_cipher_BitcoinMustDecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := _addr + __arg1 := cipher.BitcoinMustDecodeBase58Address(addr) + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_cipher_AddressFromBytes +func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1, ____return_err := cipher.AddressFromBytes(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) + } + return +} + //export SKY_cipher_AddressFromPubKey -func SKY_cipher_AddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__Address) { +func SKY_cipher_AddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__Address) uint32 { pubKey := (*cipher.PubKey)(unsafe.Pointer(_pubKey)) addr := cipher.AddressFromPubKey(*pubKey) *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + return SKY_OK } //export SKY_cipher_AddressFromSecKey -func SKY_cipher_AddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__Address) { +func SKY_cipher_AddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__Address) uint32 { var secKey cipher.SecKey secKey = *(*cipher.SecKey)(unsafe.Pointer(_secKey)) addr := cipher.AddressFromSecKey(secKey) *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + return SKY_OK } //export SKY_cipher_BitcoinDecodeBase58Address @@ -56,18 +94,47 @@ func SKY_cipher_BitcoinDecodeBase58Address(_addr string, _arg1 *C.cipher__Addres return errcode } +//export SKY_cipher_MustAddressFromBytes +func SKY_cipher_MustAddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1, ____return_err := cipher.MustAddressFromBytes(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) + } + return +} + //export SKY_cipher_Address_Bytes -func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) { +func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) bytes := addr.Bytes() copyToGoSlice(reflect.ValueOf(bytes), _arg0) + return SKY_OK +} + +//export SKY_cipher_Address_Null +func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := *inplaceAddress(_addr) + __arg0 := addr.Null() + *_arg0 = __arg0 + return } //export SKY_cipher_Address_BitcoinBytes -func SKY_cipher_Address_BitcoinBytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) { +func SKY_cipher_Address_BitcoinBytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) bytes := addr.BitcoinBytes() copyToGoSlice(reflect.ValueOf(bytes), _arg0) + return SKY_OK } //export SKY_cipher_Address_Verify @@ -79,49 +146,51 @@ func SKY_cipher_Address_Verify(_addr *C.cipher__Address, _key *C.cipher__PubKey) } //export SKY_cipher_Address_String -func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) { +func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) s := addr.String() copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_Address_BitcoinString -func SKY_cipher_Address_BitcoinString(_addr *C.cipher__Address, _arg1 *C.GoString_) { +func SKY_cipher_Address_BitcoinString(_addr *C.cipher__Address, _arg1 *C.GoString_) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) s := addr.BitcoinString() copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_Address_Checksum -func SKY_cipher_Address_Checksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) { +func SKY_cipher_Address_Checksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) cs := addr.Checksum() C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs))) + return SKY_OK } //export SKY_cipher_Address_BitcoinChecksum -func SKY_cipher_Address_BitcoinChecksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) { +func SKY_cipher_Address_BitcoinChecksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) uint32 { addr := (*cipher.Address)(unsafe.Pointer(_addr)) cs := addr.BitcoinChecksum() C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs))) + return SKY_OK } -/* -Bitcoin Functions -*/ - //export SKY_cipher_BitcoinAddressFromPubkey -func SKY_cipher_BitcoinAddressFromPubkey(_pubkey *C.cipher__PubKey, _arg1 *C.GoString_) { +func SKY_cipher_BitcoinAddressFromPubkey(_pubkey *C.cipher__PubKey, _arg1 *C.GoString_) uint32 { pubkey := (*cipher.PubKey)(unsafe.Pointer(_pubkey)) s := cipher.BitcoinAddressFromPubkey(*pubkey) copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_BitcoinWalletImportFormatFromSeckey -func SKY_cipher_BitcoinWalletImportFormatFromSeckey(_seckey *C.cipher__SecKey, _arg1 *C.GoString_) { +func SKY_cipher_BitcoinWalletImportFormatFromSeckey(_seckey *C.cipher__SecKey, _arg1 *C.GoString_) uint32 { seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) s := cipher.BitcoinWalletImportFormatFromSeckey(*seckey) copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_BitcoinAddressFromBytes @@ -143,3 +212,15 @@ func SKY_cipher_SecKeyFromWalletImportFormat(_input string, _arg1 *C.cipher__Sec } return errcode } + +//export SKY_cipher_MustSecKeyFromWalletImportFormat +func SKY_cipher_MustSecKeyFromWalletImportFormat(_input string, _arg1 *C.cipher__SecKey) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + input := _input + __arg1 := cipher.MustSecKeyFromWalletImportFormat(input) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + return +} diff --git a/lib/cgo/cipher.base58.base58.go b/lib/cgo/cipher.base58.base58.go new file mode 100644 index 0000000000..0abcad2124 --- /dev/null +++ b/lib/cgo/cipher.base58.base58.go @@ -0,0 +1,152 @@ +package main + +import ( + "reflect" + "unsafe" + + base58 "github.com/skycoin/skycoin/src/cipher/base58" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_base58_String2Hex +func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := _s + __arg1 := base58.String2Hex(s) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_base58_Base58_ToInt +func SKY_base58_Base58_ToInt(_b string, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := (base58.Base58)(_b) + __arg0, ____return_err := b.ToInt() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_base58_Base58_ToHex +func SKY_base58_Base58_ToHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := (base58.Base58)(_b) + __arg0, ____return_err := b.ToHex() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_base58_Base58_Base582Int +func SKY_base58_Base58_Base582Int(_b string, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := (base58.Base58)(_b) + __arg0, ____return_err := b.Base582Int() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_base58_Base582Hex +func SKY_base58_Base582Hex(_b string, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := _b + __arg1, ____return_err := base58.Base582Hex(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_base58_Base58_BitHex +func SKY_base58_Base58_BitHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := (base58.Base58)(_b) + __arg0, ____return_err := b.BitHex() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_base58_Int2Base58 +func SKY_base58_Int2Base58(_val int, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + val := _val + __arg1 := base58.Int2Base58(val) + copyString(string(__arg1), _arg1) + return +} + +//export SKY_base58_Hex2Base58 +func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + val := *(*[]byte)(unsafe.Pointer(&_val)) + __arg1 := base58.Hex2Base58(val) + copyString(string(__arg1), _arg1) + return +} + +//export SKY_base58_Hex2Base58String +func SKY_base58_Hex2Base58String(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + val := *(*[]byte)(unsafe.Pointer(&_val)) + __arg1 := base58.Hex2Base58String(val) + copyString(__arg1, _arg1) + return +} + +//export SKY_base58_Hex2Base58Str +func SKY_base58_Hex2Base58Str(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + val := *(*[]byte)(unsafe.Pointer(&_val)) + __arg1 := base58.Hex2Base58Str(val) + copyString(__arg1, _arg1) + return +} diff --git a/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go b/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index 15910e0d2a..0e554567b6 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -1,10 +1,10 @@ package main import ( - cipher "github.com/skycoin/skycoin/src/cipher" - "reflect" "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" ) /* @@ -29,15 +29,22 @@ func SKY_cipher_PubKeySlice_Less(_slice *C.cipher__PubKeySlice, _i, _j int) bool } //export SKY_cipher_PubKeySlice_Swap -func SKY_cipher_PubKeySlice_Swap(_slice *C.cipher__PubKeySlice, _i, _j int) { +func SKY_cipher_PubKeySlice_Swap(_slice *C.cipher__PubKeySlice, _i, _j int) uint32 { slice := inplacePubKeySlice(_slice) slice.Swap(_i, _j) + return SKY_OK } //export SKY_cipher_RandByte -func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) { - b := cipher.RandByte(_n) - copyToGoSlice(reflect.ValueOf(b), _arg1) +func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + n := _n + __arg1 := cipher.RandByte(n) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return } //export SKY_cipher_NewPubKey @@ -45,10 +52,22 @@ func SKY_cipher_NewPubKey(_b []byte, _arg1 *C.cipher__PubKey) (errcode uint32) { defer func() { errcode = catchApiPanic(errcode, recover()) }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1 := cipher.NewPubKey(b) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + return +} - pubkey := cipher.NewPubKey(_b) - copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) - return libErrorCode(nil) +//export SKY_cipher_MustPubKeyFromHex +func SKY_cipher_MustPubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (errcode uint32) { + errcode = 0 + defer func() { + errcode = catchApiPanic(errcode, recover()) + }() + s := _s + __arg1 := cipher.MustPubKeyFromHex(s) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + return } //export SKY_cipher_PubKeyFromHex @@ -56,13 +75,13 @@ func SKY_cipher_PubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (errcode uint3 defer func() { errcode = catchApiPanic(errcode, recover()) }() - - pubkey, err := cipher.PubKeyFromHex(_s) - errcode = libErrorCode(err) - if err == nil { - copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + s := _s + __arg1, ____return_err := cipher.PubKeyFromHex(s) + errcode = libErrorCode(____return_err) + if ____return_err == nil { + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) } - return errcode + return } //export SKY_cipher_PubKeyFromSecKey @@ -70,13 +89,10 @@ func SKY_cipher_PubKeyFromSecKey(_seckey *C.cipher__SecKey, _arg1 *C.cipher__Pub defer func() { errcode = catchApiPanic(errcode, recover()) }() - - seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) - - pubkey := cipher.PubKeyFromSecKey(*seckey) - - copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) - return libErrorCode(nil) + seckey := *(*cipher.SecKey)(unsafe.Pointer(_seckey)) + __arg1 := cipher.PubKeyFromSecKey(seckey) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + return } //export SKY_cipher_PubKeyFromSig @@ -89,6 +105,7 @@ func SKY_cipher_PubKeyFromSig(_sig *C.cipher__Sig, _hash *C.cipher__SHA256, _arg errcode := libErrorCode(err) if err == nil { copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg2), uint(SizeofPubKey)) + } return errcode } @@ -103,17 +120,19 @@ func SKY_cipher_PubKey_Verify(_pk *C.cipher__PubKey) uint32 { } //export SKY_cipher_PubKey_Hex -func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) { +func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) uint32 { pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) s := pk.Hex() copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_PubKey_ToAddressHash -func SKY_cipher_PubKey_ToAddressHash(_pk *C.cipher__PubKey, _arg0 *C.cipher__Ripemd160) { +func SKY_cipher_PubKey_ToAddressHash(_pk *C.cipher__PubKey, _arg0 *C.cipher__Ripemd160) uint32 { pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) - h := pk.ToAddressHash() - copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg0), uint(SizeofRipemd160)) + __arg0 := pk.ToAddressHash() + copyToBuffer(reflect.ValueOf(__arg0[:]), unsafe.Pointer(_arg0), uint(SizeofRipemd160)) + return SKY_OK } //export SKY_cipher_NewSecKey @@ -121,10 +140,22 @@ func SKY_cipher_NewSecKey(_b []byte, _arg1 *C.cipher__SecKey) (errcode uint32) { defer func() { errcode = catchApiPanic(errcode, recover()) }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1 := cipher.NewSecKey(b) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + return +} - sk := cipher.NewSecKey(_b) - copyToBuffer(reflect.ValueOf(sk[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) - return SKY_OK +//export SKY_cipher_MustSecKeyFromHex +func SKY_cipher_MustSecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := _s + __arg1 := cipher.MustSecKeyFromHex(s) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + return } //export SKY_cipher_SecKeyFromHex @@ -145,18 +176,20 @@ func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) uint32 { } //export SKY_cipher_SecKey_Hex -func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) { +func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) uint32 { sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) s := sk.Hex() copyString(s, _arg1) + return SKY_OK } //export SKY_cipher_ECDH -func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.GoSlice_) { +func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.GoSlice_) uint32 { pub := (*cipher.PubKey)(unsafe.Pointer(_pub)) sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) b := cipher.ECDH(*pub, *sec) copyToGoSlice(reflect.ValueOf(b), _arg2) + return SKY_OK } //export SKY_cipher_NewSig @@ -164,11 +197,22 @@ func SKY_cipher_NewSig(_b []byte, _arg1 *C.cipher__Sig) (errcode uint32) { defer func() { errcode = catchApiPanic(errcode, recover()) }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1 := cipher.NewSig(b) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) + return +} - s := cipher.NewSig(_b) - copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) - - return SKY_OK +//export SKY_cipher_MustSigFromHex +func SKY_cipher_MustSigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := _s + __arg1 := cipher.MustSigFromHex(s) + copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) + return } //export SKY_cipher_SigFromHex @@ -182,17 +226,19 @@ func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) uint32 { } //export SKY_cipher_Sig_Hex -func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) { +func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) uint32 { s := (*cipher.Sig)(unsafe.Pointer(_s)) copyString(s.Hex(), _arg1) + return SKY_OK } //export SKY_cipher_SignHash -func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 *C.cipher__Sig) { +func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 *C.cipher__Sig) uint32 { hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) s := cipher.SignHash(*hash, *sec) copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg2), uint(SizeofSig)) + return SKY_OK } //export SKY_cipher_ChkSig @@ -225,39 +271,56 @@ func SKY_cipher_VerifySignature(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, } //export SKY_cipher_GenerateKeyPair -func SKY_cipher_GenerateKeyPair(_arg0 *C.cipher__PubKey, _arg1 *C.cipher__SecKey) { +func SKY_cipher_GenerateKeyPair(_arg0 *C.cipher__PubKey, _arg1 *C.cipher__SecKey) uint32 { p, s := cipher.GenerateKeyPair() copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg0), uint(SizeofPubKey)) copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + return SKY_OK } //export SKY_cipher_GenerateDeterministicKeyPair -func SKY_cipher_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.cipher__PubKey, _arg2 *C.cipher__SecKey) { +func SKY_cipher_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.cipher__PubKey, _arg2 *C.cipher__SecKey) uint32 { p, s := cipher.GenerateDeterministicKeyPair(_seed) copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg2), uint(SizeofSecKey)) + return SKY_OK } //export SKY_cipher_DeterministicKeyPairIterator -func SKY_cipher_DeterministicKeyPairIterator(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.cipher__PubKey, _arg3 *C.cipher__SecKey) { +func SKY_cipher_DeterministicKeyPairIterator(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.cipher__PubKey, _arg3 *C.cipher__SecKey) uint32 { h, p, s := cipher.DeterministicKeyPairIterator(_seed) copyToGoSlice(reflect.ValueOf(h), _arg1) copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg2), uint(SizeofPubKey)) copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg3), uint(SizeofSecKey)) + return SKY_OK } //export SKY_cipher_GenerateDeterministicKeyPairs -func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoSlice_) { - sks := cipher.GenerateDeterministicKeyPairs(_seed, _n) - copyToGoSlice(reflect.ValueOf(sks), _arg2) +func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seed := *(*[]byte)(unsafe.Pointer(&_seed)) + n := _n + __arg2 := cipher.GenerateDeterministicKeyPairs(seed, n) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return } //export SKY_cipher_GenerateDeterministicKeyPairsSeed -func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) { - h, sks := cipher.GenerateDeterministicKeyPairsSeed(_seed, _n) - copyToGoSlice(reflect.ValueOf(h), _arg2) - copyToGoSlice(reflect.ValueOf(sks), _arg3) +func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seed := *(*[]byte)(unsafe.Pointer(&_seed)) + n := _n + __arg2, __arg3 := cipher.GenerateDeterministicKeyPairsSeed(seed, n) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + return } //export SKY_cipher_TestSecKey diff --git a/lib/cgo/cipher.encoder.encoder.go b/lib/cgo/cipher.encoder.encoder.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.encoder.encoder.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.encoder.field.go b/lib/cgo/cipher.encoder.field.go new file mode 100644 index 0000000000..ba79c6687b --- /dev/null +++ b/lib/cgo/cipher.encoder.field.go @@ -0,0 +1,41 @@ +package main + +import ( + "unsafe" + + encoder "github.com/skycoin/skycoin/src/cipher/encoder" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_encoder_StructField_String +func SKY_encoder_StructField_String(_s *C.encoder__StructField, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := (*encoder.StructField)(unsafe.Pointer(_s)) + __arg0 := s.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_encoder_ParseFields +func SKY_encoder_ParseFields(_in []byte, _fields []C.encoder__StructField, _arg2 *C.GoStringMap_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + in := *(*[]byte)(unsafe.Pointer(&_in)) + fields := *(*[]encoder.StructField)(unsafe.Pointer(&_fields)) + __arg2 := encoder.ParseFields(in, fields) + copyToStringMap(__arg2, _arg2) + return +} diff --git a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go new file mode 100644 index 0000000000..21e0d32506 --- /dev/null +++ b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go @@ -0,0 +1,51 @@ +package main + +import ( + "reflect" + "unsafe" + + encrypt "github.com/skycoin/skycoin/src/cipher/encrypt" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_encrypt_ScryptChacha20poly1305_Encrypt +func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg1, ____return_err := s.Encrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_encrypt_ScryptChacha20poly1305_Decrypt +func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg1, ____return_err := s.Decrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go new file mode 100644 index 0000000000..41ab7c4648 --- /dev/null +++ b/lib/cgo/cipher.encrypt.sha256xor.go @@ -0,0 +1,51 @@ +package main + +import ( + "reflect" + "unsafe" + + encrypt "github.com/skycoin/skycoin/src/cipher/encrypt" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_encrypt_Sha256Xor_Encrypt +func SKY_encrypt_Sha256Xor_Encrypt(_s *C.encrypt__Sha256Xor, _data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := *(*encrypt.Sha256Xor)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg2, ____return_err := s.Encrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} + +//export SKY_encrypt_Sha256Xor_Decrypt +func SKY_encrypt_Sha256Xor_Decrypt(_s *C.encrypt__Sha256Xor, _data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := *(*encrypt.Sha256Xor)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg2, ____return_err := s.Decrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} diff --git a/lib/cgo/cipher.go-bip39.bip39.go b/lib/cgo/cipher.go-bip39.bip39.go new file mode 100644 index 0000000000..d9531394ff --- /dev/null +++ b/lib/cgo/cipher.go-bip39.bip39.go @@ -0,0 +1,88 @@ +package main + +import ( + "reflect" + "unsafe" + + gobip39 "github.com/skycoin/skycoin/src/cipher/go-bip39" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_bip39_NewDefaultMnemomic +func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0, ____return_err := gobip39.NewDefaultMnemonic() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_bip39_NewEntropy +func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bitSize := _bitSize + __arg1, ____return_err := gobip39.NewEntropy(bitSize) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_bip39_NewMnemonic +func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + entropy := *(*[]byte)(unsafe.Pointer(&_entropy)) + __arg1, ____return_err := gobip39.NewMnemonic(entropy) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_bip39_MnemonicToByteArray +func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + mnemonic := _mnemonic + __arg1, ____return_err := gobip39.MnemonicToByteArray(mnemonic) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_bip39_IsMnemonicValid +func SKY_bip39_IsMnemonicValid(_mnemonic string, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + mnemonic := _mnemonic + __arg1 := gobip39.IsMnemonicValid(mnemonic) + *_arg1 = __arg1 + return +} diff --git a/lib/cgo/cipher.go-bip39.wordlist.go b/lib/cgo/cipher.go-bip39.wordlist.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.go-bip39.wordlist.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.hash.go b/lib/cgo/cipher.hash.go index 59ab70e503..e3048f24d2 100644 --- a/lib/cgo/cipher.hash.go +++ b/lib/cgo/cipher.hash.go @@ -1,10 +1,10 @@ package main import ( - cipher "github.com/skycoin/skycoin/src/cipher" - "reflect" "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" ) /* @@ -29,10 +29,11 @@ func SKY_cipher_Ripemd160_Set(_rd *C.cipher__Ripemd160, _b []byte) (errcode uint } //export SKY_cipher_HashRipemd160 -func SKY_cipher_HashRipemd160(_data []byte, _arg1 *C.cipher__Ripemd160) { +func SKY_cipher_HashRipemd160(_data []byte, _arg1 *C.cipher__Ripemd160) uint32 { rd := cipher.HashRipemd160(_data) copyToBuffer(reflect.ValueOf(rd[:]), unsafe.Pointer(_arg1), uint(SizeofRipemd160)) + return SKY_OK } //export SKY_cipher_SHA256_Set @@ -48,18 +49,20 @@ func SKY_cipher_SHA256_Set(_g *C.cipher__SHA256, _b []byte) (errcode uint32) { } //export SKY_cipher_SHA256_Hex -func SKY_cipher_SHA256_Hex(_g *C.cipher__SHA256, _arg1 *C.GoString_) { +func SKY_cipher_SHA256_Hex(_g *C.cipher__SHA256, _arg1 *C.GoString_) uint32 { g := (*cipher.SHA256)(unsafe.Pointer(_g)) copyString(g.Hex(), _arg1) + return SKY_OK } //export SKY_cipher_SHA256_Xor -func SKY_cipher_SHA256_Xor(_g *C.cipher__SHA256, _b *C.cipher__SHA256, _arg1 *C.cipher__SHA256) { +func SKY_cipher_SHA256_Xor(_g *C.cipher__SHA256, _b *C.cipher__SHA256, _arg1 *C.cipher__SHA256) uint32 { g := (*cipher.SHA256)(unsafe.Pointer(_g)) b := (*cipher.SHA256)(unsafe.Pointer(_b)) x := g.Xor(*b) copyToBuffer(reflect.ValueOf(x[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return SKY_OK } //export SKY_cipher_SumSHA256 @@ -85,23 +88,39 @@ func SKY_cipher_SHA256FromHex(_hs string, _arg1 *C.cipher__SHA256) uint32 { } //export SKY_cipher_DoubleSHA256 -func SKY_cipher_DoubleSHA256(_b []byte, _arg1 *C.cipher__SHA256) { +func SKY_cipher_DoubleSHA256(_b []byte, _arg1 *C.cipher__SHA256) uint32 { h := cipher.DoubleSHA256(_b) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return SKY_OK } //export SKY_cipher_AddSHA256 -func SKY_cipher_AddSHA256(_a *C.cipher__SHA256, _b *C.cipher__SHA256, _arg2 *C.cipher__SHA256) { +func SKY_cipher_AddSHA256(_a *C.cipher__SHA256, _b *C.cipher__SHA256, _arg2 *C.cipher__SHA256) uint32 { a := (*cipher.SHA256)(unsafe.Pointer(_a)) b := (*cipher.SHA256)(unsafe.Pointer(_b)) h := cipher.AddSHA256(*a, *b) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg2), uint(SizeofSHA256)) + return SKY_OK } //export SKY_cipher_Merkle -func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) { +func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) uint32 { h0 := (*[]cipher.SHA256)(unsafe.Pointer(_h0)) h := cipher.Merkle(*h0) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return SKY_OK +} + +//export SKY_cipher_MustSumSHA256 +func SKY_cipher_MustSumSHA256(_b []byte, _n int, _arg2 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + n := _n + __arg2 := cipher.MustSumSHA256(b, n) + copyToBuffer(reflect.ValueOf(__arg2[:]), unsafe.Pointer(_arg2), uint(SizeofSHA256)) + return } diff --git a/lib/cgo/cipher.pbkdf2.pbkdf2.go b/lib/cgo/cipher.pbkdf2.pbkdf2.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.pbkdf2.pbkdf2.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.poly1305.poly1305.go b/lib/cgo/cipher.poly1305.poly1305.go new file mode 100644 index 0000000000..c8aeb48b3d --- /dev/null +++ b/lib/cgo/cipher.poly1305.poly1305.go @@ -0,0 +1,30 @@ +package main + +import ( + "unsafe" + + poly1305 "github.com/skycoin/skycoin/src/cipher/poly1305" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_poly1305_Verify +func SKY_poly1305_Verify(_mac *C.GoSlice_, _m []byte, _key *C.GoSlice_, _arg3 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + mac := (*[16]byte)(unsafe.Pointer(_mac)) + m := *(*[]byte)(unsafe.Pointer(&_m)) + key := (*[32]byte)(unsafe.Pointer(_key)) + __arg3 := poly1305.Verify(mac, m, key) + *_arg3 = __arg3 + return +} diff --git a/lib/cgo/cipher.ripemd160.ripemd160block.go b/lib/cgo/cipher.ripemd160.ripemd160block.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.ripemd160.ripemd160block.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.ripemd160.ripmd_160.go b/lib/cgo/cipher.ripemd160.ripmd_160.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.ripemd160.ripmd_160.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.scrypt.scrypt.go b/lib/cgo/cipher.scrypt.scrypt.go new file mode 100644 index 0000000000..c1e4e7d8f2 --- /dev/null +++ b/lib/cgo/cipher.scrypt.scrypt.go @@ -0,0 +1,37 @@ +package main + +import ( + "reflect" + "unsafe" + + scrypt "github.com/skycoin/skycoin/src/cipher/scrypt" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_scrypt_Key +func SKY_scrypt_Key(_password, _salt []byte, _N, _r, _p, _keyLen int, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + password := *(*[]byte)(unsafe.Pointer(&_password)) + salt := *(*[]byte)(unsafe.Pointer(&_salt)) + N := _N + r := _r + p := _p + keyLen := _keyLen + __arg2, ____return_err := scrypt.Key(password, salt, N, r, p, keyLen) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256_rand.go b/lib/cgo/cipher.secp256k1-go.secp256_rand.go new file mode 100644 index 0000000000..676171d64e --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256_rand.go @@ -0,0 +1,41 @@ +package main + +import ( + "reflect" + "unsafe" + + secp256k1go "github.com/skycoin/skycoin/src/cipher/secp256k1-go" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1_SumSHA256 +func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1 := secp256k1go.SumSHA256(b) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_RandByte +func SKY_secp256k1_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + n := _n + __arg1 := secp256k1go.RandByte(n) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go new file mode 100644 index 0000000000..db1b66af74 --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go @@ -0,0 +1,119 @@ +package main + +import ( + "reflect" + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_DecompressPoint +func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + X := *(*[]byte)(unsafe.Pointer(&_X)) + off := _off + Y := *(*[]byte)(unsafe.Pointer(&_Y)) + secp256k1go2.DecompressPoint(X, off, Y) + return +} + +//export SKY_secp256k1go_RecoverPublicKey +func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _arg3 *C.GoSlice_, _arg4 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sigByte := *(*[]byte)(unsafe.Pointer(&_sigByte)) + h := *(*[]byte)(unsafe.Pointer(&_h)) + recid := _recid + __arg3, __arg4 := secp256k1go2.RecoverPublicKey(sigByte, h, recid) + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + *_arg4 = __arg4 + return +} + +//export SKY_secp256k1go_Multiply +func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := *(*[]byte)(unsafe.Pointer(&_xy)) + k := *(*[]byte)(unsafe.Pointer(&_k)) + __arg1 := secp256k1go2.Multiply(xy, k) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1go_BaseMultiply +func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + k := *(*[]byte)(unsafe.Pointer(&_k)) + __arg1 := secp256k1go2.BaseMultiply(k) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1go_BaseMultiplyAdd +func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := *(*[]byte)(unsafe.Pointer(&_xy)) + k := *(*[]byte)(unsafe.Pointer(&_k)) + __arg1 := secp256k1go2.BaseMultiplyAdd(xy, k) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1go_GeneratePublicKey +func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + k := *(*[]byte)(unsafe.Pointer(&_k)) + __arg1 := secp256k1go2.GeneratePublicKey(k) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1go_SeckeyIsValid +func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + __arg1 := secp256k1go2.SeckeyIsValid(seckey) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1go_PubkeyIsValid +func SKY_secp256k1go_PubkeyIsValid(_pubkey []byte, _arg1 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) + __arg1 := secp256k1go2.PubkeyIsValid(pubkey) + *_arg1 = __arg1 + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go new file mode 100644 index 0000000000..d29d496b5c --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go @@ -0,0 +1,246 @@ +package main + +import ( + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_Field_String +func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + __arg0 := fd.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_secp256k1go_Field_Print +func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + lab := _lab + fd.Print(lab) + return +} + +//export SKY_secp256k1go_Field_SetB32 +func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + a := *(*[]byte)(unsafe.Pointer(&_a)) + fd.SetB32(a) + return +} + +//export SKY_secp256k1go_Field_SetBytes +func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + a := *(*[]byte)(unsafe.Pointer(&_a)) + fd.SetBytes(a) + return +} + +//export SKY_secp256k1go_Field_SetHex +func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + s := _s + fd.SetHex(s) + return +} + +//export SKY_secp256k1go_Field_IsOdd +func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + __arg0 := fd.IsOdd() + *_arg0 = __arg0 + return +} + +//export SKY_secp256k1go_Field_IsZero +func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + __arg0 := fd.IsZero() + *_arg0 = __arg0 + return +} + +//export SKY_secp256k1go_Field_SetInt +func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + a := _a + fd.SetInt(a) + return +} + +//export SKY_secp256k1go_Field_Normalize +func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + fd.Normalize() + return +} + +//export SKY_secp256k1go_Field_GetB32 +func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := *(*[]byte)(unsafe.Pointer(&_r)) + fd.GetB32(r) + return +} + +//export SKY_secp256k1go_Field_Equals +func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__Field, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) + __arg1 := fd.Equals(b) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1go_Field_SetAdd +func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + a := (*secp256k1go2.Field)(unsafe.Pointer(_a)) + fd.SetAdd(a) + return +} + +//export SKY_secp256k1go_Field_MulInt +func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + a := _a + fd.MulInt(a) + return +} + +//export SKY_secp256k1go_Field_Negate +func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field, _m uint32) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + m := _m + fd.Negate(r, m) + return +} + +//export SKY_secp256k1go_Field_Inv +func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + fd.Inv(r) + return +} + +//export SKY_secp256k1go_Field_Sqrt +func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + fd.Sqrt(r) + return +} + +//export SKY_secp256k1go_Field_InvVar +func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + fd.InvVar(r) + return +} + +//export SKY_secp256k1go_Field_Mul +func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) + fd.Mul(r, b) + return +} + +//export SKY_secp256k1go_Field_Sqr +func SKY_secp256k1go_Field_Sqr(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) + r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) + fd.Sqr(r) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go new file mode 100644 index 0000000000..383ebac002 --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -0,0 +1,52 @@ +package main + +import ( + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_Number_Print +func SKY_secp256k1go_Number_Print(_num *C.Number, _label string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) + label := _label + num.Print(label) + return +} + +//export SKY_secp256k1go_Number_SetHex +func SKY_secp256k1go_Number_SetHex(_num *C.Number, _s string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) + s := _s + num.SetHex(s) + return +} + +//export SKY_secp256k1go_Number_IsOdd +func SKY_secp256k1go_Number_IsOdd(_num *C.Number, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) + __arg0 := num.IsOdd() + *_arg0 = __arg0 + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go new file mode 100644 index 0000000000..1f4ae602be --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -0,0 +1,98 @@ +package main + +import ( + "reflect" + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_Signature_Print +func SKY_secp256k1go_Signature_Print(_sig *C.Signature, _lab string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + lab := _lab + sig.Print(lab) + return +} + +//export SKY_secp256k1go_Signature_Verify +func SKY_secp256k1go_Signature_Verify(_sig *C.Signature, _pubkey *C.secp256k1go__XY, _message *C.Number, _arg2 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) + message := (*secp256k1go2.Number)(unsafe.Pointer(_message)) + __arg2 := sig.Verify(pubkey, message) + *_arg2 = __arg2 + return +} + +//export SKY_secp256k1go_Signature_Recover +func SKY_secp256k1go_Signature_Recover(_sig *C.Signature, _pubkey *C.secp256k1go__XY, _m *C.Number, _recid int, _arg3 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) + m := (*secp256k1go2.Number)(unsafe.Pointer(_m)) + recid := _recid + __arg3 := sig.Recover(pubkey, m, recid) + *_arg3 = __arg3 + return +} + +//export SKY_secp256k1go_Signature_Sign +func SKY_secp256k1go_Signature_Sign(_sig *C.Signature, _seckey, _message, _nonce *C.Number, _recid *int, _arg2 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + seckey := (*secp256k1go2.Number)(unsafe.Pointer(_seckey)) + message := (*secp256k1go2.Number)(unsafe.Pointer(_message)) + nonce := (*secp256k1go2.Number)(unsafe.Pointer(_nonce)) + recid := _recid + __arg2 := sig.Sign(seckey, message, nonce, recid) + *_arg2 = __arg2 + return +} + +//export SKY_secp256k1go_Signature_ParseBytes +func SKY_secp256k1go_Signature_ParseBytes(_sig *C.Signature, _v []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + v := *(*[]byte)(unsafe.Pointer(&_v)) + sig.ParseBytes(v) + return +} + +//export SKY_secp256k1go_Signature_Bytes +func SKY_secp256k1go_Signature_Bytes(_sig *C.Signature, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + __arg0 := sig.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go new file mode 100644 index 0000000000..3d0c20cc50 --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go @@ -0,0 +1,152 @@ +package main + +import ( + "reflect" + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_XY_Print +func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + lab := _lab + xy.Print(lab) + return +} + +//export SKY_secp256k1go_XY_ParsePubkey +func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + pub := *(*[]byte)(unsafe.Pointer(&_pub)) + __arg1 := xy.ParsePubkey(pub) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1go_XY_Bytes +func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := *(*secp256k1go2.XY)(unsafe.Pointer(_xy)) + __arg0 := xy.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_secp256k1go_XY_BytesUncompressed +func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + __arg0 := xy.BytesUncompressed() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_secp256k1go_XY_SetXY +func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Field) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) + Y := (*secp256k1go2.Field)(unsafe.Pointer(_Y)) + xy.SetXY(X, Y) + return +} + +//export SKY_secp256k1go_XY_IsValid +func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + __arg0 := xy.IsValid() + *_arg0 = __arg0 + return +} + +//export SKY_secp256k1go_XY_SetXYZ +func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + a := (*secp256k1go2.XYZ)(unsafe.Pointer(_a)) + xy.SetXYZ(a) + return +} + +//export SKY_secp256k1go_XY_Neg +func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + r := (*secp256k1go2.XY)(unsafe.Pointer(_r)) + xy.Neg(r) + return +} + +//export SKY_secp256k1go_XY_SetXO +func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, _odd bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) + odd := _odd + xy.SetXO(X, odd) + return +} + +//export SKY_secp256k1go_XY_AddXY +func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) + xy.AddXY(a) + return +} + +//export SKY_secp256k1go_XY_GetPublicKey +func SKY_secp256k1go_XY_GetPublicKey(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) + __arg0 := xy.GetPublicKey() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go new file mode 100644 index 0000000000..008d7b64af --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go @@ -0,0 +1,164 @@ +package main + +import ( + "unsafe" + + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1go_XYZ_Print +func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + lab := _lab + xyz.Print(lab) + return +} + +//export SKY_secp256k1go_XYZ_SetXY +func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) + xyz.SetXY(a) + return +} + +//export SKY_secp256k1go_XYZ_IsInfinity +func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + __arg0 := xyz.IsInfinity() + *_arg0 = __arg0 + return +} + +//export SKY_secp256k1go_XYZ_IsValid +func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + __arg0 := xyz.IsValid() + *_arg0 = __arg0 + return +} + +//export SKY_secp256k1go_XYZ_Normalize +func SKY_secp256k1go_XYZ_Normalize(_xyz *C.secp256k1go__XYZ) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz.Normalize() + return +} + +//export SKY_secp256k1go_XYZ_Equals +func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) + __arg1 := xyz.Equals(b) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1go_XYZ_ECmult +func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng *C.Number) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + na := (*secp256k1go2.Number)(unsafe.Pointer(_na)) + ng := (*secp256k1go2.Number)(unsafe.Pointer(_ng)) + xyz.ECmult(r, na, ng) + return +} + +//export SKY_secp256k1go_XYZ_Neg +func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + xyz.Neg(r) + return +} + +//export SKY_secp256k1go_XYZ_Double +func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + xyz.Double(r) + return +} + +//export SKY_secp256k1go_XYZ_AddXY +func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _b *C.secp256k1go__XY) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + b := (*secp256k1go2.XY)(unsafe.Pointer(_b)) + xyz.AddXY(r, b) + return +} + +//export SKY_secp256k1go_XYZ_Add +func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XYZ) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) + xyz.Add(r, b) + return +} + +//export SKY_secp256k1go_ECmultGen +func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a *C.Number) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) + a := (*secp256k1go2.Number)(unsafe.Pointer(_a)) + secp256k1go2.ECmultGen(r, a) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go new file mode 100644 index 0000000000..b9416d99e1 --- /dev/null +++ b/lib/cgo/cipher.secp256k1-go.secp256k1.go @@ -0,0 +1,221 @@ +package main + +import ( + "reflect" + "unsafe" + + secp256k1go "github.com/skycoin/skycoin/src/cipher/secp256k1-go" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_secp256k1_GenerateKeyPair +func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0, __arg1 := secp256k1go.GenerateKeyPair() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_PubkeyFromSeckey +func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + __arg1 := secp256k1go.PubkeyFromSeckey(seckey) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_UncompressPubkey +func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) + __arg1 := secp256k1go.UncompressPubkey(pubkey) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_UncompressedPubkeyFromSeckey +func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + __arg1 := secp256k1go.UncompressedPubkeyFromSeckey(seckey) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_Secp256k1Hash +func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + hash := *(*[]byte)(unsafe.Pointer(&_hash)) + __arg1 := secp256k1go.Secp256k1Hash(hash) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_secp256k1_GenerateDeterministicKeyPair +func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seed := *(*[]byte)(unsafe.Pointer(&_seed)) + __arg1, __arg2 := secp256k1go.GenerateDeterministicKeyPair(seed) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return +} + +//export SKY_secp256k1_DeterministicKeyPairIterator +func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seedIn := *(*[]byte)(unsafe.Pointer(&_seedIn)) + __arg1, __arg2, __arg3 := secp256k1go.DeterministicKeyPairIterator(seedIn) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + return +} + +//export SKY_secp256k1_Sign +func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + msg := *(*[]byte)(unsafe.Pointer(&_msg)) + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + __arg2 := secp256k1go.Sign(msg, seckey) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return +} + +//export SKY_secp256k1_SignDeterministic +func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []byte, _arg3 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + msg := *(*[]byte)(unsafe.Pointer(&_msg)) + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + nonceSeed := *(*[]byte)(unsafe.Pointer(&_nonceSeed)) + __arg3 := secp256k1go.SignDeterministic(msg, seckey, nonceSeed) + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + return +} + +//export SKY_secp256k1_VerifySeckey +func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) + __arg1 := secp256k1go.VerifySeckey(seckey) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1_VerifyPubkey +func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) + __arg1 := secp256k1go.VerifyPubkey(pubkey) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1_VerifySignatureValidity +func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig := *(*[]byte)(unsafe.Pointer(&_sig)) + __arg1 := secp256k1go.VerifySignatureValidity(sig) + *_arg1 = __arg1 + return +} + +//export SKY_secp256k1_VerifySignature +func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + msg := *(*[]byte)(unsafe.Pointer(&_msg)) + sig := *(*[]byte)(unsafe.Pointer(&_sig)) + pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) + __arg3 := secp256k1go.VerifySignature(msg, sig, pubkey1) + *_arg3 = __arg3 + return +} + +//export SKY_secp256k1_SignatureErrorString +func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + msg := *(*[]byte)(unsafe.Pointer(&_msg)) + sig := *(*[]byte)(unsafe.Pointer(&_sig)) + pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) + __arg3 := secp256k1go.SignatureErrorString(msg, sig, pubkey1) + copyString(__arg3, _arg3) + return +} + +//export SKY_secp256k1_RecoverPubkey +func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + msg := *(*[]byte)(unsafe.Pointer(&_msg)) + sig := *(*[]byte)(unsafe.Pointer(&_sig)) + __arg2 := secp256k1go.RecoverPubkey(msg, sig) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return +} + +//export SKY_secp256k1_ECDH +func SKY_secp256k1_ECDH(_pub []byte, _sec []byte, _arg2 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pub := *(*[]byte)(unsafe.Pointer(&_pub)) + sec := *(*[]byte)(unsafe.Pointer(&_sec)) + __arg2 := secp256k1go.ECDH(pub, sec) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return +} diff --git a/lib/cgo/cli.add_private_key.go b/lib/cgo/cli.add_private_key.go new file mode 100644 index 0000000000..923447792b --- /dev/null +++ b/lib/cgo/cli.add_private_key.go @@ -0,0 +1,53 @@ +package main + +import ( + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_AddPrivateKey +func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + wlt, okwlt := lookupWalletHandle(_wlt) + if !okwlt { + ____error_code = SKY_ERROR + return + } + key := _key + ____return_err := cli.AddPrivateKey(wlt, key) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_cli_AddPrivateKeyToFile +func SKY_cli_AddPrivateKeyToFile(_walletFile, _key string, pwd C.PasswordReader__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + walletFile := _walletFile + key := _key + pr, okc := lookupPasswordReaderHandle(pwd) + if !okc { + ____error_code = SKY_ERROR + return + } + ____return_err := cli.AddPrivateKeyToFile(walletFile, key, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/cli.address_gen.go b/lib/cgo/cli.address_gen.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.address_gen.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.blocks.go b/lib/cgo/cli.blocks.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.blocks.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.broadcast_rawtx.go b/lib/cgo/cli.broadcast_rawtx.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.broadcast_rawtx.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go new file mode 100644 index 0000000000..7cacb580f8 --- /dev/null +++ b/lib/cgo/cli.check_balance.go @@ -0,0 +1,56 @@ +package main + +import ( + "unsafe" + + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_CheckWalletBalance +func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + walletFile := _walletFile + __arg2, ____return_err := cli.CheckWalletBalance(c, walletFile) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_cli_GetBalanceOfAddresses +func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg2, ____return_err := cli.GetBalanceOfAddresses(c, addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + } + return +} diff --git a/lib/cgo/cli.checkdb.go b/lib/cgo/cli.checkdb.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.checkdb.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.cli.go b/lib/cgo/cli.cli.go new file mode 100644 index 0000000000..e58495d293 --- /dev/null +++ b/lib/cgo/cli.cli.go @@ -0,0 +1,154 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/skycoin/skycoin/src/api/webrpc" + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_LoadConfig +func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0, ____return_err := cli.LoadConfig() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerConfigHandle(&__arg0) + } + return +} + +//export SKY_cli_Config_FullWalletPath +func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + c := *__c + __arg0 := c.FullWalletPath() + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Config_FullDBPath +func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + c := *__c + __arg0 := c.FullDBPath() + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_NewApp +func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __cfg, okcfg := lookupConfigHandle(_cfg) + if !okcfg { + ____error_code = SKY_ERROR + return + } + cfg := *__cfg + __arg1, ____return_err := cli.NewApp(cfg) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerAppHandle(__arg1) + } + return +} + +//export SKY_cli_RPCClientFromContext +func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupContextHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + webrpcClient := c.App.Metadata["rpc"].(*webrpc.Client) + *_arg1 = registerWebRpcClientHandle(webrpcClient) + return +} + +//export SKY_cli_ConfigFromContext +func SKY_cli_ConfigFromContext(_c C.Context__Handle, _arg1 *C.Config__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupContextHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + config := c.App.Metadata["config"].(cli.Config) + *_arg1 = registerConfigHandle(&config) + return +} + +func SKY_cli_NewPasswordReader(_password []byte, passwordReader *C.PasswordReader__Handle) { + password := *(*[]byte)(unsafe.Pointer(&_password)) + pr := cli.NewPasswordReader(password) + *passwordReader = registerPasswordReaderHandle(&pr) +} + +//export SKY_cli_PasswordFromBytes_Password +func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + p := *(*cli.PasswordFromBytes)(unsafe.Pointer(_p)) + __arg0, ____return_err := p.Password() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_cli_PasswordFromTerm_Password +func SKY_cli_PasswordFromTerm_Password(_p *C.cli__PasswordFromTerm, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + p := *(*cli.PasswordFromTerm)(unsafe.Pointer(_p)) + __arg0, ____return_err := p.Password() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index fe416fb962..64403e785b 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -19,7 +19,7 @@ import ( import "C" //export SKY_cli_CreateRawTxFromWallet -func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd string, _arg4 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.coin__Transaction) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -29,11 +29,16 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA ____error_code = SKY_ERROR return } + walletFile := _walletFile chgAddr := _chgAddr toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) - pr := cli.NewPasswordReader([]byte(pwd)) - __arg4, ____return_err := cli.CreateRawTxFromWallet(c, walletFile, chgAddr, toAddrs, pr) + pr, okp := lookupPasswordReaderHandle(pwd) + if !okp { + ____error_code = SKY_ERROR + return + } + __arg4, ____return_err := cli.CreateRawTxFromWallet(c, walletFile, chgAddr, toAddrs, *pr) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg4 = *(*C.coin__Transaction)(unsafe.Pointer(__arg4)) @@ -42,7 +47,7 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA } //export SKY_cli_CreateRawTxFromAddress -func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd string, _arg4 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.coin__Transaction) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -56,8 +61,12 @@ func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFil walletFile := _walletFile chgAddr := _chgAddr toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) - pr := cli.NewPasswordReader([]byte(pwd)) - __arg4, ____return_err := cli.CreateRawTxFromAddress(c, addr, walletFile, chgAddr, toAddrs, pr) + pr, okp := lookupPasswordReaderHandle(pwd) + if !okp { + ____error_code = SKY_ERROR + return + } + __arg4, ____return_err := cli.CreateRawTxFromAddress(c, addr, walletFile, chgAddr, toAddrs, *pr) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg4 = *(*C.coin__Transaction)(unsafe.Pointer(__arg4)) diff --git a/lib/cgo/cli.decryptWallet.go b/lib/cgo/cli.decryptWallet.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.decryptWallet.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.encrypt_wallet.go b/lib/cgo/cli.encrypt_wallet.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.encrypt_wallet.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go new file mode 100644 index 0000000000..a65914161b --- /dev/null +++ b/lib/cgo/cli.generate_addrs.go @@ -0,0 +1,78 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GenerateAddressesInFile +func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.PasswordReader__Handle, _arg3 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + walletFile := _walletFile + num := _num + pr, okc := lookupPasswordReaderHandle(pwd) + if !okc { + ____error_code = SKY_ERROR + return + } + __arg3, ____return_err := cli.GenerateAddressesInFile(walletFile, num, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + } + return +} + +//export SKY_cli_FormatAddressesAsJSON +func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := cli.FormatAddressesAsJSON(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_cli_FormatAddressesAsJoinedArray +func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __arg1 := cli.FormatAddressesAsJoinedArray(addrs) + copyString(__arg1, _arg1) + return +} + +//export SKY_cli_AddressesToStrings +func SKY_cli_AddressesToStrings(_addrs []C.cipher__Address, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __arg1 := cli.AddressesToStrings(addrs) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} diff --git a/lib/cgo/cli.generate_wallet.go b/lib/cgo/cli.generate_wallet.go new file mode 100644 index 0000000000..45f963a862 --- /dev/null +++ b/lib/cgo/cli.generate_wallet.go @@ -0,0 +1,47 @@ +package main + +import ( + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GenerateWallet +func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAddrs uint64, _arg3 *C.Wallet__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + walletFile := _walletFile + __opts, okopts := lookupOptionsHandle(*_opts) + if !okopts { + ____error_code = SKY_ERROR + return + } + opts := *__opts + numAddrs := _numAddrs + __arg3, ____return_err := cli.GenerateWallet(walletFile, opts, numAddrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = registerWalletHandle(__arg3) + } + return +} + +//export SKY_cli_MakeAlphanumericSeed +func SKY_cli_MakeAlphanumericSeed(_arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := cli.MakeAlphanumericSeed() + copyString(__arg0, _arg0) + return +} diff --git a/lib/cgo/cli.integration.empty.go b/lib/cgo/cli.integration.empty.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.integration.empty.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.last_blocks.go b/lib/cgo/cli.last_blocks.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.last_blocks.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.list_addrs.go b/lib/cgo/cli.list_addrs.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.list_addrs.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.list_wallets.go b/lib/cgo/cli.list_wallets.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.list_wallets.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go new file mode 100644 index 0000000000..f2217a6e4c --- /dev/null +++ b/lib/cgo/cli.outputs.go @@ -0,0 +1,60 @@ +package main + +import ( + "unsafe" + + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GetWalletOutputsFromFile +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + walletFile := _walletFile + __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_cli_GetWalletOutputs +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + wlt, okwlt := lookupWalletHandle(*_wlt) + if !okwlt { + ____error_code = SKY_ERROR + return + } + __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + } + return +} diff --git a/lib/cgo/cli.send.go b/lib/cgo/cli.send.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.send.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.show_seed.go b/lib/cgo/cli.show_seed.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.show_seed.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.status.go b/lib/cgo/cli.status.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.status.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.transaction.go b/lib/cgo/cli.transaction.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.transaction.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.verify_address.go b/lib/cgo/cli.verify_address.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.verify_address.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.version.go b/lib/cgo/cli.version.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.version.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.wallet_dir.go b/lib/cgo/cli.wallet_dir.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.wallet_dir.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli.wallet_history.go b/lib/cgo/cli.wallet_history.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/cli.wallet_history.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/cli_helper.go b/lib/cgo/cli_helper.go new file mode 100644 index 0000000000..5c470decbd --- /dev/null +++ b/lib/cgo/cli_helper.go @@ -0,0 +1,106 @@ +package main + +import ( + "os" + + "github.com/skycoin/skycoin/src/api/webrpc" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_App_Run +func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + app, okapp := lookupAppHandle(_app) + if !okapp { + ____error_code = SKY_ERROR + return + } + args := splitCliArgs(_args) + ____return_err := app.Run(args) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_cli_Config_GetCoin +func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + c := *__c + __arg0 := c.Coin + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Config_GetRPCAddress +func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_ERROR + return + } + c := *__c + __arg0 := c.RPCAddress + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_RPCClientFromApp +func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + app, okapp := lookupAppHandle(_app) + if !okapp { + ____error_code = SKY_ERROR + return + } + __arg1 := app.App.Metadata["rpc"].(*webrpc.Client) + *_arg1 = registerWebRpcClientHandle(__arg1) + return +} + +//export SKY_cli_Getenv +func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := os.Getenv(varname) + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Setenv +func SKY_cli_Setenv(varname string, value string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + os.Setenv(varname, value) + return +} diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go new file mode 100644 index 0000000000..ddb59e7a8b --- /dev/null +++ b/lib/cgo/coin.block.go @@ -0,0 +1,266 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_coin_SignedBlock_VerifySignature +func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.cipher__PubKey) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.SignedBlock)(unsafe.Pointer(_b)) + pubkey := *(*cipher.PubKey)(unsafe.Pointer(_pubkey)) + ____return_err := b.VerifySignature(pubkey) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_NewGenesisBlock +func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.coin__Block) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + genesisAddr := *(*cipher.Address)(unsafe.Pointer(_genesisAddr)) + genesisCoins := _genesisCoins + timestamp := _timestamp + __arg2, ____return_err := coin.NewGenesisBlock(genesisAddr, genesisCoins, timestamp) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.coin__Block)(unsafe.Pointer(__arg2)) + } + return +} + +//export SKY_coin_Block_HashHeader +func SKY_coin_Block_HashHeader(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.HashHeader() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_PreHashHeader +func SKY_coin_Block_PreHashHeader(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.PreHashHeader() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_Time +func SKY_coin_Block_Time(_b *C.coin__Block, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.Time() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Block_Seq +func SKY_coin_Block_Seq(_b *C.coin__Block, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.Seq() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Block_HashBody +func SKY_coin_Block_HashBody(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.HashBody() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_Size +func SKY_coin_Block_Size(_b *C.coin__Block, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.Size() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Block_String +func SKY_coin_Block_String(_b *C.coin__Block, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + __arg0 := b.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_Block_GetTransaction +func SKY_coin_Block_GetTransaction(_b *C.coin__Block, _txHash *C.cipher__SHA256, _arg1 *C.coin__Transaction, _arg2 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + txHash := *(*cipher.SHA256)(unsafe.Pointer(_txHash)) + __arg1, __arg2 := b.GetTransaction(txHash) + *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + *_arg2 = __arg2 + return +} + +//export SKY_coin_NewBlockHeader +func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body *C.coin__BlockBody, _arg4 *C.coin__BlockHeader) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + prev := *(*coin.BlockHeader)(unsafe.Pointer(_prev)) + uxHash := *(*cipher.SHA256)(unsafe.Pointer(_uxHash)) + currentTime := _currentTime + fee := _fee + body := *(*coin.BlockBody)(unsafe.Pointer(_body)) + __arg4 := coin.NewBlockHeader(prev, uxHash, currentTime, fee, body) + *_arg4 = *(*C.coin__BlockHeader)(unsafe.Pointer(&__arg4)) + return +} + +//export SKY_coin_BlockHeader_Hash +func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_BlockHeader_Bytes +func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_BlockHeader_String +func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_BlockBody_Hash +func SKY_coin_BlockBody_Hash(_bb *C.coin__BlockBody, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) + __arg0 := bb.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_BlockBody_Size +func SKY_coin_BlockBody_Size(_bb *C.coin__BlockBody, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) + __arg0 := bb.Size() + *_arg0 = __arg0 + return +} + +//export SKY_coin_BlockBody_Bytes +func SKY_coin_BlockBody_Bytes(_bb *C.coin__BlockBody, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) + __arg0 := bb.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_CreateUnspents +func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx *C.coin__Transaction, _arg2 *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + tx := *(*coin.Transaction)(unsafe.Pointer(_tx)) + __arg2 := coin.CreateUnspents(bh, tx) + *_arg2 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg2)) + return +} + +//export SKY_coin_CreateUnspent +func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx *C.coin__Transaction, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + tx := *(*coin.Transaction)(unsafe.Pointer(_tx)) + outIndex := _outIndex + __arg3, ____return_err := coin.CreateUnspent(bh, tx, outIndex) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = *(*C.coin__UxOut)(unsafe.Pointer(&__arg3)) + } + return +} diff --git a/lib/cgo/coin.math.go b/lib/cgo/coin.math.go new file mode 100644 index 0000000000..6d2eb7a520 --- /dev/null +++ b/lib/cgo/coin.math.go @@ -0,0 +1,58 @@ +package main + +import coin "github.com/skycoin/skycoin/src/coin" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_coin_AddUint64 +func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + a := _a + b := _b + __arg1, ____return_err := coin.AddUint64(a, b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_Uint64ToInt64 +func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + a := _a + __arg1, ____return_err := coin.Uint64ToInt64(a) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_Int64ToUint64 +func SKY_coin_Int64ToUint64(_a int64, _arg1 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + a := _a + __arg1, ____return_err := coin.Int64ToUint64(a) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 66aac972c2..2695b6d181 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -8,6 +8,7 @@ import ( ) /* + #include #include @@ -80,33 +81,65 @@ func SKY_coin_UxArray_Hashes(_ua *C.coin__UxArray, _arg0 *C.GoSlice_) (____error } //export SKY_coin_UxArray_HasDupes -func SKY_coin_UxArray_HasDupes(_ua *C.coin__UxArray) bool { +func SKY_coin_UxArray_HasDupes(_ua *C.coin__UxArray, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) - return ua.HasDupes() + __arg0 := ua.HasDupes() + *_arg0 = __arg0 + return } //export SKY_coin_UxArray_Sort -func SKY_coin_UxArray_Sort(_ua *C.coin__UxArray) { +func SKY_coin_UxArray_Sort(_ua *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) ua.Sort() + return } //export SKY_coin_UxArray_Len -func SKY_coin_UxArray_Len(_ua *C.coin__UxArray) int { +func SKY_coin_UxArray_Len(_ua *C.coin__UxArray, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) - return ua.Len() + __arg0 := ua.Len() + *_arg0 = __arg0 + return } //export SKY_coin_UxArray_Less -func SKY_coin_UxArray_Less(_ua *C.coin__UxArray, _i, _j int) bool { +func SKY_coin_UxArray_Less(_ua *C.coin__UxArray, _i, _j int, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) - return ua.Less(_i, _j) + i := _i + j := _j + __arg1 := ua.Less(i, j) + *_arg1 = __arg1 + return } //export SKY_coin_UxArray_Swap -func SKY_coin_UxArray_Swap(_ua *C.coin__UxArray, _i, _j int) { +func SKY_coin_UxArray_Swap(_ua *C.coin__UxArray, _i, _j int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) - ua.Swap(_i, _j) + i := _i + j := _j + ua.Swap(i, j) + return } //export SKY_coin_UxArray_Coins @@ -141,17 +174,27 @@ func SKY_coin_UxArray_CoinHours(_ua *C.coin__UxArray, _headTime uint64, _arg1 *u } //export SKY_coin_UxArray_Sub -func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) { +func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Sub(other) *_arg1 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg1)) + return } //export SKY_coin_UxArray_Add -func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) { +func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Add(other) *_arg1 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg1)) + return } diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go new file mode 100644 index 0000000000..9fcbf8617b --- /dev/null +++ b/lib/cgo/coin.transactions.go @@ -0,0 +1,355 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_coin_Transaction_Verify +func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + ____return_err := txn.Verify() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_Transaction_VerifyInput +func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := *(*coin.Transaction)(unsafe.Pointer(_txn)) + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + ____return_err := txn.VerifyInput(uxIn) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_Transaction_PushInput +func SKY_coin_Transaction_PushInput(_txn *C.coin__Transaction, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) + __arg1 := txn.PushInput(uxOut) + *_arg1 = __arg1 + return +} + +//export SKY_coin_TransactionOutput_UxID +func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txOut := *(*coin.TransactionOutput)(unsafe.Pointer(_txOut)) + txID := *(*cipher.SHA256)(unsafe.Pointer(_txID)) + __arg1 := txOut.UxID(txID) + *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_coin_Transaction_PushOutput +func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + dst := *(*cipher.Address)(unsafe.Pointer(_dst)) + coins := _coins + hours := _hours + txn.PushOutput(dst, coins, hours) + return +} + +//export SKY_coin_Transaction_SignInputs +func SKY_coin_Transaction_SignInputs(_txn *C.coin__Transaction, _keys []C.cipher__SecKey) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) + txn.SignInputs(keys) + return +} + +//export SKY_coin_Transaction_Size +func SKY_coin_Transaction_Size(_txn *C.coin__Transaction, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.Size() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Transaction_Hash +func SKY_coin_Transaction_Hash(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Transaction_SizeHash +func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0, __arg1 := txn.SizeHash() + *_arg0 = __arg0 + *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_coin_Transaction_TxID +func SKY_coin_Transaction_TxID(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.TxID() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_Transaction_TxIDHex +func SKY_coin_Transaction_TxIDHex(_txn *C.coin__Transaction, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.TxIDHex() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_Transaction_UpdateHeader +func SKY_coin_Transaction_UpdateHeader(_txn *C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn.UpdateHeader() + return +} + +//export SKY_coin_Transaction_HashInner +func SKY_coin_Transaction_HashInner(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.HashInner() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Transaction_Serialize +func SKY_coin_Transaction_Serialize(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0 := txn.Serialize() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_MustTransactionDeserialize +func SKY_coin_MustTransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1 := coin.MustTransactionDeserialize(b) + *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_coin_TransactionDeserialize +func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1, ____return_err := coin.TransactionDeserialize(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + } + return +} + +//export SKY_coin_Transaction_OutputHours +func SKY_coin_Transaction_OutputHours(_txn *C.coin__Transaction, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + __arg0, ____return_err := txn.OutputHours() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_Transactions_Hashes +func SKY_coin_Transactions_Hashes(_txns *C.coin__Transactions, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + __arg0 := txns.Hashes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_Transactions_Size +func SKY_coin_Transactions_Size(_txns *C.coin__Transactions, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + __arg0 := txns.Size() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Transactions_TruncateBytesTo +func SKY_coin_Transactions_TruncateBytesTo(_txns *C.coin__Transactions, _size int, _arg1 *C.coin__Transactions) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + size := _size + __arg1 := txns.TruncateBytesTo(size) + *_arg1 = *(*C.coin__Transactions)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_coin_SortableTransactions_Sort +func SKY_coin_SortableTransactions_Sort(_txns *C.coin__SortableTransactions) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns.Sort() + return +} + +//export SKY_coin_SortableTransactions_Len +func SKY_coin_SortableTransactions_Len(_txns *C.coin__SortableTransactions, _arg0 *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + __arg0 := txns.Len() + *_arg0 = __arg0 + return +} + +//export SKY_coin_SortableTransactions_Less +func SKY_coin_SortableTransactions_Less(_txns *C.coin__SortableTransactions, _i, _j int, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + i := _i + j := _j + __arg1 := txns.Less(i, j) + *_arg1 = __arg1 + return +} + +//export SKY_coin_SortableTransactions_Swap +func SKY_coin_SortableTransactions_Swap(_txns *C.coin__SortableTransactions, _i, _j int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + i := _i + j := _j + txns.Swap(i, j) + return +} + +//export SKY_coin_VerifyTransactionCoinsSpending +func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) + ____return_err := coin.VerifyTransactionCoinsSpending(uxIn, uxOut) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_VerifyTransactionHoursSpending +func SKY_coin_VerifyTransactionHoursSpending(_headTime uint64, _uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + headTime := _headTime + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) + ____return_err := coin.VerifyTransactionHoursSpending(headTime, uxIn, uxOut) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 698bce7cfc..05b67a94a3 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -5,33 +5,36 @@ package main #include #include + #include "skytypes.h" */ import "C" import ( - "unsafe" - + api "github.com/skycoin/skycoin/src/api" webrpc "github.com/skycoin/skycoin/src/api/webrpc" cli "github.com/skycoin/skycoin/src/cli" wallet "github.com/skycoin/skycoin/src/wallet" + gcli "github.com/urfave/cli" ) type Handle uint64 var ( - handleMap = make(map[Handle]interface{}) + handlesCounter uint64 = 0 + handleMap = make(map[Handle]interface{}) ) -func registerHandle(obj interface{}) Handle { - ptr := &obj - handle := *(*Handle)(unsafe.Pointer(&ptr)) - handleMap[handle] = obj - return handle +func registerHandle(obj interface{}) C.Handle { + handlesCounter++ + handle := handlesCounter + //handle := *(*Handle)(unsafe.Pointer(&obj)) + handleMap[Handle(handle)] = obj + return (C.Handle)(handle) } -func lookupHandle(handle Handle) (interface{}, bool) { - obj, ok := handleMap[handle] +func lookupHandle(handle C.Handle) (interface{}, bool) { + obj, ok := handleMap[Handle(handle)] return obj, ok } @@ -40,7 +43,7 @@ func registerWebRpcClientHandle(obj *webrpc.Client) C.WebRpcClient__Handle { } func lookupWebRpcClientHandle(handle C.WebRpcClient__Handle) (*webrpc.Client, bool) { - obj, ok := lookupHandle(Handle(handle)) + obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*webrpc.Client); isOK { return obj, true @@ -54,7 +57,7 @@ func registerWalletHandle(obj *wallet.Wallet) C.Wallet__Handle { } func lookupWalletHandle(handle C.Wallet__Handle) (*wallet.Wallet, bool) { - obj, ok := lookupHandle(Handle(handle)) + obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*wallet.Wallet); isOK { return obj, true @@ -63,12 +66,40 @@ func lookupWalletHandle(handle C.Wallet__Handle) (*wallet.Wallet, bool) { return nil, false } +func registerReadableWalletHandle(obj *wallet.ReadableWallet) C.ReadableWallet__Handle { + return (C.ReadableWallet__Handle)(registerHandle(obj)) +} + +func lookupReadableWalletHandle(handle C.ReadableWallet__Handle) (*wallet.ReadableWallet, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableWallet); isOK { + return obj, true + } + } + return nil, false +} + +func registerReadableEntryHandle(obj *wallet.ReadableEntry) C.ReadableEntry__Handle { + return (C.ReadableEntry__Handle)(registerHandle(obj)) +} + +func lookupReadableEntryHandle(handle C.ReadableEntry__Handle) (*wallet.ReadableEntry, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableEntry); isOK { + return obj, true + } + } + return nil, false +} + func registerOptionsHandle(obj *wallet.Options) C.Options__Handle { return (C.Options__Handle)(registerHandle(obj)) } func lookupOptionsHandle(handle C.Options__Handle) (*wallet.Options, bool) { - obj, ok := lookupHandle(Handle(handle)) + obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*wallet.Options); isOK { return obj, true @@ -82,7 +113,7 @@ func registerConfigHandle(obj *cli.Config) C.Config__Handle { } func lookupConfigHandle(handle C.Config__Handle) (*cli.Config, bool) { - obj, ok := lookupHandle(Handle(handle)) + obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*cli.Config); isOK { return obj, true @@ -91,14 +122,98 @@ func lookupConfigHandle(handle C.Config__Handle) (*cli.Config, bool) { return nil, false } -func registerPasswordReaderHandle(obj cli.PasswordReader) C.PasswordReader__Handle { +func registerAppHandle(obj *cli.App) C.App__Handle { + return (C.App__Handle)(registerHandle(obj)) +} + +func lookupAppHandle(handle C.App__Handle) (*cli.App, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.App); isOK { + return obj, true + } + } + return nil, false +} + +func registerContextHandle(obj *gcli.Context) C.Context__Handle { + return (C.Context__Handle)(registerHandle(obj)) +} + +func lookupContextHandle(handle C.Context__Handle) (*gcli.Context, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*gcli.Context); isOK { + return obj, true + } + } + return nil, false +} + +func registerClientHandle(obj *api.Client) C.Client__Handle { + return (C.Client__Handle)(registerHandle(obj)) +} + +func lookupClientHandle(handle C.Client__Handle) (*api.Client, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.Client); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletsHandle(obj []*api.WalletResponse) C.Wallets__Handle { + return (C.Wallets__Handle)(registerHandle(obj)) +} + +func lookupWalletsHandle(handle C.Wallets__Handle) ([]*api.WalletResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]*api.WalletResponse); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletResponseHandle(obj *api.WalletResponse) C.WalletResponse__Handle { + return (C.WalletResponse__Handle)(registerHandle(obj)) +} + +func lookupWalletResponseHandle(handle C.WalletResponse__Handle) (*api.WalletResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.WalletResponse); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreateTransactionRequestHandle(obj *api.CreateTransactionRequest) C.CreateTransactionRequest__Handle { + return (C.CreateTransactionRequest__Handle)(registerHandle(obj)) +} + +func lookupCreateTransactionRequestHandle(handle C.CreateTransactionRequest__Handle) (*api.CreateTransactionRequest, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreateTransactionRequest); isOK { + return obj, true + } + } + return nil, false +} + +func registerPasswordReaderHandle(obj *cli.PasswordReader) C.PasswordReader__Handle { return (C.PasswordReader__Handle)(registerHandle(obj)) } -func lookupPasswordReaderHandle(handle C.PasswordReader__Handle) (cli.PasswordReader, bool) { - obj, ok := lookupHandle(Handle(handle)) +func lookupPasswordReaderHandle(handle C.PasswordReader__Handle) (*cli.PasswordReader, bool) { + obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(cli.PasswordReader); isOK { + if obj, isOK := (obj).(*cli.PasswordReader); isOK { return obj, true } } diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go new file mode 100644 index 0000000000..6391de88fb --- /dev/null +++ b/lib/cgo/libsky_handle_helper.go @@ -0,0 +1,370 @@ +package main + +/* + + #include + #include + + + #include "skytypes.h" +*/ +import "C" + +import ( + "encoding/json" + "path/filepath" + "sort" + "unsafe" + + api "github.com/skycoin/skycoin/src/api" + "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/visor" +) + +//export SKY_JsonEncode_Handle +func SKY_JsonEncode_Handle(handle C.Handle, json_string *C.GoString_) uint32 { + obj, ok := lookupHandle(handle) + if ok { + jsonBytes, err := json.Marshal(obj) + if err == nil { + copyString(string(jsonBytes), json_string) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Progress_GetCurrent +func SKY_Handle_Progress_GetCurrent(handle C.Handle, current *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*daemon.BlockchainProgress); isOK { + *current = obj.Current + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Block_GetHeadSeq +func SKY_Handle_Block_GetHeadSeq(handle C.Handle, seq *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + *seq = obj.Head.BkSeq + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Block_GetHeadHash +func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + copyString(obj.Head.BlockHash, hash) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Block_GetPreviousBlockHash +func SKY_Handle_Block_GetPreviousBlockHash(handle C.Handle, hash *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + copyString(obj.Head.PreviousBlockHash, hash) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Blocks_GetAt +func SKY_Handle_Blocks_GetAt(handle C.Handle, + index uint64, blockHandle *C.Handle) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableBlocks); isOK { + *blockHandle = registerHandle(&obj.Blocks[index]) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Blocks_GetCount +func SKY_Handle_Blocks_GetCount(handle C.Handle, + count *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableBlocks); isOK { + *count = uint64(len(obj.Blocks)) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Connections_GetCount +func SKY_Handle_Connections_GetCount(handle C.Handle, + count *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.Connections); isOK { + *count = uint64(len(obj.Connections)) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Strings_GetCount +func SKY_Handle_Strings_GetCount(handle C.Strings__Handle, + count *uint32) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + *count = uint32(len(obj)) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Strings_Sort +func SKY_Handle_Strings_Sort(handle C.Strings__Handle) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + sort.Strings(obj) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_Handle_Strings_GetAt +func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, + index int, + str *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + copyString(obj[index], str) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_Client_GetWalletDir +func SKY_api_Handle_Client_GetWalletDir(handle C.Client__Handle, + walletDir *C.GoString_) uint32 { + client, ok := lookupClientHandle(handle) + if ok { + wf, err := client.WalletFolderName() + if err == nil { + copyString(wf.Address, walletDir) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_Client_GetWalletFileName +func SKY_api_Handle_Client_GetWalletFileName(handle C.WalletResponse__Handle, + walletFileName *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.Filename, walletFileName) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_Client_GetWalletLabel +func SKY_api_Handle_Client_GetWalletLabel(handle C.WalletResponse__Handle, + walletLabel *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.Label, walletLabel) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_Client_GetWalletFullPath +func SKY_api_Handle_Client_GetWalletFullPath( + clientHandle C.Client__Handle, + walletHandle C.WalletResponse__Handle, + fullPath *C.GoString_) uint32 { + client, ok := lookupClientHandle(clientHandle) + if ok { + wf, err := client.WalletFolderName() + if err == nil { + w, okw := lookupWalletResponseHandle(walletHandle) + if okw { + walletPath := filepath.Join(wf.Address, w.Meta.Filename) + copyString(walletPath, fullPath) + return SKY_OK + } + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_GetWalletMeta +func SKY_api_Handle_GetWalletMeta(handle C.Wallet__Handle, + gomap *C.GoStringMap_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyToStringMap(w.Meta, gomap) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_GetWalletEntriesCount +func SKY_api_Handle_GetWalletEntriesCount(handle C.Wallet__Handle, + count *uint32) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + *count = uint32(len(w.Entries)) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_Client_GetWalletResponseEntriesCount +func SKY_api_Handle_Client_GetWalletResponseEntriesCount( + handle C.WalletResponse__Handle, + count *uint32) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + *count = uint32(len(w.Entries)) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletGetEntry +func SKY_api_Handle_WalletGetEntry(handle C.Wallet__Handle, + index uint32, + address *C.cipher__Address, + pubkey *C.cipher__PubKey) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + if index < uint32(len(w.Entries)) { + *address = *(*C.cipher__Address)(unsafe.Pointer(&w.Entries[index].Address)) + *pubkey = *(*C.cipher__PubKey)(unsafe.Pointer(&w.Entries[index].Public)) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletResponseGetEntry +func SKY_api_Handle_WalletResponseGetEntry(handle C.WalletResponse__Handle, + index uint32, + address *C.GoString_, + pubkey *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + if index < uint32(len(w.Entries)) { + copyString(w.Entries[index].Address, address) + copyString(w.Entries[index].Public, pubkey) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletResponseIsEncrypted +func SKY_api_Handle_WalletResponseIsEncrypted( + handle C.WalletResponse__Handle, + isEncrypted *bool) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + *isEncrypted = w.Meta.Encrypted + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletResponseGetCryptoType +func SKY_api_Handle_WalletResponseGetCryptoType( + handle C.WalletResponse__Handle, + cryptoType *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.CryptoType, cryptoType) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletsResponseGetCount +func SKY_api_Handle_WalletsResponseGetCount( + handle C.Wallets__Handle, + count *uint32) uint32 { + w, ok := lookupWalletsHandle(handle) + if ok { + *count = uint32(len(w)) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_WalletsResponseGetAt +func SKY_api_Handle_WalletsResponseGetAt( + walletsHandle C.Wallets__Handle, + index uint32, + walletHandle *C.WalletResponse__Handle) uint32 { + w, ok := lookupWalletsHandle(walletsHandle) + if ok { + if index < uint32(len(w)) { + *walletHandle = registerWalletResponseHandle(w[index]) + } + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_GetWalletFolderAddress +func SKY_api_Handle_GetWalletFolderAddress( + folderHandle C.Handle, + address *C.GoString_) uint32 { + obj, ok := lookupHandle(folderHandle) + if ok { + if obj, isOK := (obj).(*api.WalletFolder); isOK { + copyString(obj.Address, address) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_api_Handle_GetWalletSeed +func SKY_api_Handle_GetWalletSeed(handle C.Wallet__Handle, + seed *C.GoString_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyString(w.Meta["seed"], seed) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_api_Handle_GetWalletLastSeed +func SKY_api_Handle_GetWalletLastSeed(handle C.Wallet__Handle, + lastSeed *C.GoString_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyString(w.Meta["lastSeed"], lastSeed) + return SKY_OK + } + return SKY_ERROR +} diff --git a/lib/cgo/libsky_map.go b/lib/cgo/libsky_map.go new file mode 100644 index 0000000000..03addb621e --- /dev/null +++ b/lib/cgo/libsky_map.go @@ -0,0 +1,52 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_map_get +func SKY_map_get(gomap *C.GoStringMap_, key string, value *C.GoString_) (____error_code uint32) { + obj, ok := lookupHandle(C.Handle(*gomap)) + ____error_code = SKY_ERROR + if ok { + if m, isMap := (obj).(map[string]string); isMap { + result, ok := m[key] + if ok { + copyString(result, value) + ____error_code = SKY_OK + } + } + } + return +} + +//export SKY_map_has_key +func SKY_map_has_key(gomap *C.GoStringMap_, key string) (found bool) { + obj, ok := lookupHandle(C.Handle(*gomap)) + found = false + if ok { + if m, isMap := (obj).(map[string]string); isMap { + _, found = m[key] + } + } + return +} + +//export SKY_map_close +func SKY_map_close(gomap *C.GoStringMap_) (____error_code uint32) { + obj, ok := lookupHandle(C.Handle(*gomap)) + ____error_code = SKY_ERROR + if ok { + if _, isMap := (obj).(map[string]string); isMap { + closeHandle(Handle(*gomap)) + ____error_code = SKY_OK + } + } + return + +} diff --git a/lib/cgo/libsky_mem.go b/lib/cgo/libsky_mem.go index 74eca3f02d..10f4a17e84 100644 --- a/lib/cgo/libsky_mem.go +++ b/lib/cgo/libsky_mem.go @@ -1,10 +1,12 @@ package main import ( + "hash" "reflect" "unsafe" "github.com/skycoin/skycoin/src/cipher" + "github.com/skycoin/skycoin/src/util/http" ) /* @@ -48,8 +50,8 @@ func inplaceAddress(p *C.cipher__Address) *cipher.Address { return (*cipher.Address)(unsafe.Pointer(p)) } -func nop(p unsafe.Pointer) { - // Do nothing +func inplaceHttpHelperAddress(p *C.httphelper__Address) *httphelper.Address { + return (*httphelper.Address)(unsafe.Pointer(p)) } /** @@ -57,15 +59,14 @@ func nop(p unsafe.Pointer) { */ func copyString(src string, dest *C.GoString_) { - strAddr := (*C.GoString_)(unsafe.Pointer(&src)) srcLen := len(src) - dest.p = (*C.char)(C.memcpy( - C.malloc(C.size_t(srcLen+1)), - unsafe.Pointer(strAddr.p), - C.size_t(srcLen), - )) - C.eos(dest.p, C.int(srcLen)) - dest.n = C.GoInt_(srcLen) + dest.p = (*C.char)(C.malloc(C.size_t(srcLen + 1))) + strAddr := (*C.GoString_)(unsafe.Pointer(&src)) + result := C.memcpy(unsafe.Pointer(dest.p), unsafe.Pointer(strAddr.p), C.size_t(srcLen)) + if result != nil { + C.eos(dest.p, C.int(srcLen)) + dest.n = C.GoInt_(srcLen) + } } // Determine the memory address of a slice buffer and the @@ -89,7 +90,8 @@ func copyToBuffer(src reflect.Value, dest unsafe.Pointer, n uint) { return } srcAddr, elemSize := getBufferData(src) - nop(C.memcpy(dest, srcAddr, C.size_t(n)*elemSize)) + if C.memcpy(dest, srcAddr, C.size_t(n)*elemSize) != nil { + } } // Copy source slice/array/string onto instance of C.GSlice struct @@ -113,11 +115,53 @@ func copyToGoSlice(src reflect.Value, dest *C.GoSlice_) { if overflow { n = int(dest.cap) } - nop(C.memcpy(dest.data, srcAddr, C.size_t(n)*elemSize)) - // Do not modify slice metadata until memory is actually copied - if overflow { - dest.len = dest.cap - C.GoInt_(srcLen) - } else { - dest.len = C.GoInt_(srcLen) + result := C.memcpy(dest.data, srcAddr, C.size_t(n)*elemSize) + if result != nil { + // Do not modify slice metadata until memory is actually copied + if overflow { + dest.len = dest.cap - C.GoInt_(srcLen) + } else { + dest.len = C.GoInt_(srcLen) + } + } +} + +func convertToInterface(a *C.GoInterface_) interface{} { + //TODO: Implement + return nil +} + +func copyToFunc(f C.Handle) func() hash.Hash { + //TODO: Implement + return nil +} + +func copyToStringMap(gomap map[string]string, dest *C.GoStringMap_) { + *dest = (C.GoStringMap_)(registerHandle(gomap)) +} + +func splitCliArgs(args string) (result []string) { + prevSep := -1 + quoted := false + var i int + for i = 0; i < len(args); i++ { + if args[i] == '"' { + quoted = !quoted + if !quoted { + result = append(result, args[prevSep+1:i]) + } + prevSep = i + } else if !quoted && args[i] == ' ' { + if prevSep+1 < i { + result = append(result, args[prevSep+1:i]) + } + prevSep = i + } } + if len(args) > 0 { + if prevSep+1 < i { + result = append(result, args[prevSep+1:i]) + } + } + return } diff --git a/lib/cgo/tests/libsky_string.c b/lib/cgo/tests/libsky_string.c deleted file mode 100644 index 5cf44ff925..0000000000 --- a/lib/cgo/tests/libsky_string.c +++ /dev/null @@ -1,30 +0,0 @@ - -#include "skystring.h" - -#define ALPHANUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define ALPHANUM_LEN 62 -#define SIZE_ALL -1 - -void randBytes(GoSlice *bytes, size_t n) { - size_t i = 0; - unsigned char *ptr = (unsigned char *) bytes->data; - for (; i < n; ++i, ++ptr) { - *ptr = ALPHANUM[rand() % ALPHANUM_LEN]; - } - bytes->len = (GoInt) n; -} - -void strnhex(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789ABCDEF"; - char * pout = str; - for(; *pin && n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; -} - -void strhex(unsigned char* buf, char *str){ - strnhex(buf, str, SIZE_ALL); -} diff --git a/lib/cgo/tests/libsky_testutil.c b/lib/cgo/tests/libsky_testutil.c deleted file mode 100644 index b38a03be4a..0000000000 --- a/lib/cgo/tests/libsky_testutil.c +++ /dev/null @@ -1,121 +0,0 @@ - -#include -#include -#include -#include -#include - -#include "json.h" -#include "skytest.h" -#include "skytypes.h" - -int MEMPOOLIDX = 0; -void *MEMPOOL[1024 * 256]; - -int JSONPOOLIDX = 0; -json_value* JSON_POOL[128]; - -void* registerMemCleanup(void* p) { - int i; - for (i = 0; i < MEMPOOLIDX; i++) { - if(MEMPOOL[i] == NULL){ - MEMPOOL[i] = p; - return p; - } - } - MEMPOOL[MEMPOOLIDX++] = p; - return p; -} - -int registerJsonFree(void *p){ - int i; - for (i = 0; i < JSONPOOLIDX; i++) { - if(JSON_POOL[i] == NULL){ - JSON_POOL[i] = p; - return i; - } - } - JSON_POOL[JSONPOOLIDX++] = p; - return JSONPOOLIDX-1; -} - -void cleanupMem() { - int i; - void **ptr; - - for (i = MEMPOOLIDX, ptr = MEMPOOL; i; --i) { - if( *ptr ) { - free(*ptr); - *ptr = NULL; - } - ptr++; - } - MEMPOOLIDX = 0; - for (i = JSONPOOLIDX, ptr = (void*)JSON_POOL; i; --i) { - if( *ptr ) { - json_value_free(*ptr); - *ptr = NULL; - } - ptr++; - } - JSONPOOLIDX = 0; -} - -json_value* loadJsonFile(const char* filename){ - FILE *fp; - struct stat filestatus; - int file_size; - char* file_contents; - json_char* json; - json_value* value; - - if ( stat(filename, &filestatus) != 0) { - return NULL; - } - file_size = filestatus.st_size; - file_contents = (char*)malloc(filestatus.st_size); - if ( file_contents == NULL) { - return NULL; - } - fp = fopen(filename, "rt"); - if (fp == NULL) { - free(file_contents); - return NULL; - } - if ( fread(file_contents, file_size, 1, fp) != 1 ) { - fclose(fp); - free(file_contents); - return NULL; - } - fclose(fp); - - json = (json_char*)file_contents; - value = json_parse(json, file_size); - free(file_contents); - return value; -} - -void setup(void) { - srand ((unsigned int) time (NULL)); -} - -void teardown(void) { - cleanupMem(); -} - -// TODO: Move to libsky_io.c -void fprintbuff(FILE *f, void *buff, size_t n) { - unsigned char *ptr = (unsigned char *) buff; - fprintf(f, "[ "); - for (; n; --n, ptr++) { - fprintf(f, "%02d ", *ptr); - } - fprintf(f, "]"); -} - - -void toGoString(GoString_ *s, GoString *r){ -GoString * tmp = r; - - *tmp = (*(GoString *) s); -} diff --git a/lib/cgo/tests/testutils/base64.c b/lib/cgo/tests/testutils/base64.c index fa9585b4f4..f77da4121e 100644 --- a/lib/cgo/tests/testutils/base64.c +++ b/lib/cgo/tests/testutils/base64.c @@ -14,7 +14,7 @@ Thank you for inspiration: //Base64 char table - used internally for encoding unsigned char b64_chr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -unsigned int b64_int(unsigned int ch) { +int b64_int(unsigned int ch) { // ASCII to base64_int // 65-90 Upper Case >> 0-25 // 97-122 Lower Case >> 26-51 @@ -34,7 +34,7 @@ unsigned int b64_int(unsigned int ch) { return ch - 'A'; if ((ch>96) && (ch<123)) return (ch - 'a') + 26; - return 0; + return -1; //Invalid character, invalid base64 string } unsigned int b64e_size(unsigned int in_size) { @@ -51,7 +51,7 @@ unsigned int b64d_size(unsigned int in_size) { return ((3*in_size)/4); } -unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out) { +unsigned int b64_encode(const unsigned char * in, unsigned int in_len, unsigned char* out) { unsigned int i=0, j=0, k=0, s[3]; for (i=0;i>4); if (s[2]!=64) { @@ -149,7 +152,7 @@ unsigned int b64_encodef(char *InFile, char *OutFile) { return i; } -unsigned int b64_decodef(char *InFile, char *OutFile) { +int b64_decodef(char *InFile, char *OutFile) { FILE *pInFile = fopen(InFile,"rb"); FILE *pOutFile = fopen(OutFile,"wb"); @@ -157,12 +160,16 @@ unsigned int b64_decodef(char *InFile, char *OutFile) { return 0; unsigned int c=0, j=0, k=0, s[4]; + int n; while(c!=EOF) { c=fgetc(pInFile); if (c==EOF) break; - s[j++]=b64_int(c); + n = b64_int(c); + if( n < 0 ) + return -1; + s[j++] = (unsigned int)n; if (j==4) { fputc(((s[0]&255)<<2)+((s[1]&0x30)>>4),pOutFile); if (s[2]!=64) { @@ -182,6 +189,18 @@ unsigned int b64_decodef(char *InFile, char *OutFile) { fclose(pInFile); fclose(pOutFile); - return k; + return (int)k; } - +/* +unsigned int b64_encode_string(const unsigned char* in, unsigned int in_len, unsigned char* out){ + unsigned int* data = malloc(in_len * sizeof(unsigned int)); + unsigned int result = 0; + if ( data ) { + for(int i = 0; i < in_len; i++){ + data[i] = in[i]; + } + result = b64_encode(data, in_len, out); + free(data); + } + return result; +}*/ diff --git a/lib/cgo/tests/testutils/json.c b/lib/cgo/tests/testutils/json.c index bae4b35d73..a1fbe90d54 100644 --- a/lib/cgo/tests/testutils/json.c +++ b/lib/cgo/tests/testutils/json.c @@ -1,4 +1,3 @@ - /* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. diff --git a/lib/cgo/tests/testutils/json_util.c b/lib/cgo/tests/testutils/json_util.c index 63187bec17..ec741c3fa0 100644 --- a/lib/cgo/tests/testutils/json_util.c +++ b/lib/cgo/tests/testutils/json_util.c @@ -32,20 +32,23 @@ int json_set_string(json_value* value, const char* new_string_value){ return 0; } -int compareJsonValues(json_value* value1, json_value* value2); +int _compareJsonValues(json_value* value1, json_value* value2, const char* ignore); -int compareJsonObjects(json_value* value1, json_value* value2){ +int compareJsonObjects(json_value* value1, json_value* value2, + const char* ignore){ int length1 = value1->u.object.length; int length2 = value2->u.object.length; - if( length1 != length2 ) - return 0; + /*if( length1 != length2 ) + return 0;*/ for (int x = 0; x < length1; x++) { char* name = value1->u.object.values[x].name; + if( ignore != NULL && strcmp( ignore, name ) == 0) + continue; int found = 0; for( int y = 0; y < length2; y++){ if( strcmp( value2->u.object.values[y].name, name ) == 0){ - if( !compareJsonValues( value1->u.object.values[x].value, - value2->u.object.values[y].value ) ) + if( !_compareJsonValues( value1->u.object.values[x].value, + value2->u.object.values[y].value, ignore ) ) return 0; found = 1; break; @@ -57,19 +60,20 @@ int compareJsonObjects(json_value* value1, json_value* value2){ return 1; } -int compareJsonArrays(json_value* value1, json_value* value2){ +int compareJsonArrays(json_value* value1, json_value* value2, const char* ignore){ int length1 = value1->u.array.length; int length2 = value2->u.array.length; if( length1 != length2 ) return 0; for (int x = 0; x < length1; x++) { - if( !compareJsonValues(value1->u.array.values[x], value2->u.array.values[x]) ) + if( !_compareJsonValues(value1->u.array.values[x], + value2->u.array.values[x], ignore) ) return 0; } return 1; } -int compareJsonValues(json_value* value1, json_value* value2){ +int _compareJsonValues(json_value* value1, json_value* value2, const char* ignore){ if( value1 == NULL && value2 == NULL) return 1; if( value1 == NULL || value2 == NULL) @@ -80,9 +84,9 @@ int compareJsonValues(json_value* value1, json_value* value2){ case json_none: return 1; case json_object: - return compareJsonObjects(value1, value2); + return compareJsonObjects(value1, value2, ignore); case json_array: - return compareJsonArrays(value1, value2); + return compareJsonArrays(value1, value2, ignore); case json_integer: return value1->u.integer == value2->u.integer; case json_double: @@ -95,6 +99,14 @@ int compareJsonValues(json_value* value1, json_value* value2){ return 1; } +int compareJsonValues(json_value* value1, json_value* value2){ + return _compareJsonValues(value2, value1, NULL); +} + +int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, const char* ignoreList){ + return _compareJsonValues(value2, value1, ignoreList); +} + json_value* get_json_value_not_strict(json_value* node, const char* path, json_type type, int allow_null){ @@ -102,7 +114,7 @@ json_value* get_json_value_not_strict(json_value* node, const char* path, const char* p = strchr(path, '/'); if( p == NULL ) n = strlen(path); - else + else n = p - path; if( n > 0 ) { if( node->type == json_object){ @@ -112,11 +124,11 @@ json_value* get_json_value_not_strict(json_value* node, const char* path, json_value* value = entry->value; if( strncmp( path, name, n ) == 0){ if( p == NULL){ - if( value->type == type || + if( value->type == type || (allow_null && value->type == json_null)) return value; }else - return get_json_value_not_strict( + return get_json_value_not_strict( value, p + 1, type, allow_null); } } @@ -131,4 +143,3 @@ json_value* get_json_value(json_value* node, const char* path, json_type type){ get_json_value_not_strict(node, path, type, 1); } - diff --git a/lib/cgo/tests/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c similarity index 58% rename from lib/cgo/tests/libsky_criterion.c rename to lib/cgo/tests/testutils/libsky_criterion.c index 29c4700feb..361c447f85 100644 --- a/lib/cgo/tests/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -1,103 +1,137 @@ - -#include -#include "skycriterion.h" -#include "skystring.h" - -int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ - if(addr1->Version != addr2->Version) - return 0; - for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { - if(addr1->Key[i] != addr2->Key[i]) - return 0; - } - return 1; -} - -char *cr_user_cipher__Address_tostr(cipher__Address *addr1) -{ - char *out; - - cr_asprintf(&out, "(cipher__Address) { .Key = %s, .Version = %llu }", addr1->Key, (unsigned long long) addr1->Version); - return out; -} - -int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2){ - if(addr1->Version != addr2->Version) - return 0; - for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { - if(addr1->Key[i] != addr2->Key[i]) - return 0; - } - return 1; -} - -int cr_user_GoString_eq(GoString *string1, GoString *string2){ - return (string1->n == string2->n) && - (strcmp( (char *) string1->p, (char *) string2->p) == 0); -} - -char *cr_user_GoString_tostr(GoString *string) -{ - char *out; - cr_asprintf(&out, "(GoString) { .Data = %s, .Length = %llu }", - string->p, (unsigned long long) string->n); - return out; -} - -int cr_user_GoString__eq(GoString_ *string1, GoString_ *string2){ - return cr_user_GoString_eq((GoString *) &string1, (GoString *) &string2); -} - -char *cr_user_GoString__tostr(GoString_ *string) { - return cr_user_GoString_tostr((GoString *)string); -} - -int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2){ - return memcmp((void *)seckey1,(void *)seckey2, sizeof(cipher__SecKey)) == 0; -} - -char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) -{ - char *out; - char hexdump[101]; - - strnhex((unsigned char *)seckey1, hexdump, sizeof(cipher__SecKey)); - cr_asprintf(&out, "(cipher__SecKey) { %s }", hexdump); - return out; -} - - -int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) != 0; -} - -int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) == 0; -} - -char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) -{ - char *out; - char hexdump[101]; - - strnhex((unsigned char *)rp1, hexdump, sizeof(cipher__Ripemd160)); - cr_asprintf(&out, "(cipher__Ripemd160) { %s }", hexdump ); -} - -int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ - return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) != 0; -} - -int cr_user_cipher__SHA256_eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ - return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) == 0; -} - -char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) { - char *out; - char hexdump[101]; - - strnhex((unsigned char *)sh1, hexdump, sizeof(cipher__SHA256)); - cr_asprintf(&out, "(cipher__SHA256) { %s }", hexdump); - return out; -} - + +#include +#include "skycriterion.h" +#include "skystring.h" + +int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ + if(addr1->Version != addr2->Version) + return 0; + for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { + if(addr1->Key[i] != addr2->Key[i]) + return 0; + } + return 1; +} + +char *cr_user_cipher__Address_tostr(cipher__Address *addr1) +{ + char *out; + + cr_asprintf(&out, "(cipher__Address) { .Key = %s, .Version = %llu }", addr1->Key, (unsigned long long) addr1->Version); + return out; +} + +int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2){ + if(addr1->Version != addr2->Version) + return 0; + for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { + if(addr1->Key[i] != addr2->Key[i]) + return 0; + } + return 1; +} + +int cr_user_GoString_eq(GoString *string1, GoString *string2){ + return (string1->n == string2->n) && + (strcmp( (char *) string1->p, (char *) string2->p) == 0); +} + +char *cr_user_GoString_tostr(GoString *string) +{ + char *out; + cr_asprintf(&out, "(GoString) { .Data = %s, .Length = %llu }", + string->p, (unsigned long long) string->n); + return out; +} + +int cr_user_GoString__eq(GoString_ *string1, GoString_ *string2){ + return cr_user_GoString_eq((GoString *) string1, (GoString *) string2); +} + +char *cr_user_GoString__tostr(GoString_ *string) { + return cr_user_GoString_tostr((GoString *)string); +} + +int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2){ + return memcmp((void *)seckey1,(void *)seckey2, sizeof(cipher__SecKey)) == 0; +} + +char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) +{ + char *out; + char hexdump[101]; + + strnhex((unsigned char *)seckey1, hexdump, sizeof(cipher__SecKey)); + cr_asprintf(&out, "(cipher__SecKey) { %s }", hexdump); + return out; +} + + +int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) != 0; +} + +int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) == 0; +} + +char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1) +{ + char *out; + char hexdump[101]; + + strnhex((unsigned char *)rp1, hexdump, sizeof(cipher__Ripemd160)); + cr_asprintf(&out, "(cipher__Ripemd160) { %s }", hexdump ); +} + +int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ + return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) != 0; +} + +int cr_user_cipher__SHA256_eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ + return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) == 0; +} + +char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) { + char *out; + char hexdump[101]; + + strnhex((unsigned char *)sh1, hexdump, sizeof(cipher__SHA256)); + cr_asprintf(&out, "(cipher__SHA256) { %s }", hexdump); + return out; +} + +int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2){ + return + (slice1->len == slice2->len) && + (memcmp(slice1->data, slice2->data, slice1->len)==0); +} + +int cr_user_GoSlice_noteq(GoSlice *slice1, GoSlice *slice2){ + return !(((slice1->len == slice2->len)) && + (memcmp(slice1->data,slice2->data, slice1->len)==0)); +} + +char *cr_user_GoSlice_tostr(GoSlice *slice1) { + char *out; + cr_asprintf(&out, "(GoSlice) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + return out; +} + +int cr_user_GoSlice__eq(GoSlice_ *slice1, GoSlice_ *slice2){ + return ((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, slice1->len)==0 ); +} + +char *cr_user_GoSlice__tostr(GoSlice_ *slice1) { + char *out; + cr_asprintf(&out, "(GoSlice_) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + return out; +} + +int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2){ + for( int i = 0; i < 10; i++){ + if( f1->n[i] != f2->n[i]) + return 0; +} +return 1; +} diff --git a/lib/cgo/tests/testutils/libsky_number.c b/lib/cgo/tests/testutils/libsky_number.c new file mode 100644 index 0000000000..5b6c82bc7a --- /dev/null +++ b/lib/cgo/tests/testutils/libsky_number.c @@ -0,0 +1,13 @@ +#include "skynumber.h" + +int number_eq(Number* n1, Number* n2){ + if ( n1->neg != n2->neg ) + return 0; + if ( n1->nat.len != n2->nat.len ) + return 0; + for( int i = 0; i < n1->nat.len; i++){ + if( ((char*)n1->nat.data)[i] != ((char*)n2->nat.data)[i]) + return 0; + } + return 1; +} \ No newline at end of file diff --git a/lib/cgo/tests/testutils/libsky_string.c b/lib/cgo/tests/testutils/libsky_string.c new file mode 100644 index 0000000000..130761eb9c --- /dev/null +++ b/lib/cgo/tests/testutils/libsky_string.c @@ -0,0 +1,115 @@ + +#include "skystring.h" + +#define ALPHANUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +#define ALPHANUM_LEN 62 +#define SIZE_ALL -1 + +void randBytes(GoSlice *bytes, size_t n) { + size_t i = 0; + unsigned char *ptr = (unsigned char *) bytes->data; + for (; i < n; ++i, ++ptr) { + *ptr = ALPHANUM[rand() % ALPHANUM_LEN]; + } + bytes->len = (GoInt) n; +} + +void strnhex(unsigned char* buf, char *str, int n){ + unsigned char * pin = buf; + const char * hex = "0123456789ABCDEF"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; +} + +void strnhexlower(unsigned char* buf, char *str, int n){ + unsigned char * pin = buf; + const char * hex = "0123456789abcdef"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; +} + + +int hexnstr(const char* hex, unsigned char* str, int n){ + const char * pin = hex; + unsigned char * pout = str; + unsigned char c; + int odd = 0; + int size = 0; + for(; *pin && size < n; pin++){ + if(*pin >= '0' && *pin <= '9'){ + c = *pin - '0'; + } else if(*pin >= 'A' && *pin <= 'F'){ + c = 10 + (*pin - 'A'); + } else if(*pin >= 'a' && *pin <= 'f'){ + c = 10 + (*pin - 'a'); + } else { //Invalid hex string + return -1; + } + if(odd){ + *pout = (*pout << 4) | c; + pout++; + size++; + } else { + *pout = c; + } + odd = !odd; + } + if( odd ) + return -1; + if( size < n ) + *pout = 0; + return size; +} + +int cmpGoSlice_GoSlice(GoSlice *slice1, GoSlice_ *slice2){ + return ((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, sizeof(GoSlice_))==0 ); +} + +void bin2hex(unsigned char* buf, char *str, int n){ + unsigned char * pin = buf; + const char * hex = "0123456789ABCDEF"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; +} + +int string_has_suffix(const char* str, const char* suffix){ + int string_len = strlen(str); + int suffix_len = strlen(suffix); + if(string_len >= suffix_len){ + char* p = (char*)str + (string_len - suffix_len); + return strcmp(p, suffix) == 0; + } + return 0; +} + +int string_has_prefix(const char* str, const char* prefix){ + int string_len = strlen(str); + int prefix_len = strlen(prefix); + if(string_len >= prefix_len){ + return strncmp(str, prefix, prefix_len) == 0; + } + return 0; +} + +extern int count_words(const char* str, int length){ + int words = 1; + char prevChar = 0; + for(int i = 0; i < length; i++){ + char c = str[i]; + if( c == ' ' && prevChar != ' ' ) words++; + prevChar = c; + } + return words; +} diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c new file mode 100644 index 0000000000..a28b7af0dc --- /dev/null +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -0,0 +1,363 @@ + +#include +#include +#include +#include +#include +#include "json.h" +#include "skytypes.h" +#include "skytest.h" + +#define BUFFER_SIZE 1024 +#define stableWalletName "integration-test.wlt" +#define STRING_SIZE 128 +#define JSON_FILE_SIZE 4096 +#define JSON_BIG_FILE_SIZE 102400 +#define TEST_DATA_DIR "src/cli/integration/testdata/" +#define stableEncryptWalletName "integration-test-encrypted.wlt" + +//Define function pipe2 to avoid warning implicit declaration of function 'pipe2' +int pipe2(int pipefd[2], int flags); +//Define function SKY_handle_close to avoid including libskycoin.h +void SKY_handle_close(Handle p0); + +int MEMPOOLIDX = 0; +void *MEMPOOL[1024 * 256]; + +int JSONPOOLIDX = 0; +json_value* JSON_POOL[128]; + +int HANDLEPOOLIDX = 0; +Handle HANDLE_POOL[128]; + +typedef struct { + Client__Handle client; + WalletResponse__Handle wallet; +} wallet_register; + +int WALLETPOOLIDX = 0; +wallet_register WALLET_POOL[64]; + +int stdout_backup; +int pipefd[2]; + +void * registerMemCleanup(void *p) { + int i; + for (i = 0; i < MEMPOOLIDX; i++) { + if(MEMPOOL[i] == NULL){ + MEMPOOL[i] = p; + return p; + } + } + MEMPOOL[MEMPOOLIDX++] = p; + return p; +} + +void freeRegisteredMemCleanup(void *p){ + int i; + for (i = 0; i < MEMPOOLIDX; i++) { + if(MEMPOOL[i] == p){ + free(p); + MEMPOOL[i] = NULL; + break; + } + } +} + +int registerJsonFree(void *p){ + int i; + for (i = 0; i < JSONPOOLIDX; i++) { + if(JSON_POOL[i] == NULL){ + JSON_POOL[i] = p; + return i; + } + } + JSON_POOL[JSONPOOLIDX++] = p; + return JSONPOOLIDX-1; +} + +void freeRegisteredJson(void *p){ + int i; + for (i = 0; i < JSONPOOLIDX; i++) { + if(JSON_POOL[i] == p){ + JSON_POOL[i] = NULL; + json_value_free( (json_value*)p ); + break; + } + } +} + +int registerWalletClean(Client__Handle clientHandle, + WalletResponse__Handle walletHandle){ + int i; + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].wallet == 0 && WALLET_POOL[i].client == 0){ + WALLET_POOL[i].wallet = walletHandle; + WALLET_POOL[i].client = clientHandle; + return i; + } + } + WALLET_POOL[WALLETPOOLIDX].wallet = walletHandle; + WALLET_POOL[WALLETPOOLIDX].client = clientHandle; + return WALLETPOOLIDX++; +} + +int registerHandleClose(Handle handle){ + int i; + for (i = 0; i < HANDLEPOOLIDX; i++) { + if(HANDLE_POOL[i] == 0){ + HANDLE_POOL[i] = handle; + return i; + } + } + HANDLE_POOL[HANDLEPOOLIDX++] = handle; + return HANDLEPOOLIDX - 1; +} + +void closeRegisteredHandle(Handle handle){ + int i; + for (i = 0; i < HANDLEPOOLIDX; i++) { + if(HANDLE_POOL[i] == handle){ + HANDLE_POOL[i] = 0; + SKY_handle_close(handle); + break; + } + } +} + +void cleanupWallet(Client__Handle client, WalletResponse__Handle wallet){ + int result; + GoString_ strWalletDir; + GoString_ strFileName; + memset(&strWalletDir, 0, sizeof(GoString_)); + memset(&strFileName, 0, sizeof(GoString_)); + + + result = SKY_api_Handle_Client_GetWalletDir(client, &strWalletDir); + if( result != SKY_OK ){ + return; + } + result = SKY_api_Handle_Client_GetWalletFileName(wallet, &strFileName); + if( result != SKY_OK ){ + free( (void*)strWalletDir.p ); + return; + } + char fullPath[128]; + if( strWalletDir.n + strFileName.n < 126){ + strcpy( fullPath, strWalletDir.p ); + if( fullPath[0] == 0 || fullPath[strlen(fullPath) - 1] != '/' ) + strcat(fullPath, "/"); + strcat( fullPath, strFileName.p ); + result = unlink( fullPath ); + if( strlen(fullPath) < 123 ){ + strcat( fullPath, ".bak" ); + result = unlink( fullPath ); + } + } + GoString str = { strFileName.p, strFileName.n }; + result = SKY_api_Client_UnloadWallet( client, str ); + GoString strFullPath = { fullPath, strlen(fullPath) }; + free( (void*)strWalletDir.p ); + free( (void*)strFileName.p ); +} + +void cleanRegisteredWallet( + Client__Handle client, + WalletResponse__Handle wallet){ + + int i; + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].wallet == wallet && WALLET_POOL[i].client == client){ + WALLET_POOL[i].wallet = 0; + WALLET_POOL[i].client = 0; + cleanupWallet( client, wallet ); + return; + } + } +} + +void cleanupMem() { + int i; + + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].client != 0 && WALLET_POOL[i].wallet != 0){ + cleanupWallet( WALLET_POOL[i].client, WALLET_POOL[i].wallet ); + } + } + + void **ptr; + for (i = MEMPOOLIDX, ptr = MEMPOOL; i; --i) { + if( *ptr ) + free(*ptr); + ptr++; + } + for (i = JSONPOOLIDX, ptr = (void*)JSON_POOL; i; --i) { + if( *ptr ) + json_value_free(*ptr); + ptr++; + } + for (i = 0; i < HANDLEPOOLIDX; i++) { + if( HANDLE_POOL[i] ) + SKY_handle_close(HANDLE_POOL[i]); + } +} + +void redirectStdOut(){ + stdout_backup = dup(fileno(stdout)); + pipe2(pipefd, 0); + dup2(pipefd[1], fileno(stdout)); +} + +int getStdOut(char* str, unsigned int max_size){ + fflush(stdout); + close(pipefd[1]); + dup2(stdout_backup, fileno(stdout)); + int bytes_read = read(pipefd[0], str, max_size - 1); + if( bytes_read > 0 && bytes_read < max_size) + str[bytes_read] = 0; + close(pipefd[0]); + return bytes_read; +} + +json_value* loadJsonFile(const char* filename){ + FILE *fp; + struct stat filestatus; + int file_size; + char* file_contents; + json_char* json; + json_value* value; + + if ( stat(filename, &filestatus) != 0) { + return NULL; + } + file_size = filestatus.st_size; + file_contents = (char*)malloc(filestatus.st_size); + if ( file_contents == NULL) { + return NULL; + } + fp = fopen(filename, "rt"); + if (fp == NULL) { + free(file_contents); + return NULL; + } + if ( fread(file_contents, file_size, 1, fp) != 1 ) { + fclose(fp); + free(file_contents); + return NULL; + } + fclose(fp); + + json = (json_char*)file_contents; + value = json_parse(json, file_size); + free(file_contents); + return value; +} + + +void setup(void) { + srand ((unsigned int) time (NULL)); +} + +void teardown(void) { + cleanupMem(); +} + +// TODO: Move to libsky_io.c +void fprintbuff(FILE *f, void *buff, size_t n) { + unsigned char *ptr = (unsigned char *) buff; + fprintf(f, "[ "); + for (; n; --n, ptr++) { + fprintf(f, "%02d ", *ptr); + } + fprintf(f, "]"); +} + +int parseBoolean(const char* str, int length){ + int result = 0; + if(length == 1){ + result = str[0] == '1' || str[0] == 't' || str[0] == 'T'; + } else { + result = strncmp(str, "true", length) == 0 || + strncmp(str, "True", length) == 0 || + strncmp(str, "TRUE", length) == 0; + } + return result; +} + +void toGoString(GoString_ *s, GoString *r){ +GoString * tmp = r; + + *tmp = (*(GoString *) s); +} + +/* +json_value *loadGoldenFile_Cli(const char *file) { + char path[STRING_SIZE]; + if (strlen(TEST_DATA_DIR) + strlen(file) < STRING_SIZE) { + strcpy(path, TEST_DATA_DIR); + strcat(path, file); + return loadJsonFile(path); + } + return NULL; +} + +void createTempWalletDir(bool encrypt) { + const char *temp = "build/libskycoin/wallet-data-dir"; + + int valueMkdir = mkdir(temp, S_IRWXU); + + if (valueMkdir == -1) { + int errr = system("rm -r build/libskycoin/wallet-data-dir/*.*"); + } + + // Copy the testdata/$stableWalletName to the temporary dir. + char walletPath[JSON_BIG_FILE_SIZE]; + if (encrypt) { + strcpy(walletPath, stableEncryptWalletName); + } else { + strcpy(walletPath, stableWalletName); + } + unsigned char pathnameURL[BUFFER_SIZE]; + strcpy(pathnameURL, temp); + strcat(pathnameURL, "/"); + strcat(pathnameURL, walletPath); + + FILE *rf; + FILE *f; + f = fopen(pathnameURL, "wb"); + unsigned char fullUrl[BUFFER_SIZE]; + strcpy(fullUrl, TEST_DATA_DIR); + strcat(fullUrl, walletPath); + rf = fopen(fullUrl, "rb"); + unsigned char buff[2048]; + int readBits; + // Copy file rf to f + if (f && rf) { + while ((readBits = fread(buff, 1, 2048, rf))) + fwrite(buff, 1, readBits, f); + + fclose(rf); + fclose(f); + + GoString WalletDir = {"WALLET_DIR", 10}; + GoString Dir = {temp, strlen(temp)}; + SKY_cli_Setenv(WalletDir, Dir); + GoString WalletPath = {"WALLET_NAME", 11}; + GoString pathname = {walletPath, strlen(walletPath)}; + SKY_cli_Setenv(WalletPath, pathname); + } + strcpy(walletPath, ""); +}; + + +int getCountWord(const char *str) { + int len = 0; + do { + str = strpbrk(str, " "); // find separator + if (str) + str += strspn(str, " "); // skip separator + ++len; // increment word count + } while (str && *str); + + return len; +}*/ diff --git a/lib/cgo/testutil.assert.assertions.go b/lib/cgo/testutil.assert.assertions.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/testutil.assert.assertions.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/testutil.require.require.go b/lib/cgo/testutil.require.require.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/testutil.require.require.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/testutil.testutil.go b/lib/cgo/testutil.testutil.go new file mode 100644 index 0000000000..081543f75e --- /dev/null +++ b/lib/cgo/testutil.testutil.go @@ -0,0 +1,27 @@ +package main + +import ( + "unsafe" + + testutil "github.com/skycoin/skycoin/src/testutil" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_testutil_MakeAddress +func SKY_testutil_MakeAddress(_arg0 *C.cipher__Address) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := testutil.MakeAddress() + *_arg0 = *(*C.cipher__Address)(unsafe.Pointer(&__arg0)) + return +} diff --git a/lib/cgo/util.apputil.apputil.go b/lib/cgo/util.apputil.apputil.go new file mode 100644 index 0000000000..ef72046d7c --- /dev/null +++ b/lib/cgo/util.apputil.apputil.go @@ -0,0 +1,42 @@ +package main + +import apputil "github.com/skycoin/skycoin/src/util/apputil" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_apputil_CatchInterruptPanic +func SKY_apputil_CatchInterruptPanic() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + apputil.CatchInterruptPanic() + return +} + +//export SKY_apputil_CatchDebug +func SKY_apputil_CatchDebug() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + apputil.CatchDebug() + return +} + +//export SKY_apputil_PrintProgramStatus +func SKY_apputil_PrintProgramStatus() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + apputil.PrintProgramStatus() + return +} diff --git a/lib/cgo/util.browser.browser.go b/lib/cgo/util.browser.browser.go new file mode 100644 index 0000000000..579e18dfaf --- /dev/null +++ b/lib/cgo/util.browser.browser.go @@ -0,0 +1,26 @@ +package main + +import browser "github.com/skycoin/skycoin/src/util/browser" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_browser_Open +func SKY_browser_Open(_url string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + url := _url + ____return_err := browser.Open(url) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/util.cert.cert.go b/lib/cgo/util.cert.cert.go new file mode 100644 index 0000000000..19edececba --- /dev/null +++ b/lib/cgo/util.cert.cert.go @@ -0,0 +1,29 @@ +package main + +import cert "github.com/skycoin/skycoin/src/util/cert" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cert_CreateCertIfNotExists +func SKY_cert_CreateCertIfNotExists(_host, _certFile, _keyFile string, _appName string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + host := _host + certFile := _certFile + keyFile := _keyFile + appName := _appName + ____return_err := cert.CreateCertIfNotExists(host, certFile, keyFile, appName) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/util.droplet.droplet.go b/lib/cgo/util.droplet.droplet.go new file mode 100644 index 0000000000..26d194bf1a --- /dev/null +++ b/lib/cgo/util.droplet.droplet.go @@ -0,0 +1,42 @@ +package main + +import droplet "github.com/skycoin/skycoin/src/util/droplet" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_droplet_FromString +func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := _b + __arg1, ____return_err := droplet.FromString(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_droplet_ToString +func SKY_droplet_ToString(_n uint64, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + n := _n + __arg1, ____return_err := droplet.ToString(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} diff --git a/lib/cgo/util.elapse.elapser.go b/lib/cgo/util.elapse.elapser.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.elapse.elapser.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go new file mode 100644 index 0000000000..fc2a842d09 --- /dev/null +++ b/lib/cgo/util.fee.fee.go @@ -0,0 +1,86 @@ +package main + +import ( + "unsafe" + + coin "github.com/skycoin/skycoin/src/coin" + fee "github.com/skycoin/skycoin/src/util/fee" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_fee_VerifyTransactionFee +func SKY_fee_VerifyTransactionFee(_t *C.coin__Transaction, _fee uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + t := (*coin.Transaction)(unsafe.Pointer(_t)) + ____return_err := fee.VerifyTransactionFee(t, _fee) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_fee_VerifyTransactionFeeForHours +func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + hours := _hours + ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_fee_RequiredFee +func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + hours := _hours + __arg1 := fee.RequiredFee(hours) + *_arg1 = __arg1 + return +} + +//export SKY_fee_RemainingHours +func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + hours := _hours + __arg1 := fee.RemainingHours(hours) + *_arg1 = __arg1 + return +} + +//export SKY_fee_TransactionFee +func SKY_fee_TransactionFee(_tx *C.coin__Transaction, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + headTime := _headTime + inUxs := *(*coin.UxArray)(unsafe.Pointer(_inUxs)) + __arg3, ____return_err := fee.TransactionFee(tx, headTime, inUxs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = __arg3 + } + return +} diff --git a/lib/cgo/util.file.file.go b/lib/cgo/util.file.file.go new file mode 100644 index 0000000000..4b3e608b34 --- /dev/null +++ b/lib/cgo/util.file.file.go @@ -0,0 +1,67 @@ +package main + +import file "github.com/skycoin/skycoin/src/util/file" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_file_InitDataDir +func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + dir := _dir + __arg1, ____return_err := file.InitDataDir(dir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_file_UserHome +func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := file.UserHome() + copyString(__arg0, _arg0) + return +} + +//export SKY_file_ResolveResourceDirectory +func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + path := _path + __arg1 := file.ResolveResourceDirectory(path) + copyString(__arg1, _arg1) + return +} + +//export SKY_file_DetermineResourcePath +func SKY_file_DetermineResourcePath(_staticDir string, _resourceDir string, _devDir string, _arg3 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + staticDir := _staticDir + resourceDir := _resourceDir + devDir := _devDir + __arg3, ____return_err := file.DetermineResourcePath(staticDir, resourceDir, devDir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg3, _arg3) + } + return +} diff --git a/lib/cgo/util.http.error.go b/lib/cgo/util.http.error.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.http.error.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.http.handler.go b/lib/cgo/util.http.handler.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.http.handler.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.http.json.go b/lib/cgo/util.http.json.go new file mode 100644 index 0000000000..6be88017c7 --- /dev/null +++ b/lib/cgo/util.http.json.go @@ -0,0 +1,131 @@ +package main + +import ( + "reflect" + "unsafe" + + http "github.com/skycoin/skycoin/src/util/http" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_httphelper_Address_UnmarshalJSON +func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + a := inplaceHttpHelperAddress(_a) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := a.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Address_MarshalJSON +func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + a := *inplaceHttpHelperAddress(_a) + __arg0, ____return_err := a.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Coins_UnmarshalJSON +func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c := (*http.Coins)(unsafe.Pointer(_c)) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := c.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Coins_MarshalJSON +func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c := *(*http.Coins)(unsafe.Pointer(_c)) + __arg0, ____return_err := c.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Coins_Value +func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + c := *(*http.Coins)(unsafe.Pointer(_c)) + __arg0 := c.Value() + *_arg0 = __arg0 + return +} + +//export SKY_httphelper_Hours_UnmarshalJSON +func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + h := (*http.Hours)(unsafe.Pointer(_h)) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := h.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Hours_MarshalJSON +func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + h := *(*http.Hours)(unsafe.Pointer(_h)) + __arg0, ____return_err := h.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Hours_Value +func SKY_httphelper_Hours_Value(_h *C.httphelper__Hours, _arg0 *uint64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + h := *(*http.Hours)(unsafe.Pointer(_h)) + __arg0 := h.Value() + *_arg0 = __arg0 + return +} diff --git a/lib/cgo/util.http.log.go b/lib/cgo/util.http.log.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.http.log.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.iputil.iputil.go b/lib/cgo/util.iputil.iputil.go new file mode 100644 index 0000000000..b42ea95cc0 --- /dev/null +++ b/lib/cgo/util.iputil.iputil.go @@ -0,0 +1,54 @@ +package main + +import iputil "github.com/skycoin/skycoin/src/util/iputil" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_iputil_LocalhostIP +func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0, ____return_err := iputil.LocalhostIP() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_iputil_IsLocalhost +func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := _addr + __arg1 := iputil.IsLocalhost(addr) + *_arg1 = __arg1 + return +} + +//export SKY_iputil_SplitAddr +func SKY_iputil_SplitAddr(_addr string, _arg1 *C.GoString_, _arg2 *uint16) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + addr := _addr + __arg1, __arg2, ____return_err := iputil.SplitAddr(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + *_arg2 = __arg2 + } + return +} diff --git a/lib/cgo/util.logging.formatter.go b/lib/cgo/util.logging.formatter.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.logging.formatter.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.logging.hooks.go b/lib/cgo/util.logging.hooks.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.logging.hooks.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.logging.logger.go b/lib/cgo/util.logging.logger.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/util.logging.logger.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/util.logging.logging.go b/lib/cgo/util.logging.logging.go new file mode 100644 index 0000000000..07260b286e --- /dev/null +++ b/lib/cgo/util.logging.logging.go @@ -0,0 +1,42 @@ +package main + +import logging "github.com/skycoin/skycoin/src/util/logging" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_logging_EnableColors +func SKY_logging_EnableColors() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + logging.EnableColors() + return +} + +//export SKY_logging_DisableColors +func SKY_logging_DisableColors() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + logging.DisableColors() + return +} + +//export SKY_logging_Disable +func SKY_logging_Disable() (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + logging.Disable() + return +} diff --git a/lib/cgo/util.utc.utc.go b/lib/cgo/util.utc.utc.go new file mode 100644 index 0000000000..03dbc8034a --- /dev/null +++ b/lib/cgo/util.utc.utc.go @@ -0,0 +1,23 @@ +package main + +import utc "github.com/skycoin/skycoin/src/util/utc" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_utc_UnixNow +func SKY_utc_UnixNow(_arg0 *int64) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := utc.UnixNow() + *_arg0 = __arg0 + return +} diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go new file mode 100644 index 0000000000..64e457cffe --- /dev/null +++ b/lib/cgo/wallet.addresses.go @@ -0,0 +1,61 @@ +package main + +import ( + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_CreateAddresses +func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _hideSecretKey bool, _arg4 *C.ReadableWallet__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + coinType := _coinType + seed := _seed + genCount := _genCount + hideSecretKey := _hideSecretKey + __arg4, ____return_err := wallet.CreateAddresses(wallet.CoinType(coinType), seed, genCount, hideSecretKey) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg4 = registerReadableWalletHandle(__arg4) + } + return +} + +//export SKY_wallet_GetSkycoinWalletEntry +func SKY_wallet_GetSkycoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) + sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) + __arg2 := wallet.GetSkycoinWalletEntry(pub, sec) + *_arg2 = registerReadableEntryHandle(&__arg2) + return +} + +//export SKY_wallet_GetBitcoinWalletEntry +func SKY_wallet_GetBitcoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) + sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) + __arg2 := wallet.GetBitcoinWalletEntry(pub, sec) + *_arg2 = registerReadableEntryHandle(&__arg2) + return +} diff --git a/lib/cgo/wallet.balance.go b/lib/cgo/wallet.balance.go new file mode 100644 index 0000000000..45c4d1f093 --- /dev/null +++ b/lib/cgo/wallet.balance.go @@ -0,0 +1,100 @@ +package main + +import ( + "unsafe" + + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewBalance +func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + coins := _coins + hours := _hours + __arg1 := wallet.NewBalance(coins, hours) + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_NewBalanceFromUxOut +func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__Balance) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + headTime := _headTime + ux := (*coin.UxOut)(unsafe.Pointer(_ux)) + __arg2, ____return_err := wallet.NewBalanceFromUxOut(headTime, ux) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg2)) + } + return +} + +//export SKY_wallet_Balance_Add +func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1, ____return_err := bal.Add(other) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + } + return +} + +//export SKY_wallet_Balance_Sub +func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1 := bal.Sub(other) + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_Balance_Equals +func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1 := bal.Equals(other) + *_arg1 = __arg1 + return +} + +//export SKY_wallet_Balance_IsZero +func SKY_wallet_Balance_IsZero(_bal *C.wallet__Balance, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + __arg0 := bal.IsZero() + *_arg0 = __arg0 + return +} diff --git a/lib/cgo/wallet.crypto.go b/lib/cgo/wallet.crypto.go new file mode 100644 index 0000000000..f0ef2fddac --- /dev/null +++ b/lib/cgo/wallet.crypto.go @@ -0,0 +1,29 @@ +package main + +import ( + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_CryptoTypeFromString +func SKY_wallet_CryptoTypeFromString(_s string, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + s := _s + __arg1, ____return_err := wallet.CryptoTypeFromString(s) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(string(__arg1), _arg1) + } + return +} diff --git a/lib/cgo/wallet.entry.go b/lib/cgo/wallet.entry.go new file mode 100644 index 0000000000..11137bb74c --- /dev/null +++ b/lib/cgo/wallet.entry.go @@ -0,0 +1,44 @@ +package main + +import ( + "unsafe" + + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_Entry_Verify +func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + we := (*wallet.Entry)(unsafe.Pointer(_we)) + ____return_err := we.Verify() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Entry_VerifyPublic +func SKY_wallet_Entry_VerifyPublic(_we *C.wallet__Entry) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + we := (*wallet.Entry)(unsafe.Pointer(_we)) + ____return_err := we.VerifyPublic() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go new file mode 100644 index 0000000000..cb527a6ae6 --- /dev/null +++ b/lib/cgo/wallet.notes.go @@ -0,0 +1,197 @@ +package main + +import ( + "reflect" + "unsafe" + + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewNotesFilename +func SKY_wallet_NewNotesFilename(_arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + __arg0 := wallet.NewNotesFilename() + copyString(__arg0, _arg0) + return +} + +//export SKY_wallet_LoadNotes +func SKY_wallet_LoadNotes(_dir string, _arg1 *C.wallet__Notes) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + dir := _dir + __arg1, ____return_err := wallet.LoadNotes(dir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__Notes)(unsafe.Pointer(&__arg1)) + } + return +} + +//export SKY_wallet_LoadReadableNotes +func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + filename := _filename + __arg1, ____return_err := wallet.LoadReadableNotes(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_wallet_ReadableNotes_Load +func SKY_wallet_ReadableNotes_Load(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + filename := _filename + ____return_err := rns.Load(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_ReadableNotes_ToNotes +func SKY_wallet_ReadableNotes_ToNotes(_rns *C.wallet__ReadableNotes, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rns := *(*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + __arg0, ____return_err := rns.ToNotes() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_wallet_ReadableNotes_Save +func SKY_wallet_ReadableNotes_Save(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + filename := _filename + ____return_err := rns.Save(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_NewReadableNote +func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__ReadableNote) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + note := *(*wallet.Note)(unsafe.Pointer(_note)) + __arg1 := wallet.NewReadableNote(note) + *_arg1 = *(*C.wallet__ReadableNote)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_NewReadableNotesFromNotes +func SKY_wallet_NewReadableNotesFromNotes(_w *C.wallet__Notes, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + w := *(*wallet.Notes)(unsafe.Pointer(_w)) + __arg1 := wallet.NewReadableNotesFromNotes(w) + *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_Notes_Save +func SKY_wallet_Notes_Save(_notes *C.wallet__Notes, _dir string, _fileName string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + dir := _dir + fileName := _fileName + ____return_err := notes.Save(dir, fileName) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Notes_SaveNote +func SKY_wallet_Notes_SaveNote(_notes *C.wallet__Notes, _dir string, _note *C.wallet__Note) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + dir := _dir + note := *(*wallet.Note)(unsafe.Pointer(_note)) + ____return_err := notes.SaveNote(dir, note) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Notes_ToReadable +func SKY_wallet_Notes_ToReadable(_notes *C.wallet__Notes, _arg0 *C.wallet__ReadableNotes) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + notes := *(*wallet.Notes)(unsafe.Pointer(_notes)) + __arg0 := notes.ToReadable() + *_arg0 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_wallet_NotesFileExist +func SKY_wallet_NotesFileExist(_dir string, _arg1 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + dir := _dir + __arg1, ____return_err := wallet.NotesFileExist(dir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_wallet_CreateNoteFileIfNotExist +func SKY_wallet_CreateNoteFileIfNotExist(_dir string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + dir := _dir + wallet.CreateNoteFileIfNotExist(dir) + return +} diff --git a/lib/cgo/wallet.readable.go b/lib/cgo/wallet.readable.go new file mode 100644 index 0000000000..5105d8f993 --- /dev/null +++ b/lib/cgo/wallet.readable.go @@ -0,0 +1,142 @@ +package main + +import ( + "unsafe" + + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewReadableEntry +func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + w := *(*wallet.Entry)(unsafe.Pointer(_w)) + __arg1 := wallet.NewReadableEntry(w) + *_arg1 = registerReadableEntryHandle(&__arg1) + return +} + +//export SKY_wallet_LoadReadableEntry +func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + filename := _filename + __arg1, ____return_err := wallet.LoadReadableEntry(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerReadableEntryHandle(&__arg1) + } + return +} + +//export SKY_wallet_NewReadableEntryFromPubkey +func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + pub := _pub + __arg1 := wallet.NewReadableEntryFromPubkey(pub) + *_arg1 = registerReadableEntryHandle(&__arg1) + return +} + +//export SKY_wallet_ReadableEntry_Save +func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + re, okre := lookupReadableEntryHandle(_re) + if !okre { + ____error_code = SKY_ERROR + return + } + filename := _filename + ____return_err := re.Save(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_LoadReadableWallet +func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + filename := _filename + __arg1, ____return_err := wallet.LoadReadableWallet(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerReadableWalletHandle(__arg1) + } + return +} + +//export SKY_wallet_ReadableWallet_Save +func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_ERROR + return + } + filename := _filename + ____return_err := rw.Save(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_ReadableWallet_Load +func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_ERROR + return + } + filename := _filename + ____return_err := rw.Load(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_ReadableWallet_Erase +func SKY_wallet_ReadableWallet_Erase(_rw C.ReadableWallet__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_ERROR + return + } + rw.Erase() + return +} diff --git a/lib/cgo/wallet.secrets.go b/lib/cgo/wallet.secrets.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/wallet.secrets.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/wallet.service.go b/lib/cgo/wallet.service.go new file mode 100644 index 0000000000..ff3967e25a --- /dev/null +++ b/lib/cgo/wallet.service.go @@ -0,0 +1,10 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" diff --git a/lib/cgo/wallet.wallet.go b/lib/cgo/wallet.wallet.go index 22b1a3cf97..8d2a1b3203 100644 --- a/lib/cgo/wallet.wallet.go +++ b/lib/cgo/wallet.wallet.go @@ -10,6 +10,7 @@ import ( ) /* + #include #include @@ -17,9 +18,23 @@ import ( */ import "C" +//export SKY_wallet_NewError +func SKY_wallet_NewError(_err error) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + err := _err + ____return_err := wallet.NewError(err) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + //export SKY_wallet_NewWallet func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -40,7 +55,7 @@ func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wal //export SKY_wallet_Wallet_Lock func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType string) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -60,7 +75,7 @@ func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType s //export SKY_wallet_Wallet_Unlock func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -80,7 +95,7 @@ func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wa //export SKY_wallet_Load func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -95,7 +110,7 @@ func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code u //export SKY_wallet_Wallet_Save func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -114,7 +129,7 @@ func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code ui //export SKY_wallet_Wallet_Validate func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -131,8 +146,8 @@ func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { } //export SKY_wallet_Wallet_Type -func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -141,14 +156,14 @@ func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____e ____error_code = SKY_ERROR return } - __argSKY_OK := w.Type() - copyString(__argSKY_OK, _argSKY_OK) + __arg0 := w.Type() + copyString(__arg0, _arg0) return } //export SKY_wallet_Wallet_Version -func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -157,14 +172,14 @@ func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (__ ____error_code = SKY_ERROR return } - __argSKY_OK := w.Version() - copyString(__argSKY_OK, _argSKY_OK) + __arg0 := w.Version() + copyString(__arg0, _arg0) return } //export SKY_wallet_Wallet_Filename -func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -173,14 +188,14 @@ func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (_ ____error_code = SKY_ERROR return } - __argSKY_OK := w.Filename() - copyString(__argSKY_OK, _argSKY_OK) + __arg0 := w.Filename() + copyString(__arg0, _arg0) return } //export SKY_wallet_Wallet_Label -func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -189,14 +204,14 @@ func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _argSKY_OK *C.GoString_) (____ ____error_code = SKY_ERROR return } - __argSKY_OK := w.Label() - copyString(__argSKY_OK, _argSKY_OK) + __arg0 := w.Label() + copyString(__arg0, _arg0) return } //export SKY_wallet_Wallet_IsEncrypted -func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _argSKY_OK *bool) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -205,14 +220,14 @@ func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _argSKY_OK *bool) (____e ____error_code = SKY_ERROR return } - __argSKY_OK := w.IsEncrypted() - *_argSKY_OK = __argSKY_OK + __arg0 := w.IsEncrypted() + *_arg0 = __arg0 return } //export SKY_wallet_Wallet_GenerateAddresses func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -231,8 +246,8 @@ func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 } //export SKY_wallet_Wallet_GetAddresses -func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _argSKY_OK *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK +func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -241,14 +256,14 @@ func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _argSKY_OK *C.GoSlice_) ____error_code = SKY_ERROR return } - __argSKY_OK := w.GetAddresses() - copyToGoSlice(reflect.ValueOf(__argSKY_OK), _argSKY_OK) + __arg0 := w.GetAddresses() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_wallet_Wallet_GetEntry func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg1 *C.wallet__Entry, _arg2 *bool) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -266,7 +281,7 @@ func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg //export SKY_wallet_Wallet_AddEntry func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -285,7 +300,7 @@ func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (_ //export SKY_wallet_DistributeSpendHours func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bool, _arg2 *uint64, _arg3 *C.GoSlice_, _arg4 *uint64) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -301,7 +316,7 @@ func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bo //export SKY_wallet_DistributeCoinHoursProportional func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -317,7 +332,7 @@ func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, //export SKY_wallet_NewUxBalances func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -333,7 +348,7 @@ func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C. //export SKY_wallet_NewUxBalance func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__UxBalance) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -349,7 +364,7 @@ func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wall //export SKY_wallet_ChooseSpendsMinimizeUxOuts func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -366,7 +381,7 @@ func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _ //export SKY_wallet_ChooseSpendsMaximizeUxOuts func SKY_wallet_ChooseSpendsMaximizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK + ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() From 4b676645105ec235f88d081feb8d6a5fd661bcd3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 16:01:54 +0000 Subject: [PATCH 009/399] [libc] refs #1191. Added C library exported function SKY_coin_NewBlock. Added new test for this function. [====] Synthesis: Tested: 52 | Passing: 52 | Failing: 0 | Crashing: 0. --- lib/cgo/coin.block.go | 20 ++++++ lib/cgo/tests/check_coin.block.c | 82 ++++++++++++++++++++++ lib/cgo/tests/testutils/libsky_criterion.c | 52 ++++++++++---- 3 files changed, 141 insertions(+), 13 deletions(-) create mode 100644 lib/cgo/tests/check_coin.block.c diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index ddb59e7a8b..f446afe0e0 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -17,6 +17,26 @@ import ( */ import "C" +//export SKY_coin_NewBlock +func SKY_coin_NewBlock(_b *C.coin__Block, _currentTime uint64, _hash *C.cipher__SHA256, _txns *C.coin__Transactions, _fee uint64, _arg2 *C.coin__Block) (____error_code uint32) { + feeCalculator := func(t *coin.Transaction) (uint64, error) { + return _fee, nil + } + + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b := *(*coin.Block)(unsafe.Pointer(_b)) + hash := *(*cipher.SHA256)(unsafe.Pointer(_hash)) + txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + __arg2, ____return_err := coin.NewBlock(b, _currentTime, hash, txns, feeCalculator) + if ____return_err == nil { + *_arg2 = *(*C.coin__Block)(unsafe.Pointer(__arg2)) + } + return +} + //export SKY_coin_SignedBlock_VerifySignature func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.cipher__PubKey) (____error_code uint32) { ____error_code = 0 diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c new file mode 100644 index 0000000000..b246e018da --- /dev/null +++ b/lib/cgo/tests/check_coin.block.c @@ -0,0 +1,82 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +TestSuite(coin_block, .init = setup, .fini = teardown); + +int newBlock(cipher__SHA256* uxHash, coin__Block* newBlock){ + int result; + cipher__SHA256 bodyhash; + coin__Block block; + coin__Transactions transactions; + + memset(&block, 0, sizeof(coin__Block)); + memset(&transactions, 0, sizeof(coin__Transactions)); + memset(newBlock, 0, sizeof(coin__Block)); + + block.Head.Version = 0x02; + block.Head.Time = 100; + block.Head.BkSeq = 0; + block.Head.Fee = 10; + result = SKY_coin_BlockBody_Hash(&block.Body, &bodyhash); + cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); + result = SKY_coin_NewBlock(&block, 100 + 200, uxHash, &transactions, 0, newBlock); + cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); + return result; +} + +Test(coin_block, TestNewBlock) { + coin__Block prevBlock; + coin__Block newBlock; + coin__Transactions transactions; + memset(&prevBlock, 0, sizeof(coin__Block)); + memset(&newBlock, 0, sizeof(coin__Block)); + memset(&transactions, 0, sizeof(coin__Transactions)); + + prevBlock.Head.Version = 0x02; + prevBlock.Head.Time = 100; + prevBlock.Head.BkSeq = 98; + int result; + + GoSlice slice; + memset(&slice, 0, sizeof(GoSlice)); + cipher__SHA256 hash; + + result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); + cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + result = SKY_cipher_SumSHA256( slice, &hash ); + cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); + + result = SKY_coin_NewBlock(&prevBlock, 133, &hash, NULL, 0, &newBlock); + cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); + transactions.data = malloc(sizeof(coin__Transaction)); + registerMemCleanup(transactions.data); + transactions.len = 1; + transactions.cap = 1; + memset(transactions.data, 0, sizeof(coin__Transaction)); + GoUint64 fee = 121; + GoUint64 currentTime = 133; + + result = SKY_coin_NewBlock(&prevBlock, currentTime, &hash, &transactions, fee, &newBlock); + cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); + cr_assert( eq( type(GoSlice), *((GoSlice*)&newBlock.Body.Transactions), *((GoSlice*)&transactions)) ); + cr_assert( eq(newBlock.Head.Fee, fee * (GoUint64)( transactions.len ))); + cr_assert( eq(newBlock.Head.Time, currentTime)); + cr_assert( eq(newBlock.Head.BkSeq, prevBlock.Head.BkSeq + 1)); + cr_assert( eq( u8[sizeof(cipher__SHA256)], newBlock.Head.UxHash, hash) ); + + coin__BlockBody body; + memset(&body, 0, sizeof(coin__BlockBody)); + body.Transactions.data = transactions.data; + body.Transactions.len = transactions.len; + body.Transactions.cap = transactions.cap; + cr_assert( eq(type(coin__BlockBody), newBlock.Body, body) ); +} diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 361c447f85..93227bdb27 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -6,11 +6,7 @@ int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ if(addr1->Version != addr2->Version) return 0; - for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { - if(addr1->Key[i] != addr2->Key[i]) - return 0; - } - return 1; + return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) == 0; } char *cr_user_cipher__Address_tostr(cipher__Address *addr1) @@ -22,13 +18,9 @@ char *cr_user_cipher__Address_tostr(cipher__Address *addr1) } int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2){ - if(addr1->Version != addr2->Version) + if(addr1->Version == addr2->Version) return 0; - for (int i = 0; i < sizeof(cipher__Ripemd160); ++i) { - if(addr1->Key[i] != addr2->Key[i]) - return 0; - } - return 1; + return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) == 1; } int cr_user_GoString_eq(GoString *string1, GoString *string2){ @@ -102,13 +94,13 @@ char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) { } int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2){ - return + return (slice1->len == slice2->len) && (memcmp(slice1->data, slice2->data, slice1->len)==0); } int cr_user_GoSlice_noteq(GoSlice *slice1, GoSlice *slice2){ - return !(((slice1->len == slice2->len)) && + return !(((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, slice1->len)==0)); } @@ -135,3 +127,37 @@ int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2 } return 1; } + +int cr_user_coin__Transactions_eq(coin__Transactions *slice1, coin__Transactions *slice2){ + return + (slice1->len == slice2->len) && + (memcmp(slice1->data, slice2->data, slice1->len)==0); +} + +int cr_user_coin__Transactions_noteq(coin__Transactions *slice1, coin__Transactions *slice2){ + return + !((slice1->len == slice2->len) && + (memcmp(slice1->data, slice2->data, slice1->len)==0)); +} + +char *cr_user_coin__Transactions_tostr(coin__Transactions *slice1) { + char *out; + cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + return out; +} + +int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2){ + return + cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); +} + +int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2){ + return + !cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); +} + +char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) { + char *out; + cr_asprintf(&out, "(coin__BlockBody) { .data %s, .len %d, .cap %d }", (char*)b->Transactions.data, b->Transactions.len, b->Transactions.cap); + return out; +} From 932b83fadab06c940d7ed0149e883298d70a3855 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 16:08:32 +0000 Subject: [PATCH 010/399] [pyskycoin] refs #1568. Added swig files for creating libraries in other languages using swig. --- lib/swig/extend.i | 19 +++ lib/swig/goslices.i | 37 ++++++ lib/swig/goslices2.i | 101 +++++++++++++++ lib/swig/gostrings.i | 38 ++++++ lib/swig/handletypemaps.i | 30 +++++ lib/swig/include/extras.h | 37 ++++++ lib/swig/simpletypes.i | 21 +++ lib/swig/skycoin.i | 22 ++++ lib/swig/structs.i | 252 ++++++++++++++++++++++++++++++++++++ lib/swig/structs_typemaps.i | 62 +++++++++ 10 files changed, 619 insertions(+) create mode 100644 lib/swig/extend.i create mode 100644 lib/swig/goslices.i create mode 100644 lib/swig/goslices2.i create mode 100644 lib/swig/gostrings.i create mode 100644 lib/swig/handletypemaps.i create mode 100644 lib/swig/include/extras.h create mode 100644 lib/swig/simpletypes.i create mode 100755 lib/swig/skycoin.i create mode 100644 lib/swig/structs.i create mode 100644 lib/swig/structs_typemaps.i diff --git a/lib/swig/extend.i b/lib/swig/extend.i new file mode 100644 index 0000000000..d365f51348 --- /dev/null +++ b/lib/swig/extend.i @@ -0,0 +1,19 @@ +%extend cipher__Address { + int isEqual(cipher__Address* a){ + if( $self-> Version == a->Version ){ + return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; + } + return 0; + } +} + +%extend cipher_SecKeys { + cipher_SecKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } +} + diff --git a/lib/swig/goslices.i b/lib/swig/goslices.i new file mode 100644 index 0000000000..3ba39548ae --- /dev/null +++ b/lib/swig/goslices.i @@ -0,0 +1,37 @@ +/*GoSlice in typemap*/ +%typemap(in) GoSlice { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1.data = buffer; + $1.len = size - 1; + $1.cap = size; +} + + +%typecheck(SWIG_TYPECHECK_STRING) GoSlice { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + $1 = SWIG_IsOK(res) ? 1 : 0; +} + +/*GoSlice_* parameter as reference */ +%typemap(in, numinputs=0) GoSlice_* (GoSlice_ temp) { + temp.data = NULL; + temp.len = 0; + temp.cap = 0; + $1 = ($1_type)&temp; +} + +/*GoSlice_* as function return typemap*/ +%typemap(argout) GoSlice_* { + %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); + free( (void*)$1->data ); +} + +%apply GoSlice_* {coin__UxArray*} + diff --git a/lib/swig/goslices2.i b/lib/swig/goslices2.i new file mode 100644 index 0000000000..093487acda --- /dev/null +++ b/lib/swig/goslices2.i @@ -0,0 +1,101 @@ + +%inline { + void __copyToSecKeys(cipher_SecKeys* secKeys, cipher__SecKey* data, int count){ + secKeys->count = count; + for(int i = 0; i < count; i++){ + memcpy( secKeys->data[i].data, data, sizeof(secKeys->data[i].data) ); + data++; + } + } + + void __copyToPubKeys(cipher_PubKeys* pubKeys, cipher__PubKey* data, int count){ + pubKeys->count = count; + for(int i = 0; i < count; i++){ + memcpy( pubKeys->data[i].data, data, sizeof(pubKeys->data[i].data) ); + data++; + } + } + + void __copyFromPubKeys(cipher_PubKeys* pubKeys, GoSlice_* slice){ + slice->data = malloc( pubKeys->count * 33 * sizeof(GoUint8) ); + slice->len = pubKeys->count; + slice->cap = slice->len; + cipher__PubKey* data = slice->data; + for(int i = 0; i < slice->len; i++){ + memcpy( data, pubKeys->data[i].data, sizeof(pubKeys->data[i].data) ); + data++; + } + } + +} + +%rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; +%inline { + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ + if( n > MAX_ARRAY_LENGTH_WRAP ) + return -1; + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); + __copyToSecKeys(secKeys, data.data, data.len); + free(data.data); + return result; + } +} + + + + +%rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; +%inline { + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ + if( n > MAX_ARRAY_LENGTH_WRAP ) + return -1; + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); + __copyToSecKeys(secKeys, data.data, data.len); + free(data.data); + return result; + } +} + +%rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; +%inline { + //[]PubKey + GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ + GoSlice_ data; + __copyFromPubKeys(pubKeys, &data); + GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); + free(data.data); + return result; + } +} + +%rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; +%inline { + GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ + GoSlice_ data; + __copyFromPubKeys(pubKeys, &data); + GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); + free(data.data); + return result; + } +} + +%rename(SKY_cipher_PubKeySlice_Swap) wrap_SKY_cipher_PubKeySlice_Swap; +%inline { + GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ + GoSlice_ data; + __copyFromPubKeys(pubKeys, &data); + GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); + free(data.data); + return result; + } +} + + diff --git a/lib/swig/gostrings.i b/lib/swig/gostrings.i new file mode 100644 index 0000000000..1f7beed3d3 --- /dev/null +++ b/lib/swig/gostrings.i @@ -0,0 +1,38 @@ +typedef struct{ + char* p; + int n; +} GoString; + +typedef struct{ + char* p; + int n; +} GoString_; + + +/*GoString in typemap*/ +%typemap(in) GoString { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1.p = buffer; + $1.n = size - 1; +} + +/*GoString* parameter as reference */ +%typemap(in, numinputs=0) GoString* (GoString temp) { + temp.p = NULL; + temp.n = 0; + $1 = ($1_type)&temp; +} + +/*GoString* as function return typemap*/ +%typemap(argout) GoString* { + %append_output( SWIG_FromCharPtrAndSize( $1->p, $1->n ) ); + free( (void*)$1->p ); +} + +%apply GoString {GoString_} +%apply GoString* {GoString_*} diff --git a/lib/swig/handletypemaps.i b/lib/swig/handletypemaps.i new file mode 100644 index 0000000000..bc3c2b495e --- /dev/null +++ b/lib/swig/handletypemaps.i @@ -0,0 +1,30 @@ +/** +* +* typemaps for Handles +* +**/ + + +/* Handle reference typemap. */ +%typemap(in, numinputs=0) Handle* (Handle temp) { + $1 = &temp; +} + +/* Handle out typemap. */ +%typemap(argout) Handle* { + %append_output( SWIG_From_long(*$1) ); +} + +/* Handle not as pointer is input. */ +%typemap(in) Handle { + SWIG_AsVal_long($input, (long*)&$1); +} + + +%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, + WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, + GoStringMap, PasswordReader__Handle_} + +%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, + WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, + App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle* } diff --git a/lib/swig/include/extras.h b/lib/swig/include/extras.h new file mode 100644 index 0000000000..04bb29bb2c --- /dev/null +++ b/lib/swig/include/extras.h @@ -0,0 +1,37 @@ + +typedef struct{ + GoUint8 data[33]; +} cipher_PubKey; + +typedef struct{ + GoUint8 data[32]; +} cipher_SecKey; + +typedef struct{ + GoUint8 data[20]; +} cipher_Ripemd160; + +typedef struct{ + GoUint8 data[65]; +} cipher_Sig; + +typedef struct{ + GoUint8 data[32]; +} cipher_SHA256; + +typedef struct{ + GoUint8 data[4]; +} cipher_Checksum; + +#define MAX_ARRAY_LENGTH_WRAP 10 + +typedef struct{ + cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_SecKeys; + +typedef struct{ + cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_PubKeys; + diff --git a/lib/swig/simpletypes.i b/lib/swig/simpletypes.i new file mode 100644 index 0000000000..b28c25a8e1 --- /dev/null +++ b/lib/swig/simpletypes.i @@ -0,0 +1,21 @@ +%apply int* OUTPUT {GoInt*} +%apply int* OUTPUT {GoUint*} +%apply int* OUTPUT {GoUint8*} +%apply int* OUTPUT {GoInt8*} +%apply int* OUTPUT {GoUint16*} +%apply int* OUTPUT {GoInt16*} +%apply int* OUTPUT {GoUint32*} +%apply int* OUTPUT {GoInt32*} +%apply int* OUTPUT {GoUint64*} +%apply int* OUTPUT {GoInt64*} + +typedef GoInt GoInt_; +typedef GoUint GoUint_; +typedef GoInt8 GoInt8_; +typedef GoUint8 GoUint8_; +typedef GoInt16 GoInt16_; +typedef GoUint16 GoUint16_; +typedef GoInt32 GoInt32_; +typedef GoUint32 GoUint32_; +typedef GoInt364 GoInt64_; +typedef GoUint64 GoUint64_; diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i new file mode 100755 index 0000000000..4753b3f7e1 --- /dev/null +++ b/lib/swig/skycoin.i @@ -0,0 +1,22 @@ +%module skycoin +%include "typemaps.i" +%{ + #define SWIG_FILE_WITH_INIT + #include "libskycoin.h" + #include "include/extras.h" +%} + +%include "simpletypes.i" +%include "handletypemaps.i" +%include "gostrings.i" +%include "goslices.i" +%include "goslices2.i" +%include "structs.i" +%include "extend.i" +%include "structs_typemaps.i" +/* Find the modified copy of libskycoin */ +%include "../../../swig/include/libskycoin.h" + + + + diff --git a/lib/swig/structs.i b/lib/swig/structs.i new file mode 100644 index 0000000000..c145a5a8f7 --- /dev/null +++ b/lib/swig/structs.i @@ -0,0 +1,252 @@ +typedef struct{ +} encrypt__Sha256Xor; + +typedef struct{ + GoInt_ N; + GoInt_ R; + GoInt_ P; + GoInt_ KeyLen; +} encrypt__ScryptChacha20poly1305; + +typedef struct{ + GoUint32_ n[10]; +} secp256k1go__Field; + + +typedef GoUint8_ cipher__PubKey[33]; + +typedef GoUint8_ cipher__Ripemd160[20]; + +typedef GoUint8_ cipher__SecKey[32]; + +typedef GoUint8_ cipher__Sig[65]; + +typedef GoUint8_ cipher__SHA256[32]; + +typedef GoUint8_ cipher__Checksum[4]; + +typedef struct{ + GoUint8 data[33]; +} cipher_PubKey; + +typedef struct{ + GoUint8 data[32]; +} cipher_SecKey; + +typedef struct{ + GoUint8 data[20]; +} cipher_Ripemd160; + +typedef struct{ + GoUint8 data[65]; +} cipher_Sig; + +typedef struct{ + GoUint8 data[32]; +} cipher_SHA256; + +typedef struct{ + GoUint8 data[4]; +} cipher_Checksum; + +typedef struct{ + cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_SecKeys; + +typedef struct{ + cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_PubKeys; + +typedef struct { + cipher__Address Address; ///< Wallet address. + cipher__PubKey Public; ///< Public key used to generate address. + cipher__SecKey Secret; ///< Secret key used to generate address. +} wallet__Entry; + + +typedef struct{ + GoUint8_ Version; ///< Address version identifier. + ///< Used to differentiate testnet + ///< vs mainnet addresses, for ins + cipher__Ripemd160 Key; ///< Address hash identifier. +} cipher__Address; + + + +typedef struct{ + GoUint64_ Coins; + GoUint64_ Hours; +} wallet__Balance; + +typedef struct{ + wallet__Balance Confirmed; + wallet__Balance Predicted; +} wallet__BalancePair; + +typedef struct{ + GoInt_ N; + BOOL IncludeDistribution; +} api__RichlistParams; + +typedef struct{ +} cli__PasswordFromTerm; + +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + secp256k1go__Field Z; + BOOL Infinity; +} secp256k1go__XYZ; + +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + BOOL Infinity; +} secp256k1go__XY; + +typedef struct{ + cipher__Address Address; ///< Receipient address. + GoUint64_ Coins; ///< Amount sent to the receipient address. + GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. +} coin__TransactionOutput; + +typedef struct { + cipher__SHA256 Hash; ///< Hash of underlying UxOut. + GoInt64_ BkSeq; ///< Block height corresponding to the + ///< moment balance calculation is performed at. + cipher__Address Address; ///< Account holder address. + GoInt64_ Coins; ///< Coins amount (e.g. in SKY). + GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. +} wallet__UxBalance; + +/* +//Requires typemap, contains GoString_ +typedef struct{ + GoString_ UxID; + GoString_ Address; + GoString_ Coins; + GoString_ Hours; +} api__CreatedTransactionOutput; + +typedef struct{ + GoString_ UxID; + GoString_ Address; + GoString_ Coins; + GoString_ Hours; + GoString_ CalculatedHours; + GoUint64_ Time; + GoUint64_ Block; + GoString_ TxID; +} api__CreatedTransactionInput; + +*/ +/* +typedef struct { + BOOL neg; + GoSlice_ nat; +} Number; + +typedef struct { + Number R; + Number S; +} Signature; +*/ +/* + +//Contain slices. Should be Handle + +typedef struct{ + visor__ReadableOutputSet Outputs; +} webrpc__OutputsResult; + + +typedef struct{ + cli__Balance Confirmed; + cli__Balance Spendable; + cli__Balance Expected; + GoSlice_ Addresses; +} cli__BalanceResult; + +typedef struct{ + wallet__BalancePair * Balance; + visor__ReadableTransaction * Transaction; + GoString_ Error; +} api__SpendResult; + +typedef struct{ + api__CreatedTransaction Transaction; + GoString_ EncodedTransaction; +} api__CreateTransactionResponse; + +typedef struct{ + GoSlice_ Blocks; +} visor__ReadableBlocks; + +typedef GoSlice_ coin__Transactions; + +typedef struct{ + coin__Transactions Transactions; +} coin__BlockBody; + +typedef struct{ + GoUint32_ Version; + GoUint64_ Time; + GoUint64_ BkSeq; + GoUint64_ Fee; + cipher__SHA256 PrevHash; + cipher__SHA256 BodyHash; + cipher__SHA256 UxHash; +} coin__BlockHeader; + + +typedef struct{ + coin__BlockHeader Head; + coin__BlockBody Body; +} coin__Block; + +typedef struct{ + coin__Block _unnamed; + cipher__Sig Sig; +} coin__SignedBlock; + +typedef struct { + GoInt32_ Length; ///< Current transaction's length expressed in bytes. + GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. + cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. + + GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. + GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. + GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. +} coin__Transaction; + +typedef struct{ + GoUint32_ Length; + GoUint8_ Type; + GoString_ TxID; + GoString_ InnerHash; + GoString_ Fee; + GoSlice_ Sigs; + GoSlice_ In; + GoSlice_ Out; +} api__CreatedTransaction; + +typedef struct{ + api__CreatedTransaction Transaction; + GoString_ EncodedTransaction; +} api__CreateTransactionResponse; + +typedef struct{ + coin__Transactions Txns; + GoSlice_ Fees; + GoSlice_ Hashes; +} coin__SortableTransactions; + +//Should be Handle +typedef struct{ + daemon__TransactionResult * Transaction; +} webrpc__TxnResult; + +*/ + diff --git a/lib/swig/structs_typemaps.i b/lib/swig/structs_typemaps.i new file mode 100644 index 0000000000..394ddbde9d --- /dev/null +++ b/lib/swig/structs_typemaps.i @@ -0,0 +1,62 @@ +/* +cipher__PubKey* input typemap +*/ +%typemap(in) cipher__PubKey* { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_PubKey, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type PubKey"); + cipher_PubKey* p = (cipher_PubKey*)argp; + $1 = &p->data; +} + + +/* +cipher__SecKey* input typemap +*/ +%typemap(in) cipher__SecKey*{ + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_SecKey, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type SecKey"); + cipher_SecKey* p = (cipher_SecKey*)argp; + $1 = &p->data; +} + +%typemap(in) cipher__Ripemd160* { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Ripemd160, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type Ripemd160"); + cipher_Ripemd160* p = (cipher_Ripemd160*)argp; + $1 = &p->data; +} + +%typemap(in) cipher__Sig* { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Sig, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type Sig"); + cipher_Sig* p = (cipher_Sig*)argp; + $1 = &p->data; +} + + + +%typemap(in) cipher__SHA256* { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type SHA256"); + cipher_SHA256* p = (cipher_SHA256*)argp; + $1 = &p->data; +} + +%typemap(in) cipher__Checksum* { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Checksum, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type Checksum"); + cipher_Checksum* p = (cipher_Checksum*)argp; + $1 = &p->data; +} From e3e646d5757df37ebf766517317f8f41a76d9f7e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 18:18:17 +0000 Subject: [PATCH 011/399] [libc] refs #1191. Added helper functions for transactions. Added two more tests for coin.block. [====] Synthesis: Tested: 54 | Passing: 54 | Failing: 0 | Crashing: 0. --- include/transutil.h | 0 lib/cgo/tests/check_coin.block.c | 51 ++++++++- lib/cgo/tests/testutils/transutils.c | 149 +++++++++++++++++++++++++++ 3 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 include/transutil.h create mode 100644 lib/cgo/tests/testutils/transutils.c diff --git a/include/transutil.h b/include/transutil.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index b246e018da..aef69d713f 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -12,7 +12,7 @@ TestSuite(coin_block, .init = setup, .fini = teardown); -int newBlock(cipher__SHA256* uxHash, coin__Block* newBlock){ +int makeNewBlock(cipher__SHA256* uxHash, coin__Block* newBlock){ int result; cipher__SHA256 bodyhash; coin__Block block; @@ -52,6 +52,7 @@ Test(coin_block, TestNewBlock) { result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + registerMemCleanup( slice.data ); result = SKY_cipher_SumSHA256( slice, &hash ); cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); @@ -80,3 +81,51 @@ Test(coin_block, TestNewBlock) { body.Transactions.cap = transactions.cap; cr_assert( eq(type(coin__BlockBody), newBlock.Body, body) ); } + +Test(coin_block, TestBlockHashHeader){ + int result; + coin__Block block; + GoSlice slice; + memset(&slice, 0, sizeof(GoSlice)); + cipher__SHA256 hash; + + result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); + cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + registerMemCleanup( slice.data ); + result = SKY_cipher_SumSHA256( slice, &hash ); + cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); + result = makeNewBlock( &hash, &block ); + cr_assert(result == SKY_OK, "makeNewBlock failed"); + + cipher__SHA256 hash1, hash2; + result = SKY_coin_Block_HashHeader(&block, &hash1); + cr_assert(result == SKY_OK, "SKY_coin_Block_HashHeader failed"); + result = SKY_coin_BlockHeader_Hash(&block.Head, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_BlockHeader_Hash failed"); + cr_assert( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ); + memset(&hash2, 0, sizeof(cipher__SHA256)); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ) ); +} + +Test(coin_block, TestBlockHashBody){ + int result; + coin__Block block; + GoSlice slice; + memset(&slice, 0, sizeof(GoSlice)); + cipher__SHA256 hash; + + result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); + cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + registerMemCleanup( slice.data ); + result = SKY_cipher_SumSHA256( slice, &hash ); + cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); + result = makeNewBlock( &hash, &block ); + cr_assert(result == SKY_OK, "makeNewBlock failed"); + + cipher__SHA256 hash1, hash2; + result = SKY_coin_Block_HashBody(&block, &hash1); + cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); + result = SKY_coin_BlockBody_Hash(&block.Body, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); + cr_assert( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ); +} diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c new file mode 100644 index 0000000000..b6aa5bc7f1 --- /dev/null +++ b/lib/cgo/tests/testutils/transutils.c @@ -0,0 +1,149 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "transutil.h" + +int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey){ + cipher__PubKey pubkey; + cipher__Address address; + int result; + + memset( puxBody, 0, sizeof(coin__UxBody) ); + + result = SKY_cipher_GenerateKeyPair(&pubkey, pseckey); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + + GoSlice slice; + memset(&slice, 0, sizeof(GoSlice)); + cipher__SHA256 hash; + + result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); + registerMemCleanup( slice.data ); + cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + result = SKY_cipher_SumSHA256( slice, &puxBody->SrcTransaction ); + cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); + + result = SKY_cipher_AddressFromPubKey( &pubkey, &puxBody->Address ); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + return result; +} + +int makeUxOutWithSecret(coin__UxOut* puxOut, cipher__SecKey* pseckey){ + int result; + memset( puxOut, 0, sizeof(coin__UxOut) ); + result = makeUxBodyWithSecret(&puxOut->Body, pseckey); + puxOut->Head.Time = 100; + puxOut->Head.BkSeq = 2; + return result; +} + +int makeUxBody(coin__UxBody* puxBody){ + cipher__SecKey seckey; + return makeUxBodyWithSecret(puxBody, &seckey); +} + +int makeUxOut(coin__UxOut* puxOut){ + cipher__SecKey seckey; + return makeUxOutWithSecret(puxOut, &seckey); +} + +int makeAddress(cipher__Address* paddress){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__Address address; + int result; + + result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + + result = SKY_cipher_AddressFromPubKey( &pubkey, paddress ); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + return result; +} + +int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, + coin__Transaction* ptransaction){ + int result; + + memset(ptransaction, 0, sizeof(coin__Transaction)); + cipher__SHA256 sha256; + result = SKY_coin_UxOut_Hash(puxOut, &sha256); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash"); + GoUint16 r; + result = SKY_coin_Transaction_PushInput(ptransaction, &sha256, &r); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushInput failed"); + + cipher__Address address1, address2; + result = makeAddress(&address1); + cr_assert(result == SKY_OK, "makeAddress failed"); + result = makeAddress(&address2); + cr_assert(result == SKY_OK, "makeAddress failed"); + + result = SKY_coin_Transaction_PushOutput(ptransaction, &address1, 0x1e6, 50); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); + result = SKY_coin_Transaction_PushOutput(ptransaction, &address2, 0x5e6, 50); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); + + GoSlice secKeys = { pseckey, 1, 1 }; + result = SKY_coin_Transaction_SignInputs( ptransaction, secKeys ); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_SignInputs failed"); + result = SKY_coin_Transaction_UpdateHeader( ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_UpdateHeader failed"); + return result; +} + +int makeTransaction(coin__Transaction* ptransaction){ + int result; + coin__UxOut uxOut; + cipher__SecKey seckey; + + result = makeUxOutWithSecret( &uxOut, &seckey ); + cr_assert(result == SKY_OK, "makeUxOutWithSecret failed"); + result = makeTransactionFromUxOut( &uxOut, &seckey, ptransaction ); + cr_assert(result == SKY_OK, "makeTransactionFromUxOut failed"); + return result; +} + +int makeTransactions(GoSlice* transactions, int n){ + void * data = malloc(sizeof(coin__Transaction) * n); + coin__Transaction* ptransaction = (coin__Transaction*)data; + int i; + int result = SKY_ERROR; // n == 0 then error + for( i = 0; i < n; i++){ + result = makeTransaction(ptransaction); + if(result != SKY_OK){ + free(data); + break; + } + ptransaction++; + } + if(result == SKY_OK) { + transactions->data = data; + transactions->len = n; + transactions->cap = n; + } + return result; +} + +void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ + pdest->len = psource->len; + pdest->cap = psource->len; + int size = pdest->len * elem_size; + pdest->data = malloc(size); + memcpy(pdest->data, psource->data, size ); +} + +void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2){ + memcpy(pt2, pt1, sizeof(coin__Transaction)); + copySlice(&pt2->Sigs, &pt1->Sigs, sizeof(cipher__Sig)); + copySlice(&pt2->In, &pt1->In, sizeof(cipher__SHA256)); + copySlice(&pt2->Out, &pt1->Out, sizeof(coin__TransactionOutput)); +} From 9e5cd3551641459d9247db9ab5c2c7ea73bc5fff Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 19:47:43 +0000 Subject: [PATCH 012/399] [libc] refs #1191. Create .h for transactions helper functions. Move copySlice function to libsky_testutil.c. [====] Synthesis: Tested: 54 | Passing: 54 | Failing: 0 | Crashing: 0 --- include/skytest.h | 15 ++++++------ include/transutil.h | 30 +++++++++++++++++++++++ lib/cgo/tests/testutils/libsky_testutil.c | 9 +++++++ lib/cgo/tests/testutils/transutils.c | 8 ------ 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/include/skytest.h b/include/skytest.h index 6ca88a2396..2ee9fee56e 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -31,9 +31,9 @@ void freeRegisteredMemCleanup(void *p); int registerWalletClean(Client__Handle clientHandle, WalletResponse__Handle walletHandle); - + void cleanRegisteredWallet( - Client__Handle client, + Client__Handle client, WalletResponse__Handle wallet); json_value* loadJsonFile(const char* filename); @@ -42,18 +42,19 @@ int compareJsonValues(json_value* value1, json_value* value2); json_value* get_json_value(json_value* node, const char* path, json_type type); - + json_value* get_json_value_not_strict(json_value* node, const char* path, json_type type, int allow_null); - + int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, const char* ignoreList); int parseBoolean(const char* str, int length); - + +void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size); + void setup(void); void teardown(void); - + extern void toGoString(GoString_ *s, GoString *r); #endif - diff --git a/include/transutil.h b/include/transutil.h index e69de29bb2..80ef3028af 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -0,0 +1,30 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey); + +int makeUxOutWithSecret(coin__UxOut* puxOut, cipher__SecKey* pseckey); + +int makeUxBody(coin__UxBody* puxBody); + +int makeUxOut(coin__UxOut* puxOut); + +int makeAddress(cipher__Address* paddress); + +int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, + coin__Transaction* ptransaction); + +int makeTransaction(coin__Transaction* ptransaction); + +int makeTransactions(GoSlice* transactions, int n); + +void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2); diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index a28b7af0dc..80f8ed02a7 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -290,6 +290,15 @@ GoString * tmp = r; *tmp = (*(GoString *) s); } +void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ + pdest->len = psource->len; + pdest->cap = psource->len; + int size = pdest->len * elem_size; + pdest->data = malloc(size); + registerMemCleanup( pdest->data ); + memcpy(pdest->data, psource->data, size ); +} + /* json_value *loadGoldenFile_Cli(const char *file) { char path[STRING_SIZE]; diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index b6aa5bc7f1..9f0b18391e 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -133,14 +133,6 @@ int makeTransactions(GoSlice* transactions, int n){ return result; } -void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ - pdest->len = psource->len; - pdest->cap = psource->len; - int size = pdest->len * elem_size; - pdest->data = malloc(size); - memcpy(pdest->data, psource->data, size ); -} - void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2){ memcpy(pt2, pt1, sizeof(coin__Transaction)); copySlice(&pt2->Sigs, &pt1->Sigs, sizeof(cipher__Sig)); From 9178e92f62ffea288b7fd6e8cfb19c5084d36c1d Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 7 Jun 2018 17:06:41 -0400 Subject: [PATCH 013/399] [libc] ref #1191 finish TestTransactionVerify [====] Synthesis: Tested: 92 | Passing: 92 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transactions.c | 141 ++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 10 deletions(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index e19071d30b..868a1647b2 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -18,6 +18,7 @@ Test(coin_transaction, TestTransactionVerify) // Mismatch header hash coin__Transaction tx; + coin__TransactionOutput* to_void; makeTransaction(&tx); memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); GoUint32 errcode = SKY_coin_Transaction_Verify(&tx); @@ -52,7 +53,7 @@ Test(coin_transaction, TestTransactionVerify) errcode = makeTransaction(&tx); cr_assert(errcode == SKY_OK); GoSlice slice = { NULL, 20, 20 }; - memset(&tx.Sigs.data, 0, sizeof(slice)); + memset(&tx.Sigs, 0, sizeof(slice)); errcode = SKY_coin_Transaction_UpdateHeader(&tx); errcode = SKY_coin_Transaction_Verify(&tx); cr_assert(errcode != SKY_OK, "Invalid number of signatures"); @@ -75,22 +76,142 @@ Test(coin_transaction, TestTransactionVerify) makeTransactionFromUxOut(&ux, &s, &tx); cipher__SHA256 sha256; SKY_coin_Transaction_Hash(&tx, &sha256); - SKY_coin_Transaction_PushInput(&tx, &sha256 , 0); + SKY_coin_Transaction_PushInput(&tx, &sha256, 0); tx.Sigs.data = NULL; GoSlice slice_duplicate; - copySlice( ((GoSlice*)&slice_duplicate.data), (GoSlice*)&tx.In.data,sizeof(cipher__SecKey) ); + copySlice(((GoSlice*)&slice_duplicate.data), + (GoSlice*)&tx.In.data, + sizeof(cipher__SecKey)); SKY_coin_Transaction_SignInputs(&tx, slice_duplicate); errcode = SKY_coin_Transaction_UpdateHeader(&tx); errcode = SKY_coin_Transaction_Verify(&tx); cr_assert(errcode != SKY_OK, "Duplicate spend"); + // Duplicate outputs + makeTransaction(&tx); + coin__TransactionOutput to; + to = (*(coin__TransactionOutput*)&tx.Out); + errcode = SKY_coin_Transaction_PushOutput( + &to, ((cipher__Address*)&to.Address), to.Coins, to.Hours); + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Duplicate output in transaction"); + + // Invalid signature, empty + makeTransaction(&tx); + memset(&tx.Sigs, 0, sizeof(cipher__Sig)); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Duplicate spend"); + + // Output coins are 0 + + makeTransaction(&tx); + memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + to_void = ((coin__TransactionOutput*)&tx.Out); + to_void->Coins = 0; + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Zero coin output"); + + // Output coin overflow + makeTransaction(&tx); + memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + to_void = ((coin__TransactionOutput*)&tx.Out); + to_void->Coins = 9223372036851775808; + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK, "Output coins overflow"); + + // Output coins are not multiples of 1e6 (valid, decimal restriction is not + // enforced here) + + memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + makeTransaction(&tx); + to = (*(coin__TransactionOutput*)&tx.Out); + to.Coins += 10; + tx.Sigs.data = NULL; + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + SKY_coin_Transaction_PushInput(&tx, &sha256, 0); + GoSlice slice_decimal; + memset(&slice_decimal.data, 0, sizeof(cipher__SecKey)); + SKY_coin_Transaction_SignInputs(&tx, slice_decimal); + cr_assert(0 != (to.Coins % ((GoUint64_)1.000000e+006))); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode != SKY_OK); + + // Valid + memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + makeTransaction(&tx); + to_void = ((coin__TransactionOutput*)&tx.Out); + to_void->Coins = 1.000000e+007; + to_void++; + to_void->Coins = 1.000000e+006; + errcode = SKY_coin_Transaction_UpdateHeader(&tx); + errcode = SKY_coin_Transaction_Verify(&tx); + cr_assert(errcode == SKY_OK); } -// Test(coin_transaction, TestTransactionPushInput) -// { +Test(coin_transaction, TestTransactionVerifyInput) +{ + coin__Transaction tx; + GoUint64_ errcode; + coin__UxArray uxArray; + + // Invalid uxIn args + makeTransaction(&tx); + cli__PasswordFromBytes seckey; + SKY_coin_UxArray_Coins(&seckey, NULL); + errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); + cr_assert(errcode != SKY_OK, "tx.In != uxIn"); + SKY_coin_UxArray_Coins(&seckey, 0); + errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); + cr_assert(errcode != SKY_OK, "tx.In != uxIn"); + SKY_coin_UxArray_Coins(&seckey, 3); + errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); + cr_assert(errcode != SKY_OK, "tx.In != uxIn"); + + // // tx.In != tx.Sigs + // ux, s := makeUxOutWithSecret(t) + // tx = makeTransactionFromUxOut(ux, s) + // tx.Sigs = []cipher.Sig{} + // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { + // tx.VerifyInput(UxArray{ux}) + // }) + + // ux, s = makeUxOutWithSecret(t) + // tx = makeTransactionFromUxOut(ux, s) + // tx.Sigs = append(tx.Sigs, cipher.Sig{}) + // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { + // tx.VerifyInput(UxArray{ux}) + // }) + + // tx.InnerHash != tx.HashInner() + coin__UxOut ux; + cipher__SecKey s; + errcode = makeUxOutWithSecret(&ux, &s); + cr_assert(errcode == SKY_OK); + errcode = makeTransactionFromUxOut(&ux, &s, &tx); + cr_assert(errcode == SKY_OK); + memset(&tx.Sigs, 0, sizeof(cipher__Sig)); + memset(&uxArray, 0, sizeof(coin__UxArray)); + uxArray.data = &ux; + SKY_coin_UxArray_Coins(&uxArray, 1); + errcode = SKY_coin_Transaction_VerifyInput(&tx, &uxArray); + cr_assert(errcode != SKY_OK, "tx.In != tx.Sigs"); + + errcode = makeUxOutWithSecret(&ux, &s); + cr_assert(errcode == SKY_OK); + errcode = makeTransactionFromUxOut(&ux, &s, &tx); + cr_assert(errcode == SKY_OK); + + coin__UxOut uxo; + coin__UxArray uxa; + uxa.data = uxo.; +} -// coin__Transaction tx; -// coin__UxOut ux; -// int errcode = makeUxOut(&ux); -// cr_assert(errcode == SKY_OK); -// } +Test(coin_transaction, TestTransactionPushInput) +{ + coin__Transaction tx; + memset(&tx, 0, sizeof(coin__Transaction)); + coin__UxOut makeUxOut() +} From 027ca6b52a0a3d2daa168717ed925009f8c634c1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 21:23:05 +0000 Subject: [PATCH 014/399] [libc] refs #1191. Finished with block tests. Fixed SKY_coin_CreateUnspents wrapper function. [====] Synthesis: Tested: 57 | Passing: 57 | Failing: 0 | Crashing: 0. --- include/transutil.h | 2 + lib/cgo/coin.block.go | 2 +- lib/cgo/tests/check_coin.block.c | 126 ++++++++++++++++++++++++++- lib/cgo/tests/testutils/transutils.c | 13 ++- 4 files changed, 139 insertions(+), 4 deletions(-) diff --git a/include/transutil.h b/include/transutil.h index 80ef3028af..19d1cfb1b3 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -10,6 +10,8 @@ #include "skystring.h" #include "skytest.h" +int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress); + int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey); int makeUxOutWithSecret(coin__UxOut* puxOut, cipher__SecKey* pseckey); diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index f446afe0e0..be5479466f 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -264,7 +264,7 @@ func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx *C.coin__Transaction, bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx := *(*coin.Transaction)(unsafe.Pointer(_tx)) __arg2 := coin.CreateUnspents(bh, tx) - *_arg2 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg2)) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) return } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index aef69d713f..06c4211e4e 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -9,6 +9,8 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" +#include "transutil.h" +#include "time.h" TestSuite(coin_block, .init = setup, .fini = teardown); @@ -127,5 +129,127 @@ Test(coin_block, TestBlockHashBody){ cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); result = SKY_coin_BlockBody_Hash(&block.Body, &hash2); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - cr_assert( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); +} + +Test(coin_block, TestNewGenesisBlock){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__Address address; + GoUint64 genTime = 1000; + GoUint64 genCoins = 1000 * 1000 * 1000; + GoUint64 genCoinHours = 1000 * 1000; + coin__Block block; + + memset(&block, 0, sizeof(coin__Block)); + int result = makeKeysAndAddress(&pubkey, &seckey, &address); + cr_assert(result == SKY_OK, "makeKeysAndAddress failed"); + result = SKY_coin_NewGenesisBlock(&address, genCoins, genTime, &block); + cr_assert(result == SKY_OK, "SKY_coin_NewGenesisBlock failed"); + + cipher__SHA256 nullHash; + memset(&nullHash, 0, sizeof(cipher__SHA256)); + cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, block.Head.PrevHash) ); + cr_assert( genTime == block.Head.Time ); + cr_assert( 0 == block.Head.BkSeq ); + cr_assert( 0 == block.Head.Version ); + cr_assert( 0 == block.Head.Fee ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, block.Head.UxHash) ); + + cr_assert( 1 == block.Body.Transactions.len ); + coin__Transaction* ptransaction = (coin__Transaction*)block.Body.Transactions.data; + cr_assert( 0 == ptransaction->In.len); + cr_assert( 0 == ptransaction->Sigs.len); + cr_assert( 1 == ptransaction->Out.len); + + coin__TransactionOutput* poutput = (coin__TransactionOutput*)ptransaction->Out.data; + cr_assert( eq( type(cipher__Address), address, poutput->Address ) ); + cr_assert( genCoins == poutput->Coins ); + cr_assert( genCoins == poutput->Hours ); +} + +typedef struct { + int index; + int failure; +} testcase_unspent; + +Test(coin_block, TestCreateUnspent){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__Address address; + int result = makeKeysAndAddress(&pubkey, &seckey, &address); + + cipher__SHA256 hash; + coin__Transaction tx; + memset( &tx, 0, sizeof(coin__Transaction) ); + result = SKY_coin_Transaction_PushOutput(&tx, &address, 11000000, 255); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); + coin__BlockHeader bh; + memset(&bh, 0, sizeof(coin__BlockHeader)); + bh.Time = time(0); + bh.BkSeq = 1; + + testcase_unspent t[] = { + {0, 0}, {10, 1}, + }; + coin__UxOut ux; + int tests_count = sizeof(t) / sizeof(testcase_unspent); + for( int i = 0; i < tests_count; i++){ + memset(&ux, 0, sizeof(coin__UxOut)); + result = SKY_coin_CreateUnspent( &bh, &tx, t[i].index, &ux ); + if( t[i].failure ){ + cr_assert( result == SKY_ERROR, "SKY_coin_CreateUnspent should have failed" ); + continue; + } else { + cr_assert( result == SKY_OK, "SKY_coin_CreateUnspent failed" ); + } + cr_assert( bh.Time == ux.Head.Time ); + cr_assert( bh.BkSeq == ux.Head.BkSeq ); + result = SKY_coin_Transaction_Hash( &tx, &hash ); + cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ux.Body.SrcTransaction) ); + cr_assert( t[i].index < tx.Out.len); + coin__TransactionOutput* poutput = (coin__TransactionOutput*)tx.Out.data; + cr_assert( eq( type(cipher__Address), ux.Body.Address, poutput->Address ) ); + cr_assert( ux.Body.Coins == poutput->Coins ); + cr_assert( ux.Body.Hours == poutput->Hours ); + } +} + +Test(coin_block, TestCreateUnspents){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__Address address; + int result = makeKeysAndAddress(&pubkey, &seckey, &address); + + cipher__SHA256 hash; + coin__Transaction tx; + memset( &tx, 0, sizeof(coin__Transaction) ); + result = SKY_coin_Transaction_PushOutput(&tx, &address, 11000000, 255); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); + coin__BlockHeader bh; + memset(&bh, 0, sizeof(coin__BlockHeader)); + bh.Time = time(0); + bh.BkSeq = 1; + + coin__UxArray uxs = {NULL, 0, 0}; + result = SKY_coin_CreateUnspents(&bh, &tx, &uxs); + cr_assert( result == SKY_OK, "SKY_coin_CreateUnspents failed" ); + registerMemCleanup( uxs.data ); + cr_assert( uxs.len == 1 ); + cr_assert( uxs.len == tx.Out.len ); + coin__UxOut* pout = (coin__UxOut*)uxs.data; + coin__TransactionOutput* ptxout = (coin__TransactionOutput*)tx.Out.data; + for(int i = 0; i < uxs.len; i++){ + cr_assert( bh.Time == pout->Head.Time ); + cr_assert( bh.BkSeq == pout->Head.BkSeq ); + result = SKY_coin_Transaction_Hash( &tx, &hash ); + cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, pout->Body.SrcTransaction) ); + cr_assert( eq( type(cipher__Address), pout->Body.Address, ptxout->Address ) ); + cr_assert( pout->Body.Coins == ptxout->Coins ); + cr_assert( pout->Body.Hours == ptxout->Hours ); + pout++; + ptxout++; + } } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 9f0b18391e..bb9bf2b1a3 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -11,6 +11,15 @@ #include "skytest.h" #include "transutil.h" +int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress){ + int result; + result = SKY_cipher_GenerateKeyPair(ppubkey, pseckey); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + result = SKY_cipher_AddressFromPubKey( ppubkey, paddress ); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + return result; +} + int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey){ cipher__PubKey pubkey; cipher__Address address; @@ -87,9 +96,9 @@ int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, result = makeAddress(&address2); cr_assert(result == SKY_OK, "makeAddress failed"); - result = SKY_coin_Transaction_PushOutput(ptransaction, &address1, 0x1e6, 50); + result = SKY_coin_Transaction_PushOutput(ptransaction, &address1, 1000000, 50); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); - result = SKY_coin_Transaction_PushOutput(ptransaction, &address2, 0x5e6, 50); + result = SKY_coin_Transaction_PushOutput(ptransaction, &address2, 5000000, 50); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); GoSlice secKeys = { pseckey, 1, 1 }; From 590ae0727d610d96d83e031b8c2759129eb16203 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 7 Jun 2018 22:01:17 +0000 Subject: [PATCH 015/399] [libc] refs #1191. Added tests for coin. [====] Synthesis: Tested: 61 | Passing: 61 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.coin.c | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 lib/cgo/tests/check_coin.coin.c diff --git a/lib/cgo/tests/check_coin.coin.c b/lib/cgo/tests/check_coin.coin.c new file mode 100644 index 0000000000..7bd8b46c78 --- /dev/null +++ b/lib/cgo/tests/check_coin.coin.c @@ -0,0 +1,88 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "transutil.h" +#include "time.h" + +TestSuite(coin_coin, .init = setup, .fini = teardown); + +Test(coin_coin, TestAddress1){ + char* address_hex = "02fa939957e9fc52140e180264e621c2576a1bfe781f88792fb315ca3d1786afb8"; + char address[128]; + int result; + int length = hexnstr(address_hex, address, 128); + cr_assert(result > 0, "Error decoding hex string"); + GoSlice slice = { address, length, 128 }; + cipher__PubKey pubkey; + result = SKY_cipher_NewPubKey(slice, &pubkey); + cr_assert( result == SKY_OK, "SKY_cipher_NewPubKey failed" ); + cipher__Address c_address; + result = SKY_cipher_AddressFromPubKey( &pubkey, &c_address ); + cr_assert( result == SKY_OK, "SKY_cipher_AddressFromPubKey failed" ); +} + +Test(coin_coin, TestAddress2){ + char* address_hex = "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; + char address[128]; + int result; + int length = hexnstr(address_hex, address, 128); + cr_assert(result > 0, "Error decoding hex string"); + GoSlice slice = { address, length, 128 }; + cipher__PubKey pubkey; + cipher__SecKey seckey; + result = SKY_cipher_NewSecKey(slice, &seckey); + cr_assert( result == SKY_OK, "SKY_cipher_NewSecKey failed" ); + result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); + cr_assert( result == SKY_OK, "SKY_cipher_PubKeyFromSecKey failed" ); + cipher__Address c_address; + result = SKY_cipher_AddressFromPubKey( &pubkey, &c_address ); + cr_assert( result == SKY_OK, "SKY_cipher_AddressFromPubKey failed" ); +} + +Test(coin_coin, TestCrypto1){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + int result; + for(int i = 0; i < 10; i ++){ + result = SKY_cipher_GenerateKeyPair( &pubkey, &seckey ); + cr_assert( result == SKY_OK, "SKY_cipher_GenerateKeyPair failed" ); + result = SKY_cipher_TestSecKey( &seckey ); + cr_assert( result == SKY_OK, "CRYPTOGRAPHIC INTEGRITY CHECK FAILED" ); + } +} + +Test(coin_coin, TestCrypto2){ + char* address_hex = "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; + char address[128]; + int result; + int length = hexnstr(address_hex, address, 128); + cr_assert(length == 32, "Error decoding hex string"); + + GoSlice slice = { address, length, 128 }; + cipher__PubKey pubkey; + cipher__SecKey seckey; + result = SKY_cipher_NewSecKey(slice, &seckey); + cr_assert( result == SKY_OK, "SKY_cipher_NewSecKey failed" ); + result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); + cr_assert( result == SKY_OK, "SKY_cipher_PubKeyFromSecKey failed" ); + cipher__Address c_address; + result = SKY_cipher_AddressFromPubKey( &pubkey, &c_address ); + cr_assert( result == SKY_OK, "SKY_cipher_AddressFromPubKey failed" ); + + char* text = "test message"; + int len = strlen(text); + GoSlice textslice = {text, len, len}; + cipher__SHA256 hash; + result = SKY_cipher_SumSHA256(textslice, &hash); + cr_assert( result == SKY_OK, "SKY_cipher_SumSHA256 failed" ); + result = SKY_cipher_TestSecKeyHash( &seckey, &hash ); + cr_assert( result == SKY_OK, "SKY_cipher_TestSecKeyHash failed" ); +} From dab1f0db52b495cf6857812393af045cd6fc1aab Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 7 Jun 2018 21:12:46 -0400 Subject: [PATCH 016/399] [libc] ref #1191 finish TestTransactionPushInput [====] Synthesis: Tested: 115 | Passing: 115 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transactions.c | 137 ++++++++++++++---------- 1 file changed, 79 insertions(+), 58 deletions(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 868a1647b2..2ba03a18e4 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -151,67 +151,88 @@ Test(coin_transaction, TestTransactionVerify) cr_assert(errcode == SKY_OK); } -Test(coin_transaction, TestTransactionVerifyInput) -{ - coin__Transaction tx; - GoUint64_ errcode; - coin__UxArray uxArray; - - // Invalid uxIn args - makeTransaction(&tx); - cli__PasswordFromBytes seckey; - SKY_coin_UxArray_Coins(&seckey, NULL); - errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); - cr_assert(errcode != SKY_OK, "tx.In != uxIn"); - SKY_coin_UxArray_Coins(&seckey, 0); - errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); - cr_assert(errcode != SKY_OK, "tx.In != uxIn"); - SKY_coin_UxArray_Coins(&seckey, 3); - errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); - cr_assert(errcode != SKY_OK, "tx.In != uxIn"); - - // // tx.In != tx.Sigs - // ux, s := makeUxOutWithSecret(t) - // tx = makeTransactionFromUxOut(ux, s) - // tx.Sigs = []cipher.Sig{} - // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { - // tx.VerifyInput(UxArray{ux}) - // }) - - // ux, s = makeUxOutWithSecret(t) - // tx = makeTransactionFromUxOut(ux, s) - // tx.Sigs = append(tx.Sigs, cipher.Sig{}) - // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { - // tx.VerifyInput(UxArray{ux}) - // }) - - // tx.InnerHash != tx.HashInner() - coin__UxOut ux; - cipher__SecKey s; - errcode = makeUxOutWithSecret(&ux, &s); - cr_assert(errcode == SKY_OK); - errcode = makeTransactionFromUxOut(&ux, &s, &tx); - cr_assert(errcode == SKY_OK); - memset(&tx.Sigs, 0, sizeof(cipher__Sig)); - memset(&uxArray, 0, sizeof(coin__UxArray)); - uxArray.data = &ux; - SKY_coin_UxArray_Coins(&uxArray, 1); - errcode = SKY_coin_Transaction_VerifyInput(&tx, &uxArray); - cr_assert(errcode != SKY_OK, "tx.In != tx.Sigs"); - - errcode = makeUxOutWithSecret(&ux, &s); - cr_assert(errcode == SKY_OK); - errcode = makeTransactionFromUxOut(&ux, &s, &tx); - cr_assert(errcode == SKY_OK); - - coin__UxOut uxo; - coin__UxArray uxa; - uxa.data = uxo.; -} +// Test(coin_transaction, TestTransactionVerifyInput) +// { +// coin__Transaction tx; +// GoUint64_ errcode; +// coin__UxArray uxArray; + +// // Invalid uxIn args +// makeTransaction(&tx); +// cli__PasswordFromBytes seckey; +// SKY_coin_UxArray_Coins(&seckey, NULL); +// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); +// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); +// SKY_coin_UxArray_Coins(&seckey, 0); +// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); +// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); +// SKY_coin_UxArray_Coins(&seckey, 3); +// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); +// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); + +// // // tx.In != tx.Sigs +// // ux, s := makeUxOutWithSecret(t) +// // tx = makeTransactionFromUxOut(ux, s) +// // tx.Sigs = []cipher.Sig{} +// // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { +// // tx.VerifyInput(UxArray{ux}) +// // }) + +// // ux, s = makeUxOutWithSecret(t) +// // tx = makeTransactionFromUxOut(ux, s) +// // tx.Sigs = append(tx.Sigs, cipher.Sig{}) +// // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { +// // tx.VerifyInput(UxArray{ux}) +// // }) + +// // tx.InnerHash != tx.HashInner() +// coin__UxOut ux; +// cipher__SecKey s; +// errcode = makeUxOutWithSecret(&ux, &s); +// cr_assert(errcode == SKY_OK); +// errcode = makeTransactionFromUxOut(&ux, &s, &tx); +// cr_assert(errcode == SKY_OK); +// memset(&tx.Sigs, 0, sizeof(cipher__Sig)); +// memset(&uxArray, 0, sizeof(coin__UxArray)); +// uxArray.data = &ux; +// SKY_coin_UxArray_Coins(&uxArray, 1); +// errcode = SKY_coin_Transaction_VerifyInput(&tx, &uxArray); +// cr_assert(errcode != SKY_OK, "tx.In != tx.Sigs"); + +// errcode = makeUxOutWithSecret(&ux, &s); +// cr_assert(errcode == SKY_OK); +// errcode = makeTransactionFromUxOut(&ux, &s, &tx); +// cr_assert(errcode == SKY_OK); + +// // coin__UxOut uxo; +// // coin__UxArray uxa; +// // uxa.data = uxo.; +// } Test(coin_transaction, TestTransactionPushInput) { coin__Transaction tx; memset(&tx, 0, sizeof(coin__Transaction)); - coin__UxOut makeUxOut() + coin__UxOut ux; + memset(&ux, 0, sizeof(coin__UxOut)); + GoUint64_ errcode = makeUxOut(&ux); + GoUint16 value; + SKY_coin_Transaction_PushInput(&tx, &ux, &value); + cr_assert(value == 0); + cr_assert(tx.In.len == 1); + errcode = memcmp(((cipher__SHA256*)&tx.In.data), &ux, sizeof(cipher__SHA256)); + cr_assert(errcode > 0); + + cipher__SHA256* cipher; + + cipher = ((cipher__SHA256*)&tx.In.data); + makeRandHash(&cipher); + for (int i = 0; i < (1 << 16 - 1); ++i) { + cipher++; + makeRandHash(&cipher); + } + errcode = makeUxOut(&ux); + errcode =SKY_coin_Transaction_PushInput(&tx, &ux, &value); + + cr_assert(errcode==SKY_OK); } From c94ac494572ae3b6b10a8c1878f6f1623517e87a Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 8 Jun 2018 14:22:38 +0000 Subject: [PATCH 017/399] [libc] refs #1191. Added tests coin. Fixed bug in SKY_coin_UxArray_Sub. [====] Synthesis: Tested: 71 | Passing: 71 | Failing: 0 | Crashing: 0. --- include/skytest.h | 6 +- include/transutil.h | 4 + lib/cgo/coin.outputs.go | 4 +- lib/cgo/tests/check_coin.outputs.c | 399 ++++++++++++++++++++++ lib/cgo/tests/testutils/libsky_testutil.c | 46 ++- lib/cgo/tests/testutils/transutils.c | 31 ++ 6 files changed, 486 insertions(+), 4 deletions(-) create mode 100644 lib/cgo/tests/check_coin.outputs.c diff --git a/include/skytest.h b/include/skytest.h index 2ee9fee56e..98440d43c4 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -50,7 +50,11 @@ int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, cons int parseBoolean(const char* str, int length); -void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size); +int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size); + +int cutSlice(GoSlice_* slice, int start, int end, int elem_size, GoSlice_* result); + +int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* result); void setup(void); void teardown(void); diff --git a/include/transutil.h b/include/transutil.h index 19d1cfb1b3..4744968851 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -30,3 +30,7 @@ int makeTransaction(coin__Transaction* ptransaction); int makeTransactions(GoSlice* transactions, int n); void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2); + +void makeRandHash(cipher__SHA256* phash); + +int makeUxArray(coin__UxArray* parray, int n); diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 2695b6d181..4b1aecba16 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -182,7 +182,7 @@ func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Sub(other) - *_arg1 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } @@ -195,6 +195,6 @@ func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Add(other) - *_arg1 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c new file mode 100644 index 0000000000..0ca98169a2 --- /dev/null +++ b/lib/cgo/tests/check_coin.outputs.c @@ -0,0 +1,399 @@ +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "transutil.h" + +TestSuite(coin_outputs, .init = setup, .fini = teardown); + +Test(coin_outputs, TestUxBodyHash){ + int result; + coin__UxBody uxbody; + result = makeUxBody(&uxbody); + cr_assert( result == SKY_OK, "makeUxBody failed" ); + cipher__SHA256 hash, nullHash; + result = SKY_coin_UxBody_Hash(&uxbody, &hash); + cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); +} + +Test(coin_outputs, TestUxOutHash){ + int result; + coin__UxBody uxbody; + result = makeUxBody(&uxbody); + cr_assert( result == SKY_OK, "makeUxBody failed" ); + + coin__UxOut uxout; + memset(&uxout, 0, sizeof(coin__UxOut)); + memcpy(&uxout.Body, &uxbody, sizeof(coin__UxBody)); + + cipher__SHA256 hashBody, hashOut; + result = SKY_coin_UxBody_Hash(&uxbody, &hashBody); + cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); + result = SKY_coin_UxOut_Hash(&uxout, &hashOut); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); + + //Head should not affect hash + uxout.Head.Time = 0; + uxout.Head.BkSeq = 1; + result = SKY_coin_UxOut_Hash(&uxout, &hashOut); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); +} + +Test(coin_outputs, TestUxOutSnapshotHash){ + int result; + coin__UxOut uxout, uxout2; + result = makeUxOut(&uxout); + cr_assert( result == SKY_OK, "makeUxOut failed" ); + cipher__SHA256 hash1, hash2; + result = SKY_coin_UxOut_SnapshotHash(&uxout, &hash1); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + uxout2.Head.Time = 20; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + uxout2.Head.BkSeq = 4; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + makeRandHash(&uxout2.Body.SrcTransaction); + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + makeAddress(&uxout2.Body.Address); + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + uxout2.Body.Coins = uxout.Body.Coins * 2; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + + memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); + uxout2.Body.Hours = uxout.Body.Hours * 2; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); +} + +Test(coin_outputs, TestUxOutCoinHours){ + GoUint64 _genCoins = 1000000000; + GoUint64 _genCoinHours = 1000 * 1000; + + int result; + coin__UxOut ux; + result = makeUxOut(&ux); + cr_assert( result == SKY_OK, "makeUxOut failed" ); + + GoUint64 now, hours; + + //Less than an hour passed + now = ux.Head.Time + 100; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours ); + + //An hour passed + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + ux.Body.Coins / 1000000 ); + + //6 hours passed + now = ux.Head.Time + 3600 * 6; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + (ux.Body.Coins / 1000000) * 6 ); + + //Time is backwards (treated as no hours passed) + now = ux.Head.Time / 2; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours ); + + //1 hour has passed, output has 1.5 coins, should gain 1 coinhour + ux.Body.Coins = 1500000; + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + 1 ); + + //2 hours have passed, output has 1.5 coins, should gain 3 coin hours + ux.Body.Coins = 1500000; + now = ux.Head.Time + 3600 * 2; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + 3 ); + + //1 second has passed, output has 3600 coins, should gain 1 coin hour + ux.Body.Coins = 3600000000; + now = ux.Head.Time + 1; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + 1 ); + + //1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour + ux.Body.Coins = 1; + now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600)-1; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours ); + + //1000000 hours have passed, output has 1 droplet, should gain 1 coin hour + ux.Body.Coins = 1; + now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600); + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + 1 ); + + // No hours passed, using initial coin hours + ux.Body.Coins = _genCoins; + ux.Body.Hours = _genCoinHours; + now = ux.Head.Time; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours ); + + // One hour passed, using initial coin hours + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == ux.Body.Hours + _genCoins / 1000000 ); + + // No hours passed and no hours to begin with0 + ux.Body.Hours = 0; + now = ux.Head.Time; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( hours == 0 ); + + // Centuries have passed, time-based calculation overflows uint64 + // when calculating the whole coin seconds + ux.Body.Coins = 2000000; + now = 0xFFFFFFFFFFFFFFFF; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); + + // Centuries have passed, time-based calculation overflows uint64 + // when calculating the droplet seconds + ux.Body.Coins = 1500000; + now = 0xFFFFFFFFFFFFFFFF; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); + + // Output would overflow if given more hours, has reached its limit + ux.Body.Coins = 3600000000; + now = 0xFFFFFFFFFFFFFFFE; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); +} + +Test(coin_outputs, TestUxArrayCoins){ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + GoUint64 coins; + result = SKY_coin_UxArray_Coins( &uxs, &coins ); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Coins failed" ); + cr_assert( coins == 4000000 ); + coin__UxOut* p = (coin__UxOut*)uxs.data; + p += 2; + p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; + result = SKY_coin_UxArray_Coins( &uxs, &coins ); + cr_assert( result != SKY_OK, "SKY_coin_UxArray_Coins should fail with overflow" ); +} + +Test(coin_outputs, TestUxArrayCoinHours){ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + coin__UxOut* p = (coin__UxOut*)uxs.data; + GoUint64 n; + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( n == 400 ); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600, &n); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( n == 404 ); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600 + 4600, &n); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); + cr_assert( n == 408 ); + + p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); + cr_assert( result != SKY_OK, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); + cr_assert( result != SKY_OK, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); +} + +Test(coin_outputs, TestUxArrayHashArray){ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + coin__UxOut* p = (coin__UxOut*)uxs.data; + + GoSlice_ hashes = {NULL, 0, 0}; + result = SKY_coin_UxArray_Hashes(&uxs, &hashes); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Hashes failed" ); + registerMemCleanup( hashes.data ); + cr_assert(hashes.len == uxs.len); + coin__UxOut* pux = (coin__UxOut*)uxs.data; + cipher__SHA256* ph = (cipher__SHA256*)hashes.data; + cipher__SHA256 hash; + for(int i = 0; i < hashes.len; i++){ + result = SKY_coin_UxOut_Hash(pux, &hash); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *ph) ); + pux++; + ph++; + } +} + +Test(coin_outputs, TestUxArrayHasDupes){ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + GoUint8 hasDupes; + result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); + cr_assert( hasDupes == 0 ); + coin__UxOut* p = (coin__UxOut*)uxs.data; + p++; + memcpy(uxs.data, p, sizeof(coin__UxOut)); + result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); + cr_assert( hasDupes != 0 ); +} + +Test(coin_outputs, TestUxArraySub){ + + int result; + coin__UxArray uxa, uxb, uxc, uxd; + coin__UxArray t1, t2, t3, t4; + + int arraySize = sizeof(coin__UxArray); + memset(&uxa, 0, arraySize); memset(&uxb, 0, arraySize); + memset(&uxc, 0, arraySize); memset(&uxd, 0, arraySize); + memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); + memset(&t3, 0, arraySize); memset(&t4, 0, arraySize); + + result = makeUxArray(&uxa, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + result = makeUxArray(&uxb, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + + int elems_size = sizeof(coin__UxOut); + cutSlice(&uxa, 0, 1, elems_size, &t1); + cr_assert( result == SKY_OK, "cutSlice failed" ); + result = concatSlices( &t1, &uxb, elems_size, &t2 ); + cr_assert( result == SKY_OK, "concatSlices failed" ); + result = cutSlice(&uxa, 1, 2, elems_size, &t3); + cr_assert( result == SKY_OK, "cutSlice failed" ); + result = concatSlices( &t2, &t3, elems_size, &uxc ); + cr_assert( result == SKY_OK, "concatSlices failed" ); + + memset(&uxd, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); + registerMemCleanup( uxd.data ); + cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&uxb)) ); + + memset(&uxd, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); + registerMemCleanup( uxd.data ); + cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); + cutSlice(&uxa, 0, 2, elems_size, &t1); + cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); + + // No intersection + memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxa, &uxb, &t1); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); + registerMemCleanup( t1.data ); + result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); + registerMemCleanup( t2.data ); + cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); + cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); +} + +int isUxArraySorted(coin__UxArray* uxa){ + int n = uxa->len; + coin__UxOut* prev = uxa->data; + coin__UxOut* current = prev; + current++; + cipher__SHA256 hash1, hash2; + cipher__SHA256* prevHash = NULL; + cipher__SHA256* currentHash = NULL; + + int result; + for(int i = 1; i < n; i++){ + if(prevHash == NULL){ + result = SKY_coin_UxOut_Hash(prev, &hash1); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + prevHash = &hash1; + } + if(currentHash == NULL) + currentHash = &hash2; + result = SKY_coin_UxOut_Hash(current, currentHash); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + if( memcmp(prevHash, currentHash, sizeof(cipher__SHA256)) > 0) + return 0; //Array is not sorted + if(i % 2 != 0){ + prevHash = &hash2; + currentHash = &hash1; + } else { + prevHash = &hash1; + currentHash = &hash2; + } + prev++; + current++; + } + return 1; +} + +Test(coin_outputs, TestUxArraySorting){ + + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + int isSorted = isUxArraySorted(&uxa); + if( isSorted ){ + coin__UxOut temp; + coin__UxOut* p = uxa.data; + memcpy(&temp, p, sizeof(coin__UxOut)); + memcpy(p, p + 1, sizeof(coin__UxOut)); + memcpy(p + 1, &temp, sizeof(coin__UxOut)); + } + isSorted = isUxArraySorted(&uxa); + cr_assert( isSorted == 0); + result = SKY_coin_UxArray_Sort( &uxa ); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sort failed" ); + isSorted = isUxArraySorted(&uxa); + cr_assert( isSorted == 1); +} diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index 80f8ed02a7..cfd6031b8c 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -290,13 +290,57 @@ GoString * tmp = r; *tmp = (*(GoString *) s); } -void copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ +int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ pdest->len = psource->len; pdest->cap = psource->len; int size = pdest->len * elem_size; pdest->data = malloc(size); + if( pdest->data == NULL ) + return SKY_ERROR; registerMemCleanup( pdest->data ); memcpy(pdest->data, psource->data, size ); + return SKY_OK; +} + +int cutSlice(GoSlice_* slice, int start, int end, int elem_size, GoSlice_* result){ + int size = end - start; + if( size <= 0) + return SKY_ERROR; + void* data = malloc(size * elem_size); + if( data == NULL ) + return SKY_ERROR; + registerMemCleanup( data ); + result->data = data; + result->len = size; + result->cap = size; + char* p = slice->data; + p += (elem_size * start); + memcpy( data, p, elem_size * size ); + return SKY_OK; +} + +int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* result){ + int size1 = slice1->len; + int size2 = slice2->len; + int size = size1 + size2; + if (size <= 0) + return SKY_ERROR; + void* data = malloc(size * elem_size); + if( data == NULL ) + return SKY_ERROR; + registerMemCleanup( data ); + result->data = data; + result->len = size; + result->cap = size; + char* p = data; + if(size1 > 0){ + memcpy( p, slice1->data, size1 * elem_size ); + p += (elem_size * size1); + } + if(size2 > 0){ + memcpy( p, slice2->data, size2 * elem_size ); + } + return SKY_OK; } /* diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index bb9bf2b1a3..d80c0b8ebc 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -27,6 +27,9 @@ int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey){ memset( puxBody, 0, sizeof(coin__UxBody) ); + puxBody->Coins = 1000000; + puxBody->Hours = 100; + result = SKY_cipher_GenerateKeyPair(&pubkey, pseckey); cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); @@ -148,3 +151,31 @@ void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2){ copySlice(&pt2->In, &pt1->In, sizeof(cipher__SHA256)); copySlice(&pt2->Out, &pt1->Out, sizeof(coin__TransactionOutput)); } + +void makeRandHash(cipher__SHA256* phash){ + GoSlice slice; + memset(&slice, 0, sizeof(GoSlice)); + + int result = SKY_cipher_RandByte( 128, (coin__UxArray*)&slice ); + cr_assert(result == SKY_OK, "SKY_cipher_RandByte failed"); + registerMemCleanup( slice.data ); + result = SKY_cipher_SumSHA256( slice, phash ); + cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); +} + +int makeUxArray(coin__UxArray* parray, int n){ + parray->data = malloc( sizeof(coin__UxOut) * n ); + if(!parray->data) + return SKY_ERROR; + registerMemCleanup( parray->data ); + parray->cap = parray->len = n; + coin__UxOut* p = (coin__UxOut*)parray->data; + int result = SKY_OK; + for(int i = 0; i < n; i++){ + result = makeUxOut(p); + if( result != SKY_OK ) + break; + p++; + } + return result; +} From dc53115151824af6699f0beeecebf03d77b645f1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 8 Jun 2018 14:26:27 +0000 Subject: [PATCH 018/399] [libc] refs #1191. Fixed bug in libsky_criterion. [====] Synthesis: Tested: 71 | Passing: 71 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/testutils/libsky_criterion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 93227bdb27..068e2f1dbb 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -20,7 +20,7 @@ char *cr_user_cipher__Address_tostr(cipher__Address *addr1) int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2){ if(addr1->Version == addr2->Version) return 0; - return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) == 1; + return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) != 0; } int cr_user_GoString_eq(GoString *string1, GoString *string2){ From bcea91d68ded83979b865953102152bc7223c878 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 8 Jun 2018 15:42:47 +0000 Subject: [PATCH 019/399] [libc] refs #1191. Added tests for coin.outputs and coin.math. [====] Synthesis: Tested: 76 | Passing: 76 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.math.c | 56 ++++++++++++++++++ lib/cgo/tests/check_coin.outputs.c | 66 +++++++++++++++++++++- lib/cgo/tests/testutils/libsky_criterion.c | 14 +++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 lib/cgo/tests/check_coin.math.c diff --git a/lib/cgo/tests/check_coin.math.c b/lib/cgo/tests/check_coin.math.c new file mode 100644 index 0000000000..c570d504e1 --- /dev/null +++ b/lib/cgo/tests/check_coin.math.c @@ -0,0 +1,56 @@ +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +TestSuite(coin_math, .init = setup, .fini = teardown); + +Test(coin_math, TestAddUint64){ + int result; + GoUint64 r; + result = SKY_coin_AddUint64(10, 11, &r); + cr_assert( result == SKY_OK ); + cr_assert(r == 21); + GoUint64 maxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 one = 1; + result = SKY_coin_AddUint64(maxUint64, one, &r); + cr_assert( result != SKY_OK ); +} + +typedef struct{ + GoUint64 a; + GoInt64 b; + int failure; +} math_tests; + +Test(coin_math, TestUint64ToInt64){ + int result; + GoInt64 r; + GoUint64 maxUint64 = 0xFFFFFFFFFFFFFFFF; + GoInt64 maxInt64 = 0x7FFFFFFFFFFFFFFF; + + math_tests tests[] = { + {0, 0, 0}, + {1, 1, 0}, + {maxInt64, maxInt64, 0}, + {maxUint64, 0, 1}, + //This is reset to zero in C, and it doesn't fail + //{maxUint64 + 1, 0, 1}, + }; + int tests_count = sizeof(tests) / sizeof(math_tests); + for(int i = 0; i < tests_count; i++){ + result = SKY_coin_Uint64ToInt64(tests[i].a, &r); + if( tests[i].failure ){ + cr_assert(result != SKY_OK, "Failed test # %d", i + 1); + } else { + cr_assert(result == SKY_OK, "Failed test # %d", i + 1); + cr_assert( tests[i].b == r ); + } + } +} diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 0ca98169a2..8ba7bb1fde 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -383,7 +383,7 @@ Test(coin_outputs, TestUxArraySorting){ result = makeUxArray(&uxa, 4); cr_assert( result == SKY_OK, "makeUxArray failed" ); int isSorted = isUxArraySorted(&uxa); - if( isSorted ){ + if( isSorted ){ //If already sorted then break the order coin__UxOut temp; coin__UxOut* p = uxa.data; memcpy(&temp, p, sizeof(coin__UxOut)); @@ -397,3 +397,67 @@ Test(coin_outputs, TestUxArraySorting){ isSorted = isUxArraySorted(&uxa); cr_assert( isSorted == 1); } + +Test(coin_outputs, TestUxArrayLen){ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 4); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + GoInt len; + result = SKY_coin_UxArray_Len(&uxa, &len); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Len failed" ); + cr_assert( len == uxa.len ); + cr_assert( len == 4 ); +} + +Test(coin_outputs, TestUxArrayLess){ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 2); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + cipher__SHA256 hashes[2]; + coin__UxOut* p = uxa.data; + result = SKY_coin_UxOut_Hash(p, &hashes[0]); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + p++; + result = SKY_coin_UxOut_Hash(p, &hashes[1]); + cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); + GoUint8 lessResult1, lessResult2; + int memcmpResult; + result = SKY_coin_UxArray_Less(&uxa, 0, 1, &lessResult1); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); + result = SKY_coin_UxArray_Less(&uxa, 1, 0, &lessResult2); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); + memcmpResult = memcmp( &hashes[0], &hashes[1], sizeof(cipher__SHA256) ); + int r; + r = (lessResult1 == 1) == (memcmpResult < 0); + cr_assert(r != 0); + r = (lessResult2 == 1) == (memcmpResult > 0); + cr_assert(r != 0); +} + +Test(coin_outputs, TestUxArraySwap){ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 2); + cr_assert( result == SKY_OK, "makeUxArray failed" ); + coin__UxOut uxx, uxy; + coin__UxOut* p = uxa.data; + memcpy(&uxx, p, sizeof(coin__UxOut)); + memcpy(&uxy, p + 1, sizeof(coin__UxOut)); + + result = SKY_coin_UxArray_Swap(&uxa, 0, 1); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); + cr_assert( eq(type(coin__UxOut), uxy, *p) ); + cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); + + result = SKY_coin_UxArray_Swap(&uxa, 0, 1); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); + cr_assert( eq(type(coin__UxOut), uxy, *(p+1)) ); + cr_assert( eq(type(coin__UxOut), uxx, *p) ); + + result = SKY_coin_UxArray_Swap(&uxa, 1, 0); + cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); + cr_assert( eq(type(coin__UxOut), uxy, *p) ); + cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); +} diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 068e2f1dbb..e36d033e19 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -161,3 +161,17 @@ char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) { cr_asprintf(&out, "(coin__BlockBody) { .data %s, .len %d, .cap %d }", (char*)b->Transactions.data, b->Transactions.len, b->Transactions.cap); return out; } + +int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2){ + return memcmp(x1, x2, sizeof(coin__UxOut)) == 0; +} + +int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2){ + return memcmp(x1, x2, sizeof(coin__UxOut)) != 0; +} + +char* cr_user_coin__UxOut_tostr(coin__UxOut *x1){ + char *out; + cr_asprintf(&out, "(coin__UxOut) { %s }", (char*)x1); + return out; +} From 18417465bceee26bf27a42ccdb789e981903a006 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 8 Jun 2018 16:51:35 +0000 Subject: [PATCH 020/399] [libc] refs #1191. Fixed criterion issues. [====] Synthesis: Tested: 76 | Passing: 76 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 8 ++++++++ lib/cgo/tests/check_coin.block.c | 1 + lib/cgo/tests/check_coin.outputs.c | 1 + 3 files changed, 10 insertions(+) diff --git a/include/skycriterion.h b/include/skycriterion.h index fb36608b39..4d0d521017 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -39,4 +39,12 @@ extern char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1); extern int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2); +extern int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2); +extern int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2); +extern char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b); + +extern int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2); +extern int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2); +extern char* cr_user_coin__UxOut_tostr(coin__UxOut *x1); + #endif //LIBCRITERION_H diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 06c4211e4e..6edb6dc3a9 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -10,6 +10,7 @@ #include "skystring.h" #include "skytest.h" #include "transutil.h" +#include "skycriterion.h" #include "time.h" TestSuite(coin_block, .init = setup, .fini = teardown); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 8ba7bb1fde..0826b3d0da 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -8,6 +8,7 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" +#include "skycriterion.h" #include "transutil.h" TestSuite(coin_outputs, .init = setup, .fini = teardown); From 8abd8964562b29be882e2e04c0af50e1f6e280f8 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Fri, 8 Jun 2018 15:58:14 -0400 Subject: [PATCH 021/399] [libc] ref #1191 [====] Synthesis: Tested: 127 | Passing: 127 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transactions.c | 80 ++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 2ba03a18e4..b642c87b6e 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -231,8 +231,82 @@ Test(coin_transaction, TestTransactionPushInput) cipher++; makeRandHash(&cipher); } - errcode = makeUxOut(&ux); - errcode =SKY_coin_Transaction_PushInput(&tx, &ux, &value); + errcode = makeUxOut(&ux); + errcode = SKY_coin_Transaction_PushInput(&tx, &ux, &value); - cr_assert(errcode==SKY_OK); + cr_assert(errcode == SKY_OK); +} + +Test(coin_transaction, TestTransactionPushOutput) +{ + coin__Transaction tx; + cipher__Address a; + GoUint32 errcode = makeAddress(a); + cr_assert(errcode == SKY_OK); + memset(&tx, 0, sizeof(tx)); + errcode = SKY_coin_Transaction_PushOutput(&tx, &a, 100, 500); + cr_assert(tx.Out.len == 1); + coin__TransactionOutput value = { a, 100, 150 }; + GoSlice_ slice = { &value, 1, 1 }; + cr_assert(eq(type(GoSlice_), slice, tx.Out)); + + memset(&tx, 0, sizeof(coin__Transaction)); + coin__TransactionOutput* slice_void = + ((coin__TransactionOutput*)&tx.Out.data); + for (int i = 0; i < 20; i++) { + cipher__Address address; + errcode = makeAddress(&address); + cr_assert(errcode == SKY_OK); + GoUint16 coins = ((GoUint16)(i * 100)); + GoUint16 hours = ((GoUint16)(i * 50)); + errcode = SKY_coin_Transaction_PushOutput(&tx, &address, coins, hours); + cr_assert(tx.Out.len == (i + 1)); + // slice_void++; + } +} + + + +Test(coin_transaction, TestTransactionHash) +{ + coin__Transaction tx; + cleanupMem(&tx); + makeTransaction(&tx); + cipher__SHA256 sha; + cipher__SHA256 shatmp; + cipher__SHA256 shainner; + memset(&sha, 0, sizeof(cipher__SHA256)); + memset(&shatmp, 0, sizeof(cipher__SHA256)); + memset(&shainner, 0, sizeof(cipher__SHA256)); + SKY_coin_Transaction_Hash(&tx, &shatmp); + SKY_coin_Transaction_HashInner(&tx, &shainner); + + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], sha, shatmp))); + + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], sha, shainner))); +} + +Test(coin_transaction, TestTransactionUpdateHeader) +{ + coin__Transaction tx; + cleanupMem(&tx); + makeTransaction(&tx); + cipher__SHA256 h; + cipher__SHA256 shatmp; + cipher__SHA256 sha_clean; + cipher__SHA256 shainner; + memset(&h, 0, sizeof(cipher__SHA256)); + memset(&sha_clean, 0, sizeof(cipher__SHA256)); + + SKY_coin_Transaction_HashInner(&tx, &shainner); + // + memcpy(&h, &tx.InnerHash, sizeof(cipher__SHA256)); + memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); + + SKY_coin_Transaction_UpdateHeader(&tx); + SKY_coin_Transaction_HashInner(&tx, &shatmp); + + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, sha_clean))); + cr_assert(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, h)); + cr_assert(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, shainner)); } From 2417128741b78c720c69e774107d3ee12be4ceb9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 8 Jun 2018 21:19:12 +0000 Subject: [PATCH 022/399] [libc] refs #1191 Added 2 transactions tests. [====] Synthesis: Tested: 79 | Passing: 79 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.outputs.c | 5 + lib/cgo/tests/check_coin.transaction2.c | 241 ++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 lib/cgo/tests/check_coin.transaction2.c diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 0826b3d0da..66967fe1e7 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -462,3 +462,8 @@ Test(coin_outputs, TestUxArraySwap){ cr_assert( eq(type(coin__UxOut), uxy, *p) ); cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); } + +/********************************************************** +* 6 Tests involvinf AddressUxOuts were not done +* because the corresponding functions were not exported +*************************************************************/ diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c new file mode 100644 index 0000000000..601aad0c7e --- /dev/null +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -0,0 +1,241 @@ +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "skycriterion.h" +#include "transutil.h" + +TestSuite(coin_transactions, .init = setup, .fini = teardown); + +Test(coin_outputs, TestTransactionsTruncateBytesTo){ + //SKY_coin_Transactions_TruncateBytesTo +} + +typedef struct { + GoUint64 coins; + GoUint64 hours; +} test_ux; + +typedef struct { + test_ux* inUxs; + test_ux* outUxs; + int sizeIn; + int sizeOut; + GoUint64 headTime; + int failure; +} test_case; + +int makeTestCaseArrays(test_ux* elems, int size, coin__UxArray* pArray){ + if(size <= 0){ + pArray->len = 0; + pArray->cap = 0; + pArray->data = NULL; + return SKY_OK; + } + int elems_size = sizeof(coin__UxOut); + void* data; + data = malloc(size * elems_size); + if( data == NULL) + return SKY_ERROR; + registerMemCleanup( data ); + pArray->data = data; + pArray->len = size; + pArray->cap = size; + coin__UxOut* p = data; + for(int i = 0; i < size; i++){ + p->Body.Coins = elems[i].coins; + p->Body.Hours = elems[i].hours; + p++; + } + return SKY_OK; +} + +Test(coin_outputs, TestVerifyTransactionCoinsSpending){ + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 Million = 1000000; + + //Input coins overflow + test_ux in1[] = { + {MaxUint64 - Million + 1, 10}, + {Million, 0} + }; + + //Output coins overflow + test_ux in2[] = { + {10 * Million, 10} + }; + test_ux out2[] = { + {MaxUint64 - 10 * Million + 1, 0}, + {20 * Million, 1} + }; + + //Insufficient coins + test_ux in3[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + test_ux out3[] = { + {20 * Million, 1}, + {10 * Million, 1} + }; + + //Destroyed coins + test_ux in4[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + test_ux out4[] = { + {5 * Million, 1}, + {10 * Million, 1} + }; + + //Valid + test_ux in5[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + test_ux out5[] = { + {10 * Million, 11}, + {10 * Million, 1}, + {5 * Million, 0} + }; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, //Input coins overflow + {in2, out2, 1, 2, 0, 1}, //Output coins overflow + {in3, out3, 2, 2, 0, 1}, //Destroyed coins + {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) + {in5, out5, 2, 3, 0, 0} //Valid + }; + + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for( int i = 0; i < count; i++){ + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); + if( tests[i].failure ) + cr_assert( result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", i+1 ); + else + cr_assert( result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", i+1 ); + } +} + +Test(coin_outputs, TestVerifyTransactionHoursSpending){ + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 Million = 1000000; + + //Input hours overflow + test_ux in1[] = { + {3 * Million, MaxUint64 - Million + 1}, + {Million, Million} + }; + + //Insufficient coin hours + test_ux in2[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + + + test_ux out2[] = { + {15 * Million, 10}, + {10 * Million, 11} + }; + + //coin hours time calculation overflow + test_ux in3[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + + + test_ux out3[] = { + {10 * Million, 11}, + {10 * Million, 1}, + {5 * Million, 0} + }; + + //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) + test_ux in4[] = { + {10 * Million, MaxUint64} + }; + + test_ux out4[] = { + {10 * Million, 1} + }; + + //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) + test_ux in5[] = { + {10 * Million, MaxUint64} + }; + + test_ux out5[] = { + {10 * Million, 0} + }; + + //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) + test_ux in6[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + + test_ux out6[] = { + {15 * Million, 10}, + {10 * Million, 11} + }; + + //valid + test_ux in7[] = { + {10 * Million, 10}, + {15 * Million, 10} + }; + + test_ux out7[] = { + {10 * Million, 11}, + {10 * Million, 1}, + {5 * Million, 0} + }; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, //Input hours overflow + {in2, out2, 2, 2, 0, 1}, //Insufficient coin hours + {in3, out3, 2, 3, MaxUint64, 1}, //coin hours time calculation overflow + {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) + {in5, out5, 1, 1, 0, 0}, //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) + {in6, out6, 2, 2, 1492707255, 0}, //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) + {in7, out7, 2, 3, 0, 0}, //Valid + }; + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for( int i = 0; i < count; i++){ + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, &inArray, &outArray); + if( tests[i].failure ) + cr_assert( result != SKY_OK, "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i+1 ); + else + cr_assert( result == SKY_OK, "SKY_coin_VerifyTransactionHoursSpending failed %d", i+1 ); + } +} + + +/******************************************************* +* Tests not done because of wrapper functions were not created: +* TestTransactionsFees +* TestSortTransactions +********************************************************/ From 041d17d8522360dd5ee4973b78d6c4ccbdd12275 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 00:11:33 +0000 Subject: [PATCH 023/399] [libc] refs #1191. Added tests for coin package. [====] Synthesis: Tested: 83 | Passing: 83 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 4 + lib/cgo/coin.transactions.go | 2 +- lib/cgo/tests/check_coin.transaction2.c | 271 ++++++++++++++++++++- lib/cgo/tests/testutils/libsky_criterion.c | 26 ++ lib/cgo/tests/testutils/transutils.c | 3 + 5 files changed, 301 insertions(+), 5 deletions(-) diff --git a/include/skycriterion.h b/include/skycriterion.h index 4d0d521017..c5a3c8ce1b 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -47,4 +47,8 @@ extern int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2); extern int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2); extern char* cr_user_coin__UxOut_tostr(coin__UxOut *x1); +extern int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2); +extern int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2); +extern char* cr_user_coin__Transaction_tostr(coin__Transaction *x1); + #endif //LIBCRITERION_H diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 9fcbf8617b..cf253f4c29 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -269,7 +269,7 @@ func SKY_coin_Transactions_TruncateBytesTo(_txns *C.coin__Transactions, _size in txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) size := _size __arg1 := txns.TruncateBytesTo(size) - *_arg1 = *(*C.coin__Transactions)(unsafe.Pointer(&__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index 601aad0c7e..ceccd0a849 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -13,10 +13,273 @@ TestSuite(coin_transactions, .init = setup, .fini = teardown); -Test(coin_outputs, TestTransactionsTruncateBytesTo){ - //SKY_coin_Transactions_TruncateBytesTo +Test(coin_transactions, TestTransactionVerifyInput){ + int result; + coin__Transaction tx; + makeTransaction( &tx ); + result = SKY_coin_Transaction_VerifyInput(&tx, NULL); + cr_assert( result != SKY_OK ); + coin__UxArray ux; + memset(&ux, 0, sizeof(coin__UxArray)); + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + memset(&ux, 0, sizeof(coin__UxArray)); + ux.data = malloc(3 * sizeof(coin__UxOut)); + cr_assert(ux.data != NULL); + registerMemCleanup(ux.data); + ux.len = 3; + ux.cap = 3; + memset(ux.data, 0, 3 * sizeof(coin__UxOut)); + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + coin__UxOut uxOut; + cipher__SecKey seckey; + cipher__Sig sig; + cipher__SHA256 hash; + + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + tx.Sigs.data = NULL; tx.Sigs.len = 0; tx.Sigs.cap = 0; + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + memset(&sig, 0, sizeof(cipher__Sig)); + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + tx.Sigs.data = &sig; tx.Sigs.len = 1; tx.Sigs.cap = 1; + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + //Invalid Tx Inner Hash + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + memset( tx.InnerHash, 0, sizeof(cipher__SHA256) ); + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + //Ux hash mismatch + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + memset( &uxOut, 0, sizeof(coin__UxOut) ); + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + //Invalid signature + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + if(tx.Sigs.len > 0){ + memset(&tx.Sigs.data, 0, sizeof(cipher__Sig)); + } else { + memset(&sig, 0, sizeof(cipher__Sig)); + tx.Sigs.data = &sig; tx.Sigs.len = 1; tx.Sigs.cap = 1; + } + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result != SKY_OK ); + + //Valid + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + cr_assert( result == SKY_OK ); + ux.data = &uxOut; + ux.len = 1; ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + cr_assert( result == SKY_OK ); +} + +Test(coin_transactions, TestTransactionHashInner){ + int result; + coin__Transaction tx, tx2; + makeTransaction( &tx ); + cipher__SHA256 hash, nullHash; + result = SKY_coin_Transaction_HashInner( &tx, &hash ); + cr_assert( result == SKY_OK ); + memset( &nullHash, 0, sizeof(cipher__SHA256) ); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); + + // If tx.In is changed, hash should change + copyTransaction( &tx, &tx2 ); + coin__UxOut uxOut; + makeUxOut( &uxOut ); + cipher__SHA256* phash = tx2.In.data; + result = SKY_coin_UxOut_Hash( &uxOut, phash ); + cr_assert( result == SKY_OK ); + cr_assert( not( eq( type(coin__Transaction), tx, tx2 ) ) ); + cipher__SHA256 hash1, hash2; + result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + cr_assert( result == SKY_OK ); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); + + // If tx.Out is changed, hash should change + copyTransaction( &tx, &tx2 ); + cipher__Address* paddr = tx2.Out.data; + cipher__Address addr; + makeAddress( &addr ); + memcpy(paddr, &addr, sizeof(cipher__Address)); + cr_assert( not( eq( type(coin__Transaction), tx, tx2 ) ) ); + cr_assert(eq(type(cipher__Address), addr, *paddr)); + result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + cr_assert( result == SKY_OK ); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); + + // If tx.Head is changed, hash should not change + copyTransaction( &tx, &tx2 ); + cipher__Sig* newSigs = malloc((tx2.Sigs.len + 1) * sizeof(cipher__Sig)); + cr_assert( newSigs != NULL ); + registerMemCleanup( newSigs ); + memcpy( newSigs, tx2.Sigs.data, tx2.Sigs.len * sizeof(cipher__Sig)); + tx2.Sigs.data = newSigs; + newSigs += tx2.Sigs.len; + tx2.Sigs.len++; + tx2.Sigs.cap = tx2.Sigs.len; + memset( newSigs, 0, sizeof(cipher__Sig) ); + result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + cr_assert( result == SKY_OK ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); +} + +Test(coin_transactions, TestTransactionSerialization){ + int result; + coin__Transaction tx; + makeTransaction( &tx ); + GoSlice_ data; + memset( &data, 0, sizeof(GoSlice_) ); + result = SKY_coin_Transaction_Serialize( &tx, &data ); + cr_assert( result == SKY_OK ); + registerMemCleanup( data.data ); + coin__Transaction tx2; + memset( &tx2, 0, sizeof(coin__Transaction) ); + GoSlice d = {data.data, data.len, data.cap}; + result = SKY_coin_TransactionDeserialize(d, &tx2); + cr_assert( result == SKY_OK ); + cr_assert( eq( type(coin__Transaction), tx, tx2) ); +} + +Test(coin_transactions, TestTransactionOutputHours){ + coin__Transaction tx; + memset( &tx, 0, sizeof(coin__Transaction) ); + cipher__Address addr; + makeAddress(&addr); + int result; + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 100); + cr_assert( result == SKY_OK ); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 200); + cr_assert( result == SKY_OK ); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 500); + cr_assert( result == SKY_OK ); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 0); + cr_assert( result == SKY_OK ); + GoUint64 hours; + result = SKY_coin_Transaction_OutputHours(&tx, &hours); + cr_assert( result == SKY_OK ); + cr_assert( hours == 800 ); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); + result = SKY_coin_Transaction_OutputHours(&tx, &hours); + cr_assert( result != SKY_OK ); } +/************************ +* TestTransactionsSize not done for missing encoder.Serialize +***********************/ + +Test(coin_transactions, TestTransactionsTruncateBytesTo){ + int result; + GoSlice_ transactions, hashes; + memset(&transactions, 0, sizeof(GoSlice_)); + memset(&hashes, 0, sizeof(GoSlice_)); + result = makeTransactions((GoSlice*)&transactions, 4); + cr_assert( result == SKY_OK ); + + result = SKY_coin_Transactions_Hashes(&transactions, &hashes); + cr_assert( result == SKY_OK, "SKY_coin_Transactions_Hashes failed" ); + registerMemCleanup( hashes.data ); + cr_assert( hashes.len == 4 ); + coin__Transaction* pt = transactions.data; + cipher__SHA256* ph = hashes.data; + cipher__SHA256 hash; + for(int i = 0; i < 4; i++){ + result = SKY_coin_Transaction_Hash(pt, &hash); + cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], *ph, hash) ); + pt++; + ph++; + } +} + +/**************************** +* Test crashing randomly. +* TODO: check why this tests is crashing +***************************/ +/*Test(coin_transactions, TestTransactionsTruncateBytesTo){ + int result; + GoSlice_ transactions, transactions2; + memset(&transactions, 0, sizeof(GoSlice_)); + memset(&transactions2, 0, sizeof(GoSlice_)); + result = makeTransactions((GoSlice*)&transactions, 10); + cr_assert( result == SKY_OK ); + int trunc = 0; + coin__Transaction* pTx = transactions.data; + GoInt size; + for(int i = 0; i < transactions.len / 2; i++){ + result = SKY_coin_Transaction_Size(pTx, &size); + trunc += size; + cr_assert( result == SKY_OK, "SKY_coin_Transaction_Size failed" ); + pTx++; + } + result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); + cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); + registerMemCleanup( transactions2.data ); + + cr_assert( transactions2.len == transactions.len / 2 ); + result = SKY_coin_Transactions_Size( &transactions2, &size ); + cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); + cr_assert( trunc == size ); + + freeRegisteredMemCleanup( transactions2.data ); + trunc++; + memset(&transactions2, 0, sizeof(GoSlice_)); + result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); + cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); + registerMemCleanup( transactions2.data ); + + // Stepping into next boundary has same cutoff, must exceed + cr_assert( transactions2.len == transactions.len / 2 ); + result = SKY_coin_Transactions_Size( &transactions2, &size ); + cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); + cr_assert( trunc - 1 == size ); +}*/ + typedef struct { GoUint64 coins; GoUint64 hours; @@ -56,7 +319,7 @@ int makeTestCaseArrays(test_ux* elems, int size, coin__UxArray* pArray){ return SKY_OK; } -Test(coin_outputs, TestVerifyTransactionCoinsSpending){ +Test(coin_transactions, TestVerifyTransactionCoinsSpending){ GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; GoUint64 Million = 1000000; @@ -131,7 +394,7 @@ Test(coin_outputs, TestVerifyTransactionCoinsSpending){ } } -Test(coin_outputs, TestVerifyTransactionHoursSpending){ +Test(coin_transactions, TestVerifyTransactionHoursSpending){ GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; GoUint64 Million = 1000000; diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index e36d033e19..c2ba31158c 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -175,3 +175,29 @@ char* cr_user_coin__UxOut_tostr(coin__UxOut *x1){ cr_asprintf(&out, "(coin__UxOut) { %s }", (char*)x1); return out; } + +int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2){ + if( x1->Length != x2->Length || + x1->Type != x2->Type ){ + return 0; + } + if(!cr_user_cipher__SHA256_eq(&x1->InnerHash, &x2->InnerHash)) + return 0; + if(!cr_user_GoSlice__eq(&x1->Sigs, &x2->Sigs) ) + return 0; + if(!cr_user_GoSlice__eq(&x1->In, &x2->In) ) + return 0; + if(!cr_user_GoSlice__eq(&x1->Out, &x2->Out) ) + return 0; + return 1; +} + +int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2){ + return !cr_user_coin__Transaction_eq(x1, x2); +} + +char* cr_user_coin__Transaction_tostr(coin__Transaction *x1){ + char *out; + cr_asprintf(&out, "(coin__Transaction) { Length : %d }", x1->Length); + return out; +} diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index d80c0b8ebc..4bce368d0e 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -126,6 +126,9 @@ int makeTransaction(coin__Transaction* ptransaction){ int makeTransactions(GoSlice* transactions, int n){ void * data = malloc(sizeof(coin__Transaction) * n); + if(data == NULL) + return SKY_ERROR; + registerMemCleanup(data); coin__Transaction* ptransaction = (coin__Transaction*)data; int i; int result = SKY_ERROR; // n == 0 then error From c4cb28ef2f957b9ebba7651b32a993d27833f0f5 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 00:41:34 +0000 Subject: [PATCH 024/399] [libc] refs #1191. Fixed bug when decoding hex string. [====] Synthesis: Tested: 83 | Passing: 83 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.coin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cgo/tests/check_coin.coin.c b/lib/cgo/tests/check_coin.coin.c index 7bd8b46c78..188c85a75f 100644 --- a/lib/cgo/tests/check_coin.coin.c +++ b/lib/cgo/tests/check_coin.coin.c @@ -19,7 +19,7 @@ Test(coin_coin, TestAddress1){ char address[128]; int result; int length = hexnstr(address_hex, address, 128); - cr_assert(result > 0, "Error decoding hex string"); + cr_assert(length > 0, "Error decoding hex string"); GoSlice slice = { address, length, 128 }; cipher__PubKey pubkey; result = SKY_cipher_NewPubKey(slice, &pubkey); @@ -34,7 +34,7 @@ Test(coin_coin, TestAddress2){ char address[128]; int result; int length = hexnstr(address_hex, address, 128); - cr_assert(result > 0, "Error decoding hex string"); + cr_assert(length > 0, "Error decoding hex string"); GoSlice slice = { address, length, 128 }; cipher__PubKey pubkey; cipher__SecKey seckey; From 02f8b67fd7fd3721c7135e59ae7dd6918981278a Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 14:00:00 +0000 Subject: [PATCH 025/399] [libc] refs#1191. Added test function TestTransactionSignInputs. [====] Synthesis: Tested: 84 | Passing: 84 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.transaction2.c | 90 +++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index ceccd0a849..408906df4b 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -108,6 +108,96 @@ Test(coin_transactions, TestTransactionVerifyInput){ cr_assert( result == SKY_OK ); } +Test(coin_transactions, TestTransactionSignInputs){ + int result; + coin__Transaction tx; + coin__UxOut ux, ux2; + cipher__SecKey seckey, seckey2; + cipher__SHA256 hash, hash2; + cipher__Address addr, addr2; + cipher__PubKey pubkey; + GoUint16 r; + GoSlice keys; + + //Error if txns already signed + memset(&tx, 0, sizeof(coin__Transaction)); + tx.Sigs.data = malloc(sizeof(cipher__Sig)); + cr_assert( tx.Sigs.data != NULL ); + registerMemCleanup( tx.Sigs.data ); + memset( tx.Sigs.data, 0, sizeof(cipher__Sig) ); + tx.Sigs.len = 1; + tx.Sigs.cap = 1; + + memset( &seckey, 0, sizeof(cipher__SecKey) ); + keys.data = &seckey; keys.len = 1; keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(&tx, keys); + cr_assert( result != SKY_OK ); + + // Panics if not enough keys + memset(&tx, 0, sizeof(coin__Transaction)); + memset(&seckey, 0, sizeof(cipher__SecKey)); + memset(&seckey2, 0, sizeof(cipher__SecKey)); + result = makeUxOutWithSecret( &ux, &seckey ); + cr_assert( result == SKY_OK ); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + cr_assert( result == SKY_OK ); + result = makeUxOutWithSecret( &ux2, &seckey2 ); + cr_assert( result == SKY_OK ); + result = SKY_coin_UxOut_Hash(&ux2, &hash2); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_PushInput(&tx, &hash2, &r); + cr_assert( result == SKY_OK ); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, 40, 80); + cr_assert( result == SKY_OK ); + cr_assert( tx.Sigs.len == 0 ); + keys.data = &seckey; keys.len = 1; keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(&tx, keys); + cr_assert( result != SKY_OK ); + cr_assert( tx.Sigs.len == 0 ); + + // Valid signing + result = SKY_coin_Transaction_HashInner( &tx, &hash ); + cr_assert( result == SKY_OK ); + keys.data = malloc(2 * sizeof(cipher__SecKey)); + cr_assert( keys.data != NULL ); + registerMemCleanup( keys.data ); + keys.len = keys.cap = 2; + memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); + memcpy(((cipher__SecKey*)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); + result = SKY_coin_Transaction_SignInputs(&tx, keys); + cr_assert( result == SKY_OK ); + cr_assert(tx.Sigs.len == 2); + result = SKY_coin_Transaction_HashInner( &tx, &hash2 ); + cr_assert( result == SKY_OK ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, hash2) ); + + result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); + cr_assert( result == SKY_OK ); + result = SKY_cipher_AddressFromPubKey( &pubkey, &addr ); + cr_assert( result == SKY_OK ); + result = SKY_cipher_PubKeyFromSecKey(&seckey2, &pubkey); + cr_assert( result == SKY_OK ); + result = SKY_cipher_AddressFromPubKey( &pubkey, &addr2 ); + cr_assert( result == SKY_OK ); + + cipher__SHA256 addHash, addHash2; + result = SKY_cipher_AddSHA256(&hash, (cipher__SHA256*)tx.In.data, &addHash); + cr_assert( result == SKY_OK ); + result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256*)tx.In.data) + 1, &addHash2); + cr_assert( result == SKY_OK ); + result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig*)tx.Sigs.data); + cr_assert( result == SKY_OK ); + result = SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig*)tx.Sigs.data)+1); + cr_assert( result == SKY_OK ); + result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig*)tx.Sigs.data)+1); + cr_assert( result != SKY_OK ); + result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig*)tx.Sigs.data); + cr_assert( result != SKY_OK ); +} + Test(coin_transactions, TestTransactionHashInner){ int result; coin__Transaction tx, tx2; From 655c6bfd88a1950a88f69a8f370d3174f3f189e9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 15:52:31 +0000 Subject: [PATCH 026/399] [libc] refs #1191. Copied remaining cipher tests. [====] Synthesis: Tested: 121 | Passing: 121 | Failing: 0 | Crashing: 0. --- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 188 +++++ .../tests/check_cipher.encrypt.sha256xor.c | 311 ++++++++ lib/cgo/tests/check_cipher.scrypt.c | 164 ++++ .../tests/check_cipher.secp256k1.secp256.c | 170 +++++ .../tests/check_cipher.secp256k1.secp256_2.c | 702 ++++++++++++++++++ .../check_cipher.secp256k1.secp256k1-go2.ec.c | 143 ++++ ...eck_cipher.secp256k1.secp256k1-go2.field.c | 41 + ...check_cipher.secp256k1.secp256k1-go2.sig.c | 101 +++ ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 63 ++ 9 files changed, 1883 insertions(+) create mode 100644 lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c create mode 100644 lib/cgo/tests/check_cipher.encrypt.sha256xor.c create mode 100644 lib/cgo/tests/check_cipher.scrypt.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256_2.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c create mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c new file mode 100644 index 0000000000..3cc4dd4258 --- /dev/null +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -0,0 +1,188 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define PLAINTEXT "plaintext" +#define PASSWORD "password" +#define PASSWORD2 "pwd" +#define WRONG_PASSWORD "wrong password" +#define ENCRYPTED "dQB7Im4iOjUyNDI4OCwiciI6OCwicCI6MSwia2V5TGVuIjozMiwic2FsdCI6ImpiejUrSFNjTFFLWkI5T0tYblNNRmt2WDBPY3JxVGZ0ZFpDNm9KUFpaeHc9Iiwibm9uY2UiOiJLTlhOQmRQa1ZUWHZYNHdoIn3PQFmOot0ETxTuv//skTG7Q57UVamGCgG5" +#define BUFFER_SIZE 1024 +#define SCRYPTCHACHA20METALENGTHSIZE 2 + +TestSuite(cipher_encrypt_scrypt_chacha20poly1305, .init = setup, .fini = teardown); + +void parseJsonMetaData(char* metadata, int* n, int* r, int* p, int* keyLen){ + *n = *r = *p = *keyLen = 0; + int length = strlen(metadata); + int openingQuote = -1; + const char* keys[] = {"n", "r", "p", "keyLen"}; + int keysCount = 4; + int keyIndex = -1; + int startNumber = -1; + for(int i = 0; i < length; i++){ + if( metadata[i] == '\"'){ + startNumber = -1; + if(openingQuote >= 0){ + keyIndex = -1; + metadata[i] = 0; + for(int k = 0; k < keysCount; k++){ + if(strcmp(metadata + openingQuote + 1, keys[k]) == 0){ + keyIndex = k; + } + } + openingQuote = -1; + } else { + openingQuote = i; + } + } else if( metadata[i] >= '0' && metadata[i] <= '9' ){ + if(startNumber < 0) + startNumber = i; + } else if( metadata[i] == ',' ){ + if(startNumber >= 0){ + metadata[i] = 0; + int number = atoi(metadata + startNumber); + startNumber = -1; + if(keyIndex == 0) *n = number; + else if(keyIndex == 1) *r = number; + else if(keyIndex == 2) *p = number; + else if(keyIndex == 3) *keyLen = number; + } + } else { + startNumber = -1; + } + } +} + +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + char str[BUFFER_SIZE]; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; + + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(str, 0, BUFFER_SIZE); + + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; + + GoUint32 errcode; + unsigned int metalength; + encrypt__ScryptChacha20poly1305 encrypt = {1, 8, 1, 32}; + for(int i = 1; i <= 20; i++) { + memset(&result, 0, sizeof(GoSlice)); + encrypt.N = 1 << i; + errcode = SKY_encrypt_ScryptChacha20poly1305_Encrypt( + &encrypt, text, password, (coin__UxArray*)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed"); + registerMemCleanup( (void*) result.data ); + cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); + int decode_len = b64_decode((const unsigned char*)result.data, + result.len, str); + cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); + cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); + metalength = (unsigned int) str[0]; + for(int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++){ + if(str[m] > 0){ + metalength += (((unsigned int)str[m]) << (m * 8)); + } + } + cr_assert(metalength + SCRYPTCHACHA20METALENGTHSIZE < decode_len, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata length greater than result lentgh."); + char* meta = str + SCRYPTCHACHA20METALENGTHSIZE; + meta[metalength] = 0; + int n, r, p, keyLen; + parseJsonMetaData(meta, &n, &r, &p, &keyLen); + + cr_assert(n == encrypt.N, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value N incorrect."); + cr_assert(r == encrypt.R, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value R incorrect."); + cr_assert(p == encrypt.P, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value P incorrect."); + cr_assert(keyLen == encrypt.KeyLen, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value KeyLen incorrect."); + } +} + +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; + + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(&result, 0, sizeof(coin__UxArray)); + + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; + + GoUint32 errcode; + encrypt__ScryptChacha20poly1305 encrypt = {0, 0, 0, 0}; + + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (coin__UxArray*)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt failed"); + registerMemCleanup( (void*) result.data ); + cr_assert( eq(type(GoSlice), text, result) ); + + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, nullData, password2, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null encrypted data."); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray*)&result); + cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); +} diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c new file mode 100644 index 0000000000..3359696175 --- /dev/null +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -0,0 +1,311 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define BUFFER_SIZE 1024 +#define PASSWORD1 "pwd" +#define PASSWORD2 "key" +#define PASSWORD3 "9JMkCPphe73NQvGhmab" +#define WRONGPASSWORD "wrongpassword" +#define SHA256XORDATALENGTHSIZE 4 +#define SHA256XORBLOCKSIZE 32 +#define SHA256XORCHECKSUMSIZE 32 +#define SHA256XORNONCESIZE 32 + +TestSuite(cipher_encrypt_sha256xor, .init = setup, .fini = teardown); + +typedef struct{ + int dataLength; + GoSlice* pwd; + GoSlice* decryptPwd; + int success; + int tampered; +} TEST_DATA; + +int putUvarint(GoSlice* buf , GoUint64 x){ + int i = 0; + while( x >= 0x80 && i < buf->cap) { + ((unsigned char*)buf->data)[i] = ((GoUint8)x) | 0x80; + x >>= 7; + i++; + } + if( i < buf->cap ){ + ((unsigned char*)buf->data)[i] = (GoUint8)(x); + buf->len = i + 1; + } else { + buf->len = i; + } + return buf->len; +} + +int putVarint(GoSlice* buf , GoInt64 x){ + GoUint64 ux = (GoUint64)x << 1; + if ( x < 0 ) { + ux = ~ux; + } + return putUvarint(buf, ux); +} + +void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, + cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ + GoUint32 errcode; + int length = 32 + sizeof(cipher__SHA256); + unsigned char buff[length]; + GoSlice slice = {buff, 0, length}; + memset(buff, 0, length * sizeof(char)); + putVarint( &slice, index ); + memcpy(buff + 32, *nonceHash, sizeof(cipher__SHA256)); + slice.len = length; + cipher__SHA256 indexNonceHash; + errcode = SKY_cipher_SumSHA256(slice, &indexNonceHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + SKY_cipher_AddSHA256(key.data, &indexNonceHash, resultHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_AddSHA256 failed. Error adding hashes"); +} + +void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxArray* encrypted){ + GoUint32 fullLength = dataLength + SHA256XORDATALENGTHSIZE; + GoUint32 n = fullLength / SHA256XORBLOCKSIZE; + GoUint32 m = fullLength % SHA256XORBLOCKSIZE; + GoUint32 errcode; + + if( m > 0 ){ + fullLength += SHA256XORBLOCKSIZE - m; + } + cr_assert(SHA256XORBLOCKSIZE == sizeof(cipher__SHA256), "Size of SHA256 block size different that cipher.SHA256 struct"); + fullLength += SHA256XORBLOCKSIZE; + char* buffer = malloc(fullLength); + cr_assert(buffer != NULL, "Couldn\'t allocate buffer"); + //Add data length to the beginning, saving space for the checksum + for(int i = 0; i < SHA256XORDATALENGTHSIZE; i++){ + int shift = i * 8; + buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; + } + //Add the data + memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, + data.data, dataLength); + /*for(int i = 0; i < dataLength; i++){ + buffer[i + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE] = ((char*)data.data)[i]; + }*/ + //Add padding + for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ + buffer[i] = 0; + } + //Buffer with space for the checksum, then data length, then data, and then padding + GoSlice _data = {buffer + SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE}; + //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; + errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + char bufferNonce[SHA256XORNONCESIZE]; + GoSlice sliceNonce = {bufferNonce, 0, SHA256XORNONCESIZE}; + randBytes(&sliceNonce, SHA256XORNONCESIZE); + cipher__SHA256 hashNonce; + errcode = SKY_cipher_SumSHA256(sliceNonce, &hashNonce); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash for nonce"); + char bufferHash[BUFFER_SIZE]; + coin__UxArray hashPassword = {bufferHash, 0, BUFFER_SIZE}; + errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); + cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); + cipher__SHA256 h; + + + int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + unsigned char* dest_buffer = malloc(fullDestLength); + cr_assert(dest_buffer != NULL, "Couldn\'t allocate result buffer"); + for(int i = 0; i < n; i++){ + hashKeyIndexNonce(hashPassword, i, &hashNonce, &h); + cipher__SHA256* pBuffer = (cipher__SHA256*)(buffer + i *SHA256XORBLOCKSIZE); + cipher__SHA256* xorResult = (cipher__SHA256*)(dest_buffer + destBufferStart + i *SHA256XORBLOCKSIZE); + SKY_cipher_SHA256_Xor(pBuffer, &h, xorResult); + } + // Prefix the nonce + memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); + // Calculates the checksum + GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), + fullLength + SHA256XORNONCESIZE, + fullLength + SHA256XORNONCESIZE + }; + cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; + errcode = SKY_cipher_SumSHA256(nonceAndDataBytes, checksum); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating final checksum"); + unsigned char bufferb64[BUFFER_SIZE]; + unsigned int size = b64_encode((const unsigned char*)dest_buffer, fullDestLength, encrypted->data); + encrypted->len = size; +} + +Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ + unsigned char buff[BUFFER_SIZE]; + unsigned char encryptedBuffer[BUFFER_SIZE]; + unsigned char encryptedText[BUFFER_SIZE]; + GoSlice data = { buff, 0, BUFFER_SIZE }; + coin__UxArray encrypted = { encryptedBuffer, 0, BUFFER_SIZE }; + GoSlice pwd1 = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice pwd2 = { PASSWORD2, strlen(PASSWORD2), strlen(PASSWORD2) }; + GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; + + TEST_DATA test_data[] = { + {1, &nullPwd, &nullPwd, 0, 0}, + {1, &pwd2, &nullPwd, 1, 0}, + {2, &pwd1, &nullPwd, 1, 0}, + {32, &pwd1, &nullPwd, 1, 0}, + {64, &pwd3, &nullPwd, 1, 0}, + {65, &pwd3, &nullPwd, 1, 0}, + }; + + encrypt__Sha256Xor encryptSettings = {}; + + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, test_data[i].dataLength); + errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, *(test_data[i].pwd), &encrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + } else { + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); + } + if( errcode == SKY_OK ){ + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; + + int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } + + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert(decode_length >= 0, "base64_decode_string failed."); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + } + } + + for(int i = 33; i <= 64; i++){ + randBytes(&data, i); + errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd1, &encrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; + + int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } + + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert( decode_length >= 0, "base64_decode failed" ); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + + } +} + +Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ + unsigned char buff[BUFFER_SIZE]; + unsigned char encrypted_buffer[BUFFER_SIZE]; + unsigned char decrypted_buffer[BUFFER_SIZE]; + GoSlice data = {buff, 0, BUFFER_SIZE}; + GoSlice pwd = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice wrong_pwd = { WRONGPASSWORD, strlen(WRONGPASSWORD), strlen(WRONGPASSWORD) }; + coin__UxArray encrypted = {encrypted_buffer, 0, BUFFER_SIZE}; + coin__UxArray decrypted = {decrypted_buffer, 0, BUFFER_SIZE}; + GoSlice emptyPwd = {"", 1, 1}; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; + + TEST_DATA test_data[] = { + {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum + {32, &pwd, &emptyPwd, 0, 0}, //Empty password + {32, &pwd, &nullPwd, 0, 0}, //Null password + {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password + }; + encrypt__Sha256Xor encryptSettings = {}; + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, 32); + makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); + //SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + if( test_data[i].tampered ){ + ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; + } + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + *(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + } else { + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); + } + } + + for(int i = 0; i <= 64; i++){ + randBytes(&data, i); + //makeEncryptedData(data, i, pwd, &encrypted); + SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + *(GoSlice*)&encrypted, pwd, &decrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); + int equal = 1; + for(int j = 0; j < data.len; j++){ + if( ((unsigned char*)data.data)[j] != ((unsigned char*)decrypted.data)[j] ) + equal = 0; + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); + } +} + diff --git a/lib/cgo/tests/check_cipher.scrypt.c b/lib/cgo/tests/check_cipher.scrypt.c new file mode 100644 index 0000000000..7863fab99a --- /dev/null +++ b/lib/cgo/tests/check_cipher.scrypt.c @@ -0,0 +1,164 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define BUFFER_SIZE 1024 + +TestSuite(cipher_scrypt, .init = setup, .fini = teardown); + +typedef struct { + char* password; + char* salt; + GoInt N, r, p; + GoUint8* output; + GoInt keyLength; + GoInt passwordLength; + GoInt saltLength; +} TESTVECTOR; + +Test(cipher_scrypt, TestKey){ + GoUint8 g1[] = { + 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f, + 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb, + 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a, + 0xc5, 0xe5, 0xa, 0xa1, 0x5f, + }; + GoUint8 g2[] = { + 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18, + 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e, + 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5, + 0x7f, 0x91, 0x96, 0x3c, 0x37, + }; + GoUint8 g3[] = { + 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70, + 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09, + 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f, + 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98, + 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50, + 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa, + 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11, + 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40, + 0x18, 0x79, 0xe6, 0x41, 0xae, + }; + GoUint8 g4[] = { + 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98, + 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52, + }; + GoUint8 g5[] = { + 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b, + 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b, + 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa, + 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d, + 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f, + 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d, + 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89, + 0x06, + }; + GoUint8 g6[] = { + 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78, + 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a, + 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76, + 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9, + 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d, + 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, + 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, + 0x40, + }; + GoUint8 g7[] = { + 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46, + 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8, + 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43, + 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55, + 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24, + 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65, + 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58, + 0x87, + }; + TESTVECTOR good_ones[] = { + {"password", "salt", 2, 10, 10, g1, sizeof(g1) / sizeof(GoUint8), -1, -1}, + {"password", "salt", 16, 100, 100, g2, sizeof(g2) / sizeof(GoUint8), -1, -1}, + {"this is a long \000 password", + "and this is a long \000 salt", + 16384, 8, 1, g3, sizeof(g3) / sizeof(GoUint8), 25, 25}, + {"p", "s", 2, 1, 1, g4, sizeof(g4) / sizeof(GoUint8), -1, -1}, + {"", "", 16, 1, 1, g5, sizeof(g5) / sizeof(GoUint8), -1, -1}, + {"password", "NaCl", 1024, 8, 16, g6, sizeof(g6) / sizeof(GoUint8), -1, -1}, + {"pleaseletmein", "SodiumChloride", 16384, 8, 1, g7, sizeof(g7) / sizeof(GoUint8), -1, -1}, + }; + + GoInt32 maxInt = (GoInt32)(~((GoUint32)0) >> 1); + + TESTVECTOR bad_ones[] = { + {"p", "s", 0, 1, 1, NULL, -1, -1}, // N == 0 + {"p", "s", 1, 1, 1, NULL, -1, -1}, // N == 1 + {"p", "s", 7, 8, 1, NULL, -1, -1}, // N is not power of 2 + {"p", "s", 16, maxInt / 2, maxInt / 2, NULL, -1, -1}, // p * r too large + }; + + GoUint32 errcode; + GoSlice password; + GoSlice salt; + GoUint8 buffer[BUFFER_SIZE]; + coin__UxArray key = {buffer, 0, BUFFER_SIZE}; + + int good_ones_count = sizeof(good_ones) / sizeof(good_ones[0]); + int bad_ones_count = sizeof(bad_ones) / sizeof(bad_ones[0]); + for(int i = 0; i < good_ones_count; i++){ + password.data = good_ones[i].password; + if( good_ones[i].passwordLength < 0) + password.len = strlen(good_ones[i].password); + else + password.len = good_ones[i].passwordLength; + password.cap = password.len; + + salt.data = good_ones[i].salt; + if( good_ones[i].saltLength < 0) + salt.len = strlen(good_ones[i].salt); + else + salt.len = good_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + good_ones[i].N, good_ones[i].r, good_ones[i].p, + good_ones[i].keyLength, &key); + cr_assert(errcode == SKY_OK, "SKY_scrypt_Key failed"); + cr_assert(good_ones[i].keyLength == key.len, "SKY_scrypt_Key failed, incorrect generated key length."); + int equal = 1; + for(int j = 0; j < key.len; j++){ + if( ((GoUint8*)key.data)[j] != good_ones[i].output[j]){ + equal = 0; + } + } + cr_assert(equal == 1, "SKY_scrypt_Key failed. Invalid key generated."); + } + + for(int i = 0; i < bad_ones_count; i++){ + password.data = bad_ones[i].password; + if( bad_ones[i].passwordLength < 0) + password.len = strlen(bad_ones[i].password); + else + password.len = bad_ones[i].passwordLength; + password.cap = password.len; + + salt.data = bad_ones[i].salt; + if( bad_ones[i].saltLength < 0) + salt.len = strlen(bad_ones[i].salt); + else + salt.len = bad_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, + bad_ones[i].keyLength, &key); + cr_assert(errcode != SKY_OK, "SKY_scrypt_Key didn\'t failed"); + } +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c new file mode 100644 index 0000000000..c9bb5b178a --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -0,0 +1,170 @@ + +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +#define BUFFER_SIZE 128 +#define TESTS 1 +#define SigSize 65 + +TestSuite(cipher_secp256k1, .init = setup, .fini = teardown); + +Test(cipher_secp256k1,Test_Secp256_00){ + unsigned char buff[SigSize]; + visor__ReadableOutputs nonce = {buff,0,64}; + SKY_secp256k1_RandByte(32,&nonce); + if (nonce.len != 32) cr_fatal(); +} + + +Test(cipher_secp256k1,Test_Secp256_01){ + + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; + SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); + if (!errorSecKey) cr_fatal(); + + GoInt errorPubKey; + GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); + if (!errorPubKey) cr_fatal(); +} + +Test(cipher_secp256k1, TestPubkeyFromSeckey) { + + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char* hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; + + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + + GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; + GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; + + + visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; + + GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey,&pubkey); + if(errocode) cr_fatal(); + + cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + +} + +Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) { + + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char* hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; + + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + + GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; + GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; + + + visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; + + GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey,&pubkey); + if(errocode) cr_fatal(); + + cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + +} + +Test(cipher_secp256k1, Test_SignatureVerifyPubkey){ + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoInt result = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&recoveredPubKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); +} + +Test(cipher_secp256k1, Test_verify_functions){ + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoInt result = 0; + + error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySeckey failed"); + cr_assert(result == 1, "Sec key not verified"); + + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + + error_code = SKY_secp256k1_VerifySignature(msg, sig, pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result == 1, "Signature not verified"); +} + +Test(cipher_secp256k1,Test_SignatureVerifySecKey ){ + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; + SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); + cr_assert(errorSecKey != SKY_OK); + GoInt errorPubKey; + GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); + cr_assert(errorPubKey != SKY_OK); +} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c new file mode 100644 index 0000000000..3e2fadf77b --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c @@ -0,0 +1,702 @@ + +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" + +#define BUFFER_SIZE 128 +#define TESTS 1 +#define SigSize 65 + +int keys_count = 4; +const char* test_keys[] = { + "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", + "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", + "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", + "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", +}; + +//test size of messages +Test(cipher_secp256k1, Test_Secp256_02s){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); + cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char*) sig.data)[64]; + cr_assert( last <= 4 ); +} + +//test signing message +Test(cipher_secp256k1, Test_Secp256_02){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); +} + +//test pubkey recovery +Test(cipher_secp256k1, Test_Secp256_02a){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); +} + +//test random messages for the same pub/private key +Test(cipher_secp256k1, Test_Secp256_03){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for( int i = 0; i < TESTS; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + } +} + +//test random messages for different pub/private keys +Test(cipher_secp256k1, Test_Secp256_04){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for( int i = 0; i < TESTS; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char*) sig.data)[64]; + cr_assert( last < 4 ); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + } +} + +Test(cipher_secp256k1, Test_Secp256_06a_alt0){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + GoInt result; + for(int i = 0; i < TESTS; i++){ + error_code = SKY_secp256k1_RandByte(65, (coin__UxArray*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char*)sig.data)[32] = ((unsigned char*)sig.data)[32] & 0x70; + ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); + SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Secp256_06b){ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + + GoInt result; + for(int i = 0; i < TESTS; i++){ + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_00){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_01){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_02){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for( int i = 0; i < 64; i++){ + error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash, + (coin__UxArray*)&pub1, + (coin__UxArray*)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&pub2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_03){ + int test_count = 16; + const char* testArray[] = { + "tQ93w5Aqcunm9SGUfnmF4fJv", "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", + "DC7qdQQtbWSSaekXnFmvQgse", "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", + "X8EkuUZC7Td7PAXeS7Duc7vR", "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", + "tVqPYHHNVPRWyEed62v7f23u", "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", + "kCy4R57HDfLqF3pVhBWxuMcg", "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", + "j8bjv86ZNjKqzafR6mtSUVCE", "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", + "qShryAzVY8EtsuD3dsAc7qnG", "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", + "5FGG7ZBa8wVMBJkmzpXj5ESX", "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", + "f46TZG4xJHXUGWx8ekbNqa9F", "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", + "XkZdQJ5LT96wshN8JBH8rvEt", "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", + "GFDqXU4zYymhJJ9UGqRgS8ty", "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", + "tmwZksH2XyvuamnddYxyJ5Lp", "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", + "EuqZFsbAV5amTzkhgAMgjr7W", "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", + "TW6j8rMffZfmhyDEt2JUCrLB", "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", + "8rvkBnygfhWP8kjX9aXq68CY", "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", + "phyRfPDuf9JMRFaWdGh7NXPX", "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", + }; + + GoInt32 error_code; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {NULL, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + seed.data = (void*)testArray[2 * i]; + seed.len = strlen(testArray[2 * i]); + seed.cap = seed.len; + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&s1, (coin__UxArray*)&s2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWallets1){ + int test_count = 16; + const char* testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", + }; + GoInt32 error_code; + char bufferSeed[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&s1, (coin__UxArray*)&s2, + (coin__UxArray*)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_Secp256k1_Hash){ + int test_count = 16; + const char* testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", + }; + GoInt32 error_code; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferHash3[BUFFER_SIZE]; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; + + for(int i = 0; i < test_count; i++){ + hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); + hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); + error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray*)&hash3); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); + } +} + + +Test(cipher_secp256k1, Test_Secp256k1_Equal){ + char bufferSeed[BUFFER_SIZE]; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for(int i = 0; i < 64; i++) { + error_code = SKY_secp256k1_RandByte( 128, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray*)&hash1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&hash2, + (coin__UxArray*)&public, + (coin__UxArray*)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWalletGeneration){ + const char* pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; + const char* pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; + const char* pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; + + char bufferSeed[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + char bufferNewSeed[BUFFER_SIZE]; + char bufferPrivateExpected[BUFFER_SIZE]; + char bufferPublicExpected[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; + GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; + GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; + + strcpy(bufferSeed, pSeed); + seed.len = strlen(pSeed); + + GoInt32 error_code; + + for( int i = 0; i < 1024; i++ ) { + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray*)&newSeed, + (coin__UxArray*)&public, + (coin__UxArray*)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + memcpy( seed.data, newSeed.data, newSeed.len); + seed.len = newSeed.len; + } + + privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); + publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); + + cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); + cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); +} + +Test(cipher_secp256k1, Test_ECDH) { + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); +} + +Test(cipher_secp256k1, Test_ECDH2) { + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + + for( int i = 0; i < 32; i++ ) { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys) { + char seedBuffer[64]; + GoSlice seed = {seedBuffer, 0, 64}; + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; + GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for( int i = 0; i < 32; i++ ) { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray*)&privatekey, (coin__UxArray*)& pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys2) { + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; + GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for(int i = 0; i < keys_count; i++){ + int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); + privatekey.len = sizePrivatekey; + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray*)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys3) { + unsigned char bufferPrivatekey1[BUFFER_SIZE]; + unsigned char bufferPubKey1[BUFFER_SIZE]; + unsigned char bufferPrivatekey2[BUFFER_SIZE]; + unsigned char bufferPubKey2[BUFFER_SIZE]; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + int sizePrivatekey1, sizePrivatekey2; + int sizePubKey1, sizePubKey2; + GoSlice privatekey1 = { bufferPrivatekey1, 0, BUFFER_SIZE }; + GoSlice privatekey2 = { bufferPrivatekey2, 0, BUFFER_SIZE }; + GoSlice pubKey1 = { bufferPubKey1, 0, BUFFER_SIZE }; + GoSlice pubKey2 = { bufferPubKey2, 0, BUFFER_SIZE }; + GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; + GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + GoInt32 error_code; + + for(int i = 0; i < keys_count; i++){ + int randn = rand() % keys_count; + sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); + sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); + privatekey1.len = sizePrivatekey1; + privatekey2.len = sizePrivatekey2; + + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray*)&pubKey1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray*)&pubKey2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + + SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray*)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray*)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c new file mode 100644 index 0000000000..56a61280db --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c @@ -0,0 +1,143 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define AX "0EAEBCD1DF2DF853D66CE0E1B0FDA07F67D1CABEFDE98514AAD795B86A6EA66D" +#define AY "BEB26B67D7A00E2447BAECCC8A4CEF7CD3CAD67376AC1C5785AEEBB4F6441C16" +#define AZ "0000000000000000000000000000000000000000000000000000000000000001" + +#define EX "EB6752420B6BDB40A760AC26ADD7E7BBD080BF1DF6C0B009A0D310E4511BDF49" +#define EY "8E8CEB84E1502FC536FFE67967BC44314270A0B38C79865FFED5A85D138DCA6B" +#define EZ "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" + +#define U1 "B618EBA71EC03638693405C75FC1C9ABB1A74471BAAF1A3A8B9005821491C4B4" +#define U2 "8554470195DE4678B06EDE9F9286545B51FF2D9AA756CE35A39011783563EA60" + +#define NONCE "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E" + +#define E2X "02D1BF36D37ACD68E4DD00DB3A707FD176A37E42F81AEF9386924032D3428FF0" +#define E2Y "FD52E285D33EC835230EA69F89D9C38673BD5B995716A4063C893AF02F938454" +#define E2Z "4C6ACE7C8C062A1E046F66FD8E3981DC4E8E844ED856B5415C62047129268C1B" + +TestSuite(cipher_secp256k1_xyz, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_xyz, TestXYZECMult){ + + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number u1, u2, nonce; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&u1, 0, sizeof(Number)); + memset(&u2, 0, sizeof(Number)); + memset(&nonce, 0, sizeof(Number)); + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + GoString strU1 = {U1, strlen(U1)}; + GoString strU2 = {U2, strlen(U2)}; + + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Number_SetHex(&u1, strU1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + error_code = SKY_secp256k1go_Number_SetHex(&u2, strU2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, &u2, &u1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); +} + +Test(cipher_secp256k1_xyz, TestXYZECMultGen){ + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number u1, u2, nonce; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&u1, 0, sizeof(Number)); + memset(&u2, 0, sizeof(Number)); + memset(&nonce, 0, sizeof(Number)); + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strNonce = {NONCE, strlen(NONCE)}; + GoString strEx = {E2X, strlen(E2X)}; + GoString strEy = {E2Y, strlen(E2Y)}; + GoString strEz = {E2Z, strlen(E2Z)}; + + error_code = SKY_secp256k1go_Number_SetHex(&nonce, strNonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + + error_code = SKY_secp256k1go_ECmultGen(&pr, &nonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Y, &y, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Y is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Z, &z, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); +} + diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c new file mode 100644 index 0000000000..e271c36c42 --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c @@ -0,0 +1,41 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define INHEX "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" +#define EXPHEX "7F586430EA30F914965770F6098E492699C62EE1DF6CAFFA77681C179FDF3117" + +TestSuite(cipher_secp256k1_field, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_field, TestFieldInv){ + secp256k1go__Field in; + secp256k1go__Field out; + secp256k1go__Field expected; + + memset(&in, 0, sizeof(secp256k1go__Field)); + memset(&out, 0, sizeof(secp256k1go__Field)); + memset(&expected, 0, sizeof(secp256k1go__Field)); + + GoUint32 error_code; + GoInt8 equal = 0; + + GoString InStr = {INHEX, strlen(INHEX)}; + GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; + error_code = SKY_secp256k1go_Field_SetHex(&in, InStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected, ExpStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_Inv(&in, &out); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Inv failed"); + error_code = SKY_secp256k1go_Field_Equals(&out, &expected, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Field_Inv failed, result is different than expected."); +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c new file mode 100644 index 0000000000..cba38ac40a --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -0,0 +1,101 @@ + +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "skynumber.h" + +#define BUFFER_SIZE 1024 + +#define R1 "6028b9e3a31c9e725fcbd7d5d16736aaaafcc9bf157dfb4be62bcbcf0969d488" +#define S1 "036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a" +#define MSG1 "9cff3da1a4f86caf3683f865232c64992b5ed002af42b321b8d8a48420680487" +#define X1 "56dc5df245955302893d8dda0677cc9865d8011bc678c7803a18b5f6faafec08" +#define Y1 "54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6" + +#define R2 "b470e02f834a3aaafa27bd2b49e07269e962a51410f364e9e195c31351a05e50" +#define S2 "560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09" +#define MSG2 "9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6" +#define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" +#define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" + +TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); + +Test(cipher_secp256k1_sig, TestSigRecover){ + GoUint32 error_code; + Signature sig; + Number msg; + secp256k1go__XY pubKey; + secp256k1go__XY expected; + + memset(&pubKey, 0, sizeof(secp256k1go__XY)); + memset(&expected, 0, sizeof(secp256k1go__XY)); + memset(&sig, 0, sizeof(Signature)); + memset(&msg, 0, sizeof(Number)); + + GoString R = {R1, strlen(R1)}; + GoString S = {S1, strlen(S1)}; + GoString MSG = {MSG1, strlen(MSG1)}; + GoString X = {X1, strlen(X1)}; + GoString Y = {Y1, strlen(Y1)}; + GoInt rid = 0; + GoInt8 result; + + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); + + R.p = R2; + R.n = strlen(R2); + S.p = S2; + S.n = strlen(S2); + MSG.p = MSG2; + MSG.n = strlen(MSG2); + X.p = X2; + X.n = strlen(X2); + Y.p = Y2; + Y.n = strlen(Y2); + rid = 1; + + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + GoInt8 equal; + error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); + SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c new file mode 100644 index 0000000000..31637a6da5 --- /dev/null +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c @@ -0,0 +1,63 @@ +#include +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "base64.h" + +#define AX "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" +#define AY "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" +#define AZ "01" +#define EX "7D152C041EA8E1DC2191843D1FA9DB55B68F88FEF695E2C791D40444B365AFC2" +#define EY "56915849F52CC8F76F5FD7E4BF60DB4A43BF633E1B1383F85FE89164BFADCBDB" +#define EZ "9075B4EE4D4788CABB49F7F81C221151FA2F68914D0AA833388FA11FF621A970" + + + +Test(cipher_secp256k1_xyz, TestXYZDouble){ + GoInt32 error_code; + secp256k1go__XYZ a; //sample data + secp256k1go__XYZ r; //result of double + secp256k1go__XYZ e; //expected + + memset(&a, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&r, 0, sizeof(secp256k1go__XYZ)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + error_code = SKY_secp256k1go_Field_SetHex(&a.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_Double(&a, &r); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); +} + From 8cdb29635470a3021850aa58d06643e874d53813 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 16:57:33 +0000 Subject: [PATCH 027/399] [libc] refs #1191. Commented incomplete libc test in lib/cgo/tests/check_cipher.crypto.c. [====] Synthesis: Tested: 120 | Passing: 120 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.crypto.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 97d1735b2e..f0b394fa52 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -158,7 +158,9 @@ Test(cipher_crypto, TestPubKeyVerifyDefault2) { } } -Test(cipher_crypto, TestPubKeyToAddressHash) { + +//TODO: Must complete this test +/*Test(cipher_crypto, TestPubKeyToAddressHash) { cipher__PubKey p; cipher__SecKey s; cipher__Ripemd160 h; @@ -175,7 +177,7 @@ Test(cipher_crypto, TestPubKeyToAddressHash) { // assert.True(t, bytes.Equal(h[:], y)) // // -} +}*/ Test(cipher_crypto, TestPubKeyToAddress) { cipher__PubKey p; @@ -732,4 +734,3 @@ Test(cipher_crypto, TestSecKeyHashTest) { errcode = SKY_cipher_TestSecKeyHash(&sk, &h); cr_assert(errcode == SKY_ERROR); } - From 638493a5ca48c30eb1e3bb53760bfa3ea9bd1932 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 17:04:04 +0000 Subject: [PATCH 028/399] [libc] refs #1191. Add comment explaining why TestTransactionsTruncateBytesTo test was not done. [====] Synthesis: Tested: 120 | Passing: 120 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.transaction2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index 408906df4b..0d095c44dc 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -328,8 +328,9 @@ Test(coin_transactions, TestTransactionsTruncateBytesTo){ } /**************************** -* Test crashing randomly. -* TODO: check why this tests is crashing +* This test crashes. +* Original functio returns a Transaction oject. +* Wrapper function must be modified to use a handle instead of object. ***************************/ /*Test(coin_transactions, TestTransactionsTruncateBytesTo){ int result; From a56de76a95253b84780b50a15a164058c93556fb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 9 Jun 2018 21:36:36 +0000 Subject: [PATCH 029/399] [libc] refs #1191. Added latest tests for coin. [====] Synthesis: Tested: 125 | Passing: 125 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 4 + lib/cgo/tests/check_coin.transaction2.c | 7 +- lib/cgo/tests/check_coin.transactions.c | 448 ++++++++++----------- lib/cgo/tests/testutils/libsky_criterion.c | 21 + lib/cgo/tests/testutils/transutils.c | 3 - 5 files changed, 231 insertions(+), 252 deletions(-) diff --git a/include/skycriterion.h b/include/skycriterion.h index c5a3c8ce1b..de2608d925 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -51,4 +51,8 @@ extern int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction extern int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2); extern char* cr_user_coin__Transaction_tostr(coin__Transaction *x1); +extern int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); +extern int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); +extern char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1); + #endif //LIBCRITERION_H diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index 0d095c44dc..99bbd527e9 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -223,14 +223,15 @@ Test(coin_transactions, TestTransactionHashInner){ cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); + //TODO: Fix Out is slice of TransactionOutput // If tx.Out is changed, hash should change copyTransaction( &tx, &tx2 ); - cipher__Address* paddr = tx2.Out.data; + coin__TransactionOutput* output = tx2.Out.data; cipher__Address addr; makeAddress( &addr ); - memcpy(paddr, &addr, sizeof(cipher__Address)); + memcpy( &output->Address, &addr, sizeof(cipher__Address) ); cr_assert( not( eq( type(coin__Transaction), tx, tx2 ) ) ); - cr_assert(eq(type(cipher__Address), addr, *paddr)); + cr_assert(eq(type(cipher__Address), addr, output->Address)); result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); cr_assert( result == SKY_OK ); result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index b642c87b6e..a358da4654 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -9,259 +9,227 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" +#include "skycriterion.h" +#include "transutil.h" Test(coin_transaction, TestTransactionVerify) { - char bufferSHA[1024]; - char bufferSHA_[1024]; - int error; + int result; + coin__Transaction tx; // Mismatch header hash - coin__Transaction tx; - coin__TransactionOutput* to_void; makeTransaction(&tx); memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); - GoUint32 errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Invalid header hash"); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); // No inputs - errcode = makeTransaction(&tx); - cr_assert(errcode == SKY_OK); - memset(&tx.In, 0, sizeof(GoSlice)); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - cr_assert(errcode == SKY_OK); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "No inputs"); + makeTransaction(&tx); + tx.In.len = 0; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); // No outputs - errcode = makeTransaction(&tx); - cr_assert(errcode == SKY_OK); - memset(&tx.Out, 0, sizeof(GoSlice)); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - cr_assert(errcode == SKY_OK); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "No outputs"); - - // Invalid number of sigs - errcode = makeTransaction(&tx); - cr_assert(errcode == SKY_OK); - memset(&tx.Sigs, 0, sizeof(cipher__Sig)); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Invalid number of signatures"); - - errcode = makeTransaction(&tx); - cr_assert(errcode == SKY_OK); - GoSlice slice = { NULL, 20, 20 }; - memset(&tx.Sigs, 0, sizeof(slice)); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Invalid number of signatures"); + makeTransaction(&tx); + tx.Out.len = 0; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); - errcode = makeTransaction(&tx); - cr_assert(errcode == SKY_OK); - GoSlice slice_sigs = { NULL, 32768, 32768 }; - GoSlice slice_in = { NULL, 32768, 32768 }; - memset(&tx.Sigs, 0, sizeof(slice_sigs)); - memset(&tx.In, 0, sizeof(slice_in)); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Too many signatures and inputs"); + //Invalid number of Sigs + makeTransaction(&tx); + tx.Sigs.len = 0; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + tx.Sigs.data = malloc(20 * sizeof(cipher__Sig)); + cr_assert( tx.Sigs.data != NULL ); + registerMemCleanup( tx.Sigs.data ); + memset( tx.Sigs.data, 0, 20 * sizeof(cipher__Sig) ); + tx.Sigs.len = 20; tx.Sigs.cap = 20; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + + int MaxUint16 = 0xFFFF; + // Too many sigs & inputs + makeTransaction(&tx); + tx.Sigs.data = malloc(MaxUint16 * sizeof(cipher__Sig)); + cr_assert( tx.Sigs.data != NULL ); + registerMemCleanup( tx.Sigs.data ); + memset(tx.Sigs.data, 0, MaxUint16 * sizeof(cipher__Sig)); + tx.Sigs.len = tx.Sigs.cap = MaxUint16; + tx.In.data = malloc( MaxUint16 * sizeof(cipher__SHA256) ); + cr_assert( tx.In.data != NULL ); + registerMemCleanup( tx.In.data ); + tx.In.len = tx.In.cap = MaxUint16; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + + freeRegisteredMemCleanup(tx.Sigs.data); //Too much memory (~8MB) free ASAP + freeRegisteredMemCleanup(tx.In.data); // Duplicate inputs - coin__UxOut* ux; - cipher__SecKey* s; - errcode = makeUxOutWithSecret(&ux, &s); - cr_assert(errcode == SKY_OK); - makeTransactionFromUxOut(&ux, &s, &tx); + coin__UxOut ux; + cipher__SecKey seckey; cipher__SHA256 sha256; - SKY_coin_Transaction_Hash(&tx, &sha256); - SKY_coin_Transaction_PushInput(&tx, &sha256, 0); - tx.Sigs.data = NULL; - GoSlice slice_duplicate; - copySlice(((GoSlice*)&slice_duplicate.data), - (GoSlice*)&tx.In.data, - sizeof(cipher__SecKey)); - SKY_coin_Transaction_SignInputs(&tx, slice_duplicate); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Duplicate spend"); - - // Duplicate outputs + makeUxOutWithSecret( &ux, &seckey ); + makeTransactionFromUxOut( &ux, &seckey, &tx ); + memcpy(&sha256, tx.In.data, sizeof(cipher__SHA256)); + GoUint16 r; + result = SKY_coin_Transaction_PushInput(&tx, &sha256, &r); + tx.Sigs.len = 0; + GoSlice seckeys; + seckeys.data = malloc(sizeof(cipher__SecKey) * 2); + cr_assert( seckeys.data != NULL ); + registerMemCleanup( seckeys.data ); + seckeys.len = seckeys.cap = 2; + memcpy( seckeys.data, &seckey, sizeof(cipher__SecKey) ); + memcpy( ((cipher__SecKey*)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey) ); + result = SKY_coin_Transaction_SignInputs( &tx, seckeys ); + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + + //Duplicate outputs makeTransaction(&tx); - coin__TransactionOutput to; - to = (*(coin__TransactionOutput*)&tx.Out); - errcode = SKY_coin_Transaction_PushOutput( - &to, ((cipher__Address*)&to.Address), to.Coins, to.Hours); - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Duplicate output in transaction"); + coin__TransactionOutput* pOutput = tx.Out.data; + cipher__Address addr; + memcpy(&addr, &pOutput->Address, sizeof(cipher__Address)); + result = SKY_coin_Transaction_PushOutput(&tx, &addr, pOutput->Coins, pOutput->Hours); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); // Invalid signature, empty makeTransaction(&tx); - memset(&tx.Sigs, 0, sizeof(cipher__Sig)); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Duplicate spend"); + memset(tx.Sigs.data, 0, sizeof(cipher__Sig)); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); // Output coins are 0 - makeTransaction(&tx); - memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); - to_void = ((coin__TransactionOutput*)&tx.Out); - to_void->Coins = 0; - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Zero coin output"); - + pOutput = tx.Out.data; + pOutput->Coins = 0; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow makeTransaction(&tx); - memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); - to_void = ((coin__TransactionOutput*)&tx.Out); - to_void->Coins = 9223372036851775808; - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK, "Output coins overflow"); - - // Output coins are not multiples of 1e6 (valid, decimal restriction is not - // enforced here) - - memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + pOutput = tx.Out.data; + pOutput->Coins = MaxUint64 - 3000000; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result != SKY_OK ); + + // Output coins are not multiples of 1e6 (valid, decimal restriction is not enforced here) makeTransaction(&tx); - to = (*(coin__TransactionOutput*)&tx.Out); - to.Coins += 10; - tx.Sigs.data = NULL; - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - SKY_coin_Transaction_PushInput(&tx, &sha256, 0); - GoSlice slice_decimal; - memset(&slice_decimal.data, 0, sizeof(cipher__SecKey)); - SKY_coin_Transaction_SignInputs(&tx, slice_decimal); - cr_assert(0 != (to.Coins % ((GoUint64_)1.000000e+006))); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode != SKY_OK); - - // Valid - memset(&tx.Out, 0, sizeof(coin__TransactionOutput)); + pOutput = tx.Out.data; + pOutput->Coins += 10; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + tx.Sigs.data = NULL; tx.Sigs.len = 0; tx.Sigs.cap = 0; + cipher__PubKey pubkey; + result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); + cr_assert( result == SKY_OK ); + seckeys.data = &seckey; seckeys.len = 1; seckeys.cap = 1; + result = SKY_coin_Transaction_SignInputs(&tx, seckeys); + cr_assert( result == SKY_OK ); + cr_assert( pOutput->Coins % 1000000 != 0 ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result == SKY_OK ); + + //Valid makeTransaction(&tx); - to_void = ((coin__TransactionOutput*)&tx.Out); - to_void->Coins = 1.000000e+007; - to_void++; - to_void->Coins = 1.000000e+006; - errcode = SKY_coin_Transaction_UpdateHeader(&tx); - errcode = SKY_coin_Transaction_Verify(&tx); - cr_assert(errcode == SKY_OK); + pOutput = tx.Out.data; + pOutput->Coins = 10000000; + pOutput++; + pOutput->Coins = 1000000; + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(&tx); + cr_assert( result == SKY_OK ); } -// Test(coin_transaction, TestTransactionVerifyInput) -// { -// coin__Transaction tx; -// GoUint64_ errcode; -// coin__UxArray uxArray; - -// // Invalid uxIn args -// makeTransaction(&tx); -// cli__PasswordFromBytes seckey; -// SKY_coin_UxArray_Coins(&seckey, NULL); -// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); -// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); -// SKY_coin_UxArray_Coins(&seckey, 0); -// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); -// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); -// SKY_coin_UxArray_Coins(&seckey, 3); -// errcode = SKY_coin_Transaction_VerifyInput(&tx, &seckey); -// cr_assert(errcode != SKY_OK, "tx.In != uxIn"); - -// // // tx.In != tx.Sigs -// // ux, s := makeUxOutWithSecret(t) -// // tx = makeTransactionFromUxOut(ux, s) -// // tx.Sigs = []cipher.Sig{} -// // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { -// // tx.VerifyInput(UxArray{ux}) -// // }) - -// // ux, s = makeUxOutWithSecret(t) -// // tx = makeTransactionFromUxOut(ux, s) -// // tx.Sigs = append(tx.Sigs, cipher.Sig{}) -// // _require.PanicsWithLogMessage(t, "tx.In != tx.Sigs", func() { -// // tx.VerifyInput(UxArray{ux}) -// // }) - -// // tx.InnerHash != tx.HashInner() -// coin__UxOut ux; -// cipher__SecKey s; -// errcode = makeUxOutWithSecret(&ux, &s); -// cr_assert(errcode == SKY_OK); -// errcode = makeTransactionFromUxOut(&ux, &s, &tx); -// cr_assert(errcode == SKY_OK); -// memset(&tx.Sigs, 0, sizeof(cipher__Sig)); -// memset(&uxArray, 0, sizeof(coin__UxArray)); -// uxArray.data = &ux; -// SKY_coin_UxArray_Coins(&uxArray, 1); -// errcode = SKY_coin_Transaction_VerifyInput(&tx, &uxArray); -// cr_assert(errcode != SKY_OK, "tx.In != tx.Sigs"); - -// errcode = makeUxOutWithSecret(&ux, &s); -// cr_assert(errcode == SKY_OK); -// errcode = makeTransactionFromUxOut(&ux, &s, &tx); -// cr_assert(errcode == SKY_OK); - -// // coin__UxOut uxo; -// // coin__UxArray uxa; -// // uxa.data = uxo.; -// } Test(coin_transaction, TestTransactionPushInput) { + int result; coin__Transaction tx; - memset(&tx, 0, sizeof(coin__Transaction)); coin__UxOut ux; - memset(&ux, 0, sizeof(coin__UxOut)); - GoUint64_ errcode = makeUxOut(&ux); - GoUint16 value; - SKY_coin_Transaction_PushInput(&tx, &ux, &value); - cr_assert(value == 0); - cr_assert(tx.In.len == 1); - errcode = memcmp(((cipher__SHA256*)&tx.In.data), &ux, sizeof(cipher__SHA256)); - cr_assert(errcode > 0); - - cipher__SHA256* cipher; - - cipher = ((cipher__SHA256*)&tx.In.data); - makeRandHash(&cipher); - for (int i = 0; i < (1 << 16 - 1); ++i) { - cipher++; - makeRandHash(&cipher); - } - errcode = makeUxOut(&ux); - errcode = SKY_coin_Transaction_PushInput(&tx, &ux, &value); - - cr_assert(errcode == SKY_OK); + memset( &tx, 0, sizeof(coin__Transaction) ); + makeUxOut( &ux ); + cipher__SHA256 hash; + result = SKY_coin_UxOut_Hash( &ux, &hash ); + cr_assert( result == SKY_OK ); + GoUint16 r; + result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + cr_assert( result == SKY_OK ); + cr_assert( r == 0 ); + cr_assert( tx.In.len == 1 ); + cipher__SHA256* pIn = tx.In.data; + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *pIn) ); + + GoUint16 MaxUint16 = 0xFFFF; + void* data = malloc( (tx.In.len + MaxUint16) * sizeof(cipher__SHA256) ); + cr_assert( data != NULL ); + registerMemCleanup( data ); + memset( data, 0, (tx.In.len + MaxUint16) * sizeof(cipher__SHA256) ); + memcpy( data, tx.In.data, (tx.In.len) * sizeof(cipher__SHA256) ); + tx.In.len += MaxUint16; + tx.In.cap = tx.In.len; + tx.In.data = data; + makeUxOut( &ux ); + result = SKY_coin_UxOut_Hash( &ux, &hash ); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + cr_assert( result != SKY_OK ); + + freeRegisteredMemCleanup( data ); } + Test(coin_transaction, TestTransactionPushOutput) { + int result; coin__Transaction tx; - cipher__Address a; - GoUint32 errcode = makeAddress(a); - cr_assert(errcode == SKY_OK); - memset(&tx, 0, sizeof(tx)); - errcode = SKY_coin_Transaction_PushOutput(&tx, &a, 100, 500); - cr_assert(tx.Out.len == 1); - coin__TransactionOutput value = { a, 100, 150 }; - GoSlice_ slice = { &value, 1, 1 }; - cr_assert(eq(type(GoSlice_), slice, tx.Out)); - - memset(&tx, 0, sizeof(coin__Transaction)); - coin__TransactionOutput* slice_void = - ((coin__TransactionOutput*)&tx.Out.data); - for (int i = 0; i < 20; i++) { - cipher__Address address; - errcode = makeAddress(&address); - cr_assert(errcode == SKY_OK); - GoUint16 coins = ((GoUint16)(i * 100)); - GoUint16 hours = ((GoUint16)(i * 50)); - errcode = SKY_coin_Transaction_PushOutput(&tx, &address, coins, hours); - cr_assert(tx.Out.len == (i + 1)); - // slice_void++; + cipher__Address addr; + memset( &tx, 0, sizeof(coin__Transaction) ); + makeAddress( &addr ); + result = SKY_coin_Transaction_PushOutput( &tx, &addr, 100, 150 ); + cr_assert( result == SKY_OK ); + cr_assert( tx.Out.len == 1 ); + coin__TransactionOutput* pOutput = tx.Out.data; + coin__TransactionOutput output; + memcpy(&output.Address, &addr, sizeof(cipher__Address)); + output.Coins = 100; + output.Hours = 150; + cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); + for(int i = 1; i < 20; i++){ + makeAddress( &addr ); + result = SKY_coin_Transaction_PushOutput( &tx, &addr, i * 100, i * 50 ); + cr_assert( result == SKY_OK ); + cr_assert( tx.Out.len == i + 1 ); + pOutput = tx.Out.data; + pOutput += i; + memcpy(&output.Address, &addr, sizeof(cipher__Address)); + output.Coins = i * 100; + output.Hours = i * 50; + cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); } } @@ -269,44 +237,32 @@ Test(coin_transaction, TestTransactionPushOutput) Test(coin_transaction, TestTransactionHash) { + int result; coin__Transaction tx; - cleanupMem(&tx); makeTransaction(&tx); - cipher__SHA256 sha; - cipher__SHA256 shatmp; - cipher__SHA256 shainner; - memset(&sha, 0, sizeof(cipher__SHA256)); - memset(&shatmp, 0, sizeof(cipher__SHA256)); - memset(&shainner, 0, sizeof(cipher__SHA256)); - SKY_coin_Transaction_Hash(&tx, &shatmp); - SKY_coin_Transaction_HashInner(&tx, &shainner); - - cr_assert(not(eq(u8[sizeof(cipher__SHA256)], sha, shatmp))); - - cr_assert(not(eq(u8[sizeof(cipher__SHA256)], sha, shainner))); + cipher__SHA256 nullHash, hash1, hash2; + memset( &nullHash, 0, sizeof(cipher__SHA256) ); + result = SKY_coin_Transaction_Hash( &tx, &hash1 ); + cr_assert( result == SKY_OK ); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash1) ) ); + result = SKY_coin_Transaction_HashInner( &tx, &hash2 ); + cr_assert( result == SKY_OK ); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash2, hash1) ) ); } Test(coin_transaction, TestTransactionUpdateHeader) { + int result; coin__Transaction tx; - cleanupMem(&tx); makeTransaction(&tx); - cipher__SHA256 h; - cipher__SHA256 shatmp; - cipher__SHA256 sha_clean; - cipher__SHA256 shainner; - memset(&h, 0, sizeof(cipher__SHA256)); - memset(&sha_clean, 0, sizeof(cipher__SHA256)); - - SKY_coin_Transaction_HashInner(&tx, &shainner); - // - memcpy(&h, &tx.InnerHash, sizeof(cipher__SHA256)); + cipher__SHA256 hash, nullHash, hashInner; + memcpy(&hash, &tx.InnerHash, sizeof(cipher__SHA256)); memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); - - SKY_coin_Transaction_UpdateHeader(&tx); - SKY_coin_Transaction_HashInner(&tx, &shatmp); - - cr_assert(not(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, sha_clean))); - cr_assert(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, h)); - cr_assert(eq(u8[sizeof(cipher__SHA256)], tx.InnerHash, shainner)); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + result = SKY_coin_Transaction_UpdateHeader(&tx); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], tx.InnerHash, nullHash) ) ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, tx.InnerHash) ); + result = SKY_coin_Transaction_HashInner( &tx, &hashInner ); + cr_assert( result == SKY_OK ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, tx.InnerHash) ); } diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index c2ba31158c..0f3c2f32d5 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -201,3 +201,24 @@ char* cr_user_coin__Transaction_tostr(coin__Transaction *x1){ cr_asprintf(&out, "(coin__Transaction) { Length : %d }", x1->Length); return out; } + +int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2){ + if( x1->Coins != x2->Coins || + x1->Hours != x2->Hours ){ + return 0; + } + + if(!cr_user_cipher__Address_eq(&x1->Address, &x2->Address)) + return 0; + return 1; +} + +int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2){ + return !cr_user_coin__TransactionOutput_eq(x1, x2); +} + +char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1){ + char *out; + cr_asprintf(&out, "(coin__TransactionOutput) { Coins : %d, Hours: %d, Address: %s }", x1->Coins, x1->Hours, x1->Address); + return out; +} diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 9261d949f9..857104ebc1 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -29,9 +29,6 @@ int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey){ puxBody->Coins = 1000000; puxBody->Hours = 100; - puxBody->Coins = 1000000; - puxBody->Hours = 100; - result = SKY_cipher_GenerateKeyPair(&pubkey, pseckey); cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); From 34ce0d8433ac6c52d2c8204093c1fa4954c820dd Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 13:41:33 +0000 Subject: [PATCH 030/399] [libc] refs #1191. Removed commented code. [====] Synthesis: Tested: 125 | Passing: 125 | Failing: 0 | Crashing: 0. --- .../tests/check_cipher.encrypt.sha256xor.c | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 3359696175..643fb904d9 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -55,7 +55,7 @@ int putVarint(GoSlice* buf , GoInt64 x){ return putUvarint(buf, ux); } -void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, +void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ GoUint32 errcode; int length = 32 + sizeof(cipher__SHA256); @@ -77,7 +77,7 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA GoUint32 n = fullLength / SHA256XORBLOCKSIZE; GoUint32 m = fullLength % SHA256XORBLOCKSIZE; GoUint32 errcode; - + if( m > 0 ){ fullLength += SHA256XORBLOCKSIZE - m; } @@ -91,18 +91,15 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; } //Add the data - memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, + memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, data.data, dataLength); - /*for(int i = 0; i < dataLength; i++){ - buffer[i + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE] = ((char*)data.data)[i]; - }*/ //Add padding for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ buffer[i] = 0; } //Buffer with space for the checksum, then data length, then data, and then padding - GoSlice _data = {buffer + SHA256XORBLOCKSIZE, - fullLength - SHA256XORBLOCKSIZE, + GoSlice _data = {buffer + SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE, fullLength - SHA256XORBLOCKSIZE}; //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); @@ -118,8 +115,8 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); cipher__SHA256 h; - - + + int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; unsigned char* dest_buffer = malloc(fullDestLength); @@ -133,8 +130,8 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA // Prefix the nonce memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); // Calculates the checksum - GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), - fullLength + SHA256XORNONCESIZE, + GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), + fullLength + SHA256XORNONCESIZE, fullLength + SHA256XORNONCESIZE }; cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; @@ -156,7 +153,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; GoSlice nullPwd = {NULL, 0, 0}; GoUint32 errcode; - + TEST_DATA test_data[] = { {1, &nullPwd, &nullPwd, 0, 0}, {1, &pwd2, &nullPwd, 1, 0}, @@ -165,9 +162,9 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ {64, &pwd3, &nullPwd, 1, 0}, {65, &pwd3, &nullPwd, 1, 0}, }; - + encrypt__Sha256Xor encryptSettings = {}; - + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ randBytes(&data, test_data[i].dataLength); errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, *(test_data[i].pwd), &encrypted); @@ -180,18 +177,18 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); ((char*)encrypted.data)[encrypted.len] = 0; - + int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; if ( m > 0 ) { n++; } - - int decode_length = b64_decode((const unsigned char*)encrypted.data, + + int decode_length = b64_decode((const unsigned char*)encrypted.data, encrypted.len, encryptedText); cr_assert(decode_length >= 0, "base64_decode_string failed."); int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); cipher__SHA256 enc_hash; @@ -212,7 +209,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); } } - + for(int i = 33; i <= 64; i++){ randBytes(&data, i); errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd1, &encrypted); @@ -220,18 +217,18 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); ((char*)encrypted.data)[encrypted.len] = 0; - + int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; if ( m > 0 ) { n++; } - - int decode_length = b64_decode((const unsigned char*)encrypted.data, + + int decode_length = b64_decode((const unsigned char*)encrypted.data, encrypted.len, encryptedText); cr_assert( decode_length >= 0, "base64_decode failed" ); int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); cipher__SHA256 enc_hash; @@ -250,7 +247,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ } } cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); - + } } @@ -266,7 +263,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ GoSlice emptyPwd = {"", 1, 1}; GoSlice nullPwd = {NULL, 0, 0}; GoUint32 errcode; - + TEST_DATA test_data[] = { {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum {32, &pwd, &emptyPwd, 0, 0}, //Empty password @@ -282,7 +279,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ if( test_data[i].tampered ){ ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; } - errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, *(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); @@ -290,13 +287,13 @@ Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); } } - + for(int i = 0; i <= 64; i++){ randBytes(&data, i); //makeEncryptedData(data, i, pwd, &encrypted); SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, + errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, *(GoSlice*)&encrypted, pwd, &decrypted); cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); @@ -308,4 +305,3 @@ Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); } } - From c805cc60aaa6077ab933a213a7e3ec7335de4ebd Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 17:01:01 +0000 Subject: [PATCH 031/399] [libc] refs #1191. Use handle for coin.transaction object. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 7 +- include/transutil.h | 9 +- lib/cgo/coin.transactions.go | 80 +++++++++ lib/cgo/libsky_handle.go | 15 ++ lib/cgo/tests/check_coin.transaction2.c | 200 +++++++++++----------- lib/cgo/tests/check_coin.transactions.c | 213 ++++++++++++------------ lib/cgo/tests/testutils/transutils.c | 69 +++++--- 7 files changed, 353 insertions(+), 240 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 0929bd8455..27a7491410 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -244,6 +244,12 @@ typedef Handle Options__Handle; * Memory handle to access to Skycoin CLI configuration */ typedef Handle Config__Handle; +/** + * Memory handle to access to coin.Transaction + */ +typedef Handle Transaction__Handle; + + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" @@ -255,4 +261,3 @@ typedef Handle Config__Handle; #include "wallet.wallet.go.h" */ #endif - diff --git a/include/transutil.h b/include/transutil.h index 4744968851..e23bf8e3c8 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -22,14 +22,15 @@ int makeUxOut(coin__UxOut* puxOut); int makeAddress(cipher__Address* paddress); -int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, - coin__Transaction* ptransaction); +coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey); -int makeTransaction(coin__Transaction* ptransaction); +coin__Transaction* makeTransaction(); + +coin__Transaction* makeEmptyTransaction(); int makeTransactions(GoSlice* transactions, int n); -void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2); +coin__Transaction* copyTransaction(coin__Transaction* pt1); void makeRandHash(cipher__SHA256* phash); diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index cf253f4c29..4925de50b4 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -17,6 +17,86 @@ import ( */ import "C" +//export SKY_coin_Create_Transaction +func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + tx := coin.Transaction{} + *handle = registerTransactionHandle(&tx) + return +} + +//export SKY_coin_Transaction_Copy +func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + ntx := coin.Transaction{} + ntx.Length = tx.Length + ntx.Type = tx.Type + ntx.InnerHash = tx.InnerHash + ntx.Sigs = make([]cipher.Sig, 0) + ntx.Sigs = append( ntx.Sigs, tx.Sigs... ) + ntx.In = make([]cipher.SHA256, 0) + ntx.In = append( ntx.In, tx.In... ) + ntx.Out = make([]coin.TransactionOutput, 0) + ntx.Out = append( ntx.Out, tx.Out... ) + *handle = registerTransactionHandle(&ntx) + return +} + +//export SKY_coin_Get_Transaction_Object +func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + ptx, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + } else { + *_pptx = (*C.coin__Transaction)(unsafe.Pointer(ptx)) + } + return +} + +//export SKY_coin_Transaction_ResetInputs +func SKY_coin_Transaction_ResetInputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn.In = make([]cipher.SHA256, count) + return +} + +//export SKY_coin_Transaction_ResetOutputs +func SKY_coin_Transaction_ResetOutputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn.Out = make([]coin.TransactionOutput, count) + return +} + +//export SKY_coin_Transaction_ResetSignatures +func SKY_coin_Transaction_ResetSignatures(_txn *C.coin__Transaction, count int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn.Sigs = make([]cipher.Sig, count) + return +} + //export SKY_coin_Transaction_Verify func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint32) { ____error_code = 0 diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 05b67a94a3..62a4990891 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -16,6 +16,7 @@ import ( cli "github.com/skycoin/skycoin/src/cli" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" + "github.com/skycoin/skycoin/src/coin" ) type Handle uint64 @@ -220,6 +221,20 @@ func lookupPasswordReaderHandle(handle C.PasswordReader__Handle) (*cli.PasswordR return nil, false } +func registerTransactionHandle(obj *coin.Transaction) C.Transaction__Handle { + return (C.Transaction__Handle)(registerHandle(obj)) +} + +func lookupTransactionHandle(handle C.Transaction__Handle) (*coin.Transaction, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Transaction); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index 99bbd527e9..9205bed5d6 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -15,13 +15,13 @@ TestSuite(coin_transactions, .init = setup, .fini = teardown); Test(coin_transactions, TestTransactionVerifyInput){ int result; - coin__Transaction tx; - makeTransaction( &tx ); - result = SKY_coin_Transaction_VerifyInput(&tx, NULL); + coin__Transaction* ptx; + ptx = makeTransaction(); + result = SKY_coin_Transaction_VerifyInput(ptx, NULL); cr_assert( result != SKY_OK ); coin__UxArray ux; memset(&ux, 0, sizeof(coin__UxArray)); - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); memset(&ux, 0, sizeof(coin__UxArray)); ux.data = malloc(3 * sizeof(coin__UxOut)); @@ -30,7 +30,7 @@ Test(coin_transactions, TestTransactionVerifyInput){ ux.len = 3; ux.cap = 3; memset(ux.data, 0, 3 * sizeof(coin__UxOut)); - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); coin__UxOut uxOut; @@ -40,77 +40,77 @@ Test(coin_transactions, TestTransactionVerifyInput){ result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_ResetSignatures(ptx, 0); cr_assert( result == SKY_OK ); - tx.Sigs.data = NULL; tx.Sigs.len = 0; tx.Sigs.cap = 0; ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); memset(&sig, 0, sizeof(cipher__Sig)); result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_ResetSignatures(ptx, 1); cr_assert( result == SKY_OK ); - tx.Sigs.data = &sig; tx.Sigs.len = 1; tx.Sigs.cap = 1; + memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); //Invalid Tx Inner Hash result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); cr_assert( result == SKY_OK ); - memset( tx.InnerHash, 0, sizeof(cipher__SHA256) ); + memset( ptx->InnerHash, 0, sizeof(cipher__SHA256) ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); //Ux hash mismatch result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); cr_assert( result == SKY_OK ); memset( &uxOut, 0, sizeof(coin__UxOut) ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); //Invalid signature result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); cr_assert( result == SKY_OK ); - if(tx.Sigs.len > 0){ - memset(&tx.Sigs.data, 0, sizeof(cipher__Sig)); - } else { - memset(&sig, 0, sizeof(cipher__Sig)); - tx.Sigs.data = &sig; tx.Sigs.len = 1; tx.Sigs.cap = 1; - } + result = SKY_coin_Transaction_ResetSignatures(ptx, 1); + cr_assert( result == SKY_OK ); + memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result != SKY_OK ); //Valid result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - result = makeTransactionFromUxOut(&uxOut, &seckey, &tx); + ptx = makeTransactionFromUxOut(&uxOut, &seckey); cr_assert( result == SKY_OK ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(&tx, &ux); + result = SKY_coin_Transaction_VerifyInput(ptx, &ux); cr_assert( result == SKY_OK ); } Test(coin_transactions, TestTransactionSignInputs){ int result; - coin__Transaction tx; + coin__Transaction* ptx; coin__UxOut ux, ux2; cipher__SecKey seckey, seckey2; cipher__SHA256 hash, hash2; @@ -120,46 +120,42 @@ Test(coin_transactions, TestTransactionSignInputs){ GoSlice keys; //Error if txns already signed - memset(&tx, 0, sizeof(coin__Transaction)); - tx.Sigs.data = malloc(sizeof(cipher__Sig)); - cr_assert( tx.Sigs.data != NULL ); - registerMemCleanup( tx.Sigs.data ); - memset( tx.Sigs.data, 0, sizeof(cipher__Sig) ); - tx.Sigs.len = 1; - tx.Sigs.cap = 1; + ptx = makeEmptyTransaction(); + result = SKY_coin_Transaction_ResetSignatures(ptx, 1); + cr_assert( result == SKY_OK ); memset( &seckey, 0, sizeof(cipher__SecKey) ); keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(&tx, keys); + result = SKY_coin_Transaction_SignInputs(ptx, keys); cr_assert( result != SKY_OK ); // Panics if not enough keys - memset(&tx, 0, sizeof(coin__Transaction)); + ptx = makeEmptyTransaction(); memset(&seckey, 0, sizeof(cipher__SecKey)); memset(&seckey2, 0, sizeof(cipher__SecKey)); result = makeUxOutWithSecret( &ux, &seckey ); cr_assert( result == SKY_OK ); result = SKY_coin_UxOut_Hash(&ux, &hash); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); cr_assert( result == SKY_OK ); result = makeUxOutWithSecret( &ux2, &seckey2 ); cr_assert( result == SKY_OK ); result = SKY_coin_UxOut_Hash(&ux2, &hash2); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(&tx, &hash2, &r); + result = SKY_coin_Transaction_PushInput(ptx, &hash2, &r); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 40, 80); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 40, 80); cr_assert( result == SKY_OK ); - cr_assert( tx.Sigs.len == 0 ); + cr_assert( ptx->Sigs.len == 0 ); keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(&tx, keys); + result = SKY_coin_Transaction_SignInputs(ptx, keys); cr_assert( result != SKY_OK ); - cr_assert( tx.Sigs.len == 0 ); + cr_assert( ptx->Sigs.len == 0 ); // Valid signing - result = SKY_coin_Transaction_HashInner( &tx, &hash ); + result = SKY_coin_Transaction_HashInner( ptx, &hash ); cr_assert( result == SKY_OK ); keys.data = malloc(2 * sizeof(cipher__SecKey)); cr_assert( keys.data != NULL ); @@ -167,10 +163,10 @@ Test(coin_transactions, TestTransactionSignInputs){ keys.len = keys.cap = 2; memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); memcpy(((cipher__SecKey*)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); - result = SKY_coin_Transaction_SignInputs(&tx, keys); + result = SKY_coin_Transaction_SignInputs(ptx, keys); cr_assert( result == SKY_OK ); - cr_assert(tx.Sigs.len == 2); - result = SKY_coin_Transaction_HashInner( &tx, &hash2 ); + cr_assert(ptx->Sigs.len == 2); + result = SKY_coin_Transaction_HashInner( ptx, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, hash2) ); @@ -184,119 +180,122 @@ Test(coin_transactions, TestTransactionSignInputs){ cr_assert( result == SKY_OK ); cipher__SHA256 addHash, addHash2; - result = SKY_cipher_AddSHA256(&hash, (cipher__SHA256*)tx.In.data, &addHash); + result = SKY_cipher_AddSHA256(&hash, (cipher__SHA256*)ptx->In.data, &addHash); cr_assert( result == SKY_OK ); - result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256*)tx.In.data) + 1, &addHash2); + result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256*)ptx->In.data) + 1, &addHash2); cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig*)tx.Sigs.data); + result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig*)ptx->Sigs.data); cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig*)tx.Sigs.data)+1); + result = SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig*)ptx->Sigs.data)+1); cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig*)tx.Sigs.data)+1); + result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig*)ptx->Sigs.data)+1); cr_assert( result != SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig*)tx.Sigs.data); + result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig*)ptx->Sigs.data); cr_assert( result != SKY_OK ); } Test(coin_transactions, TestTransactionHashInner){ int result; - coin__Transaction tx, tx2; - makeTransaction( &tx ); + coin__Transaction* ptx; + coin__Transaction* ptx2; + ptx = makeTransaction(); cipher__SHA256 hash, nullHash; - result = SKY_coin_Transaction_HashInner( &tx, &hash ); + result = SKY_coin_Transaction_HashInner( ptx, &hash ); cr_assert( result == SKY_OK ); memset( &nullHash, 0, sizeof(cipher__SHA256) ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); // If tx.In is changed, hash should change - copyTransaction( &tx, &tx2 ); + ptx2 = copyTransaction( ptx ); + cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); + cr_assert(ptx2->In.len > 0); coin__UxOut uxOut; makeUxOut( &uxOut ); - cipher__SHA256* phash = tx2.In.data; + cipher__SHA256* phash = ptx2->In.data; result = SKY_coin_UxOut_Hash( &uxOut, phash ); cr_assert( result == SKY_OK ); - cr_assert( not( eq( type(coin__Transaction), tx, tx2 ) ) ); + cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); cipher__SHA256 hash1, hash2; - result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); - //TODO: Fix Out is slice of TransactionOutput // If tx.Out is changed, hash should change - copyTransaction( &tx, &tx2 ); - coin__TransactionOutput* output = tx2.Out.data; + ptx2 = copyTransaction( ptx ); + coin__TransactionOutput* output = ptx2->Out.data; cipher__Address addr; makeAddress( &addr ); memcpy( &output->Address, &addr, sizeof(cipher__Address) ); - cr_assert( not( eq( type(coin__Transaction), tx, tx2 ) ) ); + cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); cr_assert(eq(type(cipher__Address), addr, output->Address)); - result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); // If tx.Head is changed, hash should not change - copyTransaction( &tx, &tx2 ); - cipher__Sig* newSigs = malloc((tx2.Sigs.len + 1) * sizeof(cipher__Sig)); + ptx2 = copyTransaction( ptx ); + int len = ptx2->Sigs.len; + cipher__Sig* newSigs = malloc((len + 1) * sizeof(cipher__Sig)); cr_assert( newSigs != NULL ); registerMemCleanup( newSigs ); - memcpy( newSigs, tx2.Sigs.data, tx2.Sigs.len * sizeof(cipher__Sig)); - tx2.Sigs.data = newSigs; - newSigs += tx2.Sigs.len; - tx2.Sigs.len++; - tx2.Sigs.cap = tx2.Sigs.len; + memcpy( newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); + result = SKY_coin_Transaction_ResetSignatures(ptx2, len + 1); + cr_assert( result == SKY_OK ); + memcpy( ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); + newSigs += len; memset( newSigs, 0, sizeof(cipher__Sig) ); - result = SKY_coin_Transaction_HashInner( &tx, &hash1 ); + result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( &tx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); } Test(coin_transactions, TestTransactionSerialization){ int result; - coin__Transaction tx; - makeTransaction( &tx ); + coin__Transaction* ptx; + ptx = makeTransaction(); GoSlice_ data; memset( &data, 0, sizeof(GoSlice_) ); - result = SKY_coin_Transaction_Serialize( &tx, &data ); + result = SKY_coin_Transaction_Serialize( ptx, &data ); cr_assert( result == SKY_OK ); registerMemCleanup( data.data ); - coin__Transaction tx2; - memset( &tx2, 0, sizeof(coin__Transaction) ); + coin__Transaction* ptx2; + ptx2 = makeEmptyTransaction(); GoSlice d = {data.data, data.len, data.cap}; - result = SKY_coin_TransactionDeserialize(d, &tx2); + result = SKY_coin_TransactionDeserialize(d, ptx2); cr_assert( result == SKY_OK ); - cr_assert( eq( type(coin__Transaction), tx, tx2) ); + cr_assert( eq( type(coin__Transaction), *ptx, *ptx2) ); } Test(coin_transactions, TestTransactionOutputHours){ - coin__Transaction tx; - memset( &tx, 0, sizeof(coin__Transaction) ); + coin__Transaction* ptx; + ptx = makeEmptyTransaction(); cipher__Address addr; makeAddress(&addr); int result; - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 100); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 100); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 200); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 200); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 500); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 500); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 0); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 0); cr_assert( result == SKY_OK ); GoUint64 hours; - result = SKY_coin_Transaction_OutputHours(&tx, &hours); + result = SKY_coin_Transaction_OutputHours(ptx, &hours); cr_assert( result == SKY_OK ); cr_assert( hours == 800 ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); - result = SKY_coin_Transaction_OutputHours(&tx, &hours); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); + result = SKY_coin_Transaction_OutputHours(ptx, &hours); cr_assert( result != SKY_OK ); } @@ -304,7 +303,8 @@ Test(coin_transactions, TestTransactionOutputHours){ * TestTransactionsSize not done for missing encoder.Serialize ***********************/ -Test(coin_transactions, TestTransactionsTruncateBytesTo){ + +Test(coin_transactions, TestTransactionsHashes){ int result; GoSlice_ transactions, hashes; memset(&transactions, 0, sizeof(GoSlice_)); @@ -328,12 +328,8 @@ Test(coin_transactions, TestTransactionsTruncateBytesTo){ } } -/**************************** -* This test crashes. -* Original functio returns a Transaction oject. -* Wrapper function must be modified to use a handle instead of object. -***************************/ -/*Test(coin_transactions, TestTransactionsTruncateBytesTo){ + +Test(coin_transactions, TestTransactionsTruncateBytesTo){ int result; GoSlice_ transactions, transactions2; memset(&transactions, 0, sizeof(GoSlice_)); @@ -351,26 +347,26 @@ Test(coin_transactions, TestTransactionsTruncateBytesTo){ } result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerMemCleanup( transactions2.data ); + //registerMemCleanup( transactions2.data ); cr_assert( transactions2.len == transactions.len / 2 ); result = SKY_coin_Transactions_Size( &transactions2, &size ); cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); cr_assert( trunc == size ); - freeRegisteredMemCleanup( transactions2.data ); + //freeRegisteredMemCleanup( transactions2.data ); trunc++; memset(&transactions2, 0, sizeof(GoSlice_)); result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerMemCleanup( transactions2.data ); + //registerMemCleanup( transactions2.data ); // Stepping into next boundary has same cutoff, must exceed cr_assert( transactions2.len == transactions.len / 2 ); result = SKY_coin_Transactions_Size( &transactions2, &size ); cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); cr_assert( trunc - 1 == size ); -}*/ +} typedef struct { GoUint64 coins; diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index a358da4654..f8bd0dd6e9 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -15,77 +15,71 @@ Test(coin_transaction, TestTransactionVerify) { int result; - coin__Transaction tx; + coin__Transaction* ptx; // Mismatch header hash - makeTransaction(&tx); - memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); - result = SKY_coin_Transaction_Verify(&tx); + ptx = makeTransaction(); + memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); // No inputs - makeTransaction(&tx); - tx.In.len = 0; - result = SKY_coin_Transaction_UpdateHeader(&tx); + ptx = makeTransaction(); + result = SKY_coin_Transaction_ResetInputs(ptx, 0); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); // No outputs - makeTransaction(&tx); - tx.Out.len = 0; - result = SKY_coin_Transaction_UpdateHeader(&tx); + ptx = makeTransaction(); + result = SKY_coin_Transaction_ResetOutputs(ptx, 0); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); //Invalid number of Sigs - makeTransaction(&tx); - tx.Sigs.len = 0; - result = SKY_coin_Transaction_UpdateHeader(&tx); + ptx = makeTransaction(); + result = SKY_coin_Transaction_ResetSignatures(ptx, 0); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); - tx.Sigs.data = malloc(20 * sizeof(cipher__Sig)); - cr_assert( tx.Sigs.data != NULL ); - registerMemCleanup( tx.Sigs.data ); - memset( tx.Sigs.data, 0, 20 * sizeof(cipher__Sig) ); - tx.Sigs.len = 20; tx.Sigs.cap = 20; - result = SKY_coin_Transaction_UpdateHeader(&tx); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_ResetSignatures(ptx, 20); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); int MaxUint16 = 0xFFFF; // Too many sigs & inputs - makeTransaction(&tx); - tx.Sigs.data = malloc(MaxUint16 * sizeof(cipher__Sig)); - cr_assert( tx.Sigs.data != NULL ); - registerMemCleanup( tx.Sigs.data ); - memset(tx.Sigs.data, 0, MaxUint16 * sizeof(cipher__Sig)); - tx.Sigs.len = tx.Sigs.cap = MaxUint16; - tx.In.data = malloc( MaxUint16 * sizeof(cipher__SHA256) ); - cr_assert( tx.In.data != NULL ); - registerMemCleanup( tx.In.data ); - tx.In.len = tx.In.cap = MaxUint16; - result = SKY_coin_Transaction_UpdateHeader(&tx); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + ptx = makeTransaction(); + result = SKY_coin_Transaction_ResetSignatures(ptx, MaxUint16); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_ResetInputs(ptx, MaxUint16); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); - freeRegisteredMemCleanup(tx.Sigs.data); //Too much memory (~8MB) free ASAP - freeRegisteredMemCleanup(tx.In.data); // Duplicate inputs coin__UxOut ux; cipher__SecKey seckey; cipher__SHA256 sha256; makeUxOutWithSecret( &ux, &seckey ); - makeTransactionFromUxOut( &ux, &seckey, &tx ); - memcpy(&sha256, tx.In.data, sizeof(cipher__SHA256)); + ptx = makeTransactionFromUxOut( &ux, &seckey); + memcpy(&sha256, ptx->In.data, sizeof(cipher__SHA256)); GoUint16 r; - result = SKY_coin_Transaction_PushInput(&tx, &sha256, &r); - tx.Sigs.len = 0; + result = SKY_coin_Transaction_PushInput(ptx, &sha256, &r); + result = SKY_coin_Transaction_ResetSignatures(ptx, 0); + cr_assert( result == SKY_OK ); GoSlice seckeys; seckeys.data = malloc(sizeof(cipher__SecKey) * 2); cr_assert( seckeys.data != NULL ); @@ -93,75 +87,76 @@ Test(coin_transaction, TestTransactionVerify) seckeys.len = seckeys.cap = 2; memcpy( seckeys.data, &seckey, sizeof(cipher__SecKey) ); memcpy( ((cipher__SecKey*)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey) ); - result = SKY_coin_Transaction_SignInputs( &tx, seckeys ); - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_SignInputs( ptx, seckeys ); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); //Duplicate outputs - makeTransaction(&tx); - coin__TransactionOutput* pOutput = tx.Out.data; + ptx = makeTransaction(); + coin__TransactionOutput* pOutput = ptx->Out.data; cipher__Address addr; memcpy(&addr, &pOutput->Address, sizeof(cipher__Address)); - result = SKY_coin_Transaction_PushOutput(&tx, &addr, pOutput->Coins, pOutput->Hours); + result = SKY_coin_Transaction_PushOutput(ptx, &addr, pOutput->Coins, pOutput->Hours); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); // Invalid signature, empty - makeTransaction(&tx); - memset(tx.Sigs.data, 0, sizeof(cipher__Sig)); - result = SKY_coin_Transaction_Verify(&tx); + ptx = makeTransaction(); + memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); // Output coins are 0 - makeTransaction(&tx); - pOutput = tx.Out.data; + ptx = makeTransaction(); + pOutput = ptx->Out.data; pOutput->Coins = 0; - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow - makeTransaction(&tx); - pOutput = tx.Out.data; + ptx = makeTransaction(); + pOutput = ptx->Out.data; pOutput->Coins = MaxUint64 - 3000000; - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result != SKY_OK ); // Output coins are not multiples of 1e6 (valid, decimal restriction is not enforced here) - makeTransaction(&tx); - pOutput = tx.Out.data; + ptx = makeTransaction(); + pOutput = ptx->Out.data; pOutput->Coins += 10; - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_ResetSignatures(ptx, 0); cr_assert( result == SKY_OK ); - tx.Sigs.data = NULL; tx.Sigs.len = 0; tx.Sigs.cap = 0; cipher__PubKey pubkey; result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); cr_assert( result == SKY_OK ); seckeys.data = &seckey; seckeys.len = 1; seckeys.cap = 1; - result = SKY_coin_Transaction_SignInputs(&tx, seckeys); + result = SKY_coin_Transaction_SignInputs(ptx, seckeys); cr_assert( result == SKY_OK ); cr_assert( pOutput->Coins % 1000000 != 0 ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result == SKY_OK ); //Valid - makeTransaction(&tx); - pOutput = tx.Out.data; + ptx = makeTransaction(); + pOutput = ptx->Out.data; pOutput->Coins = 10000000; pOutput++; pOutput->Coins = 1000000; - result = SKY_coin_Transaction_UpdateHeader(&tx); + result = SKY_coin_Transaction_UpdateHeader(ptx); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(&tx); + result = SKY_coin_Transaction_Verify(ptx); cr_assert( result == SKY_OK ); } @@ -169,51 +164,52 @@ Test(coin_transaction, TestTransactionVerify) Test(coin_transaction, TestTransactionPushInput) { int result; - coin__Transaction tx; + coin__Transaction* ptx; coin__UxOut ux; - memset( &tx, 0, sizeof(coin__Transaction) ); + ptx = makeEmptyTransaction(); makeUxOut( &ux ); cipher__SHA256 hash; result = SKY_coin_UxOut_Hash( &ux, &hash ); cr_assert( result == SKY_OK ); GoUint16 r; - result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); cr_assert( result == SKY_OK ); cr_assert( r == 0 ); - cr_assert( tx.In.len == 1 ); - cipher__SHA256* pIn = tx.In.data; + cr_assert( ptx->In.len == 1 ); + cipher__SHA256* pIn = ptx->In.data; cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *pIn) ); GoUint16 MaxUint16 = 0xFFFF; - void* data = malloc( (tx.In.len + MaxUint16) * sizeof(cipher__SHA256) ); - cr_assert( data != NULL ); - registerMemCleanup( data ); - memset( data, 0, (tx.In.len + MaxUint16) * sizeof(cipher__SHA256) ); - memcpy( data, tx.In.data, (tx.In.len) * sizeof(cipher__SHA256) ); - tx.In.len += MaxUint16; - tx.In.cap = tx.In.len; - tx.In.data = data; + int len = ptx->In.len; + void* data = malloc(len * sizeof(cipher__SHA256)); + cr_assert(data != NULL); + registerMemCleanup(data); + memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256) ); + result = SKY_coin_Transaction_ResetInputs(ptx, MaxUint16 + len); + cr_assert( result == SKY_OK ); + memcpy(ptx->In.data, data, len * sizeof(cipher__Sig)); + freeRegisteredMemCleanup(data); makeUxOut( &ux ); result = SKY_coin_UxOut_Hash( &ux, &hash ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(&tx, &hash, &r); + result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); cr_assert( result != SKY_OK ); - freeRegisteredMemCleanup( data ); } Test(coin_transaction, TestTransactionPushOutput) { int result; - coin__Transaction tx; + coin__Transaction* ptx; + ptx = makeEmptyTransaction(); + cipher__Address addr; - memset( &tx, 0, sizeof(coin__Transaction) ); makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( &tx, &addr, 100, 150 ); + result = SKY_coin_Transaction_PushOutput( ptx, &addr, 100, 150 ); cr_assert( result == SKY_OK ); - cr_assert( tx.Out.len == 1 ); - coin__TransactionOutput* pOutput = tx.Out.data; + cr_assert( ptx->Out.len == 1 ); + coin__TransactionOutput* pOutput = ptx->Out.data; coin__TransactionOutput output; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = 100; @@ -221,10 +217,10 @@ Test(coin_transaction, TestTransactionPushOutput) cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); for(int i = 1; i < 20; i++){ makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( &tx, &addr, i * 100, i * 50 ); + result = SKY_coin_Transaction_PushOutput( ptx, &addr, i * 100, i * 50 ); cr_assert( result == SKY_OK ); - cr_assert( tx.Out.len == i + 1 ); - pOutput = tx.Out.data; + cr_assert( ptx->Out.len == i + 1 ); + pOutput = ptx->Out.data; pOutput += i; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = i * 100; @@ -238,14 +234,15 @@ Test(coin_transaction, TestTransactionPushOutput) Test(coin_transaction, TestTransactionHash) { int result; - coin__Transaction tx; - makeTransaction(&tx); + coin__Transaction* ptx; + ptx = makeEmptyTransaction(); + cipher__SHA256 nullHash, hash1, hash2; memset( &nullHash, 0, sizeof(cipher__SHA256) ); - result = SKY_coin_Transaction_Hash( &tx, &hash1 ); + result = SKY_coin_Transaction_Hash( ptx, &hash1 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash1) ) ); - result = SKY_coin_Transaction_HashInner( &tx, &hash2 ); + result = SKY_coin_Transaction_HashInner( ptx, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash2, hash1) ) ); } @@ -253,16 +250,16 @@ Test(coin_transaction, TestTransactionHash) Test(coin_transaction, TestTransactionUpdateHeader) { int result; - coin__Transaction tx; - makeTransaction(&tx); + coin__Transaction* ptx; + ptx = makeTransaction(); cipher__SHA256 hash, nullHash, hashInner; - memcpy(&hash, &tx.InnerHash, sizeof(cipher__SHA256)); - memset(&tx.InnerHash, 0, sizeof(cipher__SHA256)); + memcpy(&hash, &ptx->InnerHash, sizeof(cipher__SHA256)); + memset(&ptx->InnerHash, 0, sizeof(cipher__SHA256)); memset(&nullHash, 0, sizeof(cipher__SHA256)); - result = SKY_coin_Transaction_UpdateHeader(&tx); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], tx.InnerHash, nullHash) ) ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, tx.InnerHash) ); - result = SKY_coin_Transaction_HashInner( &tx, &hashInner ); + result = SKY_coin_Transaction_UpdateHeader(ptx); + cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash) ) ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash) ); + result = SKY_coin_Transaction_HashInner( ptx, &hashInner ); cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, tx.InnerHash) ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash) ); } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 857104ebc1..345ec805eb 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -80,14 +80,18 @@ int makeAddress(cipher__Address* paddress){ return result; } -int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, - coin__Transaction* ptransaction){ +coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey ){ int result; - - memset(ptransaction, 0, sizeof(coin__Transaction)); + coin__Transaction* ptransaction = NULL; + Transaction__Handle handle; + result = SKY_coin_Create_Transaction(&handle); + cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); + registerHandleClose(handle); + result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); cipher__SHA256 sha256; result = SKY_coin_UxOut_Hash(puxOut, &sha256); - cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash"); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); GoUint16 r; result = SKY_coin_Transaction_PushInput(ptransaction, &sha256, &r); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushInput failed"); @@ -108,21 +112,36 @@ int makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, cr_assert(result == SKY_OK, "SKY_coin_Transaction_SignInputs failed"); result = SKY_coin_Transaction_UpdateHeader( ptransaction ); cr_assert(result == SKY_OK, "SKY_coin_Transaction_UpdateHeader failed"); - return result; + return ptransaction; } -int makeTransaction(coin__Transaction* ptransaction){ +coin__Transaction* makeTransaction(){ int result; coin__UxOut uxOut; cipher__SecKey seckey; + coin__Transaction* ptransaction = NULL; + result = makeUxOutWithSecret( &uxOut, &seckey ); cr_assert(result == SKY_OK, "makeUxOutWithSecret failed"); - result = makeTransactionFromUxOut( &uxOut, &seckey, ptransaction ); + ptransaction = makeTransactionFromUxOut( &uxOut, &seckey ); cr_assert(result == SKY_OK, "makeTransactionFromUxOut failed"); - return result; + return ptransaction; } +coin__Transaction* makeEmptyTransaction(){ + int result; + coin__Transaction* ptransaction = NULL; + Transaction__Handle handle; + result = SKY_coin_Create_Transaction(&handle); + cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); + registerHandleClose(handle); + result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); + return ptransaction; +} + + int makeTransactions(GoSlice* transactions, int n){ void * data = malloc(sizeof(coin__Transaction) * n); if(data == NULL) @@ -130,28 +149,28 @@ int makeTransactions(GoSlice* transactions, int n){ registerMemCleanup(data); coin__Transaction* ptransaction = (coin__Transaction*)data; int i; - int result = SKY_ERROR; // n == 0 then error + int result = SKY_OK; for( i = 0; i < n; i++){ - result = makeTransaction(ptransaction); - if(result != SKY_OK){ - free(data); - break; - } + coin__Transaction* p = makeTransaction(); + memcpy(ptransaction, p, sizeof(coin__Transaction)); ptransaction++; } - if(result == SKY_OK) { - transactions->data = data; - transactions->len = n; - transactions->cap = n; - } + transactions->data = data; + transactions->len = n; + transactions->cap = n; return result; } -void copyTransaction(coin__Transaction* pt1, coin__Transaction* pt2){ - memcpy(pt2, pt1, sizeof(coin__Transaction)); - copySlice(&pt2->Sigs, &pt1->Sigs, sizeof(cipher__Sig)); - copySlice(&pt2->In, &pt1->In, sizeof(cipher__SHA256)); - copySlice(&pt2->Out, &pt1->Out, sizeof(coin__TransactionOutput)); +coin__Transaction* copyTransaction(coin__Transaction* pt1){ + Transaction__Handle handle = 0; + coin__Transaction* ptransaction = NULL; + int result = 0; + result = SKY_coin_Transaction_Copy(pt1, &handle); + cr_assert(result == SKY_OK); + registerHandleClose(handle); + result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); + return ptransaction; } void makeRandHash(cipher__SHA256* phash){ From eb848c01d373893c63dbec4d6b5150f87c803c93 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 17:55:24 +0000 Subject: [PATCH 032/399] [libc] Fulling working with transactions with handles, experimental --- lib/cgo/coin.transactions.go | 146 ++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 37 deletions(-) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 4925de50b4..bbc2c663d3 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -29,12 +29,16 @@ func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code } //export SKY_coin_Transaction_Copy -func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__Handle) (____error_code uint32) { +func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + tx, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } ntx := coin.Transaction{} ntx.Length = tx.Length ntx.Type = tx.Type @@ -45,7 +49,7 @@ func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__ ntx.In = append( ntx.In, tx.In... ) ntx.Out = make([]coin.TransactionOutput, 0) ntx.Out = append( ntx.Out, tx.Out... ) - *handle = registerTransactionHandle(&ntx) + *handle2 = registerTransactionHandle(&ntx) return } @@ -65,45 +69,61 @@ func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coi } //export SKY_coin_Transaction_ResetInputs -func SKY_coin_Transaction_ResetInputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.In = make([]cipher.SHA256, count) return } //export SKY_coin_Transaction_ResetOutputs -func SKY_coin_Transaction_ResetOutputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.Out = make([]coin.TransactionOutput, count) return } //export SKY_coin_Transaction_ResetSignatures -func SKY_coin_Transaction_ResetSignatures(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.Sigs = make([]cipher.Sig, count) return } //export SKY_coin_Transaction_Verify -func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } ____return_err := txn.Verify() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -112,12 +132,16 @@ func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint } //export SKY_coin_Transaction_VerifyInput -func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__UxArray) (____error_code uint32) { +func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := *(*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) ____return_err := txn.VerifyInput(uxIn) ____error_code = libErrorCode(____return_err) @@ -127,12 +151,16 @@ func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__ } //export SKY_coin_Transaction_PushInput -func SKY_coin_Transaction_PushInput(_txn *C.coin__Transaction, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { +func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) __arg1 := txn.PushInput(uxOut) *_arg1 = __arg1 @@ -153,12 +181,16 @@ func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C } //export SKY_coin_Transaction_PushOutput -func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { +func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } dst := *(*cipher.Address)(unsafe.Pointer(_dst)) coins := _coins hours := _hours @@ -167,48 +199,64 @@ func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__ } //export SKY_coin_Transaction_SignInputs -func SKY_coin_Transaction_SignInputs(_txn *C.coin__Transaction, _keys []C.cipher__SecKey) (____error_code uint32) { +func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) txn.SignInputs(keys) return } //export SKY_coin_Transaction_Size -func SKY_coin_Transaction_Size(_txn *C.coin__Transaction, _arg0 *int) (____error_code uint32) { +func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Size() *_arg0 = __arg0 return } //export SKY_coin_Transaction_Hash -func SKY_coin_Transaction_Hash(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_SizeHash -func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, __arg1 := txn.SizeHash() *_arg0 = __arg0 *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) @@ -216,59 +264,79 @@ func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 } //export SKY_coin_Transaction_TxID -func SKY_coin_Transaction_TxID(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.TxID() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_Transaction_TxIDHex -func SKY_coin_Transaction_TxIDHex(_txn *C.coin__Transaction, _arg0 *C.GoString_) (____error_code uint32) { +func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.TxIDHex() copyString(__arg0, _arg0) return } //export SKY_coin_Transaction_UpdateHeader -func SKY_coin_Transaction_UpdateHeader(_txn *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.UpdateHeader() return } //export SKY_coin_Transaction_HashInner -func SKY_coin_Transaction_HashInner(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.HashInner() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_Serialize -func SKY_coin_Transaction_Serialize(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Serialize() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return @@ -302,12 +370,16 @@ func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (___ } //export SKY_coin_Transaction_OutputHours -func SKY_coin_Transaction_OutputHours(_txn *C.coin__Transaction, _arg0 *uint64) (____error_code uint32) { +func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, ____return_err := txn.OutputHours() ____error_code = libErrorCode(____return_err) if ____return_err == nil { From 68c4f3d66cdfcd23e5e40e666fb9c58d689b2290 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 18:38:22 +0000 Subject: [PATCH 033/399] [libc] Rolled back changes in previous commit. --- lib/cgo/coin.transactions.go | 146 +++++++++-------------------------- 1 file changed, 37 insertions(+), 109 deletions(-) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index bbc2c663d3..4925de50b4 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -29,16 +29,12 @@ func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code } //export SKY_coin_Transaction_Copy -func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { +func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - tx, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + tx := (*coin.Transaction)(unsafe.Pointer(_tx)) ntx := coin.Transaction{} ntx.Length = tx.Length ntx.Type = tx.Type @@ -49,7 +45,7 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact ntx.In = append( ntx.In, tx.In... ) ntx.Out = make([]coin.TransactionOutput, 0) ntx.Out = append( ntx.Out, tx.Out... ) - *handle2 = registerTransactionHandle(&ntx) + *handle = registerTransactionHandle(&ntx) return } @@ -69,61 +65,45 @@ func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coi } //export SKY_coin_Transaction_ResetInputs -func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetInputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) txn.In = make([]cipher.SHA256, count) return } //export SKY_coin_Transaction_ResetOutputs -func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetOutputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) txn.Out = make([]coin.TransactionOutput, count) return } //export SKY_coin_Transaction_ResetSignatures -func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetSignatures(_txn *C.coin__Transaction, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) txn.Sigs = make([]cipher.Sig, count) return } //export SKY_coin_Transaction_Verify -func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { +func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) ____return_err := txn.Verify() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -132,16 +112,12 @@ func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code u } //export SKY_coin_Transaction_VerifyInput -func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { +func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__UxArray) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := *(*coin.Transaction)(unsafe.Pointer(_txn)) uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) ____return_err := txn.VerifyInput(uxIn) ____error_code = libErrorCode(____return_err) @@ -151,16 +127,12 @@ func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coi } //export SKY_coin_Transaction_PushInput -func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { +func SKY_coin_Transaction_PushInput(_txn *C.coin__Transaction, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) __arg1 := txn.PushInput(uxOut) *_arg1 = __arg1 @@ -181,16 +153,12 @@ func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C } //export SKY_coin_Transaction_PushOutput -func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { +func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) dst := *(*cipher.Address)(unsafe.Pointer(_dst)) coins := _coins hours := _hours @@ -199,64 +167,48 @@ func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.ciphe } //export SKY_coin_Transaction_SignInputs -func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { +func SKY_coin_Transaction_SignInputs(_txn *C.coin__Transaction, _keys []C.cipher__SecKey) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) txn.SignInputs(keys) return } //export SKY_coin_Transaction_Size -func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____error_code uint32) { +func SKY_coin_Transaction_Size(_txn *C.coin__Transaction, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.Size() *_arg0 = __arg0 return } //export SKY_coin_Transaction_Hash -func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_Hash(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_SizeHash -func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0, __arg1 := txn.SizeHash() *_arg0 = __arg0 *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) @@ -264,79 +216,59 @@ func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _ar } //export SKY_coin_Transaction_TxID -func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_TxID(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.TxID() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_Transaction_TxIDHex -func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { +func SKY_coin_Transaction_TxIDHex(_txn *C.coin__Transaction, _arg0 *C.GoString_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.TxIDHex() copyString(__arg0, _arg0) return } //export SKY_coin_Transaction_UpdateHeader -func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { +func SKY_coin_Transaction_UpdateHeader(_txn *C.coin__Transaction) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) txn.UpdateHeader() return } //export SKY_coin_Transaction_HashInner -func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_HashInner(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.HashInner() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_Serialize -func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_Serialize(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0 := txn.Serialize() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return @@ -370,16 +302,12 @@ func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (___ } //export SKY_coin_Transaction_OutputHours -func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { +func SKY_coin_Transaction_OutputHours(_txn *C.coin__Transaction, _arg0 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn, ok := lookupTransactionHandle(handle) - if !ok { - ____error_code = SKY_ERROR - return - } + txn := (*coin.Transaction)(unsafe.Pointer(_txn)) __arg0, ____return_err := txn.OutputHours() ____error_code = libErrorCode(____return_err) if ____return_err == nil { From 22306d4cfa4777304bafb34ed56da896367330b6 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 20:43:00 +0000 Subject: [PATCH 034/399] [libc] refs #1191. Apply handles to Transaction and Transactions in all functions in coin.transactions. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 4 + include/transutil.h | 11 +- lib/cgo/coin.transactions.go | 246 +++++++++++++++++++----- lib/cgo/libsky_handle.go | 24 +++ lib/cgo/tests/check_coin.block.c | 30 +-- lib/cgo/tests/check_coin.transaction2.c | 186 +++++++++--------- lib/cgo/tests/check_coin.transactions.c | 131 +++++++------ lib/cgo/tests/testutils/transutils.c | 66 +++---- 8 files changed, 443 insertions(+), 255 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 27a7491410..10de3f9bcc 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -249,6 +249,10 @@ typedef Handle Config__Handle; */ typedef Handle Transaction__Handle; +/** + * Memory handle to access to coin.Transactions + */ +typedef Handle Transactions__Handle; /* #include "cipher.hash.go.h" diff --git a/include/transutil.h b/include/transutil.h index e23bf8e3c8..154cd5c69a 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -9,6 +9,7 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" +#include "skytypes.h" int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress); @@ -22,15 +23,15 @@ int makeUxOut(coin__UxOut* puxOut); int makeAddress(cipher__Address* paddress); -coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey); +coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, Transaction__Handle* handle); -coin__Transaction* makeTransaction(); +coin__Transaction* makeTransaction(Transaction__Handle* handle); -coin__Transaction* makeEmptyTransaction(); +coin__Transaction* makeEmptyTransaction(Transaction__Handle* handle); -int makeTransactions(GoSlice* transactions, int n); +int makeTransactions(int n, Transactions__Handle* handle); -coin__Transaction* copyTransaction(coin__Transaction* pt1); +coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Handle* handle2); void makeRandHash(cipher__SHA256* phash); diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 4925de50b4..bdad865b28 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -29,12 +29,16 @@ func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code } //export SKY_coin_Transaction_Copy -func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__Handle) (____error_code uint32) { +func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + tx, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } ntx := coin.Transaction{} ntx.Length = tx.Length ntx.Type = tx.Type @@ -45,7 +49,7 @@ func SKY_coin_Transaction_Copy(_tx *C.coin__Transaction, handle *C.Transaction__ ntx.In = append( ntx.In, tx.In... ) ntx.Out = make([]coin.TransactionOutput, 0) ntx.Out = append( ntx.Out, tx.Out... ) - *handle = registerTransactionHandle(&ntx) + *handle2 = registerTransactionHandle(&ntx) return } @@ -65,45 +69,61 @@ func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coi } //export SKY_coin_Transaction_ResetInputs -func SKY_coin_Transaction_ResetInputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.In = make([]cipher.SHA256, count) return } //export SKY_coin_Transaction_ResetOutputs -func SKY_coin_Transaction_ResetOutputs(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.Out = make([]coin.TransactionOutput, count) return } //export SKY_coin_Transaction_ResetSignatures -func SKY_coin_Transaction_ResetSignatures(_txn *C.coin__Transaction, count int) (____error_code uint32) { +func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.Sigs = make([]cipher.Sig, count) return } //export SKY_coin_Transaction_Verify -func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } ____return_err := txn.Verify() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -112,12 +132,16 @@ func SKY_coin_Transaction_Verify(_txn *C.coin__Transaction) (____error_code uint } //export SKY_coin_Transaction_VerifyInput -func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__UxArray) (____error_code uint32) { +func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := *(*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) ____return_err := txn.VerifyInput(uxIn) ____error_code = libErrorCode(____return_err) @@ -127,12 +151,16 @@ func SKY_coin_Transaction_VerifyInput(_txn *C.coin__Transaction, _uxIn *C.coin__ } //export SKY_coin_Transaction_PushInput -func SKY_coin_Transaction_PushInput(_txn *C.coin__Transaction, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { +func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) __arg1 := txn.PushInput(uxOut) *_arg1 = __arg1 @@ -153,12 +181,16 @@ func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C } //export SKY_coin_Transaction_PushOutput -func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { +func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } dst := *(*cipher.Address)(unsafe.Pointer(_dst)) coins := _coins hours := _hours @@ -167,48 +199,64 @@ func SKY_coin_Transaction_PushOutput(_txn *C.coin__Transaction, _dst *C.cipher__ } //export SKY_coin_Transaction_SignInputs -func SKY_coin_Transaction_SignInputs(_txn *C.coin__Transaction, _keys []C.cipher__SecKey) (____error_code uint32) { +func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) txn.SignInputs(keys) return } //export SKY_coin_Transaction_Size -func SKY_coin_Transaction_Size(_txn *C.coin__Transaction, _arg0 *int) (____error_code uint32) { +func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Size() *_arg0 = __arg0 return } //export SKY_coin_Transaction_Hash -func SKY_coin_Transaction_Hash(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_SizeHash -func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, __arg1 := txn.SizeHash() *_arg0 = __arg0 *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) @@ -216,78 +264,98 @@ func SKY_coin_Transaction_SizeHash(_txn *C.coin__Transaction, _arg0 *int, _arg1 } //export SKY_coin_Transaction_TxID -func SKY_coin_Transaction_TxID(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.TxID() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_Transaction_TxIDHex -func SKY_coin_Transaction_TxIDHex(_txn *C.coin__Transaction, _arg0 *C.GoString_) (____error_code uint32) { +func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.TxIDHex() copyString(__arg0, _arg0) return } //export SKY_coin_Transaction_UpdateHeader -func SKY_coin_Transaction_UpdateHeader(_txn *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } txn.UpdateHeader() return } //export SKY_coin_Transaction_HashInner -func SKY_coin_Transaction_HashInner(_txn *C.coin__Transaction, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.HashInner() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Transaction_Serialize -func SKY_coin_Transaction_Serialize(_txn *C.coin__Transaction, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txn.Serialize() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_MustTransactionDeserialize -func SKY_coin_MustTransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_MustTransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1 := coin.MustTransactionDeserialize(b) - *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + *_arg1 = registerTransactionHandle(&__arg1) return } //export SKY_coin_TransactionDeserialize -func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (____error_code uint32) { +func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -296,18 +364,22 @@ func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.coin__Transaction) (___ __arg1, ____return_err := coin.TransactionDeserialize(b) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + *_arg1 = registerTransactionHandle(&__arg1) } return } //export SKY_coin_Transaction_OutputHours -func SKY_coin_Transaction_OutputHours(_txn *C.coin__Transaction, _arg0 *uint64) (____error_code uint32) { +func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, ____return_err := txn.OutputHours() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -316,40 +388,118 @@ func SKY_coin_Transaction_OutputHours(_txn *C.coin__Transaction, _arg0 *uint64) return } +//export SKY_coin_Create_Transactions +func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_code uint32) { + txs := make(coin.Transactions, 0, 0) + *handle = registerTransactionsHandle(&txs) + return SKY_OK +} + +//export SKY_coin_Transactions_Length +func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *_length = len(*txns) + return +} + +//export SKY_coin_Transactions_Add +func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + tx, okt := lookupTransactionHandle(th) + if !okt { + ____error_code = SKY_ERROR + return + } + *txns = append( *txns, *tx ) + result := overwriteHandle( tsh, txns ) + if !result { + ____error_code = SKY_ERROR + } + return +} + +//export SKY_coin_Transactions_GetAt +func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + if( n >= len(*txns)){ + ____error_code = SKY_ERROR + return + } + tx := (*txns)[n] + *th = registerTransactionHandle(&tx) + return +} + //export SKY_coin_Transactions_Hashes -func SKY_coin_Transactions_Hashes(_txns *C.coin__Transactions, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txns.Hashes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_Transactions_Size -func SKY_coin_Transactions_Size(_txns *C.coin__Transactions, _arg0 *int) (____error_code uint32) { +func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txns.Size() *_arg0 = __arg0 return } //export SKY_coin_Transactions_TruncateBytesTo -func SKY_coin_Transactions_TruncateBytesTo(_txns *C.coin__Transactions, _size int, _arg1 *C.coin__Transactions) (____error_code uint32) { +func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int, _arg1 *C.Transactions__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } size := _size __arg1 := txns.TruncateBytesTo(size) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + *_arg1 = registerTransactionsHandle( &__arg1 ) return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 62a4990891..70457d9477 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -19,6 +19,7 @@ import ( "github.com/skycoin/skycoin/src/coin" ) + type Handle uint64 var ( @@ -39,6 +40,15 @@ func lookupHandle(handle C.Handle) (interface{}, bool) { return obj, ok } +func overwriteHandle(handle C.Handle, obj interface{}) bool{ + _, ok := handleMap[Handle(handle)] + if ok { + handleMap[Handle(handle)] = obj + return true + } + return false +} + func registerWebRpcClientHandle(obj *webrpc.Client) C.WebRpcClient__Handle { return (C.WebRpcClient__Handle)(registerHandle(obj)) } @@ -235,6 +245,20 @@ func lookupTransactionHandle(handle C.Transaction__Handle) (*coin.Transaction, b return nil, false } +func registerTransactionsHandle(obj *coin.Transactions) C.Transactions__Handle { + return (C.Transactions__Handle)(registerHandle(obj)) +} + +func lookupTransactionsHandle(handle C.Transactions__Handle) (*coin.Transactions, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Transactions); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 6edb6dc3a9..ae0d83ce85 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -181,9 +181,10 @@ Test(coin_block, TestCreateUnspent){ int result = makeKeysAndAddress(&pubkey, &seckey, &address); cipher__SHA256 hash; - coin__Transaction tx; - memset( &tx, 0, sizeof(coin__Transaction) ); - result = SKY_coin_Transaction_PushOutput(&tx, &address, 11000000, 255); + coin__Transaction* ptx; + Transaction__Handle handle; + ptx = makeEmptyTransaction(&handle); + result = SKY_coin_Transaction_PushOutput(handle, &address, 11000000, 255); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); coin__BlockHeader bh; memset(&bh, 0, sizeof(coin__BlockHeader)); @@ -197,7 +198,7 @@ Test(coin_block, TestCreateUnspent){ int tests_count = sizeof(t) / sizeof(testcase_unspent); for( int i = 0; i < tests_count; i++){ memset(&ux, 0, sizeof(coin__UxOut)); - result = SKY_coin_CreateUnspent( &bh, &tx, t[i].index, &ux ); + result = SKY_coin_CreateUnspent( &bh, ptx, t[i].index, &ux ); if( t[i].failure ){ cr_assert( result == SKY_ERROR, "SKY_coin_CreateUnspent should have failed" ); continue; @@ -206,11 +207,11 @@ Test(coin_block, TestCreateUnspent){ } cr_assert( bh.Time == ux.Head.Time ); cr_assert( bh.BkSeq == ux.Head.BkSeq ); - result = SKY_coin_Transaction_Hash( &tx, &hash ); + result = SKY_coin_Transaction_Hash( handle, &hash ); cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ux.Body.SrcTransaction) ); - cr_assert( t[i].index < tx.Out.len); - coin__TransactionOutput* poutput = (coin__TransactionOutput*)tx.Out.data; + cr_assert( t[i].index < ptx->Out.len); + coin__TransactionOutput* poutput = (coin__TransactionOutput*)ptx->Out.data; cr_assert( eq( type(cipher__Address), ux.Body.Address, poutput->Address ) ); cr_assert( ux.Body.Coins == poutput->Coins ); cr_assert( ux.Body.Hours == poutput->Hours ); @@ -224,9 +225,10 @@ Test(coin_block, TestCreateUnspents){ int result = makeKeysAndAddress(&pubkey, &seckey, &address); cipher__SHA256 hash; - coin__Transaction tx; - memset( &tx, 0, sizeof(coin__Transaction) ); - result = SKY_coin_Transaction_PushOutput(&tx, &address, 11000000, 255); + coin__Transaction* ptx; + Transaction__Handle handle; + ptx = makeEmptyTransaction(&handle); + result = SKY_coin_Transaction_PushOutput(handle, &address, 11000000, 255); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); coin__BlockHeader bh; memset(&bh, 0, sizeof(coin__BlockHeader)); @@ -234,17 +236,17 @@ Test(coin_block, TestCreateUnspents){ bh.BkSeq = 1; coin__UxArray uxs = {NULL, 0, 0}; - result = SKY_coin_CreateUnspents(&bh, &tx, &uxs); + result = SKY_coin_CreateUnspents(&bh, ptx, &uxs); cr_assert( result == SKY_OK, "SKY_coin_CreateUnspents failed" ); registerMemCleanup( uxs.data ); cr_assert( uxs.len == 1 ); - cr_assert( uxs.len == tx.Out.len ); + cr_assert( uxs.len == ptx->Out.len ); coin__UxOut* pout = (coin__UxOut*)uxs.data; - coin__TransactionOutput* ptxout = (coin__TransactionOutput*)tx.Out.data; + coin__TransactionOutput* ptxout = (coin__TransactionOutput*)ptx->Out.data; for(int i = 0; i < uxs.len; i++){ cr_assert( bh.Time == pout->Head.Time ); cr_assert( bh.BkSeq == pout->Head.BkSeq ); - result = SKY_coin_Transaction_Hash( &tx, &hash ); + result = SKY_coin_Transaction_Hash( handle, &hash ); cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, pout->Body.SrcTransaction) ); cr_assert( eq( type(cipher__Address), pout->Body.Address, ptxout->Address ) ); diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index 9205bed5d6..a79149b296 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -15,13 +15,14 @@ TestSuite(coin_transactions, .init = setup, .fini = teardown); Test(coin_transactions, TestTransactionVerifyInput){ int result; + Transaction__Handle handle; coin__Transaction* ptx; - ptx = makeTransaction(); - result = SKY_coin_Transaction_VerifyInput(ptx, NULL); + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_VerifyInput(handle, NULL); cr_assert( result != SKY_OK ); coin__UxArray ux; memset(&ux, 0, sizeof(coin__UxArray)); - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); memset(&ux, 0, sizeof(coin__UxArray)); ux.data = malloc(3 * sizeof(coin__UxOut)); @@ -30,7 +31,7 @@ Test(coin_transactions, TestTransactionVerifyInput){ ux.len = 3; ux.cap = 3; memset(ux.data, 0, 3 * sizeof(coin__UxOut)); - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); coin__UxOut uxOut; @@ -40,77 +41,78 @@ Test(coin_transactions, TestTransactionVerifyInput){ result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(ptx, 0); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); cr_assert( result == SKY_OK ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); memset(&sig, 0, sizeof(cipher__Sig)); result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(ptx, 1); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); cr_assert( result == SKY_OK ); memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); //Invalid Tx Inner Hash result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); memset( ptx->InnerHash, 0, sizeof(cipher__SHA256) ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); //Ux hash mismatch result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); memset( &uxOut, 0, sizeof(coin__UxOut) ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); //Invalid signature result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(ptx, 1); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); cr_assert( result == SKY_OK ); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result != SKY_OK ); //Valid result = makeUxOutWithSecret(&uxOut, &seckey); cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); cr_assert( result == SKY_OK ); ux.data = &uxOut; ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(ptx, &ux); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); cr_assert( result == SKY_OK ); } Test(coin_transactions, TestTransactionSignInputs){ int result; coin__Transaction* ptx; + Transaction__Handle handle; coin__UxOut ux, ux2; cipher__SecKey seckey, seckey2; cipher__SHA256 hash, hash2; @@ -120,42 +122,42 @@ Test(coin_transactions, TestTransactionSignInputs){ GoSlice keys; //Error if txns already signed - ptx = makeEmptyTransaction(); - result = SKY_coin_Transaction_ResetSignatures(ptx, 1); + ptx = makeEmptyTransaction(&handle); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); cr_assert( result == SKY_OK ); memset( &seckey, 0, sizeof(cipher__SecKey) ); keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(ptx, keys); + result = SKY_coin_Transaction_SignInputs(handle, keys); cr_assert( result != SKY_OK ); // Panics if not enough keys - ptx = makeEmptyTransaction(); + ptx = makeEmptyTransaction(&handle); memset(&seckey, 0, sizeof(cipher__SecKey)); memset(&seckey2, 0, sizeof(cipher__SecKey)); result = makeUxOutWithSecret( &ux, &seckey ); cr_assert( result == SKY_OK ); result = SKY_coin_UxOut_Hash(&ux, &hash); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); + result = SKY_coin_Transaction_PushInput(handle, &hash, &r); cr_assert( result == SKY_OK ); result = makeUxOutWithSecret( &ux2, &seckey2 ); cr_assert( result == SKY_OK ); result = SKY_coin_UxOut_Hash(&ux2, &hash2); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(ptx, &hash2, &r); + result = SKY_coin_Transaction_PushInput(handle, &hash2, &r); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 40, 80); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 40, 80); cr_assert( result == SKY_OK ); cr_assert( ptx->Sigs.len == 0 ); keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(ptx, keys); + result = SKY_coin_Transaction_SignInputs(handle, keys); cr_assert( result != SKY_OK ); cr_assert( ptx->Sigs.len == 0 ); // Valid signing - result = SKY_coin_Transaction_HashInner( ptx, &hash ); + result = SKY_coin_Transaction_HashInner( handle, &hash ); cr_assert( result == SKY_OK ); keys.data = malloc(2 * sizeof(cipher__SecKey)); cr_assert( keys.data != NULL ); @@ -163,10 +165,10 @@ Test(coin_transactions, TestTransactionSignInputs){ keys.len = keys.cap = 2; memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); memcpy(((cipher__SecKey*)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); - result = SKY_coin_Transaction_SignInputs(ptx, keys); + result = SKY_coin_Transaction_SignInputs(handle, keys); cr_assert( result == SKY_OK ); cr_assert(ptx->Sigs.len == 2); - result = SKY_coin_Transaction_HashInner( ptx, &hash2 ); + result = SKY_coin_Transaction_HashInner( handle, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, hash2) ); @@ -196,18 +198,20 @@ Test(coin_transactions, TestTransactionSignInputs){ Test(coin_transactions, TestTransactionHashInner){ int result; - coin__Transaction* ptx; - coin__Transaction* ptx2; - ptx = makeTransaction(); + Transaction__Handle handle1 = 0, handle2 = 0; + coin__Transaction* ptx = NULL; + coin__Transaction* ptx2 = NULL; + ptx = makeTransaction(&handle1); cipher__SHA256 hash, nullHash; - result = SKY_coin_Transaction_HashInner( ptx, &hash ); + result = SKY_coin_Transaction_HashInner( handle1, &hash ); cr_assert( result == SKY_OK ); memset( &nullHash, 0, sizeof(cipher__SHA256) ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); // If tx.In is changed, hash should change - ptx2 = copyTransaction( ptx ); + ptx2 = copyTransaction( handle1, &handle2 ); cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); + cr_assert( ptx != ptx2 ); cr_assert(ptx2->In.len > 0); coin__UxOut uxOut; makeUxOut( &uxOut ); @@ -216,41 +220,44 @@ Test(coin_transactions, TestTransactionHashInner){ cr_assert( result == SKY_OK ); cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); cipher__SHA256 hash1, hash2; - result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); + result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); // If tx.Out is changed, hash should change - ptx2 = copyTransaction( ptx ); + handle2 = 0; + ptx2 = copyTransaction( handle1, &handle2 ); + cr_assert( ptx != ptx2 ); + cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); coin__TransactionOutput* output = ptx2->Out.data; cipher__Address addr; makeAddress( &addr ); memcpy( &output->Address, &addr, sizeof(cipher__Address) ); cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); cr_assert(eq(type(cipher__Address), addr, output->Address)); - result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); + result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); // If tx.Head is changed, hash should not change - ptx2 = copyTransaction( ptx ); + ptx2 = copyTransaction( handle1, &handle2 ); int len = ptx2->Sigs.len; cipher__Sig* newSigs = malloc((len + 1) * sizeof(cipher__Sig)); cr_assert( newSigs != NULL ); registerMemCleanup( newSigs ); memcpy( newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); - result = SKY_coin_Transaction_ResetSignatures(ptx2, len + 1); + result = SKY_coin_Transaction_ResetSignatures(handle2, len + 1); cr_assert( result == SKY_OK ); memcpy( ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); newSigs += len; memset( newSigs, 0, sizeof(cipher__Sig) ); - result = SKY_coin_Transaction_HashInner( ptx, &hash1 ); + result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( ptx2, &hash2 ); + result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); } @@ -258,72 +265,71 @@ Test(coin_transactions, TestTransactionHashInner){ Test(coin_transactions, TestTransactionSerialization){ int result; coin__Transaction* ptx; - ptx = makeTransaction(); + Transaction__Handle handle; + ptx = makeTransaction(&handle); GoSlice_ data; memset( &data, 0, sizeof(GoSlice_) ); - result = SKY_coin_Transaction_Serialize( ptx, &data ); + result = SKY_coin_Transaction_Serialize( handle, &data ); cr_assert( result == SKY_OK ); registerMemCleanup( data.data ); coin__Transaction* ptx2; - ptx2 = makeEmptyTransaction(); + Transaction__Handle handle2; GoSlice d = {data.data, data.len, data.cap}; - result = SKY_coin_TransactionDeserialize(d, ptx2); + result = SKY_coin_TransactionDeserialize(d, &handle2); + cr_assert( result == SKY_OK ); + result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); cr_assert( result == SKY_OK ); cr_assert( eq( type(coin__Transaction), *ptx, *ptx2) ); } Test(coin_transactions, TestTransactionOutputHours){ coin__Transaction* ptx; - ptx = makeEmptyTransaction(); + Transaction__Handle handle; + ptx = makeEmptyTransaction(&handle); cipher__Address addr; makeAddress(&addr); int result; - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 100); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 100); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 200); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 200); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 500); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 500); cr_assert( result == SKY_OK ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 0); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0); cr_assert( result == SKY_OK ); GoUint64 hours; - result = SKY_coin_Transaction_OutputHours(ptx, &hours); + result = SKY_coin_Transaction_OutputHours(handle, &hours); cr_assert( result == SKY_OK ); cr_assert( hours == 800 ); makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); - result = SKY_coin_Transaction_OutputHours(ptx, &hours); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); + result = SKY_coin_Transaction_OutputHours(handle, &hours); cr_assert( result != SKY_OK ); } -/************************ -* TestTransactionsSize not done for missing encoder.Serialize -***********************/ - - Test(coin_transactions, TestTransactionsHashes){ int result; - GoSlice_ transactions, hashes; - memset(&transactions, 0, sizeof(GoSlice_)); - memset(&hashes, 0, sizeof(GoSlice_)); - result = makeTransactions((GoSlice*)&transactions, 4); + GoSlice_ hashes = {NULL, 0, 0}; + Transactions__Handle hTxns; + result = makeTransactions(4, &hTxns); cr_assert( result == SKY_OK ); - result = SKY_coin_Transactions_Hashes(&transactions, &hashes); + result = SKY_coin_Transactions_Hashes(hTxns, &hashes); cr_assert( result == SKY_OK, "SKY_coin_Transactions_Hashes failed" ); registerMemCleanup( hashes.data ); cr_assert( hashes.len == 4 ); - coin__Transaction* pt = transactions.data; cipher__SHA256* ph = hashes.data; cipher__SHA256 hash; for(int i = 0; i < 4; i++){ - result = SKY_coin_Transaction_Hash(pt, &hash); + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Hash(handle, &hash); cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); cr_assert( eq( u8[sizeof(cipher__SHA256)], *ph, hash) ); - pt++; ph++; } } @@ -331,39 +337,45 @@ Test(coin_transactions, TestTransactionsHashes){ Test(coin_transactions, TestTransactionsTruncateBytesTo){ int result; - GoSlice_ transactions, transactions2; - memset(&transactions, 0, sizeof(GoSlice_)); - memset(&transactions2, 0, sizeof(GoSlice_)); - result = makeTransactions((GoSlice*)&transactions, 10); + Transactions__Handle h1, h2; + result = makeTransactions(10, &h1); + cr_assert( result == SKY_OK ); + GoInt length; + result = SKY_coin_Transactions_Length(h1, &length); cr_assert( result == SKY_OK ); int trunc = 0; - coin__Transaction* pTx = transactions.data; GoInt size; - for(int i = 0; i < transactions.len / 2; i++){ - result = SKY_coin_Transaction_Size(pTx, &size); + for(int i = 0; i < length / 2; i++){ + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(h1, i, &handle); + registerHandleClose(handle); + cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_Size(handle, &size); trunc += size; cr_assert( result == SKY_OK, "SKY_coin_Transaction_Size failed" ); - pTx++; } - result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - //registerMemCleanup( transactions2.data ); + registerHandleClose(h2); - cr_assert( transactions2.len == transactions.len / 2 ); - result = SKY_coin_Transactions_Size( &transactions2, &size ); + GoInt length2; + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert( result == SKY_OK ); + cr_assert( length2 == length / 2 ); + result = SKY_coin_Transactions_Size( h2, &size ); cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); cr_assert( trunc == size ); - //freeRegisteredMemCleanup( transactions2.data ); trunc++; - memset(&transactions2, 0, sizeof(GoSlice_)); - result = SKY_coin_Transactions_TruncateBytesTo(&transactions, trunc, &transactions2); + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - //registerMemCleanup( transactions2.data ); + registerHandleClose(h2); // Stepping into next boundary has same cutoff, must exceed - cr_assert( transactions2.len == transactions.len / 2 ); - result = SKY_coin_Transactions_Size( &transactions2, &size ); + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert( result == SKY_OK ); + cr_assert( length2 == length / 2 ); + result = SKY_coin_Transactions_Size( h2, &size ); cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); cr_assert( trunc - 1 == size ); } diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index f8bd0dd6e9..8574c80878 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -16,56 +16,56 @@ Test(coin_transaction, TestTransactionVerify) { int result; coin__Transaction* ptx; - + Transaction__Handle handle; // Mismatch header hash - ptx = makeTransaction(); + ptx = makeTransaction(&handle); memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); // No inputs - ptx = makeTransaction(); - result = SKY_coin_Transaction_ResetInputs(ptx, 0); + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_ResetInputs(handle, 0); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); // No outputs - ptx = makeTransaction(); - result = SKY_coin_Transaction_ResetOutputs(ptx, 0); + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_ResetOutputs(handle, 0); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); //Invalid number of Sigs - ptx = makeTransaction(); - result = SKY_coin_Transaction_ResetSignatures(ptx, 0); + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(ptx, 20); + result = SKY_coin_Transaction_ResetSignatures(handle, 20); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); int MaxUint16 = 0xFFFF; // Too many sigs & inputs - ptx = makeTransaction(); - result = SKY_coin_Transaction_ResetSignatures(ptx, MaxUint16); + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_ResetSignatures(handle, MaxUint16); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetInputs(ptx, MaxUint16); + result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); @@ -74,11 +74,11 @@ Test(coin_transaction, TestTransactionVerify) cipher__SecKey seckey; cipher__SHA256 sha256; makeUxOutWithSecret( &ux, &seckey ); - ptx = makeTransactionFromUxOut( &ux, &seckey); + ptx = makeTransactionFromUxOut( &ux, &seckey, &handle); memcpy(&sha256, ptx->In.data, sizeof(cipher__SHA256)); GoUint16 r; - result = SKY_coin_Transaction_PushInput(ptx, &sha256, &r); - result = SKY_coin_Transaction_ResetSignatures(ptx, 0); + result = SKY_coin_Transaction_PushInput(handle, &sha256, &r); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); cr_assert( result == SKY_OK ); GoSlice seckeys; seckeys.data = malloc(sizeof(cipher__SecKey) * 2); @@ -87,76 +87,76 @@ Test(coin_transaction, TestTransactionVerify) seckeys.len = seckeys.cap = 2; memcpy( seckeys.data, &seckey, sizeof(cipher__SecKey) ); memcpy( ((cipher__SecKey*)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey) ); - result = SKY_coin_Transaction_SignInputs( ptx, seckeys ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_SignInputs( handle, seckeys ); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); //Duplicate outputs - ptx = makeTransaction(); + ptx = makeTransaction(&handle); coin__TransactionOutput* pOutput = ptx->Out.data; cipher__Address addr; memcpy(&addr, &pOutput->Address, sizeof(cipher__Address)); - result = SKY_coin_Transaction_PushOutput(ptx, &addr, pOutput->Coins, pOutput->Hours); + result = SKY_coin_Transaction_PushOutput(handle, &addr, pOutput->Coins, pOutput->Hours); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); // Invalid signature, empty - ptx = makeTransaction(); + ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); // Output coins are 0 - ptx = makeTransaction(); + ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 0; - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow - ptx = makeTransaction(); + ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = MaxUint64 - 3000000; - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result != SKY_OK ); // Output coins are not multiples of 1e6 (valid, decimal restriction is not enforced here) - ptx = makeTransaction(); + ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins += 10; - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(ptx, 0); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); cr_assert( result == SKY_OK ); cipher__PubKey pubkey; result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); cr_assert( result == SKY_OK ); seckeys.data = &seckey; seckeys.len = 1; seckeys.cap = 1; - result = SKY_coin_Transaction_SignInputs(ptx, seckeys); + result = SKY_coin_Transaction_SignInputs(handle, seckeys); cr_assert( result == SKY_OK ); cr_assert( pOutput->Coins % 1000000 != 0 ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result == SKY_OK ); //Valid - ptx = makeTransaction(); + ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 10000000; pOutput++; pOutput->Coins = 1000000; - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Verify(ptx); + result = SKY_coin_Transaction_Verify(handle); cr_assert( result == SKY_OK ); } @@ -164,15 +164,16 @@ Test(coin_transaction, TestTransactionVerify) Test(coin_transaction, TestTransactionPushInput) { int result; + Transaction__Handle handle; coin__Transaction* ptx; coin__UxOut ux; - ptx = makeEmptyTransaction(); + ptx = makeEmptyTransaction(&handle); makeUxOut( &ux ); cipher__SHA256 hash; result = SKY_coin_UxOut_Hash( &ux, &hash ); cr_assert( result == SKY_OK ); GoUint16 r; - result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); + result = SKY_coin_Transaction_PushInput(handle, &hash, &r); cr_assert( result == SKY_OK ); cr_assert( r == 0 ); cr_assert( ptx->In.len == 1 ); @@ -185,14 +186,14 @@ Test(coin_transaction, TestTransactionPushInput) cr_assert(data != NULL); registerMemCleanup(data); memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256) ); - result = SKY_coin_Transaction_ResetInputs(ptx, MaxUint16 + len); + result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16 + len); cr_assert( result == SKY_OK ); memcpy(ptx->In.data, data, len * sizeof(cipher__Sig)); freeRegisteredMemCleanup(data); makeUxOut( &ux ); result = SKY_coin_UxOut_Hash( &ux, &hash ); cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(ptx, &hash, &r); + result = SKY_coin_Transaction_PushInput(handle, &hash, &r); cr_assert( result != SKY_OK ); } @@ -201,12 +202,13 @@ Test(coin_transaction, TestTransactionPushInput) Test(coin_transaction, TestTransactionPushOutput) { int result; + Transaction__Handle handle; coin__Transaction* ptx; - ptx = makeEmptyTransaction(); + ptx = makeEmptyTransaction(&handle); cipher__Address addr; makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( ptx, &addr, 100, 150 ); + result = SKY_coin_Transaction_PushOutput( handle, &addr, 100, 150 ); cr_assert( result == SKY_OK ); cr_assert( ptx->Out.len == 1 ); coin__TransactionOutput* pOutput = ptx->Out.data; @@ -217,7 +219,7 @@ Test(coin_transaction, TestTransactionPushOutput) cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); for(int i = 1; i < 20; i++){ makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( ptx, &addr, i * 100, i * 50 ); + result = SKY_coin_Transaction_PushOutput( handle, &addr, i * 100, i * 50 ); cr_assert( result == SKY_OK ); cr_assert( ptx->Out.len == i + 1 ); pOutput = ptx->Out.data; @@ -229,37 +231,38 @@ Test(coin_transaction, TestTransactionPushOutput) } } - - Test(coin_transaction, TestTransactionHash) { int result; + Transaction__Handle handle; coin__Transaction* ptx; - ptx = makeEmptyTransaction(); + ptx = makeEmptyTransaction(&handle); cipher__SHA256 nullHash, hash1, hash2; memset( &nullHash, 0, sizeof(cipher__SHA256) ); - result = SKY_coin_Transaction_Hash( ptx, &hash1 ); + result = SKY_coin_Transaction_Hash( handle, &hash1 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash1) ) ); - result = SKY_coin_Transaction_HashInner( ptx, &hash2 ); + result = SKY_coin_Transaction_HashInner( handle, &hash2 ); cr_assert( result == SKY_OK ); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash2, hash1) ) ); } + Test(coin_transaction, TestTransactionUpdateHeader) { int result; + Transaction__Handle handle; coin__Transaction* ptx; - ptx = makeTransaction(); + ptx = makeTransaction(&handle); cipher__SHA256 hash, nullHash, hashInner; memcpy(&hash, &ptx->InnerHash, sizeof(cipher__SHA256)); memset(&ptx->InnerHash, 0, sizeof(cipher__SHA256)); memset(&nullHash, 0, sizeof(cipher__SHA256)); - result = SKY_coin_Transaction_UpdateHeader(ptx); + result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash) ) ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash) ); - result = SKY_coin_Transaction_HashInner( ptx, &hashInner ); + result = SKY_coin_Transaction_HashInner( handle, &hashInner ); cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash) ); } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 345ec805eb..5919e244fa 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -80,20 +80,19 @@ int makeAddress(cipher__Address* paddress){ return result; } -coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey ){ +coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* pseckey, Transaction__Handle* handle ){ int result; coin__Transaction* ptransaction = NULL; - Transaction__Handle handle; - result = SKY_coin_Create_Transaction(&handle); + result = SKY_coin_Create_Transaction(handle); cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); - registerHandleClose(handle); - result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + registerHandleClose(*handle); + result = SKY_coin_Get_Transaction_Object( *handle, &ptransaction ); cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); cipher__SHA256 sha256; result = SKY_coin_UxOut_Hash(puxOut, &sha256); cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); GoUint16 r; - result = SKY_coin_Transaction_PushInput(ptransaction, &sha256, &r); + result = SKY_coin_Transaction_PushInput(*handle, &sha256, &r); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushInput failed"); cipher__Address address1, address2; @@ -102,20 +101,20 @@ coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* result = makeAddress(&address2); cr_assert(result == SKY_OK, "makeAddress failed"); - result = SKY_coin_Transaction_PushOutput(ptransaction, &address1, 1000000, 50); + result = SKY_coin_Transaction_PushOutput(*handle, &address1, 1000000, 50); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); - result = SKY_coin_Transaction_PushOutput(ptransaction, &address2, 5000000, 50); + result = SKY_coin_Transaction_PushOutput(*handle, &address2, 5000000, 50); cr_assert(result == SKY_OK, "SKY_coin_Transaction_PushOutput failed"); GoSlice secKeys = { pseckey, 1, 1 }; - result = SKY_coin_Transaction_SignInputs( ptransaction, secKeys ); + result = SKY_coin_Transaction_SignInputs( *handle, secKeys ); cr_assert(result == SKY_OK, "SKY_coin_Transaction_SignInputs failed"); - result = SKY_coin_Transaction_UpdateHeader( ptransaction ); + result = SKY_coin_Transaction_UpdateHeader( *handle ); cr_assert(result == SKY_OK, "SKY_coin_Transaction_UpdateHeader failed"); return ptransaction; } -coin__Transaction* makeTransaction(){ +coin__Transaction* makeTransaction(Transaction__Handle* handle){ int result; coin__UxOut uxOut; cipher__SecKey seckey; @@ -124,51 +123,44 @@ coin__Transaction* makeTransaction(){ result = makeUxOutWithSecret( &uxOut, &seckey ); cr_assert(result == SKY_OK, "makeUxOutWithSecret failed"); - ptransaction = makeTransactionFromUxOut( &uxOut, &seckey ); + ptransaction = makeTransactionFromUxOut( &uxOut, &seckey, handle ); cr_assert(result == SKY_OK, "makeTransactionFromUxOut failed"); return ptransaction; } -coin__Transaction* makeEmptyTransaction(){ +coin__Transaction* makeEmptyTransaction(Transaction__Handle* handle){ int result; coin__Transaction* ptransaction = NULL; - Transaction__Handle handle; - result = SKY_coin_Create_Transaction(&handle); + result = SKY_coin_Create_Transaction(handle); cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); - registerHandleClose(handle); - result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + registerHandleClose(*handle); + result = SKY_coin_Get_Transaction_Object( *handle, &ptransaction ); cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); return ptransaction; } -int makeTransactions(GoSlice* transactions, int n){ - void * data = malloc(sizeof(coin__Transaction) * n); - if(data == NULL) - return SKY_ERROR; - registerMemCleanup(data); - coin__Transaction* ptransaction = (coin__Transaction*)data; - int i; - int result = SKY_OK; - for( i = 0; i < n; i++){ - coin__Transaction* p = makeTransaction(); - memcpy(ptransaction, p, sizeof(coin__Transaction)); - ptransaction++; +int makeTransactions(int n, Transactions__Handle* handle){ + int result = SKY_coin_Create_Transactions(handle); + cr_assert(result == SKY_OK); + registerHandleClose(*handle); + for(int i = 0; i < n; i++){ + Transaction__Handle thandle; + makeTransaction(&thandle); + registerHandleClose(thandle); + result = SKY_coin_Transactions_Add(*handle, thandle); + cr_assert(result == SKY_OK); } - transactions->data = data; - transactions->len = n; - transactions->cap = n; return result; } -coin__Transaction* copyTransaction(coin__Transaction* pt1){ - Transaction__Handle handle = 0; +coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Handle* handle2){ coin__Transaction* ptransaction = NULL; int result = 0; - result = SKY_coin_Transaction_Copy(pt1, &handle); + result = SKY_coin_Transaction_Copy(handle, handle2); cr_assert(result == SKY_OK); - registerHandleClose(handle); - result = SKY_coin_Get_Transaction_Object( handle, &ptransaction ); + registerHandleClose(*handle2); + result = SKY_coin_Get_Transaction_Object( *handle2, &ptransaction ); cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); return ptransaction; } From 8c8e110e85ee0c563e45fde78325f5771ef81baf Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 10 Jun 2018 23:26:55 +0000 Subject: [PATCH 035/399] [libc] refs #1191. Use handles for coin.Block functions. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 15 +++ lib/cgo/coin.block.go | 203 +++++++++++++++++++++++++------ lib/cgo/coin.transactions.go | 15 +++ lib/cgo/libsky_handle.go | 42 +++++++ lib/cgo/tests/check_coin.block.c | 170 ++++++++++++++++---------- 5 files changed, 342 insertions(+), 103 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 10de3f9bcc..21e9be4759 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -254,6 +254,21 @@ typedef Handle Transaction__Handle; */ typedef Handle Transactions__Handle; +/** + * Memory handle to access to coin.Block + */ +typedef Handle Block__Handle; + +/** + * Memory handle to access to coin.SignedBlock + */ +typedef Handle SignedBlock__Handle; + +/** + * Memory handle to access to coin.BlockBody + */ +typedef Handle BlockBody__Handle; + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index be5479466f..b7660d4ae7 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -18,7 +18,7 @@ import ( import "C" //export SKY_coin_NewBlock -func SKY_coin_NewBlock(_b *C.coin__Block, _currentTime uint64, _hash *C.cipher__SHA256, _txns *C.coin__Transactions, _fee uint64, _arg2 *C.coin__Block) (____error_code uint32) { +func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, _fee uint64, _arg2 *C.Block__Handle) (____error_code uint32) { feeCalculator := func(t *coin.Transaction) (uint64, error) { return _fee, nil } @@ -27,12 +27,21 @@ func SKY_coin_NewBlock(_b *C.coin__Block, _currentTime uint64, _hash *C.cipher__ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } hash := *(*cipher.SHA256)(unsafe.Pointer(_hash)) - txns := *(*coin.Transactions)(unsafe.Pointer(_txns)) - __arg2, ____return_err := coin.NewBlock(b, _currentTime, hash, txns, feeCalculator) + txns, ok := lookupTransactionsHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalculator) + ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.coin__Block)(unsafe.Pointer(__arg2)) + *_arg2 = registerBlockHandle(__arg2) } return } @@ -53,7 +62,7 @@ func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.ci } //export SKY_coin_NewGenesisBlock -func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.coin__Block) (____error_code uint32) { +func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.Block__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -64,111 +73,143 @@ func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _t __arg2, ____return_err := coin.NewGenesisBlock(genesisAddr, genesisCoins, timestamp) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.coin__Block)(unsafe.Pointer(__arg2)) + *_arg2 = registerBlockHandle(__arg2) } return } //export SKY_coin_Block_HashHeader -func SKY_coin_Block_HashHeader(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.HashHeader() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Block_PreHashHeader -func SKY_coin_Block_PreHashHeader(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.PreHashHeader() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Block_Time -func SKY_coin_Block_Time(_b *C.coin__Block, _arg0 *uint64) (____error_code uint32) { +func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.Time() *_arg0 = __arg0 return } //export SKY_coin_Block_Seq -func SKY_coin_Block_Seq(_b *C.coin__Block, _arg0 *uint64) (____error_code uint32) { +func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.Seq() *_arg0 = __arg0 return } //export SKY_coin_Block_HashBody -func SKY_coin_Block_HashBody(_b *C.coin__Block, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.HashBody() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_Block_Size -func SKY_coin_Block_Size(_b *C.coin__Block, _arg0 *int) (____error_code uint32) { +func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.Size() *_arg0 = __arg0 return } //export SKY_coin_Block_String -func SKY_coin_Block_String(_b *C.coin__Block, _arg0 *C.GoString_) (____error_code uint32) { +func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := b.String() copyString(__arg0, _arg0) return } //export SKY_coin_Block_GetTransaction -func SKY_coin_Block_GetTransaction(_b *C.coin__Block, _txHash *C.cipher__SHA256, _arg1 *C.coin__Transaction, _arg2 *bool) (____error_code uint32) { +func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256, _arg1 *C.Transaction__Handle, _arg2 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - b := *(*coin.Block)(unsafe.Pointer(_b)) + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + return + } txHash := *(*cipher.SHA256)(unsafe.Pointer(_txHash)) __arg1, __arg2 := b.GetTransaction(txHash) - *_arg1 = *(*C.coin__Transaction)(unsafe.Pointer(&__arg1)) + *_arg1 = registerTransactionHandle(&__arg1) *_arg2 = __arg2 return } //export SKY_coin_NewBlockHeader -func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body *C.coin__BlockBody, _arg4 *C.coin__BlockHeader) (____error_code uint32) { +func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body C.BlockBody__Handle, _arg4 *C.coin__BlockHeader) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -177,8 +218,12 @@ func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA2 uxHash := *(*cipher.SHA256)(unsafe.Pointer(_uxHash)) currentTime := _currentTime fee := _fee - body := *(*coin.BlockBody)(unsafe.Pointer(_body)) - __arg4 := coin.NewBlockHeader(prev, uxHash, currentTime, fee, body) + body, ok := lookupBlockBodyHandle(_body) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg4 := coin.NewBlockHeader(prev, uxHash, currentTime, fee, *body) *_arg4 = *(*C.coin__BlockHeader)(unsafe.Pointer(&__arg4)) return } @@ -220,67 +265,145 @@ func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) ( } //export SKY_coin_BlockBody_Hash -func SKY_coin_BlockBody_Hash(_bb *C.coin__BlockBody, _arg0 *C.cipher__SHA256) (____error_code uint32) { +func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) - __arg0 := bb.Hash() + body, ok := lookupBlockBodyHandle(_body) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg0 := body.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) return } //export SKY_coin_BlockBody_Size -func SKY_coin_BlockBody_Size(_bb *C.coin__BlockBody, _arg0 *int) (____error_code uint32) { +func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) + bb, ok := lookupBlockBodyHandle(*_bb) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := bb.Size() *_arg0 = __arg0 return } //export SKY_coin_BlockBody_Bytes -func SKY_coin_BlockBody_Bytes(_bb *C.coin__BlockBody, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - bb := *(*coin.BlockBody)(unsafe.Pointer(_bb)) + bb, ok := lookupBlockBodyHandle(_bb) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := bb.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return } //export SKY_coin_CreateUnspents -func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx *C.coin__Transaction, _arg2 *C.coin__UxArray) (____error_code uint32) { +func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _arg2 *C.coin__UxArray) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) - tx := *(*coin.Transaction)(unsafe.Pointer(_tx)) - __arg2 := coin.CreateUnspents(bh, tx) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg2 := coin.CreateUnspents(bh, *tx) copyToGoSlice(reflect.ValueOf(__arg2), _arg2) return } //export SKY_coin_CreateUnspent -func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx *C.coin__Transaction, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { +func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) - tx := *(*coin.Transaction)(unsafe.Pointer(_tx)) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_ERROR + return + } outIndex := _outIndex - __arg3, ____return_err := coin.CreateUnspent(bh, tx, outIndex) + __arg3, ____return_err := coin.CreateUnspent(bh, *tx, outIndex) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg3 = *(*C.coin__UxOut)(unsafe.Pointer(&__arg3)) } return } + +//export SKY_coin_GetBlockObject +func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + } else { + *_p = (*C.coin__Block)(unsafe.Pointer(b)) + } + return +} + +//export SKY_coin_GetBlockBody +func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_ERROR + } else { + *_p = registerBlockBodyHandle(&b.Body) + } + return +} + +//export SKY_coin_NewEmptyBlock +func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle , handle *C.Block__Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } + body := coin.BlockBody{ + Transactions: *txns, + } + block := coin.Block{ + Body: body, + Head: coin.BlockHeader{ + Version: 0x02, + Time: 100, + BkSeq: 0, + Fee: 10, + PrevHash: cipher.SHA256{}, + BodyHash: body.Hash(), + }} + *handle = registerBlockHandle(&block) + return +} diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index bdad865b28..a7866ccd84 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -395,6 +395,21 @@ func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_cod return SKY_OK } +//export SKY_coin_Get_Transactions_Object +func SKY_coin_Get_Transactions_Object(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + ptx, ok := lookupTransactionsHandle(handle) + if !ok { + ____error_code = SKY_ERROR + } else { + *_pptx = (*C.coin__Transactions)(unsafe.Pointer(ptx)) + } + return +} + //export SKY_coin_Transactions_Length func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) (____error_code uint32) { ____error_code = 0 diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 70457d9477..1b65d766e8 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -259,6 +259,48 @@ func lookupTransactionsHandle(handle C.Transactions__Handle) (*coin.Transactions return nil, false } +func registerBlockHandle(obj *coin.Block) C.Block__Handle { + return (C.Block__Handle)(registerHandle(obj)) +} + +func lookupBlockHandle(handle C.Block__Handle) (*coin.Block, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Block); isOK { + return obj, true + } + } + return nil, false +} + +func registerSignedBlockHandle(obj *coin.SignedBlock) C.SignedBlock__Handle { + return (C.SignedBlock__Handle)(registerHandle(obj)) +} + +func lookupSignedBlockHandle(handle C.SignedBlock__Handle) (*coin.SignedBlock, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.SignedBlock); isOK { + return obj, true + } + } + return nil, false +} + +func registerBlockBodyHandle(obj *coin.BlockBody) C.BlockBody__Handle { + return (C.BlockBody__Handle)(registerHandle(obj)) +} + +func lookupBlockBodyHandle(handle C.BlockBody__Handle) (*coin.BlockBody, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.BlockBody); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index ae0d83ce85..4ba0c1995b 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -15,39 +15,68 @@ TestSuite(coin_block, .init = setup, .fini = teardown); -int makeNewBlock(cipher__SHA256* uxHash, coin__Block* newBlock){ +Transactions__Handle makeTestTransactions(){ + Transactions__Handle transactions; + Transaction__Handle transaction; + + int result = SKY_coin_Create_Transactions(&transactions); + cr_assert(result == SKY_OK, "SKY_coin_Create_Transactions failed"); + registerHandleClose( transactions ); + result = SKY_coin_Create_Transaction(&transaction); + cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); + registerHandleClose( transaction ); + result = SKY_coin_Transactions_Add(transactions, transaction); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Add failed"); + return transactions; +} + +int makeNewBlock(cipher__SHA256* uxHash, Block__Handle* newBlock){ int result; cipher__SHA256 bodyhash; - coin__Block block; - coin__Transactions transactions; - - memset(&block, 0, sizeof(coin__Block)); - memset(&transactions, 0, sizeof(coin__Transactions)); - memset(newBlock, 0, sizeof(coin__Block)); - - block.Head.Version = 0x02; - block.Head.Time = 100; - block.Head.BkSeq = 0; - block.Head.Fee = 10; - result = SKY_coin_BlockBody_Hash(&block.Body, &bodyhash); + BlockBody__Handle block; + Transactions__Handle transactions = makeTestTransactions(); + + result = SKY_coin_NewEmptyBlock(transactions, &block); + cr_assert(result == SKY_OK, "SKY_coin_NewEmptyBlock failed"); + registerHandleClose( block ); + coin__Block* pBlock; + result = SKY_coin_GetBlockObject(block, &pBlock); + cr_assert(result == SKY_OK, "SKY_coin_Get_Block_Object failed"); + + pBlock->Head.Version = 0x02; + pBlock->Head.Time = 100; + pBlock->Head.BkSeq = 0; + pBlock->Head.Fee = 10; + BlockBody__Handle body; + result = SKY_coin_GetBlockBody(block, &body); + cr_assert(result == SKY_OK, "SKY_coin_Get_Block_Body failed"); + result = SKY_coin_BlockBody_Hash(body, &bodyhash); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - result = SKY_coin_NewBlock(&block, 100 + 200, uxHash, &transactions, 0, newBlock); + result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, 0, newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); + registerHandleClose( *newBlock ); return result; } Test(coin_block, TestNewBlock) { - coin__Block prevBlock; - coin__Block newBlock; - coin__Transactions transactions; - memset(&prevBlock, 0, sizeof(coin__Block)); - memset(&newBlock, 0, sizeof(coin__Block)); - memset(&transactions, 0, sizeof(coin__Transactions)); - - prevBlock.Head.Version = 0x02; - prevBlock.Head.Time = 100; - prevBlock.Head.BkSeq = 98; - int result; + Block__Handle prevBlock = 0; + Block__Handle newBlock = 0; + coin__Block* pPrevBlock = NULL; + coin__Block* pNewBlock = NULL; + int result = 0; + + Transactions__Handle transactions = makeTestTransactions(); + result = SKY_coin_NewEmptyBlock(transactions, &prevBlock); + cr_assert(result == SKY_OK, "SKY_coin_NewEmptyBlock failed"); + registerHandleClose( prevBlock ); + coin__Block* pBlock; + result = SKY_coin_GetBlockObject(prevBlock, &pPrevBlock); + cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); + + pPrevBlock->Head.Version = 0x02; + pPrevBlock->Head.Time = 100; + pPrevBlock->Head.BkSeq = 98; + GoSlice slice; memset(&slice, 0, sizeof(GoSlice)); @@ -59,35 +88,42 @@ Test(coin_block, TestNewBlock) { result = SKY_cipher_SumSHA256( slice, &hash ); cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); - result = SKY_coin_NewBlock(&prevBlock, 133, &hash, NULL, 0, &newBlock); + result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, 0, &newBlock); cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); - transactions.data = malloc(sizeof(coin__Transaction)); - registerMemCleanup(transactions.data); - transactions.len = 1; - transactions.cap = 1; - memset(transactions.data, 0, sizeof(coin__Transaction)); + registerHandleClose( newBlock ); + + transactions = 0; + Transaction__Handle tx = 0; + result = SKY_coin_Create_Transactions(&transactions); + cr_assert(result == SKY_OK, "SKY_coin_Create_Transactions failed"); + registerHandleClose(transactions); + makeEmptyTransaction(&tx); + registerHandleClose(tx); + result = SKY_coin_Transactions_Add(transactions, tx); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Add failed"); + GoUint64 fee = 121; GoUint64 currentTime = 133; - result = SKY_coin_NewBlock(&prevBlock, currentTime, &hash, &transactions, fee, &newBlock); + result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fee, &newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); - cr_assert( eq( type(GoSlice), *((GoSlice*)&newBlock.Body.Transactions), *((GoSlice*)&transactions)) ); - cr_assert( eq(newBlock.Head.Fee, fee * (GoUint64)( transactions.len ))); - cr_assert( eq(newBlock.Head.Time, currentTime)); - cr_assert( eq(newBlock.Head.BkSeq, prevBlock.Head.BkSeq + 1)); - cr_assert( eq( u8[sizeof(cipher__SHA256)], newBlock.Head.UxHash, hash) ); - - coin__BlockBody body; - memset(&body, 0, sizeof(coin__BlockBody)); - body.Transactions.data = transactions.data; - body.Transactions.len = transactions.len; - body.Transactions.cap = transactions.cap; - cr_assert( eq(type(coin__BlockBody), newBlock.Body, body) ); + registerHandleClose(newBlock); + result = SKY_coin_GetBlockObject(newBlock, &pNewBlock); + cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); + coin__Transactions* pTransactions = NULL; + SKY_coin_Get_Transactions_Object(transactions, &pTransactions); + cr_assert( eq( type(GoSlice), *((GoSlice*)&pNewBlock->Body.Transactions), *((GoSlice*)pTransactions)) ); + cr_assert( eq(pNewBlock->Head.Fee, fee * (GoUint64)( pTransactions->len ))); + cr_assert( eq(pNewBlock->Head.Time, currentTime)); + cr_assert( eq(pNewBlock->Head.BkSeq, pPrevBlock->Head.BkSeq + 1)); + cr_assert( eq( u8[sizeof(cipher__SHA256)], pNewBlock->Head.UxHash, hash) ); } + Test(coin_block, TestBlockHashHeader){ int result; - coin__Block block; + Block__Handle block = 0; + coin__Block* pBlock = NULL; GoSlice slice; memset(&slice, 0, sizeof(GoSlice)); cipher__SHA256 hash; @@ -99,20 +135,23 @@ Test(coin_block, TestBlockHashHeader){ cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); result = makeNewBlock( &hash, &block ); cr_assert(result == SKY_OK, "makeNewBlock failed"); + result = SKY_coin_GetBlockObject(block, &pBlock); + cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed, block handle : %d", block); cipher__SHA256 hash1, hash2; - result = SKY_coin_Block_HashHeader(&block, &hash1); + result = SKY_coin_Block_HashHeader(block, &hash1); cr_assert(result == SKY_OK, "SKY_coin_Block_HashHeader failed"); - result = SKY_coin_BlockHeader_Hash(&block.Head, &hash2); + result = SKY_coin_BlockHeader_Hash(&pBlock->Head, &hash2); cr_assert(result == SKY_OK, "SKY_coin_BlockHeader_Hash failed"); cr_assert( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ); memset(&hash2, 0, sizeof(cipher__SHA256)); cr_assert( not( eq( u8[sizeof(cipher__SHA256)],hash1, hash2) ) ); } + Test(coin_block, TestBlockHashBody){ int result; - coin__Block block; + Block__Handle block = 0; GoSlice slice; memset(&slice, 0, sizeof(GoSlice)); cipher__SHA256 hash; @@ -126,9 +165,12 @@ Test(coin_block, TestBlockHashBody){ cr_assert(result == SKY_OK, "makeNewBlock failed"); cipher__SHA256 hash1, hash2; - result = SKY_coin_Block_HashBody(&block, &hash1); + result = SKY_coin_Block_HashBody(block, &hash1); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - result = SKY_coin_BlockBody_Hash(&block.Body, &hash2); + BlockBody__Handle blockBody = 0; + result = SKY_coin_GetBlockBody(block, &blockBody); + cr_assert(result == SKY_OK, "SKY_coin_GetBlockBody failed"); + result = SKY_coin_BlockBody_Hash(blockBody, &hash2); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); } @@ -140,25 +182,27 @@ Test(coin_block, TestNewGenesisBlock){ GoUint64 genTime = 1000; GoUint64 genCoins = 1000 * 1000 * 1000; GoUint64 genCoinHours = 1000 * 1000; - coin__Block block; + Block__Handle block = 0; + coin__Block* pBlock = NULL; - memset(&block, 0, sizeof(coin__Block)); int result = makeKeysAndAddress(&pubkey, &seckey, &address); cr_assert(result == SKY_OK, "makeKeysAndAddress failed"); result = SKY_coin_NewGenesisBlock(&address, genCoins, genTime, &block); cr_assert(result == SKY_OK, "SKY_coin_NewGenesisBlock failed"); + result = SKY_coin_GetBlockObject(block, &pBlock); + cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); cipher__SHA256 nullHash; memset(&nullHash, 0, sizeof(cipher__SHA256)); - cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, block.Head.PrevHash) ); - cr_assert( genTime == block.Head.Time ); - cr_assert( 0 == block.Head.BkSeq ); - cr_assert( 0 == block.Head.Version ); - cr_assert( 0 == block.Head.Fee ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, block.Head.UxHash) ); - - cr_assert( 1 == block.Body.Transactions.len ); - coin__Transaction* ptransaction = (coin__Transaction*)block.Body.Transactions.data; + cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, pBlock->Head.PrevHash) ); + cr_assert( genTime == pBlock->Head.Time ); + cr_assert( 0 == pBlock->Head.BkSeq ); + cr_assert( 0 == pBlock->Head.Version ); + cr_assert( 0 == pBlock->Head.Fee ); + cr_assert( eq( u8[sizeof(cipher__SHA256)], nullHash, pBlock->Head.UxHash) ); + + cr_assert( 1 == pBlock->Body.Transactions.len ); + coin__Transaction* ptransaction = (coin__Transaction*)pBlock->Body.Transactions.data; cr_assert( 0 == ptransaction->In.len); cr_assert( 0 == ptransaction->Sigs.len); cr_assert( 1 == ptransaction->Out.len); @@ -198,7 +242,7 @@ Test(coin_block, TestCreateUnspent){ int tests_count = sizeof(t) / sizeof(testcase_unspent); for( int i = 0; i < tests_count; i++){ memset(&ux, 0, sizeof(coin__UxOut)); - result = SKY_coin_CreateUnspent( &bh, ptx, t[i].index, &ux ); + result = SKY_coin_CreateUnspent( &bh, handle, t[i].index, &ux ); if( t[i].failure ){ cr_assert( result == SKY_ERROR, "SKY_coin_CreateUnspent should have failed" ); continue; @@ -236,7 +280,7 @@ Test(coin_block, TestCreateUnspents){ bh.BkSeq = 1; coin__UxArray uxs = {NULL, 0, 0}; - result = SKY_coin_CreateUnspents(&bh, ptx, &uxs); + result = SKY_coin_CreateUnspents(&bh, handle, &uxs); cr_assert( result == SKY_OK, "SKY_coin_CreateUnspents failed" ); registerMemCleanup( uxs.data ); cr_assert( uxs.len == 1 ); From 5370b8c8f8044d92fca98b2be222ec5ea03f266d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 11 Jun 2018 09:45:18 +0000 Subject: [PATCH 036/399] [libc] refs #1191. Fixed lint issues. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/coin.block.go | 2 +- lib/cgo/coin.transactions.go | 14 +++++++------- lib/cgo/libsky_handle.go | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index b7660d4ae7..08ee6f8ae2 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -381,7 +381,7 @@ func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____err } //export SKY_coin_NewEmptyBlock -func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle , handle *C.Block__Handle) (____error_code uint32) { +func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle, handle *C.Block__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index a7866ccd84..9b73af741f 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -44,11 +44,11 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact ntx.Type = tx.Type ntx.InnerHash = tx.InnerHash ntx.Sigs = make([]cipher.Sig, 0) - ntx.Sigs = append( ntx.Sigs, tx.Sigs... ) + ntx.Sigs = append(ntx.Sigs, tx.Sigs...) ntx.In = make([]cipher.SHA256, 0) - ntx.In = append( ntx.In, tx.In... ) + ntx.In = append(ntx.In, tx.In...) ntx.Out = make([]coin.TransactionOutput, 0) - ntx.Out = append( ntx.Out, tx.Out... ) + ntx.Out = append(ntx.Out, tx.Out...) *handle2 = registerTransactionHandle(&ntx) return } @@ -441,8 +441,8 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han ____error_code = SKY_ERROR return } - *txns = append( *txns, *tx ) - result := overwriteHandle( tsh, txns ) + *txns = append(*txns, *tx) + result := overwriteHandle(tsh, txns) if !result { ____error_code = SKY_ERROR } @@ -460,7 +460,7 @@ func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transa ____error_code = SKY_ERROR return } - if( n >= len(*txns)){ + if n >= len(*txns) { ____error_code = SKY_ERROR return } @@ -514,7 +514,7 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int } size := _size __arg1 := txns.TruncateBytesTo(size) - *_arg1 = registerTransactionsHandle( &__arg1 ) + *_arg1 = registerTransactionsHandle(&__arg1) return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 1b65d766e8..86ed2445f1 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -14,12 +14,11 @@ import ( api "github.com/skycoin/skycoin/src/api" webrpc "github.com/skycoin/skycoin/src/api/webrpc" cli "github.com/skycoin/skycoin/src/cli" + "github.com/skycoin/skycoin/src/coin" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" - "github.com/skycoin/skycoin/src/coin" ) - type Handle uint64 var ( @@ -40,7 +39,7 @@ func lookupHandle(handle C.Handle) (interface{}, bool) { return obj, ok } -func overwriteHandle(handle C.Handle, obj interface{}) bool{ +func overwriteHandle(handle C.Handle, obj interface{}) bool { _, ok := handleMap[Handle(handle)] if ok { handleMap[Handle(handle)] = obj From 15514cd34a28d8e0ac27699121b0545d27aaa326 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 11 Jun 2018 10:09:01 +0000 Subject: [PATCH 037/399] [libc] refs #1191. Removed api__ClientError typedef and related exported function. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/api.client.go.h | 5 ----- lib/cgo/api.client.go | 12 ------------ 2 files changed, 17 deletions(-) diff --git a/include/api.client.go.h b/include/api.client.go.h index aecac9544a..7f5db8a97f 100644 --- a/include/api.client.go.h +++ b/include/api.client.go.h @@ -1,8 +1,3 @@ -typedef struct{ - GoString_ Status; - GoInt_ StatusCode; - GoString_ Message; -} api__ClientError; typedef struct{ GoString_ ID; GoSlice_ Addresses; diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 883184b2ed..023f15c23f 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -15,18 +15,6 @@ import ( */ import "C" -//export SKY_api_ClientError_Error -func SKY_api_ClientError_Error(_e *C.api__ClientError, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - e := *(*api.ClientError)(unsafe.Pointer(_e)) - __arg0 := e.Error() - copyString(__arg0, _arg0) - return -} - //export SKY_api_NewClient func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code uint32) { ____error_code = 0 From dfdbc9492635e8a6553eecea34e022829c9df4be Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 11 Jun 2018 10:29:39 +0000 Subject: [PATCH 038/399] [libc] Removed typedefs api__CoinSupply, api__muxConfig, webrpc__ClientError. b64_decode returns int instead of unsigned int. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/api.explorer.go.h | 4 ++-- include/api.http.go.h | 6 ------ include/api.webrpc.client.go.h | 6 +----- include/base64.h | 4 ++-- lib/cgo/api.webrpc.client.go | 12 ------------ lib/cgo/tests/testutils/base64.c | 15 +-------------- 6 files changed, 6 insertions(+), 41 deletions(-) diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h index 6017b5acc0..c1ea85d870 100644 --- a/include/api.explorer.go.h +++ b/include/api.explorer.go.h @@ -1,4 +1,4 @@ -typedef struct{ +/*typedef struct{ GoString_ CurrentSupply; GoString_ TotalSupply; GoString_ MaxSupply; @@ -6,7 +6,7 @@ typedef struct{ GoString_ TotalCoinHourSupply; GoSlice_ UnlockedAddresses; GoSlice_ LockedAddresses; -} api__CoinSupply; +} api__CoinSupply;*/ typedef struct{ visor__Richlist Richlist; } api__Richlist; diff --git a/include/api.http.go.h b/include/api.http.go.h index f31f3bb717..e69de29bb2 100644 --- a/include/api.http.go.h +++ b/include/api.http.go.h @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ host; - GoString_ appLoc; - BOOL enableGUI; - BOOL enableJSON20RPC; -} api__muxConfig; diff --git a/include/api.webrpc.client.go.h b/include/api.webrpc.client.go.h index c367e9f68c..8b13789179 100644 --- a/include/api.webrpc.client.go.h +++ b/include/api.webrpc.client.go.h @@ -1,5 +1 @@ -typedef struct{ - GoString_ Status; - GoInt_ StatusCode; - GoString_ Message; -} webrpc__ClientError; + diff --git a/include/base64.h b/include/base64.h index 9dc9c4ecc7..04393042aa 100644 --- a/include/base64.h +++ b/include/base64.h @@ -31,7 +31,7 @@ unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned c // in_len : number of bytes to be decoded. // out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary // returns size of output excluding null byte -unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out); +int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out); // file-version b64_encode // Input : filenames @@ -42,5 +42,5 @@ unsigned int b64_encodef(char *InFile, char *OutFile); // Input : filenames // returns size of output int b64_decodef(char *InFile, char *OutFile); - + //unsigned int b64_encode_string(const unsigned char* in, unsigned int in_len, unsigned char* out); diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index a7da5e1f6c..31ed8e63d0 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -17,18 +17,6 @@ import ( */ import "C" -//export SKY_webrpc_ClientError_Error -func SKY_webrpc_ClientError_Error(_e *C.webrpc__ClientError, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - e := *(*webrpc.ClientError)(unsafe.Pointer(_e)) - __arg0 := e.Error() - copyString(__arg0, _arg0) - return -} - //export SKY_webrpc_NewClient func SKY_webrpc_NewClient(_addr string, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { ____error_code = 0 diff --git a/lib/cgo/tests/testutils/base64.c b/lib/cgo/tests/testutils/base64.c index f77da4121e..c39b11673c 100644 --- a/lib/cgo/tests/testutils/base64.c +++ b/lib/cgo/tests/testutils/base64.c @@ -83,7 +83,7 @@ unsigned int b64_encode(const unsigned char * in, unsigned int in_len, unsigned return k; } -unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out) { +int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out) { unsigned int i=0, j=0, k=0, s[4]; for (i=0;i Date: Mon, 11 Jun 2018 11:47:30 +0000 Subject: [PATCH 039/399] [libc] refs #1191. Added handles for CreatedTransaction__Handle and CreatedTransactionOutput__Handle. Applied Transaction__Handle to all exported functions. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 10 ++++++++++ lib/cgo/api.spend.go | 28 ++++++++++++++++++++-------- lib/cgo/api.webrpc.client.go | 9 ++++++--- lib/cgo/cli.create_rawtx.go | 16 ++++++++-------- lib/cgo/libsky_handle.go | 28 ++++++++++++++++++++++++++++ lib/cgo/util.fee.fee.go | 16 ++++++++++++---- 6 files changed, 84 insertions(+), 23 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 21e9be4759..787002b6e7 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -254,6 +254,16 @@ typedef Handle Transaction__Handle; */ typedef Handle Transactions__Handle; +/** + * Memory handle to access to api.CreatedTransaction + */ +typedef Handle CreatedTransaction__Handle; + +/** + * Memory handle to access to api.CreatedTransactionOutput + */ +typedef Handle CreatedTransactionOutput__Handle; + /** * Memory handle to access to coin.Block */ diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index a042e4a26a..f4621519d4 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -19,12 +19,16 @@ import ( import "C" //export SKY_api_NewCreateTransactionResponse -func SKY_api_NewCreateTransactionResponse(_txn *C.coin__Transaction, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreateTransactionResponse) (____error_code uint32) { +func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreateTransactionResponse) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(_txn) + if !ok { + ____error_code = SKY_ERROR + return + } inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) __arg2, ____return_err := api.NewCreateTransactionResponse(txn, inputs) ____error_code = libErrorCode(____return_err) @@ -35,32 +39,40 @@ func SKY_api_NewCreateTransactionResponse(_txn *C.coin__Transaction, _inputs []C } //export SKY_api_NewCreatedTransaction -func SKY_api_NewCreatedTransaction(_txn *C.coin__Transaction, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreatedTransaction) (____error_code uint32) { +func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreatedTransaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txn := (*coin.Transaction)(unsafe.Pointer(_txn)) + txn, ok := lookupTransactionHandle(_txn) + if !ok { + ____error_code = SKY_ERROR + return + } inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) __arg2, ____return_err := api.NewCreatedTransaction(txn, inputs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.api__CreatedTransaction)(unsafe.Pointer(__arg2)) + *_arg2 = registerCreatedTransactionHandle(__arg2) } return } //export SKY_api_CreatedTransaction_ToTransaction -func SKY_api_CreatedTransaction_ToTransaction(_r *C.api__CreatedTransaction, _arg0 *C.coin__Transaction) (____error_code uint32) { +func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _arg0 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - r := (*api.CreatedTransaction)(unsafe.Pointer(_r)) + r, ok := lookupCreatedTransactionHandle(_r) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, ____return_err := r.ToTransaction() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = *(*C.coin__Transaction)(unsafe.Pointer(__arg0)) + *_arg0 = registerTransactionHandle(__arg0) } return } diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 31ed8e63d0..2fa7bdcf71 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -5,7 +5,6 @@ import ( "unsafe" webrpc "github.com/skycoin/skycoin/src/api/webrpc" - coin "github.com/skycoin/skycoin/src/coin" ) /* @@ -92,7 +91,7 @@ func SKY_webrpc_Client_InjectTransactionString(_c C.WebRpcClient__Handle, _rawtx } //export SKY_webrpc_Client_InjectTransaction -func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx *C.coin__Transaction, _arg1 *C.GoString_) (____error_code uint32) { +func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -102,7 +101,11 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx *C.coin_ ____error_code = SKY_ERROR return } - tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_ERROR + return + } __arg1, ____return_err := c.InjectTransaction(tx) ____error_code = libErrorCode(____return_err) if ____return_err == nil { diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index 64403e785b..9e869dbb90 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -19,7 +19,7 @@ import ( import "C" //export SKY_cli_CreateRawTxFromWallet -func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -41,13 +41,13 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA __arg4, ____return_err := cli.CreateRawTxFromWallet(c, walletFile, chgAddr, toAddrs, *pr) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg4 = *(*C.coin__Transaction)(unsafe.Pointer(__arg4)) + *_arg4 = registerTransactionHandle(__arg4) } return } //export SKY_cli_CreateRawTxFromAddress -func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -69,13 +69,13 @@ func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFil __arg4, ____return_err := cli.CreateRawTxFromAddress(c, addr, walletFile, chgAddr, toAddrs, *pr) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg4 = *(*C.coin__Transaction)(unsafe.Pointer(__arg4)) + *_arg4 = registerTransactionHandle(__arg4) } return } //export SKY_cli_CreateRawTx -func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAddrs []string, _chgAddr string, _toAddrs []C.cli__SendAmount, _password []byte, _arg6 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAddrs []string, _chgAddr string, _toAddrs []C.cli__SendAmount, _password []byte, _arg6 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -97,13 +97,13 @@ func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAd __arg6, ____return_err := cli.CreateRawTx(c, wlt, inAddrs, chgAddr, toAddrs, password) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg6 = *(*C.coin__Transaction)(unsafe.Pointer(__arg6)) + *_arg6 = registerTransactionHandle(__arg6) } return } //export SKY_cli_NewTransaction -func SKY_cli_NewTransaction(_utxos []C.wallet__UxBalance, _keys []C.cipher__SecKey, _outs []C.coin__TransactionOutput, _arg3 *C.coin__Transaction) (____error_code uint32) { +func SKY_cli_NewTransaction(_utxos []C.wallet__UxBalance, _keys []C.cipher__SecKey, _outs []C.coin__TransactionOutput, _arg3 *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -112,6 +112,6 @@ func SKY_cli_NewTransaction(_utxos []C.wallet__UxBalance, _keys []C.cipher__SecK keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) outs := *(*[]coin.TransactionOutput)(unsafe.Pointer(&_outs)) __arg3 := cli.NewTransaction(utxos, keys, outs) - *_arg3 = *(*C.coin__Transaction)(unsafe.Pointer(__arg3)) + *_arg3 = registerTransactionHandle(__arg3) return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 86ed2445f1..b964ed27cf 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -300,6 +300,34 @@ func lookupBlockBodyHandle(handle C.BlockBody__Handle) (*coin.BlockBody, bool) { return nil, false } +func registerCreatedTransactionHandle(obj *api.CreatedTransaction) C.CreatedTransaction__Handle { + return (C.CreatedTransaction__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionHandle(handle C.CreatedTransaction__Handle) (*api.CreatedTransaction, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransaction); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreatedTransactionOutputHandle(obj *api.CreatedTransactionOutput) C.CreatedTransactionOutput__Handle { + return (C.CreatedTransactionOutput__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionOutputHandle(handle C.CreatedTransactionOutput__Handle) (*api.CreatedTransactionOutput, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransactionOutput); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go index fc2a842d09..6e5e7f9969 100644 --- a/lib/cgo/util.fee.fee.go +++ b/lib/cgo/util.fee.fee.go @@ -17,12 +17,16 @@ import ( import "C" //export SKY_fee_VerifyTransactionFee -func SKY_fee_VerifyTransactionFee(_t *C.coin__Transaction, _fee uint64) (____error_code uint32) { +func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - t := (*coin.Transaction)(unsafe.Pointer(_t)) + t, ok := lookupTransactionHandle(_t) + if !ok { + ____error_code = SKY_ERROR + return + } ____return_err := fee.VerifyTransactionFee(t, _fee) ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -69,12 +73,16 @@ func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32 } //export SKY_fee_TransactionFee -func SKY_fee_TransactionFee(_tx *C.coin__Transaction, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { +func SKY_fee_TransactionFee(_tx C.Transaction__Handle, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - tx := (*coin.Transaction)(unsafe.Pointer(_tx)) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_ERROR + return + } headTime := _headTime inUxs := *(*coin.UxArray)(unsafe.Pointer(_inUxs)) __arg3, ____return_err := fee.TransactionFee(tx, headTime, inUxs) From a2addca9c0cf82032e716e903dbabe3064bf4e4e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 11 Jun 2018 12:03:14 +0000 Subject: [PATCH 040/399] [libc] refs #1191. Added handles for CreatedTransactionInput__Handle and CreateTransactionResponse__Handle. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 10 ++++++++++ lib/cgo/api.spend.go | 8 ++++---- lib/cgo/libsky_handle.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 787002b6e7..e5fa28e233 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -264,6 +264,16 @@ typedef Handle CreatedTransaction__Handle; */ typedef Handle CreatedTransactionOutput__Handle; +/** + * Memory handle to access to api.CreatedTransactionInput + */ +typedef Handle CreatedTransactionInput__Handle; + +/** + * Memory handle to access to api.CreateTransactionResponse + */ +typedef Handle CreateTransactionResponse__Handle; + /** * Memory handle to access to coin.Block */ diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index f4621519d4..c78a63e345 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -19,7 +19,7 @@ import ( import "C" //export SKY_api_NewCreateTransactionResponse -func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.api__CreateTransactionResponse) (____error_code uint32) { +func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreateTransactionResponse__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -33,7 +33,7 @@ func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs [] __arg2, ____return_err := api.NewCreateTransactionResponse(txn, inputs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.api__CreateTransactionResponse)(unsafe.Pointer(__arg2)) + *_arg2 = registerCreateTransactionResponseHandle(__arg2) } return } @@ -94,7 +94,7 @@ func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid } //export SKY_api_NewCreatedTransactionInput -func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.api__CreatedTransactionInput) (____error_code uint32) { +func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.CreatedTransactionInput__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -103,7 +103,7 @@ func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.api_ __arg1, ____return_err := api.NewCreatedTransactionInput(out) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.api__CreatedTransactionInput)(unsafe.Pointer(__arg1)) + *_arg1 = registerCreatedTransactionInputHandle(__arg1) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index b964ed27cf..b55575cf51 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -328,6 +328,34 @@ func lookupCreatedTransactionOutputHandle(handle C.CreatedTransactionOutput__Han return nil, false } +func registerCreatedTransactionInputHandle(obj *api.CreatedTransactionInput) C.CreatedTransactionInput__Handle { + return (C.CreatedTransactionInput__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionInputHandle(handle C.CreatedTransactionInput__Handle) (*api.CreatedTransactionInput, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransactionInput); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreateTransactionResponseHandle(obj *api.CreateTransactionResponse) C.CreateTransactionResponse__Handle { + return (C.CreateTransactionResponse__Handle)(registerHandle(obj)) +} + +func lookupCreateTransactionResponseHandle(handle C.CreateTransactionResponse__Handle) (*api.CreateTransactionResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreateTransactionResponse); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } From 274aff7fb18becb34588467ee8da40d54001d1df Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 11 Jun 2018 15:17:58 +0000 Subject: [PATCH 041/399] [swig] refs #1568. Avoid memory copying when dealing Seckey and PubKey slices. Not tested. --- lib/swig/goslices2.i | 62 ++++++++++---------------------------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/lib/swig/goslices2.i b/lib/swig/goslices2.i index 093487acda..02bebfc5ff 100644 --- a/lib/swig/goslices2.i +++ b/lib/swig/goslices2.i @@ -1,65 +1,28 @@ -%inline { - void __copyToSecKeys(cipher_SecKeys* secKeys, cipher__SecKey* data, int count){ - secKeys->count = count; - for(int i = 0; i < count; i++){ - memcpy( secKeys->data[i].data, data, sizeof(secKeys->data[i].data) ); - data++; - } - } - - void __copyToPubKeys(cipher_PubKeys* pubKeys, cipher__PubKey* data, int count){ - pubKeys->count = count; - for(int i = 0; i < count; i++){ - memcpy( pubKeys->data[i].data, data, sizeof(pubKeys->data[i].data) ); - data++; - } - } - - void __copyFromPubKeys(cipher_PubKeys* pubKeys, GoSlice_* slice){ - slice->data = malloc( pubKeys->count * 33 * sizeof(GoUint8) ); - slice->len = pubKeys->count; - slice->cap = slice->len; - cipher__PubKey* data = slice->data; - for(int i = 0; i < slice->len; i++){ - memcpy( data, pubKeys->data[i].data, sizeof(pubKeys->data[i].data) ); - data++; - } - } - -} - %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ if( n > MAX_ARRAY_LENGTH_WRAP ) return -1; GoSlice_ data; - data.data = NULL; + data.data = secKeys->data; data.len = 0; - data.cap = 0; + data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); - __copyToSecKeys(secKeys, data.data, data.len); - free(data.data); return result; } } - - - %rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ if( n > MAX_ARRAY_LENGTH_WRAP ) return -1; GoSlice_ data; - data.data = NULL; + data.data = secKeys->data; data.len = 0; - data.cap = 0; + data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); - __copyToSecKeys(secKeys, data.data, data.len); - free(data.data); return result; } } @@ -69,9 +32,10 @@ //[]PubKey GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ GoSlice_ data; - __copyFromPubKeys(pubKeys, &data); + data.data = secKeys->data; + data.len = secKeys->count; + data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); - free(data.data); return result; } } @@ -80,9 +44,10 @@ %inline { GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - __copyFromPubKeys(pubKeys, &data); + data.data = secKeys->data; + data.len = secKeys->count; + data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); - free(data.data); return result; } } @@ -91,11 +56,10 @@ %inline { GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - __copyFromPubKeys(pubKeys, &data); + data.data = secKeys->data; + data.len = secKeys->count; + data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); - free(data.data); return result; } } - - From c3bf99bd5f7f3f4028b1917458c2a569fa80255f Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 17:46:50 +0000 Subject: [PATCH 042/399] [libc] refs #1191. Removed functions redirectStdOut and getStdOut because they were causing Travis failes and are not being used. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/testutils/libsky_testutil.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index cfd6031b8c..99624c8320 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -16,8 +16,6 @@ #define TEST_DATA_DIR "src/cli/integration/testdata/" #define stableEncryptWalletName "integration-test-encrypted.wlt" -//Define function pipe2 to avoid warning implicit declaration of function 'pipe2' -int pipe2(int pipefd[2], int flags); //Define function SKY_handle_close to avoid including libskycoin.h void SKY_handle_close(Handle p0); @@ -202,23 +200,6 @@ void cleanupMem() { } } -void redirectStdOut(){ - stdout_backup = dup(fileno(stdout)); - pipe2(pipefd, 0); - dup2(pipefd[1], fileno(stdout)); -} - -int getStdOut(char* str, unsigned int max_size){ - fflush(stdout); - close(pipefd[1]); - dup2(stdout_backup, fileno(stdout)); - int bytes_read = read(pipefd[0], str, max_size - 1); - if( bytes_read > 0 && bytes_read < max_size) - str[bytes_read] = 0; - close(pipefd[0]); - return bytes_read; -} - json_value* loadJsonFile(const char* filename){ FILE *fp; struct stat filestatus; From 6489c02236408395f99bc405c653d1b70d02b8df Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 20:01:55 +0000 Subject: [PATCH 043/399] [libc] refs #1191. Avoid using relative inclusion of skytypes.h. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/cli.create_rawtx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index 9e869dbb90..d5f7e4c1c4 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -14,7 +14,7 @@ import ( #include #include - #include "../../include/skytypes.h" + #include "skytypes.h" */ import "C" From b159c30b51f6a97568b7e732dcf375152259e679 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 20:05:22 +0000 Subject: [PATCH 044/399] [swig] refs #1568. Avoid using relative path when including skytypes.h. --- lib/cgo/cli.create_rawtx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index fe416fb962..c92417d6a5 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -14,7 +14,7 @@ import ( #include #include - #include "../../include/skytypes.h" + #include "skytypes.h" */ import "C" From 556a873f0559f6d6e1caa15d6ea6390dbbed6976 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 20:44:23 +0000 Subject: [PATCH 045/399] [swig] refs #1568. Fixed error in functions wrapping C lib functions having seckey and pubkey slices as parameters. --- lib/swig/goslices2.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/swig/goslices2.i b/lib/swig/goslices2.i index 02bebfc5ff..1ed9152ad6 100644 --- a/lib/swig/goslices2.i +++ b/lib/swig/goslices2.i @@ -32,8 +32,8 @@ //[]PubKey GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ GoSlice_ data; - data.data = secKeys->data; - data.len = secKeys->count; + data.data = pubKeys->data; + data.len = pubKeys->count; data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); return result; @@ -44,8 +44,8 @@ %inline { GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - data.data = secKeys->data; - data.len = secKeys->count; + data.data = pubKeys->data; + data.len = pubKeys->count; data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); return result; @@ -56,8 +56,8 @@ %inline { GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - data.data = secKeys->data; - data.len = secKeys->count; + data.data = pubKeys->data; + data.len = pubKeys->count; data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); return result; From 19ed56cdb36747d417ebde0e3cc8eb01cc31cd59 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 21:20:09 +0000 Subject: [PATCH 046/399] [swig] refs #1568. Fixed another error in functions wrapping C lib functions having seckey and pubkey slices as parameters. --- lib/swig/goslices2.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/swig/goslices2.i b/lib/swig/goslices2.i index 1ed9152ad6..fa27a78948 100644 --- a/lib/swig/goslices2.i +++ b/lib/swig/goslices2.i @@ -9,6 +9,8 @@ data.len = 0; data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); + if( result == 0 ) + secKeys->count = data.len; return result; } } @@ -23,6 +25,8 @@ data.len = 0; data.cap = MAX_ARRAY_LENGTH_WRAP; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); + if( result == 0 ) + secKeys->count = data.len; return result; } } From c4f4c9025284369d9254235eed0194b6e78509d9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 22:26:09 +0000 Subject: [PATCH 047/399] [swig] refs #1568. Organize swig files. --- lib/swig/extend.i | 19 --- lib/swig/golang.cgo.i | 97 ++++++++++++++ lib/swig/goslices.i | 37 ------ lib/swig/gostrings.i | 38 ------ lib/swig/handletypemaps.i | 30 ----- lib/swig/simpletypes.i | 21 --- lib/swig/skycoin.cipher.crypto.i | 71 ++++++++++ lib/swig/skycoin.cipher.encrypt.i | 9 ++ lib/swig/skycoin.cipher.secp256k1go.i | 16 +++ lib/swig/skycoin.coin.transaction.i | 41 ++++++ lib/swig/skycoin.i | 20 ++- lib/swig/{goslices2.i => skycoin.mem.i} | 39 ++++++ lib/swig/skycoin.wallet.i | 24 ++++ lib/swig/structs.i | 166 ++---------------------- 14 files changed, 313 insertions(+), 315 deletions(-) delete mode 100644 lib/swig/extend.i create mode 100644 lib/swig/golang.cgo.i delete mode 100644 lib/swig/goslices.i delete mode 100644 lib/swig/gostrings.i delete mode 100644 lib/swig/handletypemaps.i delete mode 100644 lib/swig/simpletypes.i create mode 100644 lib/swig/skycoin.cipher.crypto.i create mode 100644 lib/swig/skycoin.cipher.encrypt.i create mode 100644 lib/swig/skycoin.cipher.secp256k1go.i create mode 100644 lib/swig/skycoin.coin.transaction.i rename lib/swig/{goslices2.i => skycoin.mem.i} (60%) create mode 100644 lib/swig/skycoin.wallet.i diff --git a/lib/swig/extend.i b/lib/swig/extend.i deleted file mode 100644 index d365f51348..0000000000 --- a/lib/swig/extend.i +++ /dev/null @@ -1,19 +0,0 @@ -%extend cipher__Address { - int isEqual(cipher__Address* a){ - if( $self-> Version == a->Version ){ - return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; - } - return 0; - } -} - -%extend cipher_SecKeys { - cipher_SecKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } -} - diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i new file mode 100644 index 0000000000..2e21eae628 --- /dev/null +++ b/lib/swig/golang.cgo.i @@ -0,0 +1,97 @@ +/*GoSlice in typemap*/ +%typemap(in) GoSlice { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1.data = buffer; + $1.len = size - 1; + $1.cap = size; +} + + +%typecheck(SWIG_TYPECHECK_STRING) GoSlice { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + $1 = SWIG_IsOK(res) ? 1 : 0; +} + +/*GoSlice_* parameter as reference */ +%typemap(in, numinputs=0) GoSlice_* (GoSlice_ temp) { + temp.data = NULL; + temp.len = 0; + temp.cap = 0; + $1 = ($1_type)&temp; +} + +/*GoSlice_* as function return typemap*/ +%typemap(argout) GoSlice_* { + %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); + free( (void*)$1->data ); +} + +%apply GoSlice_* {coin__UxArray*} + +typedef struct{ + char* p; + int n; +} GoString; + +typedef struct{ + char* p; + int n; +} GoString_; + + +/*GoString in typemap*/ +%typemap(in) GoString { + char* buffer = 0; + size_t size = 0; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1.p = buffer; + $1.n = size - 1; +} + +/*GoString* parameter as reference */ +%typemap(in, numinputs=0) GoString* (GoString temp) { + temp.p = NULL; + temp.n = 0; + $1 = ($1_type)&temp; +} + +/*GoString* as function return typemap*/ +%typemap(argout) GoString* { + %append_output( SWIG_FromCharPtrAndSize( $1->p, $1->n ) ); + free( (void*)$1->p ); +} + +%apply GoString {GoString_} +%apply GoString* {GoString_*} + +%apply int* OUTPUT {GoInt*} +%apply int* OUTPUT {GoUint*} +%apply int* OUTPUT {GoUint8*} +%apply int* OUTPUT {GoInt8*} +%apply int* OUTPUT {GoUint16*} +%apply int* OUTPUT {GoInt16*} +%apply int* OUTPUT {GoUint32*} +%apply int* OUTPUT {GoInt32*} +%apply int* OUTPUT {GoUint64*} +%apply int* OUTPUT {GoInt64*} + +typedef GoInt GoInt_; +typedef GoUint GoUint_; +typedef GoInt8 GoInt8_; +typedef GoUint8 GoUint8_; +typedef GoInt16 GoInt16_; +typedef GoUint16 GoUint16_; +typedef GoInt32 GoInt32_; +typedef GoUint32 GoUint32_; +typedef GoInt64 GoInt64_; +typedef GoUint64 GoUint64_; diff --git a/lib/swig/goslices.i b/lib/swig/goslices.i deleted file mode 100644 index 3ba39548ae..0000000000 --- a/lib/swig/goslices.i +++ /dev/null @@ -1,37 +0,0 @@ -/*GoSlice in typemap*/ -%typemap(in) GoSlice { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); - } - $1.data = buffer; - $1.len = size - 1; - $1.cap = size; -} - - -%typecheck(SWIG_TYPECHECK_STRING) GoSlice { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - $1 = SWIG_IsOK(res) ? 1 : 0; -} - -/*GoSlice_* parameter as reference */ -%typemap(in, numinputs=0) GoSlice_* (GoSlice_ temp) { - temp.data = NULL; - temp.len = 0; - temp.cap = 0; - $1 = ($1_type)&temp; -} - -/*GoSlice_* as function return typemap*/ -%typemap(argout) GoSlice_* { - %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); - free( (void*)$1->data ); -} - -%apply GoSlice_* {coin__UxArray*} - diff --git a/lib/swig/gostrings.i b/lib/swig/gostrings.i deleted file mode 100644 index 1f7beed3d3..0000000000 --- a/lib/swig/gostrings.i +++ /dev/null @@ -1,38 +0,0 @@ -typedef struct{ - char* p; - int n; -} GoString; - -typedef struct{ - char* p; - int n; -} GoString_; - - -/*GoString in typemap*/ -%typemap(in) GoString { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); - } - $1.p = buffer; - $1.n = size - 1; -} - -/*GoString* parameter as reference */ -%typemap(in, numinputs=0) GoString* (GoString temp) { - temp.p = NULL; - temp.n = 0; - $1 = ($1_type)&temp; -} - -/*GoString* as function return typemap*/ -%typemap(argout) GoString* { - %append_output( SWIG_FromCharPtrAndSize( $1->p, $1->n ) ); - free( (void*)$1->p ); -} - -%apply GoString {GoString_} -%apply GoString* {GoString_*} diff --git a/lib/swig/handletypemaps.i b/lib/swig/handletypemaps.i deleted file mode 100644 index bc3c2b495e..0000000000 --- a/lib/swig/handletypemaps.i +++ /dev/null @@ -1,30 +0,0 @@ -/** -* -* typemaps for Handles -* -**/ - - -/* Handle reference typemap. */ -%typemap(in, numinputs=0) Handle* (Handle temp) { - $1 = &temp; -} - -/* Handle out typemap. */ -%typemap(argout) Handle* { - %append_output( SWIG_From_long(*$1) ); -} - -/* Handle not as pointer is input. */ -%typemap(in) Handle { - SWIG_AsVal_long($input, (long*)&$1); -} - - -%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, - WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, - GoStringMap, PasswordReader__Handle_} - -%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, - WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, - App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle* } diff --git a/lib/swig/simpletypes.i b/lib/swig/simpletypes.i deleted file mode 100644 index b28c25a8e1..0000000000 --- a/lib/swig/simpletypes.i +++ /dev/null @@ -1,21 +0,0 @@ -%apply int* OUTPUT {GoInt*} -%apply int* OUTPUT {GoUint*} -%apply int* OUTPUT {GoUint8*} -%apply int* OUTPUT {GoInt8*} -%apply int* OUTPUT {GoUint16*} -%apply int* OUTPUT {GoInt16*} -%apply int* OUTPUT {GoUint32*} -%apply int* OUTPUT {GoInt32*} -%apply int* OUTPUT {GoUint64*} -%apply int* OUTPUT {GoInt64*} - -typedef GoInt GoInt_; -typedef GoUint GoUint_; -typedef GoInt8 GoInt8_; -typedef GoUint8 GoUint8_; -typedef GoInt16 GoInt16_; -typedef GoUint16 GoUint16_; -typedef GoInt32 GoInt32_; -typedef GoUint32 GoUint32_; -typedef GoInt364 GoInt64_; -typedef GoUint64 GoUint64_; diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i new file mode 100644 index 0000000000..34b35da4f4 --- /dev/null +++ b/lib/swig/skycoin.cipher.crypto.i @@ -0,0 +1,71 @@ +%extend cipher__Address { + int isEqual(cipher__Address* a){ + if( $self-> Version == a->Version ){ + return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; + } + return 0; + } +} + +%extend cipher_SecKeys { + cipher_SecKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } +} + +typedef GoUint8_ cipher__PubKey[33]; + +typedef GoUint8_ cipher__Ripemd160[20]; + +typedef GoUint8_ cipher__SecKey[32]; + +typedef GoUint8_ cipher__Sig[65]; + +typedef GoUint8_ cipher__SHA256[32]; + +typedef GoUint8_ cipher__Checksum[4]; + +typedef struct{ + GoUint8 data[33]; +} cipher_PubKey; + +typedef struct{ + GoUint8 data[32]; +} cipher_SecKey; + +typedef struct{ + GoUint8 data[20]; +} cipher_Ripemd160; + +typedef struct{ + GoUint8 data[65]; +} cipher_Sig; + +typedef struct{ + GoUint8 data[32]; +} cipher_SHA256; + +typedef struct{ + GoUint8 data[4]; +} cipher_Checksum; + +typedef struct{ + cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_SecKeys; + +typedef struct{ + cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; + int count; +} cipher_PubKeys; + +typedef struct{ + GoUint8_ Version; ///< Address version identifier. + ///< Used to differentiate testnet + ///< vs mainnet addresses, for ins + cipher__Ripemd160 Key; ///< Address hash identifier. +} cipher__Address; diff --git a/lib/swig/skycoin.cipher.encrypt.i b/lib/swig/skycoin.cipher.encrypt.i new file mode 100644 index 0000000000..faf05f57f1 --- /dev/null +++ b/lib/swig/skycoin.cipher.encrypt.i @@ -0,0 +1,9 @@ +typedef struct{ +} encrypt__Sha256Xor; + +typedef struct{ + GoInt_ N; + GoInt_ R; + GoInt_ P; + GoInt_ KeyLen; +} encrypt__ScryptChacha20poly1305; diff --git a/lib/swig/skycoin.cipher.secp256k1go.i b/lib/swig/skycoin.cipher.secp256k1go.i new file mode 100644 index 0000000000..35cfd5d235 --- /dev/null +++ b/lib/swig/skycoin.cipher.secp256k1go.i @@ -0,0 +1,16 @@ +typedef struct{ + GoUint32_ n[10]; +} secp256k1go__Field; + +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + secp256k1go__Field Z; + BOOL Infinity; +} secp256k1go__XYZ; + +typedef struct{ + secp256k1go__Field X; + secp256k1go__Field Y; + BOOL Infinity; +} secp256k1go__XY; diff --git a/lib/swig/skycoin.coin.transaction.i b/lib/swig/skycoin.coin.transaction.i new file mode 100644 index 0000000000..2e3b616675 --- /dev/null +++ b/lib/swig/skycoin.coin.transaction.i @@ -0,0 +1,41 @@ +typedef struct{ + cipher__Address Address; ///< Receipient address. + GoUint64_ Coins; ///< Amount sent to the receipient address. + GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. +} coin__TransactionOutput; + + +typedef struct{ + coin__Transactions Transactions; +} coin__BlockBody; + +typedef struct{ + GoUint32_ Version; + GoUint64_ Time; + GoUint64_ BkSeq; + GoUint64_ Fee; + cipher__SHA256 PrevHash; + cipher__SHA256 BodyHash; + cipher__SHA256 UxHash; +} coin__BlockHeader; + + +typedef struct{ + coin__BlockHeader Head; + coin__BlockBody Body; +} coin__Block; + +typedef struct{ + coin__Block _unnamed; + cipher__Sig Sig; +} coin__SignedBlock; + +typedef struct { + GoInt32_ Length; ///< Current transaction's length expressed in bytes. + GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. + cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. + + GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. + GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. + GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. +} coin__Transaction; diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index 4753b3f7e1..b8e394bee9 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -1,22 +1,18 @@ %module skycoin %include "typemaps.i" %{ - #define SWIG_FILE_WITH_INIT + #define SWIG_FILE_WITH_INIT #include "libskycoin.h" #include "include/extras.h" %} -%include "simpletypes.i" -%include "handletypemaps.i" -%include "gostrings.i" -%include "goslices.i" -%include "goslices2.i" -%include "structs.i" -%include "extend.i" +%include "golang.cgo.i" +%include "skycoin.mem.i" +%include "skycoin.cipher.crypto.i" +%include "skycoin.cipher.encrypt.i" +%include "skycoin.cipher.secp256k1go.i" +%include "skycoin.coin.transaction.i" +%include "skycoin.wallet.i" %include "structs_typemaps.i" /* Find the modified copy of libskycoin */ %include "../../../swig/include/libskycoin.h" - - - - diff --git a/lib/swig/goslices2.i b/lib/swig/skycoin.mem.i similarity index 60% rename from lib/swig/goslices2.i rename to lib/swig/skycoin.mem.i index fa27a78948..b73a96a97d 100644 --- a/lib/swig/goslices2.i +++ b/lib/swig/skycoin.mem.i @@ -67,3 +67,42 @@ return result; } } + +/** +* +* typemaps for Handles +* +**/ + + +/* Handle reference typemap. */ +%typemap(in, numinputs=0) Handle* (Handle temp) { + $1 = &temp; +} + +/* Handle out typemap. */ +%typemap(argout) Handle* { + %append_output( SWIG_From_long(*$1) ); +} + +/* Handle not as pointer is input. */ +%typemap(in) Handle { + SWIG_AsVal_long($input, (long*)&$1); +} + + +%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, + WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, + GoStringMap, PasswordReader__Handle_, + Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, + CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, + Block__Handle, SignedBlock__Handle, BlockBody__Handle + } + +%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, + WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, + App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, + Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, + CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle* + } diff --git a/lib/swig/skycoin.wallet.i b/lib/swig/skycoin.wallet.i new file mode 100644 index 0000000000..5c2a7fcacb --- /dev/null +++ b/lib/swig/skycoin.wallet.i @@ -0,0 +1,24 @@ +typedef struct { + cipher__Address Address; ///< Wallet address. + cipher__PubKey Public; ///< Public key used to generate address. + cipher__SecKey Secret; ///< Secret key used to generate address. +} wallet__Entry; + +typedef struct{ + GoUint64_ Coins; + GoUint64_ Hours; +} wallet__Balance; + +typedef struct{ + wallet__Balance Confirmed; + wallet__Balance Predicted; +} wallet__BalancePair; + +typedef struct { + cipher__SHA256 Hash; ///< Hash of underlying UxOut. + GoInt64_ BkSeq; ///< Block height corresponding to the + ///< moment balance calculation is performed at. + cipher__Address Address; ///< Account holder address. + GoInt64_ Coins; ///< Coins amount (e.g. in SKY). + GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. +} wallet__UxBalance; diff --git a/lib/swig/structs.i b/lib/swig/structs.i index c145a5a8f7..f27f9b4b0c 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -1,126 +1,3 @@ -typedef struct{ -} encrypt__Sha256Xor; - -typedef struct{ - GoInt_ N; - GoInt_ R; - GoInt_ P; - GoInt_ KeyLen; -} encrypt__ScryptChacha20poly1305; - -typedef struct{ - GoUint32_ n[10]; -} secp256k1go__Field; - - -typedef GoUint8_ cipher__PubKey[33]; - -typedef GoUint8_ cipher__Ripemd160[20]; - -typedef GoUint8_ cipher__SecKey[32]; - -typedef GoUint8_ cipher__Sig[65]; - -typedef GoUint8_ cipher__SHA256[32]; - -typedef GoUint8_ cipher__Checksum[4]; - -typedef struct{ - GoUint8 data[33]; -} cipher_PubKey; - -typedef struct{ - GoUint8 data[32]; -} cipher_SecKey; - -typedef struct{ - GoUint8 data[20]; -} cipher_Ripemd160; - -typedef struct{ - GoUint8 data[65]; -} cipher_Sig; - -typedef struct{ - GoUint8 data[32]; -} cipher_SHA256; - -typedef struct{ - GoUint8 data[4]; -} cipher_Checksum; - -typedef struct{ - cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; - int count; -} cipher_SecKeys; - -typedef struct{ - cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; - int count; -} cipher_PubKeys; - -typedef struct { - cipher__Address Address; ///< Wallet address. - cipher__PubKey Public; ///< Public key used to generate address. - cipher__SecKey Secret; ///< Secret key used to generate address. -} wallet__Entry; - - -typedef struct{ - GoUint8_ Version; ///< Address version identifier. - ///< Used to differentiate testnet - ///< vs mainnet addresses, for ins - cipher__Ripemd160 Key; ///< Address hash identifier. -} cipher__Address; - - - -typedef struct{ - GoUint64_ Coins; - GoUint64_ Hours; -} wallet__Balance; - -typedef struct{ - wallet__Balance Confirmed; - wallet__Balance Predicted; -} wallet__BalancePair; - -typedef struct{ - GoInt_ N; - BOOL IncludeDistribution; -} api__RichlistParams; - -typedef struct{ -} cli__PasswordFromTerm; - -typedef struct{ - secp256k1go__Field X; - secp256k1go__Field Y; - secp256k1go__Field Z; - BOOL Infinity; -} secp256k1go__XYZ; - -typedef struct{ - secp256k1go__Field X; - secp256k1go__Field Y; - BOOL Infinity; -} secp256k1go__XY; - -typedef struct{ - cipher__Address Address; ///< Receipient address. - GoUint64_ Coins; ///< Amount sent to the receipient address. - GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. -} coin__TransactionOutput; - -typedef struct { - cipher__SHA256 Hash; ///< Hash of underlying UxOut. - GoInt64_ BkSeq; ///< Block height corresponding to the - ///< moment balance calculation is performed at. - cipher__Address Address; ///< Account holder address. - GoInt64_ Coins; ///< Coins amount (e.g. in SKY). - GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. -} wallet__UxBalance; - /* //Requires typemap, contains GoString_ typedef struct{ @@ -186,40 +63,6 @@ typedef struct{ typedef GoSlice_ coin__Transactions; -typedef struct{ - coin__Transactions Transactions; -} coin__BlockBody; - -typedef struct{ - GoUint32_ Version; - GoUint64_ Time; - GoUint64_ BkSeq; - GoUint64_ Fee; - cipher__SHA256 PrevHash; - cipher__SHA256 BodyHash; - cipher__SHA256 UxHash; -} coin__BlockHeader; - - -typedef struct{ - coin__BlockHeader Head; - coin__BlockBody Body; -} coin__Block; - -typedef struct{ - coin__Block _unnamed; - cipher__Sig Sig; -} coin__SignedBlock; - -typedef struct { - GoInt32_ Length; ///< Current transaction's length expressed in bytes. - GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. - cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. - - GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. - GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. - GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. -} coin__Transaction; typedef struct{ GoUint32_ Length; @@ -248,5 +91,12 @@ typedef struct{ daemon__TransactionResult * Transaction; } webrpc__TxnResult; -*/ +typedef struct{ + GoInt_ N; + BOOL IncludeDistribution; +} api__RichlistParams; +typedef struct{ +} cli__PasswordFromTerm; + +*/ From 606d21c03b386f1e37c36ed06f004fcb53dba1a5 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 12 Jun 2018 23:28:00 +0000 Subject: [PATCH 048/399] [swig] refs #1568. Remove all swig files with structure definitions and get them from header files in skycoin. --- .../{skycoin.cipher.crypto.i => custom.i} | 57 ++--- lib/swig/skycoin.cipher.encrypt.i | 9 - lib/swig/skycoin.cipher.secp256k1go.i | 16 -- lib/swig/skycoin.coin.transaction.i | 41 ---- lib/swig/skycoin.i | 8 +- lib/swig/skycoin.wallet.i | 24 -- lib/swig/structs.i | 227 ++++++++++-------- 7 files changed, 147 insertions(+), 235 deletions(-) rename lib/swig/{skycoin.cipher.crypto.i => custom.i} (61%) delete mode 100644 lib/swig/skycoin.cipher.encrypt.i delete mode 100644 lib/swig/skycoin.cipher.secp256k1go.i delete mode 100644 lib/swig/skycoin.coin.transaction.i delete mode 100644 lib/swig/skycoin.wallet.i diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/custom.i similarity index 61% rename from lib/swig/skycoin.cipher.crypto.i rename to lib/swig/custom.i index 34b35da4f4..718b2f6192 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/custom.i @@ -1,39 +1,8 @@ -%extend cipher__Address { - int isEqual(cipher__Address* a){ - if( $self-> Version == a->Version ){ - return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; - } - return 0; - } -} - -%extend cipher_SecKeys { - cipher_SecKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } -} - -typedef GoUint8_ cipher__PubKey[33]; - -typedef GoUint8_ cipher__Ripemd160[20]; - -typedef GoUint8_ cipher__SecKey[32]; - -typedef GoUint8_ cipher__Sig[65]; - -typedef GoUint8_ cipher__SHA256[32]; - -typedef GoUint8_ cipher__Checksum[4]; - typedef struct{ GoUint8 data[33]; } cipher_PubKey; -typedef struct{ +typedef struct{ GoUint8 data[32]; } cipher_SecKey; @@ -63,9 +32,21 @@ typedef struct{ int count; } cipher_PubKeys; -typedef struct{ - GoUint8_ Version; ///< Address version identifier. - ///< Used to differentiate testnet - ///< vs mainnet addresses, for ins - cipher__Ripemd160 Key; ///< Address hash identifier. -} cipher__Address; +%extend cipher__Address { + int isEqual(cipher__Address* a){ + if( $self-> Version == a->Version ){ + return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; + } + return 0; + } +} + +%extend cipher_SecKeys { + cipher_SecKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } +} diff --git a/lib/swig/skycoin.cipher.encrypt.i b/lib/swig/skycoin.cipher.encrypt.i deleted file mode 100644 index faf05f57f1..0000000000 --- a/lib/swig/skycoin.cipher.encrypt.i +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct{ -} encrypt__Sha256Xor; - -typedef struct{ - GoInt_ N; - GoInt_ R; - GoInt_ P; - GoInt_ KeyLen; -} encrypt__ScryptChacha20poly1305; diff --git a/lib/swig/skycoin.cipher.secp256k1go.i b/lib/swig/skycoin.cipher.secp256k1go.i deleted file mode 100644 index 35cfd5d235..0000000000 --- a/lib/swig/skycoin.cipher.secp256k1go.i +++ /dev/null @@ -1,16 +0,0 @@ -typedef struct{ - GoUint32_ n[10]; -} secp256k1go__Field; - -typedef struct{ - secp256k1go__Field X; - secp256k1go__Field Y; - secp256k1go__Field Z; - BOOL Infinity; -} secp256k1go__XYZ; - -typedef struct{ - secp256k1go__Field X; - secp256k1go__Field Y; - BOOL Infinity; -} secp256k1go__XY; diff --git a/lib/swig/skycoin.coin.transaction.i b/lib/swig/skycoin.coin.transaction.i deleted file mode 100644 index 2e3b616675..0000000000 --- a/lib/swig/skycoin.coin.transaction.i +++ /dev/null @@ -1,41 +0,0 @@ -typedef struct{ - cipher__Address Address; ///< Receipient address. - GoUint64_ Coins; ///< Amount sent to the receipient address. - GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. -} coin__TransactionOutput; - - -typedef struct{ - coin__Transactions Transactions; -} coin__BlockBody; - -typedef struct{ - GoUint32_ Version; - GoUint64_ Time; - GoUint64_ BkSeq; - GoUint64_ Fee; - cipher__SHA256 PrevHash; - cipher__SHA256 BodyHash; - cipher__SHA256 UxHash; -} coin__BlockHeader; - - -typedef struct{ - coin__BlockHeader Head; - coin__BlockBody Body; -} coin__Block; - -typedef struct{ - coin__Block _unnamed; - cipher__Sig Sig; -} coin__SignedBlock; - -typedef struct { - GoInt32_ Length; ///< Current transaction's length expressed in bytes. - GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. - cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. - - GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. - GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. - GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. -} coin__Transaction; diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index b8e394bee9..ad8feccb30 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -8,11 +8,9 @@ %include "golang.cgo.i" %include "skycoin.mem.i" -%include "skycoin.cipher.crypto.i" -%include "skycoin.cipher.encrypt.i" -%include "skycoin.cipher.secp256k1go.i" -%include "skycoin.coin.transaction.i" -%include "skycoin.wallet.i" +%include "custom.i" %include "structs_typemaps.i" + /* Find the modified copy of libskycoin */ %include "../../../swig/include/libskycoin.h" +%include "structs.i" diff --git a/lib/swig/skycoin.wallet.i b/lib/swig/skycoin.wallet.i deleted file mode 100644 index 5c2a7fcacb..0000000000 --- a/lib/swig/skycoin.wallet.i +++ /dev/null @@ -1,24 +0,0 @@ -typedef struct { - cipher__Address Address; ///< Wallet address. - cipher__PubKey Public; ///< Public key used to generate address. - cipher__SecKey Secret; ///< Secret key used to generate address. -} wallet__Entry; - -typedef struct{ - GoUint64_ Coins; - GoUint64_ Hours; -} wallet__Balance; - -typedef struct{ - wallet__Balance Confirmed; - wallet__Balance Predicted; -} wallet__BalancePair; - -typedef struct { - cipher__SHA256 Hash; ///< Hash of underlying UxOut. - GoInt64_ BkSeq; ///< Block height corresponding to the - ///< moment balance calculation is performed at. - cipher__Address Address; ///< Account holder address. - GoInt64_ Coins; ///< Coins amount (e.g. in SKY). - GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. -} wallet__UxBalance; diff --git a/lib/swig/structs.i b/lib/swig/structs.i index f27f9b4b0c..557cd315e2 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -1,102 +1,125 @@ -/* -//Requires typemap, contains GoString_ -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; -} api__CreatedTransactionOutput; - -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; - GoString_ CalculatedHours; - GoUint64_ Time; - GoUint64_ Block; - GoString_ TxID; -} api__CreatedTransactionInput; - -*/ -/* -typedef struct { - BOOL neg; - GoSlice_ nat; -} Number; - -typedef struct { - Number R; - Number S; -} Signature; -*/ -/* - -//Contain slices. Should be Handle - -typedef struct{ - visor__ReadableOutputSet Outputs; -} webrpc__OutputsResult; - - -typedef struct{ - cli__Balance Confirmed; - cli__Balance Spendable; - cli__Balance Expected; - GoSlice_ Addresses; -} cli__BalanceResult; - -typedef struct{ - wallet__BalancePair * Balance; - visor__ReadableTransaction * Transaction; - GoString_ Error; -} api__SpendResult; - -typedef struct{ - api__CreatedTransaction Transaction; - GoString_ EncodedTransaction; -} api__CreateTransactionResponse; - -typedef struct{ - GoSlice_ Blocks; -} visor__ReadableBlocks; - -typedef GoSlice_ coin__Transactions; - - -typedef struct{ - GoUint32_ Length; - GoUint8_ Type; - GoString_ TxID; - GoString_ InnerHash; - GoString_ Fee; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} api__CreatedTransaction; - -typedef struct{ - api__CreatedTransaction Transaction; - GoString_ EncodedTransaction; -} api__CreateTransactionResponse; - -typedef struct{ - coin__Transactions Txns; - GoSlice_ Fees; - GoSlice_ Hashes; -} coin__SortableTransactions; - -//Should be Handle -typedef struct{ - daemon__TransactionResult * Transaction; -} webrpc__TxnResult; - -typedef struct{ - GoInt_ N; - BOOL IncludeDistribution; -} api__RichlistParams; - -typedef struct{ -} cli__PasswordFromTerm; - -*/ +/* Find all header files for structures of libskycoin */ +%include "../../include/cipher.hash.go.h" +%include "../../include/cipher.address.go.h" +%include "../../include/cipher.base58.base58.go.h" +%include "../../include/cipher.chacha20poly1305.chacha20poly1305.go.h" +%include "../../include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" +%include "../../include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h" +%include "../../include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" +%include "../../include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" +%include "../../include/cipher.crypto.go.h" +%include "../../include/cipher.encoder.encoder.go.h" +%include "../../include/cipher.encoder.field.go.h" +%include "../../include/cipher.encrypt.scrypt_chacha20poly1305.go.h" +%include "../../include/cipher.encrypt.sha256xor.go.h" +%include "../../include/cipher.go-bip39.bip39.go.h" +%include "../../include/cipher.go-bip39.wordlist.go.h" + +%include "../../include/cipher.pbkdf2.pbkdf2.go.h" +%include "../../include/cipher.poly1305.poly1305.go.h" +%include "../../include/cipher.poly1305.sum_amd64.go.h" +%include "../../include/cipher.poly1305.sum_arm.go.h" +%include "../../include/cipher.poly1305.sum_ref.go.h" +%include "../../include/cipher.ripemd160.ripemd160block.go.h" +%include "../../include/cipher.ripemd160.ripmd_160.go.h" +%include "../../include/cipher.scrypt.scrypt.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.ec.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.field.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.num.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.sig.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.xy.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h" +%include "../../include/cipher.secp256k1-go.secp256k1.go.h" +%include "../../include/cipher.secp256k1-go.secp256_rand.go.h" +%include "../../include/coin.transactions.go.h" +%include "../../include/coin.block.go.h" +%include "../../include/coin.outputs.go.h" + +%include "../../include/consensus.blockstat.go.h" +%include "../../include/consensus.connection_manager.go.h" +%include "../../include/consensus.consensus.go.h" +%include "../../include/consensus.participant.go.h" +%include "../../include/consensus.public_broadcast_channel.public_broadcast_channel.go.h" + + +%include "../../include/testutil.assert.assertions.go.h" +%include "../../include/testutil.require.require.go.h" +%include "../../include/util.browser.browser.go.h" +%include "../../include/util.cert.cert.go.h" +%include "../../include/util.droplet.droplet.go.h" +%include "../../include/util.elapse.elapser.go.h" +%include "../../include/util.fee.fee.go.h" +%include "../../include/util.file.file.go.h" +%include "../../include/util.http.error.go.h" +%include "../../include/util.http.handler.go.h" +%include "../../include/util.http.json.go.h" +%include "../../include/util.http.log.go.h" +%include "../../include/util.iputil.iputil.go.h" +%include "../../include/util.logging.formatter.go.h" +%include "../../include/util.logging.hooks.go.h" +%include "../../include/util.logging.logger.go.h" +%include "../../include/util.logging.logging.go.h" +%include "../../include/util.utc.utc.go.h" +%include "../../include/visor.blockchain.go.h" +%include "../../include/visor.visor.go.h" +%include "../../include/visor.blockdb.blockchain.go.h" +%include "../../include/visor.blockdb.blocksigs.go.h" +%include "../../include/visor.blockdb.block_tree.go.h" +%include "../../include/visor.blockdb.unspent.go.h" +%include "../../include/visor.db.go.h" +%include "../../include/visor.distribution.go.h" +%include "../../include/visor.historydb.address_txn.go.h" +%include "../../include/visor.historydb.address_uxout.go.h" +%include "../../include/visor.historydb.historydb.go.h" +%include "../../include/visor.historydb.history_meta.go.h" +%include "../../include/visor.historydb.output.go.h" +%include "../../include/visor.historydb.transaction.go.h" +%include "../../include/visor.readable.go.h" +%include "../../include/visor.richlist.go.h" +%include "../../include/visor.unconfirmed.go.h" +%include "../../include/visor.verify.go.h" + + +%include "../../include/daemon.gnet.pool.go.h" +%include "../../include/daemon.gnet.message.go.h" +%include "../../include/daemon.messages.go.h" +%include "../../include/daemon.daemon.go.h" +%include "../../include/daemon.gateway.go.h" +%include "../../include/daemon.gnet.dispatcher.go.h" +%include "../../include/daemon.pex.peerlist.go.h" +%include "../../include/daemon.pex.pex.go.h" +%include "../../include/daemon.pool.go.h" +%include "../../include/daemon.rpc.go.h" +%include "../../include/daemon.storage.go.h" +%include "../../include/daemon.strand.strand.go.h" +%include "../../include/daemon.visor.go.h" + +%include "../../include/api.webrpc.block.go.h" +%include "../../include/api.webrpc.client.go.h" +%include "../../include/api.webrpc.gateway.go.h" +%include "../../include/api.webrpc.outputs.go.h" +%include "../../include/api.webrpc.status.go.h" +%include "../../include/api.webrpc.transaction.go.h" +%include "../../include/api.webrpc.uxout.go.h" +%include "../../include/api.webrpc.webrpc.go.h" +%include "../../include/wallet.addresses.go.h" +%include "../../include/wallet.balance.go.h" +%include "../../include/wallet.crypto.go.h" +%include "../../include/wallet.entry.go.h" +%include "../../include/wallet.notes.go.h" +%include "../../include/wallet.readable.go.h" +%include "../../include/wallet.secrets.go.h" +%include "../../include/wallet.service.go.h" +%include "../../include/wallet.wallet.go.h" +%include "../../include/wallet.wallets.go.h" + +%include "../../include/api.client.go.h" +%include "../../include/api.explorer.go.h" +%include "../../include/api.spend.go.h" +%include "../../include/api.wallet.go.h" +%include "../../include/cli.check_balance.go.h" +%include "../../include/cli.cli.go.h" +%include "../../include/cli.create_rawtx.go.h" From b75a65265d29769c08c3b904673c54500335a968 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 09:48:53 +0000 Subject: [PATCH 049/399] [swig] refs #1568. Rename extras.h to swig.h and move it include folder with the rest of libskycoin header files. --- lib/swig/include/extras.h => include/swig.h | 0 lib/swig/skycoin.i | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/swig/include/extras.h => include/swig.h (100%) diff --git a/lib/swig/include/extras.h b/include/swig.h similarity index 100% rename from lib/swig/include/extras.h rename to include/swig.h diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index ad8feccb30..bb79246f56 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -3,7 +3,7 @@ %{ #define SWIG_FILE_WITH_INIT #include "libskycoin.h" - #include "include/extras.h" + #include "swig.h" %} %include "golang.cgo.i" From 73acc4fa838da02c87a30e84d5d909db54add2c6 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 10:31:24 +0000 Subject: [PATCH 050/399] [swig] refs #1568. Remove relative paths for swig files. --- lib/swig/skycoin.i | 2 +- lib/swig/structs.i | 233 ++++++++++++++++++++++----------------------- 2 files changed, 117 insertions(+), 118 deletions(-) diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index bb79246f56..f07e1cb479 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -12,5 +12,5 @@ %include "structs_typemaps.i" /* Find the modified copy of libskycoin */ -%include "../../../swig/include/libskycoin.h" +%include "libskycoin.h" %include "structs.i" diff --git a/lib/swig/structs.i b/lib/swig/structs.i index 557cd315e2..f305f75421 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -1,125 +1,124 @@ -/* Find all header files for structures of libskycoin */ -%include "../../include/cipher.hash.go.h" -%include "../../include/cipher.address.go.h" -%include "../../include/cipher.base58.base58.go.h" -%include "../../include/cipher.chacha20poly1305.chacha20poly1305.go.h" -%include "../../include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" -%include "../../include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h" -%include "../../include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" -%include "../../include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" -%include "../../include/cipher.crypto.go.h" -%include "../../include/cipher.encoder.encoder.go.h" -%include "../../include/cipher.encoder.field.go.h" -%include "../../include/cipher.encrypt.scrypt_chacha20poly1305.go.h" -%include "../../include/cipher.encrypt.sha256xor.go.h" -%include "../../include/cipher.go-bip39.bip39.go.h" -%include "../../include/cipher.go-bip39.wordlist.go.h" +%include "cipher.hash.go.h" +%include "cipher.address.go.h" +%include "cipher.base58.base58.go.h" +%include "cipher.chacha20poly1305.chacha20poly1305.go.h" +%include "cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" +%include "cipher.chacha20poly1305.chacha20poly1305_generic.go.h" +%include "cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" +%include "cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" +%include "cipher.crypto.go.h" +%include "cipher.encoder.encoder.go.h" +%include "cipher.encoder.field.go.h" +%include "cipher.encrypt.scrypt_chacha20poly1305.go.h" +%include "cipher.encrypt.sha256xor.go.h" +%include "cipher.go-bip39.bip39.go.h" +%include "cipher.go-bip39.wordlist.go.h" -%include "../../include/cipher.pbkdf2.pbkdf2.go.h" -%include "../../include/cipher.poly1305.poly1305.go.h" -%include "../../include/cipher.poly1305.sum_amd64.go.h" -%include "../../include/cipher.poly1305.sum_arm.go.h" -%include "../../include/cipher.poly1305.sum_ref.go.h" -%include "../../include/cipher.ripemd160.ripemd160block.go.h" -%include "../../include/cipher.ripemd160.ripmd_160.go.h" -%include "../../include/cipher.scrypt.scrypt.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.ec.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.field.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.num.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.sig.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.xy.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.xyz.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h" -%include "../../include/cipher.secp256k1-go.secp256k1.go.h" -%include "../../include/cipher.secp256k1-go.secp256_rand.go.h" -%include "../../include/coin.transactions.go.h" -%include "../../include/coin.block.go.h" -%include "../../include/coin.outputs.go.h" +%include "cipher.pbkdf2.pbkdf2.go.h" +%include "cipher.poly1305.poly1305.go.h" +%include "cipher.poly1305.sum_amd64.go.h" +%include "cipher.poly1305.sum_arm.go.h" +%include "cipher.poly1305.sum_ref.go.h" +%include "cipher.ripemd160.ripemd160block.go.h" +%include "cipher.ripemd160.ripmd_160.go.h" +%include "cipher.scrypt.scrypt.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.ec.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.field.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.num.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.sig.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" +%include "cipher.secp256k1-go.secp256k1-go2.z_init.go.h" +%include "cipher.secp256k1-go.secp256k1.go.h" +%include "cipher.secp256k1-go.secp256_rand.go.h" +%include "coin.transactions.go.h" +%include "coin.block.go.h" +%include "coin.outputs.go.h" -%include "../../include/consensus.blockstat.go.h" -%include "../../include/consensus.connection_manager.go.h" -%include "../../include/consensus.consensus.go.h" -%include "../../include/consensus.participant.go.h" -%include "../../include/consensus.public_broadcast_channel.public_broadcast_channel.go.h" +%include "consensus.blockstat.go.h" +%include "consensus.connection_manager.go.h" +%include "consensus.consensus.go.h" +%include "consensus.participant.go.h" +%include "consensus.public_broadcast_channel.public_broadcast_channel.go.h" -%include "../../include/testutil.assert.assertions.go.h" -%include "../../include/testutil.require.require.go.h" -%include "../../include/util.browser.browser.go.h" -%include "../../include/util.cert.cert.go.h" -%include "../../include/util.droplet.droplet.go.h" -%include "../../include/util.elapse.elapser.go.h" -%include "../../include/util.fee.fee.go.h" -%include "../../include/util.file.file.go.h" -%include "../../include/util.http.error.go.h" -%include "../../include/util.http.handler.go.h" -%include "../../include/util.http.json.go.h" -%include "../../include/util.http.log.go.h" -%include "../../include/util.iputil.iputil.go.h" -%include "../../include/util.logging.formatter.go.h" -%include "../../include/util.logging.hooks.go.h" -%include "../../include/util.logging.logger.go.h" -%include "../../include/util.logging.logging.go.h" -%include "../../include/util.utc.utc.go.h" -%include "../../include/visor.blockchain.go.h" -%include "../../include/visor.visor.go.h" -%include "../../include/visor.blockdb.blockchain.go.h" -%include "../../include/visor.blockdb.blocksigs.go.h" -%include "../../include/visor.blockdb.block_tree.go.h" -%include "../../include/visor.blockdb.unspent.go.h" -%include "../../include/visor.db.go.h" -%include "../../include/visor.distribution.go.h" -%include "../../include/visor.historydb.address_txn.go.h" -%include "../../include/visor.historydb.address_uxout.go.h" -%include "../../include/visor.historydb.historydb.go.h" -%include "../../include/visor.historydb.history_meta.go.h" -%include "../../include/visor.historydb.output.go.h" -%include "../../include/visor.historydb.transaction.go.h" -%include "../../include/visor.readable.go.h" -%include "../../include/visor.richlist.go.h" -%include "../../include/visor.unconfirmed.go.h" -%include "../../include/visor.verify.go.h" +%include "testutil.assert.assertions.go.h" +%include "testutil.require.require.go.h" +%include "util.browser.browser.go.h" +%include "util.cert.cert.go.h" +%include "util.droplet.droplet.go.h" +%include "util.elapse.elapser.go.h" +%include "util.fee.fee.go.h" +%include "util.file.file.go.h" +%include "util.http.error.go.h" +%include "util.http.handler.go.h" +%include "util.http.json.go.h" +%include "util.http.log.go.h" +%include "util.iputil.iputil.go.h" +%include "util.logging.formatter.go.h" +%include "util.logging.hooks.go.h" +%include "util.logging.logger.go.h" +%include "util.logging.logging.go.h" +%include "util.utc.utc.go.h" +%include "visor.blockchain.go.h" +%include "visor.visor.go.h" +%include "visor.blockdb.blockchain.go.h" +%include "visor.blockdb.blocksigs.go.h" +%include "visor.blockdb.block_tree.go.h" +%include "visor.blockdb.unspent.go.h" +%include "visor.db.go.h" +%include "visor.distribution.go.h" +%include "visor.historydb.address_txn.go.h" +%include "visor.historydb.address_uxout.go.h" +%include "visor.historydb.historydb.go.h" +%include "visor.historydb.history_meta.go.h" +%include "visor.historydb.output.go.h" +%include "visor.historydb.transaction.go.h" +%include "visor.readable.go.h" +%include "visor.richlist.go.h" +%include "visor.unconfirmed.go.h" +%include "visor.verify.go.h" -%include "../../include/daemon.gnet.pool.go.h" -%include "../../include/daemon.gnet.message.go.h" -%include "../../include/daemon.messages.go.h" -%include "../../include/daemon.daemon.go.h" -%include "../../include/daemon.gateway.go.h" -%include "../../include/daemon.gnet.dispatcher.go.h" -%include "../../include/daemon.pex.peerlist.go.h" -%include "../../include/daemon.pex.pex.go.h" -%include "../../include/daemon.pool.go.h" -%include "../../include/daemon.rpc.go.h" -%include "../../include/daemon.storage.go.h" -%include "../../include/daemon.strand.strand.go.h" -%include "../../include/daemon.visor.go.h" +%include "daemon.gnet.pool.go.h" +%include "daemon.gnet.message.go.h" +%include "daemon.messages.go.h" +%include "daemon.daemon.go.h" +%include "daemon.gateway.go.h" +%include "daemon.gnet.dispatcher.go.h" +%include "daemon.pex.peerlist.go.h" +%include "daemon.pex.pex.go.h" +%include "daemon.pool.go.h" +%include "daemon.rpc.go.h" +%include "daemon.storage.go.h" +%include "daemon.strand.strand.go.h" +%include "daemon.visor.go.h" -%include "../../include/api.webrpc.block.go.h" -%include "../../include/api.webrpc.client.go.h" -%include "../../include/api.webrpc.gateway.go.h" -%include "../../include/api.webrpc.outputs.go.h" -%include "../../include/api.webrpc.status.go.h" -%include "../../include/api.webrpc.transaction.go.h" -%include "../../include/api.webrpc.uxout.go.h" -%include "../../include/api.webrpc.webrpc.go.h" -%include "../../include/wallet.addresses.go.h" -%include "../../include/wallet.balance.go.h" -%include "../../include/wallet.crypto.go.h" -%include "../../include/wallet.entry.go.h" -%include "../../include/wallet.notes.go.h" -%include "../../include/wallet.readable.go.h" -%include "../../include/wallet.secrets.go.h" -%include "../../include/wallet.service.go.h" -%include "../../include/wallet.wallet.go.h" -%include "../../include/wallet.wallets.go.h" +%include "api.webrpc.block.go.h" +%include "api.webrpc.client.go.h" +%include "api.webrpc.gateway.go.h" +%include "api.webrpc.outputs.go.h" +%include "api.webrpc.status.go.h" +%include "api.webrpc.transaction.go.h" +%include "api.webrpc.uxout.go.h" +%include "api.webrpc.webrpc.go.h" +%include "wallet.addresses.go.h" +%include "wallet.balance.go.h" +%include "wallet.crypto.go.h" +%include "wallet.entry.go.h" +%include "wallet.notes.go.h" +%include "wallet.readable.go.h" +%include "wallet.secrets.go.h" +%include "wallet.service.go.h" +%include "wallet.wallet.go.h" +%include "wallet.wallets.go.h" -%include "../../include/api.client.go.h" -%include "../../include/api.explorer.go.h" -%include "../../include/api.spend.go.h" -%include "../../include/api.wallet.go.h" -%include "../../include/cli.check_balance.go.h" -%include "../../include/cli.cli.go.h" -%include "../../include/cli.create_rawtx.go.h" +%include "api.client.go.h" +%include "api.explorer.go.h" +%include "api.spend.go.h" +%include "api.wallet.go.h" +%include "cli.check_balance.go.h" +%include "cli.cli.go.h" +%include "cli.create_rawtx.go.h" From 0b5bdaf2ccbd0399d317ae80824392d5b69deca9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 11:42:15 +0000 Subject: [PATCH 051/399] [swig] refs #1568. Moved swig.h from include to lib/swig. --- {include => lib/swig}/swig.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {include => lib/swig}/swig.h (100%) diff --git a/include/swig.h b/lib/swig/swig.h similarity index 100% rename from include/swig.h rename to lib/swig/swig.h From 3c308964d567825a3ed9a03c4e23581ff464186d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 12:03:09 +0000 Subject: [PATCH 052/399] [swig] refs #1568. Moved swig.h back to include folder. --- {lib/swig => include}/swig.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {lib/swig => include}/swig.h (100%) diff --git a/lib/swig/swig.h b/include/swig.h similarity index 100% rename from lib/swig/swig.h rename to include/swig.h From f43b8592fca4420b17d5571fcc50012ccce83f43 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 12:44:38 +0000 Subject: [PATCH 053/399] [swig] refs #1568. Removed redundant type definitions. Organized swig files. --- lib/swig/custom.i | 52 -------------------------------- lib/swig/golang.cgo.i | 10 ------ lib/swig/skycoin.cipher.crypto.i | 18 +++++++++++ lib/swig/skycoin.i | 3 +- lib/swig/structs.i | 2 +- 5 files changed, 21 insertions(+), 64 deletions(-) delete mode 100644 lib/swig/custom.i create mode 100644 lib/swig/skycoin.cipher.crypto.i diff --git a/lib/swig/custom.i b/lib/swig/custom.i deleted file mode 100644 index 718b2f6192..0000000000 --- a/lib/swig/custom.i +++ /dev/null @@ -1,52 +0,0 @@ -typedef struct{ - GoUint8 data[33]; -} cipher_PubKey; - -typedef struct{ - GoUint8 data[32]; -} cipher_SecKey; - -typedef struct{ - GoUint8 data[20]; -} cipher_Ripemd160; - -typedef struct{ - GoUint8 data[65]; -} cipher_Sig; - -typedef struct{ - GoUint8 data[32]; -} cipher_SHA256; - -typedef struct{ - GoUint8 data[4]; -} cipher_Checksum; - -typedef struct{ - cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; - int count; -} cipher_SecKeys; - -typedef struct{ - cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; - int count; -} cipher_PubKeys; - -%extend cipher__Address { - int isEqual(cipher__Address* a){ - if( $self-> Version == a->Version ){ - return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; - } - return 0; - } -} - -%extend cipher_SecKeys { - cipher_SecKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } -} diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 2e21eae628..f4714c66fe 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -35,16 +35,6 @@ %apply GoSlice_* {coin__UxArray*} -typedef struct{ - char* p; - int n; -} GoString; - -typedef struct{ - char* p; - int n; -} GoString_; - /*GoString in typemap*/ %typemap(in) GoString { diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i new file mode 100644 index 0000000000..dfc588cc6f --- /dev/null +++ b/lib/swig/skycoin.cipher.crypto.i @@ -0,0 +1,18 @@ +%extend cipher__Address { + int isEqual(cipher__Address* a){ + if( $self-> Version == a->Version ){ + return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; + } + return 0; + } +} + +%extend cipher_SecKeys { + cipher_SecKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } +} diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index f07e1cb479..c7221a563a 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -8,9 +8,10 @@ %include "golang.cgo.i" %include "skycoin.mem.i" -%include "custom.i" +%include "skycoin.cipher.crypto.i" %include "structs_typemaps.i" +%include "swig.h" /* Find the modified copy of libskycoin */ %include "libskycoin.h" %include "structs.i" diff --git a/lib/swig/structs.i b/lib/swig/structs.i index f305f75421..0374e9b010 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -121,4 +121,4 @@ %include "api.wallet.go.h" %include "cli.check_balance.go.h" %include "cli.cli.go.h" -%include "cli.create_rawtx.go.h" +%include "cli.create_rawtx.go.h" \ No newline at end of file From 8c0a4c0bd08c2632b909a6aa132249f79e206f06 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 14:58:29 +0000 Subject: [PATCH 054/399] [swig] refs #1568. Allocate memory in library for structure cipher_SecKeys and provide method in target language to deallocate. --- include/swig.h | 3 ++- lib/swig/skycoin.cipher.crypto.i | 10 ++++++++++ lib/swig/skycoin.mem.i | 21 +++++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/swig.h b/include/swig.h index 04bb29bb2c..3ece57cc5e 100644 --- a/include/swig.h +++ b/include/swig.h @@ -26,7 +26,7 @@ typedef struct{ #define MAX_ARRAY_LENGTH_WRAP 10 typedef struct{ - cipher_SecKey data[MAX_ARRAY_LENGTH_WRAP]; + cipher_SecKey* data; int count; } cipher_SecKeys; @@ -35,3 +35,4 @@ typedef struct{ int count; } cipher_PubKeys; + diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index dfc588cc6f..1e8e6efbf7 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -16,3 +16,13 @@ return NULL; } } + +%inline{ + void recursive_delete_cipher_SecKeys(cipher_SecKeys* p){ + if( p != NULL ){ + if( p->data != NULL ){ + free( p->data ); + } + } + } +} diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index b73a96a97d..0f0c9d7047 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,20 +1,28 @@ +%newobject wrap_SKY_cipher_GenerateDeterministicKeyPairs; +%typemap(newfree) cipher_SecKeys* "recursive_delete_cipher_SecKeys($1);"; %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ + cipher_SecKeys* wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n){ + cipher_SecKeys* secKeys; if( n > MAX_ARRAY_LENGTH_WRAP ) - return -1; + return NULL; + secKeys = malloc(sizeof(cipher_SecKeys)); + memset(secKeys, 0, sizeof(cipher_SecKeys)); GoSlice_ data; - data.data = secKeys->data; + data.data = NULL; data.len = 0; - data.cap = MAX_ARRAY_LENGTH_WRAP; + data.cap = 0; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); - if( result == 0 ) + if( result == 0 ){ secKeys->count = data.len; - return result; + secKeys->data = data.data; + } + return secKeys; } } +/* %rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ @@ -30,6 +38,7 @@ return result; } } +*/ %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { From fe8e15dc0891eced9b00b3416c3f125a64542f32 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 16:28:32 +0000 Subject: [PATCH 055/399] [swig] refs #1568. Managing memory allocated in library to be released in host script language. --- include/swig.h | 3 +- lib/swig/skycoin.cipher.crypto.i | 60 +++++++++++++++++++++++++++++++- lib/swig/skycoin.mem.i | 35 +++++++++++-------- 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/include/swig.h b/include/swig.h index 3ece57cc5e..2b5176bb31 100644 --- a/include/swig.h +++ b/include/swig.h @@ -31,8 +31,7 @@ typedef struct{ } cipher_SecKeys; typedef struct{ - cipher_PubKey data[MAX_ARRAY_LENGTH_WRAP]; + cipher_PubKey* data; int count; } cipher_PubKeys; - diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index 1e8e6efbf7..d3cda09094 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -15,10 +15,68 @@ else return NULL; } + + int setAt(int i, cipher_SecKey* seckey){ + if( i < $self->count){ + memcpy(&self->data[i], seckey, sizeof(*seckey)); + return i; + } else { + return -1; + } + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + destroy_cipher_SecKeys($self); + } +} + +//Called by hosting script language when garbage collecting p +%inline{ + void destroy_cipher_SecKeys(cipher_SecKeys* p){ + if( p != NULL ){ + if( p->data != NULL ){ + free( p->data ); + } + } + } +} + +%extend cipher_PubKeys { + cipher_PubKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, cipher_PubKey* pubkey){ + if( i < $self->count){ + memcpy(&self->data[i], pubkey, sizeof(*pubkey)); + return i; + } else { + return -1; + } + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + destroy_cipher_PubKeys($self); + } } +//Called by hosting script language when garbage collecting p %inline{ - void recursive_delete_cipher_SecKeys(cipher_SecKeys* p){ + void destroy_cipher_PubKeys(cipher_PubKeys* p){ if( p != NULL ){ if( p->data != NULL ){ free( p->data ); diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 0f0c9d7047..d82c41abf7 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,12 +1,14 @@ %newobject wrap_SKY_cipher_GenerateDeterministicKeyPairs; -%typemap(newfree) cipher_SecKeys* "recursive_delete_cipher_SecKeys($1);"; +%newobject wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; +%typemap(newfree) cipher_SecKeys* "destroy_cipher_SecKeys($1);"; +%typemap(newfree) cipher_PubKeys* "destroy_cipher_PubKeys($1);"; + +//returning error code is sacrificed in order to return an allocate object that can be garbage collected %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { cipher_SecKeys* wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n){ cipher_SecKeys* secKeys; - if( n > MAX_ARRAY_LENGTH_WRAP ) - return NULL; secKeys = malloc(sizeof(cipher_SecKeys)); memset(secKeys, 0, sizeof(cipher_SecKeys)); GoSlice_ data; @@ -22,23 +24,26 @@ } } -/* + %rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ - if( n > MAX_ARRAY_LENGTH_WRAP ) - return -1; + cipher_SecKeys* wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed){ + cipher_SecKeys* secKeys; + secKeys = malloc(sizeof(cipher_SecKeys)); + memset(secKeys, 0, sizeof(cipher_SecKeys)); GoSlice_ data; - data.data = secKeys->data; + data.data = NULL; data.len = 0; - data.cap = MAX_ARRAY_LENGTH_WRAP; + data.cap = 0; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); - if( result == 0 ) + if( result == 0 ){ secKeys->count = data.len; - return result; + secKeys->data = data.data; + } + return secKeys; } } -*/ + %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { @@ -47,7 +52,7 @@ GoSlice_ data; data.data = pubKeys->data; data.len = pubKeys->count; - data.cap = MAX_ARRAY_LENGTH_WRAP; + data.cap = pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); return result; } @@ -59,7 +64,7 @@ GoSlice_ data; data.data = pubKeys->data; data.len = pubKeys->count; - data.cap = MAX_ARRAY_LENGTH_WRAP; + data.cap = pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); return result; } @@ -71,7 +76,7 @@ GoSlice_ data; data.data = pubKeys->data; data.len = pubKeys->count; - data.cap = MAX_ARRAY_LENGTH_WRAP; + data.cap = pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); return result; } From f4d33751bc5935f364cd93db5ebd6b58a037dad7 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 16:49:16 +0000 Subject: [PATCH 056/399] [swig] refs #1568. When using slices of SecKey or PubKey let the host script language allocate the memory. --- lib/swig/skycoin.mem.i | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index d82c41abf7..bc266db749 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,53 +1,31 @@ -%newobject wrap_SKY_cipher_GenerateDeterministicKeyPairs; -%newobject wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; -%typemap(newfree) cipher_SecKeys* "destroy_cipher_SecKeys($1);"; -%typemap(newfree) cipher_PubKeys* "destroy_cipher_PubKeys($1);"; - - -//returning error code is sacrificed in order to return an allocate object that can be garbage collected %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { - cipher_SecKeys* wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n){ - cipher_SecKeys* secKeys; - secKeys = malloc(sizeof(cipher_SecKeys)); - memset(secKeys, 0, sizeof(cipher_SecKeys)); + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; + data.data = secKeys->data; + data.len = secKeys->count; + data.cap = secKeys->count; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); - if( result == 0 ){ - secKeys->count = data.len; - secKeys->data = data.data; - } - return secKeys; + return result; } } %rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { - cipher_SecKeys* wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed){ - cipher_SecKeys* secKeys; - secKeys = malloc(sizeof(cipher_SecKeys)); - memset(secKeys, 0, sizeof(cipher_SecKeys)); + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; + data.data = secKeys->data; + data.len = secKeys->count; + data.cap = secKeys->count; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); - if( result == 0 ){ - secKeys->count = data.len; - secKeys->data = data.data; - } - return secKeys; + return result; } } %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { - //[]PubKey GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ GoSlice_ data; data.data = pubKeys->data; From 9350e7b9c5079db22b22f6e9a1c7356d630008c3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 17:48:46 +0000 Subject: [PATCH 057/399] [swig] refs #1568. Removed #define of max array length, not using fixed size array anymore. --- include/swig.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/swig.h b/include/swig.h index 2b5176bb31..89d47f8089 100644 --- a/include/swig.h +++ b/include/swig.h @@ -23,8 +23,6 @@ typedef struct{ GoUint8 data[4]; } cipher_Checksum; -#define MAX_ARRAY_LENGTH_WRAP 10 - typedef struct{ cipher_SecKey* data; int count; From b094695abce4923f6f4a4c6b14bf921ad62a6d9f Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 13 Jun 2018 20:08:12 +0000 Subject: [PATCH 058/399] [swig] refs #1568. Removed wrong explanation in comments. --- lib/swig/skycoin.cipher.crypto.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index d3cda09094..157a2c7031 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -35,7 +35,6 @@ } } -//Called by hosting script language when garbage collecting p %inline{ void destroy_cipher_SecKeys(cipher_SecKeys* p){ if( p != NULL ){ @@ -74,7 +73,7 @@ } } -//Called by hosting script language when garbage collecting p + %inline{ void destroy_cipher_PubKeys(cipher_PubKeys* p){ if( p != NULL ){ From b652879543a78daa55cf87a529f615bf872a7054 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 14 Jun 2018 12:28:21 +0000 Subject: [PATCH 059/399] [swig] refs #1568. Treat PubKey and SecKey slices as list, only for Python. --- lib/swig/python_pubkeys.i | 58 +++++++++++++++++++++++++++++++++++++++ lib/swig/python_seckeys.i | 53 +++++++++++++++++++++++++++++++++++ lib/swig/skycoin.mem.i | 11 ++++++-- 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 lib/swig/python_pubkeys.i create mode 100644 lib/swig/python_seckeys.i diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i new file mode 100644 index 0000000000..eac64ec951 --- /dev/null +++ b/lib/swig/python_pubkeys.i @@ -0,0 +1,58 @@ +/*cipher_SecKeys* parameter to return as a list */ +%typemap(in) (cipher_PubKeys* __in_pubKeys) { + int i; + $1->count = PyList_Size($input); + $1->data = malloc(sizeof(cipher_PubKey) * $1->count); + cipher_PubKey* pdata = $1->data; + for(i = 0; i < $1->count; i++){ + PyObject *o = PyList_GetItem($input, i); + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_PubKey, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type PubKey"); + cipher_PubKey* p = (cipher_PubKey*)argp; + memcpy(p, pdata, sizeof(cipher_PubKey)); + pdata++; + } +} + +%typemap(freearg) (cipher_PubKeys* __in_pubKeys) { + if ($1->data) free($1->data); +} + +%rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; +%inline { + GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys){ + GoSlice_ data; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; + GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); + return result; + } +} + +%rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; +%inline { + GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ + GoSlice_ data; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; + GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); + return result; + } +} + +%rename(SKY_cipher_PubKeySlice_Swap) wrap_SKY_cipher_PubKeySlice_Swap; +%inline { + GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ + GoSlice_ data; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; + GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); + return result; + } +} + diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i new file mode 100644 index 0000000000..abd234856c --- /dev/null +++ b/lib/swig/python_seckeys.i @@ -0,0 +1,53 @@ +/*cipher_SecKeys* parameter to return as a list */ +%typemap(in, numinputs=0) (cipher_SecKeys* __out_secKeys) (cipher_SecKeys temp) { + temp.data = NULL; + temp.count = 0; + $1 = &temp; +} + +/*cipher_SecKeys* as function return typemap*/ +%typemap(argout) (cipher_SecKeys* __out_secKeys) { + int i; + PyObject *list = PyList_New($1->count); + for (i = 0; i < $1->count; i++) { + cipher_SecKey* key = &($1->data[i]); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW | 0 ); + PyList_SetItem(list,i,o); + } + if( $1->data != NULL) + free( (void*)$1->data ); + %append_output( list ); +} + + +%rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; +%inline { + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); + if( result == 0){ + __out_secKeys->data = data.data; + __out_secKeys->count = data.len; + } + return result; + } +} + +%inline { + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); + if( result == 0){ + __out_secKeys->data = data.data; + __out_secKeys->count = data.len; + } + return result; + } +} + diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index bc266db749..95fba36924 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,3 +1,7 @@ +#if defined(SWIGPYTHON) + %include "python_seckeys.i" + %include "python_pubkeys.i" +#elif %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ @@ -10,7 +14,6 @@ } } - %rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ @@ -23,7 +26,6 @@ } } - %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ @@ -60,6 +62,11 @@ } } +#endif + + + + /** * * typemaps for Handles From 5b56637f8a0116a54e9ec6117a1c37b034761308 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 14 Jun 2018 14:46:18 +0000 Subject: [PATCH 060/399] [swig] refs #1568. Fixes wrong comment. --- lib/swig/python_pubkeys.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i index eac64ec951..bebebbf84d 100644 --- a/lib/swig/python_pubkeys.i +++ b/lib/swig/python_pubkeys.i @@ -1,4 +1,4 @@ -/*cipher_SecKeys* parameter to return as a list */ +/*cipher_PubKeys* input parameter */ %typemap(in) (cipher_PubKeys* __in_pubKeys) { int i; $1->count = PyList_Size($input); From 4fc2712179c1ada0c7acf3950792a751b5298947 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 17 Jun 2018 17:34:03 +0000 Subject: [PATCH 061/399] [swig] refs #1568. Bug fixed. --- lib/swig/skycoin.mem.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 95fba36924..cdc248b90e 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,7 +1,7 @@ #if defined(SWIGPYTHON) %include "python_seckeys.i" %include "python_pubkeys.i" -#elif +#else %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ From a56030b41f51821bfdc85b149cc8d84adb14d698 Mon Sep 17 00:00:00 2001 From: Carlos Ramos Date: Tue, 19 Jun 2018 01:09:13 -0400 Subject: [PATCH 062/399] [ci'] refs #1661 - New make targets : build-libc-static build-libc-shared --- Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index dc12e19c94..1e6c368781 100644 --- a/Makefile +++ b/Makefile @@ -77,18 +77,29 @@ configure-build: mkdir -p $(BUILD_DIR)/usr/tmp $(BUILD_DIR)/usr/lib $(BUILD_DIR)/usr/include mkdir -p $(BUILDLIB_DIR) $(BIN_DIR) $(INCLUDE_DIR) -build-libc: configure-build $(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a ## Build libskycoin C client library - -$(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) - rm -Rf $(BUILDLIB_DIR)/* +$(BUILDLIB_DIR)/libskycoin.so: $(LIB_FILES) $(SRC_FILES) + rm -Rf $(BUILDLIB_DIR)/libskycoin.so go build -buildmode=c-shared -o $(BUILDLIB_DIR)/libskycoin.so $(LIB_FILES) + mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ + +$(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) + rm -Rf $(BUILDLIB_DIR)/libskycoin.a go build -buildmode=c-archive -o $(BUILDLIB_DIR)/libskycoin.a $(LIB_FILES) mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ +## Build libskycoin C static library +build-libc-static: $(BUILDLIB_DIR)/libskycoin.a + +## Build libskycoin C shared library +build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so + +## Build libskycoin C client libraries +build-libc: configure-build build-libc-static build-libc-shared + ## Build libskycoin C client library and executable C test suites ## with debug symbols. Use this target to debug the source code ## with the help of an IDE -build-libc-dbg: configure-build $(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a +build-libc-dbg: configure-build build-libc-static build-libc-shared $(CC) -g -o $(BIN_DIR)/test_libskycoin_shared $(LIB_DIR)/cgo/tests/*.c -lskycoin $(LDLIBS) $(LDFLAGS) $(CC) -g -o $(BIN_DIR)/test_libskycoin_static $(LIB_DIR)/cgo/tests/*.c $(BUILDLIB_DIR)/libskycoin.a $(LDLIBS) $(LDFLAGS) From 5e63638aeb75b5e8ef76907a6e7f81c9dbf05e38 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 13:56:57 +0000 Subject: [PATCH 063/399] [swig] refs #1568. Added make rules to compilelibc as static or shared library. --- Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index dc12e19c94..1e6c368781 100644 --- a/Makefile +++ b/Makefile @@ -77,18 +77,29 @@ configure-build: mkdir -p $(BUILD_DIR)/usr/tmp $(BUILD_DIR)/usr/lib $(BUILD_DIR)/usr/include mkdir -p $(BUILDLIB_DIR) $(BIN_DIR) $(INCLUDE_DIR) -build-libc: configure-build $(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a ## Build libskycoin C client library - -$(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) - rm -Rf $(BUILDLIB_DIR)/* +$(BUILDLIB_DIR)/libskycoin.so: $(LIB_FILES) $(SRC_FILES) + rm -Rf $(BUILDLIB_DIR)/libskycoin.so go build -buildmode=c-shared -o $(BUILDLIB_DIR)/libskycoin.so $(LIB_FILES) + mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ + +$(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) + rm -Rf $(BUILDLIB_DIR)/libskycoin.a go build -buildmode=c-archive -o $(BUILDLIB_DIR)/libskycoin.a $(LIB_FILES) mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ +## Build libskycoin C static library +build-libc-static: $(BUILDLIB_DIR)/libskycoin.a + +## Build libskycoin C shared library +build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so + +## Build libskycoin C client libraries +build-libc: configure-build build-libc-static build-libc-shared + ## Build libskycoin C client library and executable C test suites ## with debug symbols. Use this target to debug the source code ## with the help of an IDE -build-libc-dbg: configure-build $(BUILDLIB_DIR)/libskycoin.so $(BUILDLIB_DIR)/libskycoin.a +build-libc-dbg: configure-build build-libc-static build-libc-shared $(CC) -g -o $(BIN_DIR)/test_libskycoin_shared $(LIB_DIR)/cgo/tests/*.c -lskycoin $(LDLIBS) $(LDFLAGS) $(CC) -g -o $(BIN_DIR)/test_libskycoin_static $(LIB_DIR)/cgo/tests/*.c $(BUILDLIB_DIR)/libskycoin.a $(LDLIBS) $(LDFLAGS) From b95a69072106c1dc409fd3b23749486313db1df1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 17:32:23 -0400 Subject: [PATCH 064/399] [libc] refs #1191. Removed unused structs. Modified some exported functions to use handles. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/api.explorer.go.h | 20 -------------------- include/api.spend.go.h | 40 --------------------------------------- lib/cgo/api.client.go | 4 ++-- lib/cgo/api.spend.go | 4 ++-- 4 files changed, 4 insertions(+), 64 deletions(-) diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h index c1ea85d870..e80bac62c3 100644 --- a/include/api.explorer.go.h +++ b/include/api.explorer.go.h @@ -1,23 +1,3 @@ -/*typedef struct{ - GoString_ CurrentSupply; - GoString_ TotalSupply; - GoString_ MaxSupply; - GoString_ CurrentCoinHourSupply; - GoString_ TotalCoinHourSupply; - GoSlice_ UnlockedAddresses; - GoSlice_ LockedAddresses; -} api__CoinSupply;*/ typedef struct{ visor__Richlist Richlist; } api__Richlist; -typedef struct{ - visor__TransactionStatus Status; - GoUint32_ Length; - GoUint8_ Type; - GoString_ Hash; - GoString_ InnerHash; - GoUint64_ Timestamp; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} api__ReadableTransaction; diff --git a/include/api.spend.go.h b/include/api.spend.go.h index e884eee5aa..e69de29bb2 100644 --- a/include/api.spend.go.h +++ b/include/api.spend.go.h @@ -1,40 +0,0 @@ -typedef struct{ - GoUint32_ Length; - GoUint8_ Type; - GoString_ TxID; - GoString_ InnerHash; - GoString_ Fee; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} api__CreatedTransaction; -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; -} api__CreatedTransactionOutput; -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; - GoString_ CalculatedHours; - GoUint64_ Time; - GoUint64_ Block; - GoString_ TxID; -} api__CreatedTransactionInput; -typedef struct{ - GoString_ ID; - GoSlice_ Addresses; - GoString_ Password; -} api__createTransactionRequestWallet; -typedef struct{ - api__CreatedTransaction Transaction; - GoString_ EncodedTransaction; -} api__CreateTransactionResponse; -typedef struct{ - httphelper__Address Address; - httphelper__Coins Coins; - httphelper__Hours * Hours; -} api__receiver; diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 023f15c23f..c84f436116 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -472,7 +472,7 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, } //export SKY_api_Client_CreateTransaction -func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.api__CreateTransactionResponse) (____error_code uint32) { +func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.CreateTransactionResponse__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -490,7 +490,7 @@ func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 __arg1, ____return_err := c.CreateTransaction(*req) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.api__CreateTransactionResponse)(unsafe.Pointer(__arg1)) + *_arg1 = registerCreateTransactionResponseHandle(__arg1) } return } diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index c78a63e345..5a65ac3c1f 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -78,7 +78,7 @@ func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _ } //export SKY_api_NewCreatedTransactionOutput -func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.api__CreatedTransactionOutput) (____error_code uint32) { +func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.CreatedTransactionOutput__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -88,7 +88,7 @@ func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.api__CreatedTransactionOutput)(unsafe.Pointer(__arg2)) + *_arg2 = registerCreatedTransactionOutputHandle(__arg2) } return } From bc5c3cc414e7b17d2794a12630542efee44a3bcb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 17:52:14 -0400 Subject: [PATCH 065/399] [libc] refs #1191. Added handle for cli.BalanceResult. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/cli.check_balance.go.h | 17 +---------------- include/skytypes.h | 7 +++++++ lib/cgo/cli.check_balance.go | 8 ++++---- lib/cgo/libsky_handle.go | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/include/cli.check_balance.go.h b/include/cli.check_balance.go.h index ad2218e8d7..8b13789179 100644 --- a/include/cli.check_balance.go.h +++ b/include/cli.check_balance.go.h @@ -1,16 +1 @@ -typedef struct{ - GoString_ Coins; - GoString_ Hours; -} cli__Balance; -typedef struct{ - cli__Balance Confirmed; - cli__Balance Spendable; - cli__Balance Expected; - GoString_ Address; -} cli__AddressBalance; -typedef struct{ - cli__Balance Confirmed; - cli__Balance Spendable; - cli__Balance Expected; - GoSlice_ Addresses; -} cli__BalanceResult; + diff --git a/include/skytypes.h b/include/skytypes.h index e5fa28e233..89ab2af724 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -289,6 +289,13 @@ typedef Handle SignedBlock__Handle; */ typedef Handle BlockBody__Handle; +/** + * Memory handle to access to cli.BalanceResult + */ + +typedef Handle BalanceResult_Handle; + + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go index 7cacb580f8..4313be2697 100644 --- a/lib/cgo/cli.check_balance.go +++ b/lib/cgo/cli.check_balance.go @@ -16,7 +16,7 @@ import ( import "C" //export SKY_cli_CheckWalletBalance -func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { +func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -30,13 +30,13 @@ func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _ __arg2, ____return_err := cli.CheckWalletBalance(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerBalanceResultHandle(__arg2) } return } //export SKY_cli_GetBalanceOfAddresses -func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { +func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -50,7 +50,7 @@ func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _ __arg2, ____return_err := cli.GetBalanceOfAddresses(c, addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerBalanceResultHandle(__arg2) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index b55575cf51..947aefa6f7 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -356,6 +356,20 @@ func lookupCreateTransactionResponseHandle(handle C.CreateTransactionResponse__H return nil, false } +func registerBalanceResultHandle(obj *cli.BalanceResult) C.BalanceResult_Handle { + return (C.BalanceResult_Handle)(registerHandle(obj)) +} + +func lookupBalanceResultHandle(handle C.BalanceResult_Handle) (*cli.BalanceResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.BalanceResult); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } From b8ebef8e1f6056fff7f924b3e106d52e022b6400 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 18:08:38 -0400 Subject: [PATCH 066/399] [libc] refs #1191. Replace visor__ReadableBlocks for GoSlice_. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/visor.readable.go.h | 3 --- lib/cgo/api.webrpc.client.go | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h index bac09f1429..ccbc43e90c 100644 --- a/include/visor.readable.go.h +++ b/include/visor.readable.go.h @@ -55,9 +55,6 @@ typedef struct{ visor__ReadableBlockBody Body; GoInt_ Size; } visor__ReadableBlock; -typedef struct{ - GoSlice_ Blocks; -} visor__ReadableBlocks; typedef struct{ GoString_ Hash; GoString_ SourceTransaction; diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 2fa7bdcf71..190334e883 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -174,7 +174,7 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri } //export SKY_webrpc_Client_GetBlocks -func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -189,13 +189,13 @@ func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, __arg1, ____return_err := c.GetBlocks(start, end) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } //export SKY_webrpc_Client_GetBlocksBySeq -func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -209,13 +209,13 @@ func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _ __arg1, ____return_err := c.GetBlocksBySeq(ss) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } //export SKY_webrpc_Client_GetLastBlocks -func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -229,7 +229,7 @@ func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 __arg1, ____return_err := c.GetLastBlocks(n) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } From 334eb03ca0e7ccdc56849e48df096361da90ac34 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 18:19:57 -0400 Subject: [PATCH 067/399] [libc] refs #1191. Added handle for api.SpendResult. Removed unneeded typedefs. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 6 ++++++ include/visor.readable.go.h | 22 ---------------------- lib/cgo/api.client.go | 4 ++-- lib/cgo/libsky_handle.go | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 89ab2af724..6e98ce56f5 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -296,6 +296,12 @@ typedef Handle BlockBody__Handle; typedef Handle BalanceResult_Handle; +/** + * Memory handle to access to api.SpendResult + */ + +typedef Handle SpendResult_Handle; + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h index ccbc43e90c..da26e4566f 100644 --- a/include/visor.readable.go.h +++ b/include/visor.readable.go.h @@ -5,28 +5,6 @@ typedef struct{ GoUint64_ BlockSeq; BOOL Unknown; } visor__TransactionStatus; -typedef struct{ - GoString_ Hash; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__ReadableTransactionOutput; -typedef struct{ - GoString_ Hash; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__ReadableTransactionInput; -typedef struct{ - GoString_ Hash; - GoUint64_ Time; - GoUint64_ BkSeq; - GoString_ SourceTransaction; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; - GoUint64_ CalculatedHours; -} visor__ReadableOutput; typedef GoSlice_ visor__ReadableOutputs; typedef struct{ GoUint32_ Length; diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index c84f436116..b2a67db0a7 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -449,7 +449,7 @@ func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wall } //export SKY_api_Client_Spend -func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.api__SpendResult) (____error_code uint32) { +func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.SpendResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -466,7 +466,7 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, __arg3, ____return_err := c.Spend(id, dst, coins, password) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg3 = *(*C.api__SpendResult)(unsafe.Pointer(__arg3)) + *_arg3 = registerSpendResultHandle(__arg3) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 947aefa6f7..6dbdb4f06a 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -370,6 +370,20 @@ func lookupBalanceResultHandle(handle C.BalanceResult_Handle) (*cli.BalanceResul return nil, false } +func registerSpendResultHandle(obj *api.SpendResult) C.SpendResult_Handle { + return (C.SpendResult_Handle)(registerHandle(obj)) +} + +func lookupSpendResultHandle(handle C.SpendResult_Handle) (*api.SpendResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.SpendResult); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } From 8b94b40f2ce7b4c2883abfebb6a03f18c94a2236 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 20:39:25 -0400 Subject: [PATCH 068/399] [libc] refs #1191. Added handle for webrpc.TransactionResult. Use copyString twice to return wallet.ReadableNote. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 6 ++++++ include/visor.readable.go.h | 27 --------------------------- lib/cgo/api.webrpc.client.go | 4 ++-- lib/cgo/libsky_handle.go | 14 ++++++++++++++ lib/cgo/wallet.notes.go | 3 ++- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 6e98ce56f5..fb2cd5258d 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -302,6 +302,12 @@ typedef Handle BalanceResult_Handle; typedef Handle SpendResult_Handle; +/** + * Memory handle to access to webrpc.TxnResult + */ + +typedef Handle TransactionResult_Handle; + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h index da26e4566f..86eeb7bed4 100644 --- a/include/visor.readable.go.h +++ b/include/visor.readable.go.h @@ -25,33 +25,6 @@ typedef struct{ GoUint32_ Version; GoString_ BodyHash; } visor__ReadableBlockHeader; -typedef struct{ - GoSlice_ Transactions; -} visor__ReadableBlockBody; -typedef struct{ - visor__ReadableBlockHeader Head; - visor__ReadableBlockBody Body; - GoInt_ Size; -} visor__ReadableBlock; -typedef struct{ - GoString_ Hash; - GoString_ SourceTransaction; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__TransactionOutputJSON; -typedef struct{ - GoString_ Hash; - GoString_ InnerHash; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} visor__TransactionJSON; -typedef struct{ - visor__ReadableBlockHeader Head; - GoUint64_ Unspents; - GoUint64_ Unconfirmed; -} visor__BlockchainMetadata; typedef struct{ visor__ReadableOutputs HeadOutputs; visor__ReadableOutputs OutgoingOutputs; diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 190334e883..9df0fba1b5 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -134,7 +134,7 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__Sta } //export SKY_webrpc_Client_GetTransactionByID -func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.webrpc__TxnResult) (____error_code uint32) { +func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.TransactionResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -148,7 +148,7 @@ func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid strin __arg1, ____return_err := c.GetTransactionByID(txid) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.webrpc__TxnResult)(unsafe.Pointer(__arg1)) + *_arg1 = registerTransactionResultHandle(__arg1) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 6dbdb4f06a..05cea89cc1 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -384,6 +384,20 @@ func lookupSpendResultHandle(handle C.SpendResult_Handle) (*api.SpendResult, boo return nil, false } +func registerTransactionResultHandle(obj *webrpc.TxnResult) C.TransactionResult_Handle { + return (C.TransactionResult_Handle)(registerHandle(obj)) +} + +func lookupTransactionResultHandle(handle C.TransactionResult_Handle) (*webrpc.TxnResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.TxnResult); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go index cb527a6ae6..20d0591058 100644 --- a/lib/cgo/wallet.notes.go +++ b/lib/cgo/wallet.notes.go @@ -110,7 +110,8 @@ func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__Readable }() note := *(*wallet.Note)(unsafe.Pointer(_note)) __arg1 := wallet.NewReadableNote(note) - *_arg1 = *(*C.wallet__ReadableNote)(unsafe.Pointer(&__arg1)) + copyString(__arg1.TransactionID, &_arg1.TransactionID) + copyString(__arg1.ActualNote, &_arg1.ActualNote) return } From 25b3c0c58cabf76b25ee98dd6e21e179dd531621 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 21:23:09 -0400 Subject: [PATCH 069/399] [libc] refs #1191. Added handles for wallet.Notes and wallet.ReadableNotes. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 12 +++++++ lib/cgo/libsky_handle.go | 28 +++++++++++++++ lib/cgo/wallet.notes.go | 74 +++++++++++++++++++++++++++------------- 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index fb2cd5258d..6e6a0563dd 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -308,6 +308,18 @@ typedef Handle SpendResult_Handle; typedef Handle TransactionResult_Handle; +/** + * Memory handle to access to wallet.Notes + */ + +typedef Handle WalletNotes_Handle; + +/** + * Memory handle to access to wallet.ReadableNotes + */ + +typedef Handle WalletReadableNotes_Handle; + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 05cea89cc1..bbad75cd5a 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -398,6 +398,34 @@ func lookupTransactionResultHandle(handle C.TransactionResult_Handle) (*webrpc.T return nil, false } +func registerWalletNotesHandle(obj *wallet.Notes) C.WalletNotes_Handle { + return (C.WalletNotes_Handle)(registerHandle(obj)) +} + +func lookupWalletNotesHandle(handle C.WalletNotes_Handle) (*wallet.Notes, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.Notes); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletReadableNotesHandle(obj *wallet.ReadableNotes) C.WalletReadableNotes_Handle { + return (C.WalletReadableNotes_Handle)(registerHandle(obj)) +} + +func lookupWalletReadableNotesHandle(handle C.WalletReadableNotes_Handle) (*wallet.ReadableNotes, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableNotes); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go index 20d0591058..6d6f160ab3 100644 --- a/lib/cgo/wallet.notes.go +++ b/lib/cgo/wallet.notes.go @@ -1,7 +1,6 @@ package main import ( - "reflect" "unsafe" wallet "github.com/skycoin/skycoin/src/wallet" @@ -28,7 +27,7 @@ func SKY_wallet_NewNotesFilename(_arg0 *C.GoString_) (____error_code uint32) { } //export SKY_wallet_LoadNotes -func SKY_wallet_LoadNotes(_dir string, _arg1 *C.wallet__Notes) (____error_code uint32) { +func SKY_wallet_LoadNotes(_dir string, _arg1 *C.WalletNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -37,13 +36,13 @@ func SKY_wallet_LoadNotes(_dir string, _arg1 *C.wallet__Notes) (____error_code u __arg1, ____return_err := wallet.LoadNotes(dir) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.wallet__Notes)(unsafe.Pointer(&__arg1)) + *_arg1 = registerWalletNotesHandle(&__arg1) } return } //export SKY_wallet_LoadReadableNotes -func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -52,18 +51,22 @@ func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.wallet__ReadableNot __arg1, ____return_err := wallet.LoadReadableNotes(filename) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(__arg1)) + *_arg1 = registerWalletReadableNotesHandle(__arg1) } return } //export SKY_wallet_ReadableNotes_Load -func SKY_wallet_ReadableNotes_Load(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { +func SKY_wallet_ReadableNotes_Load(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } filename := _filename ____return_err := rns.Load(filename) ____error_code = libErrorCode(____return_err) @@ -73,27 +76,36 @@ func SKY_wallet_ReadableNotes_Load(_rns *C.wallet__ReadableNotes, _filename stri } //export SKY_wallet_ReadableNotes_ToNotes -func SKY_wallet_ReadableNotes_ToNotes(_rns *C.wallet__ReadableNotes, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_wallet_ReadableNotes_ToNotes(_rns C.WalletReadableNotes_Handle, _arg0 *C.WalletNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := *(*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, ____return_err := rns.ToNotes() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + notes := wallet.Notes(__arg0) + *_arg0 = registerWalletNotesHandle(¬es) } return } //export SKY_wallet_ReadableNotes_Save -func SKY_wallet_ReadableNotes_Save(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { +func SKY_wallet_ReadableNotes_Save(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } filename := _filename ____return_err := rns.Save(filename) ____error_code = libErrorCode(____return_err) @@ -116,24 +128,32 @@ func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__Readable } //export SKY_wallet_NewReadableNotesFromNotes -func SKY_wallet_NewReadableNotesFromNotes(_w *C.wallet__Notes, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_NewReadableNotesFromNotes(_w C.WalletNotes_Handle, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - w := *(*wallet.Notes)(unsafe.Pointer(_w)) - __arg1 := wallet.NewReadableNotesFromNotes(w) - *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg1)) + w, ok := lookupWalletNotesHandle(_w) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg1 := wallet.NewReadableNotesFromNotes(*w) + *_arg1 = registerWalletReadableNotesHandle(&__arg1) return } //export SKY_wallet_Notes_Save -func SKY_wallet_Notes_Save(_notes *C.wallet__Notes, _dir string, _fileName string) (____error_code uint32) { +func SKY_wallet_Notes_Save(_notes C.WalletNotes_Handle, _dir string, _fileName string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } dir := _dir fileName := _fileName ____return_err := notes.Save(dir, fileName) @@ -144,12 +164,16 @@ func SKY_wallet_Notes_Save(_notes *C.wallet__Notes, _dir string, _fileName strin } //export SKY_wallet_Notes_SaveNote -func SKY_wallet_Notes_SaveNote(_notes *C.wallet__Notes, _dir string, _note *C.wallet__Note) (____error_code uint32) { +func SKY_wallet_Notes_SaveNote(_notes C.WalletNotes_Handle, _dir string, _note *C.wallet__Note) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } dir := _dir note := *(*wallet.Note)(unsafe.Pointer(_note)) ____return_err := notes.SaveNote(dir, note) @@ -160,14 +184,18 @@ func SKY_wallet_Notes_SaveNote(_notes *C.wallet__Notes, _dir string, _note *C.wa } //export SKY_wallet_Notes_ToReadable -func SKY_wallet_Notes_ToReadable(_notes *C.wallet__Notes, _arg0 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_Notes_ToReadable(_notes C.WalletNotes_Handle, _arg0 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := *(*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := notes.ToReadable() - *_arg0 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg0)) + *_arg0 = registerWalletReadableNotesHandle(&__arg0) return } From e500574ec7cb26dbbd6a55a0e4c7ffda97f20f4c Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 21:42:29 -0400 Subject: [PATCH 070/399] [libc] refs #1191. Removed unneeded typesdefs. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/api.client.go.h | 21 ------------------- include/api.wallet.go.h | 30 +-------------------------- include/api.webrpc.transaction.go.h | 6 ------ include/api.webrpc.uxout.go.h | 5 +---- include/cli.list_wallets.go.h | 5 ----- include/visor.blockdb.chain_meta.go.h | 3 +-- 6 files changed, 3 insertions(+), 67 deletions(-) diff --git a/include/api.client.go.h b/include/api.client.go.h index 7f5db8a97f..4dfe4e7cf1 100644 --- a/include/api.client.go.h +++ b/include/api.client.go.h @@ -1,25 +1,4 @@ -typedef struct{ - GoString_ ID; - GoSlice_ Addresses; - GoString_ Password; -} api__CreateTransactionRequestWallet; -typedef struct{ - GoString_ Type; - GoString_ Mode; - GoString_ ShareFactor; -} api__HoursSelection; -typedef struct{ - GoString_ Address; - GoString_ Coins; - GoString_ Hours; -} api__Receiver; typedef struct{ GoInt_ N; BOOL IncludeDistribution; } api__RichlistParams; -typedef struct{ - api__HoursSelection HoursSelection; - api__CreateTransactionRequestWallet Wallet; - GoString_ ChangeAddress; - GoSlice_ To; -} api__CreateTransactionRequest; diff --git a/include/api.wallet.go.h b/include/api.wallet.go.h index a80d2c1ff4..8b13789179 100644 --- a/include/api.wallet.go.h +++ b/include/api.wallet.go.h @@ -1,29 +1 @@ -typedef struct{ - GoSlice_ Transactions; -} api__UnconfirmedTxnsResponse; -typedef struct{ - GoString_ Address; - GoString_ Public; -} api__WalletEntry; -typedef struct{ - GoString_ Coin; - GoString_ Filename; - GoString_ Label; - GoString_ Type; - GoString_ Version; - GoString_ CryptoType; - GoInt64_ Timestamp; - BOOL Encrypted; -} api__WalletMeta; -typedef struct{ - api__WalletMeta Meta; - GoSlice_ Entries; -} api__WalletResponse; -typedef struct{ - GoString_ Address; -} api__WalletFolder; -typedef struct{ - wallet__BalancePair * Balance; - visor__ReadableTransaction * Transaction; - GoString_ Error; -} api__SpendResult; + diff --git a/include/api.webrpc.transaction.go.h b/include/api.webrpc.transaction.go.h index 5f542a6c66..e69de29bb2 100644 --- a/include/api.webrpc.transaction.go.h +++ b/include/api.webrpc.transaction.go.h @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ Txid; -} webrpc__TxIDJson; -typedef struct{ - daemon__TransactionResult * Transaction; -} webrpc__TxnResult; diff --git a/include/api.webrpc.uxout.go.h b/include/api.webrpc.uxout.go.h index f5540e314e..8b13789179 100644 --- a/include/api.webrpc.uxout.go.h +++ b/include/api.webrpc.uxout.go.h @@ -1,4 +1 @@ -typedef struct{ - GoString_ Address; - GoSlice_ UxOuts; -} webrpc__AddrUxoutResult; + diff --git a/include/cli.list_wallets.go.h b/include/cli.list_wallets.go.h index 2650079be5..e69de29bb2 100644 --- a/include/cli.list_wallets.go.h +++ b/include/cli.list_wallets.go.h @@ -1,5 +0,0 @@ -typedef struct{ - GoString_ Name; - GoString_ Label; - GoInt_ AddressNum; -} cli__WalletEntry; diff --git a/include/visor.blockdb.chain_meta.go.h b/include/visor.blockdb.chain_meta.go.h index 7d2cdc3053..8b13789179 100644 --- a/include/visor.blockdb.chain_meta.go.h +++ b/include/visor.blockdb.chain_meta.go.h @@ -1,2 +1 @@ -typedef struct{ -} blockdb__chainMeta; + From 199ec5dbe3904a82ebfa90c791605b41686edd62 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 22:00:46 -0400 Subject: [PATCH 071/399] [libc] refs #1191. Added handles for webrpc.OutputsResult and webrpc.StatusResult. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 12 ++++++++++++ lib/cgo/api.webrpc.client.go | 8 ++++---- lib/cgo/cli.outputs.go | 9 ++++----- lib/cgo/libsky_handle.go | 28 ++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 6e6a0563dd..80453c3783 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -320,6 +320,18 @@ typedef Handle WalletNotes_Handle; typedef Handle WalletReadableNotes_Handle; +/** + * Memory handle to access to webrpc.OutputsResult + */ + +typedef Handle OutputsResult_Handle; + +/** + * Memory handle to access to webrpc.StatusResult + */ + +typedef Handle StatusResult_Handle; + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 9df0fba1b5..236ed9c802 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -51,7 +51,7 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ } //export SKY_webrpc_Client_GetUnspentOutputs -func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -65,7 +65,7 @@ func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []str __arg1, ____return_err := c.GetUnspentOutputs(addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg1)) + *_arg1 = registerOutputsResultHandle(__arg1) } return } @@ -115,7 +115,7 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transa } //export SKY_webrpc_Client_GetStatus -func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__StatusResult) (____error_code uint32) { +func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -128,7 +128,7 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__Sta __arg0, ____return_err := c.GetStatus() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = *(*C.webrpc__StatusResult)(unsafe.Pointer(__arg0)) + *_arg0 = registerStatusResultHandle(__arg0) } return } diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index f2217a6e4c..f0ee2ce1e1 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -1,7 +1,6 @@ package main import ( - "unsafe" cli "github.com/skycoin/skycoin/src/cli" ) @@ -16,7 +15,7 @@ import ( import "C" //export SKY_cli_GetWalletOutputsFromFile -func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -30,13 +29,13 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerOutputsResultHandle(__arg2) } return } //export SKY_cli_GetWalletOutputs -func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -54,7 +53,7 @@ func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerOutputsResultHandle(__arg2) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index bbad75cd5a..e5491bc9b4 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -426,6 +426,34 @@ func lookupWalletReadableNotesHandle(handle C.WalletReadableNotes_Handle) (*wall return nil, false } +func registerOutputsResultHandle(obj *webrpc.OutputsResult) C.OutputsResult_Handle { + return (C.OutputsResult_Handle)(registerHandle(obj)) +} + +func lookupOutputsResultHandle(handle C.OutputsResult_Handle) (*webrpc.OutputsResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.OutputsResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerStatusResultHandle(obj *webrpc.StatusResult) C.StatusResult_Handle { + return (C.StatusResult_Handle)(registerHandle(obj)) +} + +func lookupStatusResultHandle(handle C.StatusResult_Handle) (*webrpc.StatusResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.StatusResult); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } From b1ca03858ab7158b3ea8be6c2023e1727577e0b9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 22:04:23 -0400 Subject: [PATCH 072/399] [libc] refs #1191. Fixed lint issues. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/cli.outputs.go | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index f0ee2ce1e1..b8686bb876 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -1,7 +1,6 @@ package main import ( - cli "github.com/skycoin/skycoin/src/cli" ) From 0122f38391e0de116388402b97574ce89a6f8a56 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 19 Jun 2018 23:30:30 -0400 Subject: [PATCH 073/399] [libc] refs #1191. Fix in test, memset coin__UxOut struct before using. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.transaction2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c index a79149b296..a042466397 100644 --- a/lib/cgo/tests/check_coin.transaction2.c +++ b/lib/cgo/tests/check_coin.transaction2.c @@ -407,6 +407,7 @@ int makeTestCaseArrays(test_ux* elems, int size, coin__UxArray* pArray){ if( data == NULL) return SKY_ERROR; registerMemCleanup( data ); + memset(data, 0, size * elems_size); pArray->data = data; pArray->len = size; pArray->cap = size; From 347ebfeaa96a3ad5f0a368b7e3700affb4a14928 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 20 Jun 2018 16:02:56 +0000 Subject: [PATCH 074/399] [pyskycoin] refs #1. Apply typemaps only for Python. Other languages that fit in will be added. --- lib/swig/skycoin.i | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index c7221a563a..e740299062 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -6,10 +6,17 @@ #include "swig.h" %} + +//Apply typemaps only for Python +//It can be applied to other languages that fit in +#if defined(SWIGPYTHON) %include "golang.cgo.i" %include "skycoin.mem.i" %include "skycoin.cipher.crypto.i" %include "structs_typemaps.i" +#else +%include "skycoin.cipher.crypto.i" +#endif %include "swig.h" /* Find the modified copy of libskycoin */ From bc9128ee4bcf3f110199e8f59779d579864991cf Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sat, 23 Jun 2018 23:37:20 +0000 Subject: [PATCH 075/399] [libc] ref #1191. Added function TestTransactionsSize [====] Synthesis: Tested: 127 | Passing: 127 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transactions.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 8574c80878..91d1a738a8 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -266,3 +266,27 @@ Test(coin_transaction, TestTransactionUpdateHeader) cr_assert( result == SKY_OK ); cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash) ); } + +Test(coin_transaction, TestTransactionsSize) { + int result; + Transactions__Handle txns; + result = makeTransactions(10, &txns); + cr_assert(result == SKY_OK); + GoInt size = 0; + for (size_t i = 0; i < 10; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(txns, i, &handle); + registerHandleClose(handle); + cr_assert(result == SKY_OK); + cipher__PubKeySlice p1 = {NULL, 0, 0}; + result = SKY_coin_Transaction_Serialize(handle, &p1); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Serialize failed"); + GoInt count; + size += p1.len; + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size failed"); + } + GoInt sizeTransactions; + result = SKY_coin_Transactions_Size(txns, &sizeTransactions); + cr_assert(size != 0); + cr_assert(sizeTransactions == size); +} \ No newline at end of file From 6a512855659e15cae25438d9732f0d2653aa4cbb Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 24 Jun 2018 11:23:35 +0000 Subject: [PATCH 076/399] [libc] ref #1191. Complete check_cipher.address [====] Synthesis: Tested: 131 | Passing: 131 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.address.c | 233 +++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 6d5d5f5419..c91079aa88 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -112,6 +112,37 @@ Test(cipher_address, TestAddressVerify){ } Test(cipher_address,TestAddressString){ +cipher__PubKey p; +cipher__SecKey s1; +GoInt result; +result = SKY_cipher_GenerateKeyPair(&p,&s1); +cr_assert(result==SKY_OK,"SKY_cipher_GenerateKeyPair failed"); + +cipher__Address a; +result = SKY_cipher_AddressFromPubKey(&p,&a); +cr_assert(result==SKY_OK,"SKY_cipher_AddressFromPubKey failed"); +char buffer_s[1024]; +GoString_ s= {buffer_s,0}; +result =SKY_cipher_Address_String(&a,&s); +cr_assert(result==SKY_OK,"SKY_cipher_Address_String failed"); +cipher__Address a2; +char buffer_sConvert[1024]; +GoString sConvert={buffer_sConvert,0}; +toGoString(&s,&sConvert); +result = SKY_cipher_DecodeBase58Address(sConvert,&a2); +cr_assert(result == SKY_OK); +cr_assert(eq(type(cipher__Address),a,a2)); +char buffer_s2[1024]; +GoString_ s2={buffer_s2,0}; +result = SKY_cipher_Address_String(&a2,&s2); +cr_assert(result == SKY_OK,"SKY_cipher_Address_String failed"); +cipher__Address a3; +char buffer_s2Convert[1024]; +GoString s2Convert={buffer_s2Convert,0}; +toGoString(&s2,&s2Convert); +result =SKY_cipher_DecodeBase58Address(s2Convert,&a3); +cr_assert(result == SKY_OK,"SKY_cipher_DecodeBase58Address failed"); +cr_assert(eq(type(cipher__Address),a2,a3)); } @@ -335,3 +366,205 @@ Test(cipher_address, TestAddressBulk){ } +Test(cipher_address, TestBitcoinAddressFromBytes) { + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + cipher__Address a2; + cipher__PubKeySlice pk = {NULL, 0, 0}; + result = SKY_cipher_Address_BitcoinBytes(&a, &pk); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); + GoSlice pk_convert = {pk.data, pk.len, pk.cap}; + result = SKY_cipher_BitcoinAddressFromBytes(pk_convert, &a2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(cipher__Address), a2, a)); + + cipher__PubKeySlice b; + result = SKY_cipher_Address_BitcoinBytes(&a, &b); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes"); + + GoInt_ b_len = b.len; + + // Invalid number of bytes + b.len = b.len - 2; + cipher__Address addr2; + GoSlice b_convert = {b.data, b.len, b.cap}; + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + "Invalid address length"); + + // Invalid checksum + b_convert.len = b_len; + ((char *)b_convert.data)[b_convert.len - 1] = '2'; + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + "Invalid checksum"); + + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + a.Version = 2; + char *buffer[1024]; + cipher__PubKeySlice b1 = {buffer, 0, 0}; + result = SKY_cipher_Address_BitcoinBytes(&a, &b1); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); + GoSlice b1_convert = {b1.data, b1.len, b1.cap}; + result = SKY_cipher_BitcoinAddressFromBytes(b1_convert, &addr2); + cr_assert(result == SKY_ERROR, "Invalid version"); +} + +Test(cipher_address, TestMustDecodeBase58Address) { + + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + + result = SKY_cipher_Address_Verify(&a, &p); + cr_assert(result == SKY_OK); + GoString str = {"", 0}; + cipher__Address addr; + result = SKY_cipher_MustDecodeBase58Address(str, &addr); + cr_assert(result == SKY_ERROR); + str.p = "cascs"; + str.n = 5; + result = SKY_cipher_MustDecodeBase58Address(str, &addr); + cr_assert(result == SKY_ERROR); + + char *buff_pks[1024]; + cipher__PubKeySlice b = {buff_pks, 0, 0}; + result = SKY_cipher_Address_Bytes(&a, &b); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); + int b_len = b.len; + b.len = (int)(b_len / 2); + GoSlice bConvert = {&b.data, b.len, b.cap}; + char buffer_h[1024]; + GoString_ h = {buffer_h, 0}; + result = SKY_base58_Hex2Base58String(bConvert, &h); + cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); + char buffer_hConvert[1024]; + GoString hConvert = {buffer_hConvert, 0}; + toGoString(&h, &hConvert); + result = SKY_cipher_MustDecodeBase58Address(hConvert, &addr); + cr_assert(result == SKY_ERROR); + + b.len = b_len; + GoSlice b2Convert = {b.data, b.len, b.cap}; + char buffer_h2[1024]; + GoString_ h2 = {buffer_h2, 0}; + result = SKY_base58_Hex2Base58String(b2Convert, &h2); + cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); + char buffer_h2Convert[1024]; + GoString h2Convert = {buffer_h2, 0}; + toGoString(&h2, &h2Convert); + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &addr); + cr_assert(result == SKY_OK); + + cipher__Address a2; + + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address), a, a2)); + + result = SKY_cipher_Address_String(&a, &h2); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); + toGoString(&h2, &h2Convert); + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address), a, a2)); + + char strbadAddr[1024]; + char buffer_addrStr[1024]; + GoString_ addStr = {buffer_addrStr, 0}; + result = SKY_cipher_Address_String(&a, &addStr); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); + + // preceding whitespace is invalid + strcpy(strbadAddr, " "); + strncat(strbadAddr, addStr.p, addStr.n); + GoString badAddr = {strbadAddr, strlen(strbadAddr)}; + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // preceding zeroes are invalid + strcpy(strbadAddr, "000"); + strncat(strbadAddr, addStr.p, addStr.n); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // trailing whitespace is invalid + strcpy(strbadAddr, addStr.p); + strcat(strbadAddr, " "); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // trailing zeroes are invalid + strcpy(strbadAddr, addStr.p); + strcat(strbadAddr, "000"); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); +} + +Test(cipher_address,TestAddressRoundtrip){ + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + char buffer_aBytes[1024]; + cipher__PubKeySlice aBytes= {buffer_aBytes,0}; + result = SKY_cipher_Address_Bytes(&a, &aBytes); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); + GoSlice aBytesSlice = {aBytes.data, aBytes.len, aBytes.cap}; + cipher__Address a2; + result = SKY_cipher_AddressFromBytes(aBytesSlice, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromBytes failed"); + + cr_assert(eq(type(cipher__Address),a,a2)); + char buffer_aString[1024]; + char buffer_a2String[1024]; + GoString_ aString = {buffer_aString,0}; + GoString_ a2String = {buffer_a2String,0}; + result = SKY_cipher_Address_String(&a,&aString); + result = SKY_cipher_Address_String(&a2,&a2String); + + cr_assert(eq(type(GoString_),a2String,aString)); + +} + +Test(cipher_address, TestAddressNull) { + cipher__Address a; + memset(&a, 0, sizeof(cipher__Address)); + GoUint32 result; + GoUint8 isNull; + result = SKY_cipher_Address_Null(&a, &isNull); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Null"); + cr_assert(isNull == 1); + + cipher__PubKey p; + cipher__SecKey s; + + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + result = SKY_cipher_Address_Null(&a, &isNull); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Null"); + cr_assert(isNull == 0); +} From a014fdd4d5b04ebfbc3a5faae58ba1039c3624bc Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 24 Jun 2018 11:35:04 +0000 Subject: [PATCH 077/399] [libc] ref #1191. Move all the tests from check_coin.transaction2.c to check_coin.transactions.c, so that they are all a single file [====] Synthesis: Tested: 131 | Passing: 131 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_coin.transaction2.c | 605 ------------------- lib/cgo/tests/check_coin.transactions.c | 767 ++++++++++++++++++++---- 2 files changed, 657 insertions(+), 715 deletions(-) delete mode 100644 lib/cgo/tests/check_coin.transaction2.c diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c deleted file mode 100644 index a042466397..0000000000 --- a/lib/cgo/tests/check_coin.transaction2.c +++ /dev/null @@ -1,605 +0,0 @@ -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "skycriterion.h" -#include "transutil.h" - -TestSuite(coin_transactions, .init = setup, .fini = teardown); - -Test(coin_transactions, TestTransactionVerifyInput){ - int result; - Transaction__Handle handle; - coin__Transaction* ptx; - ptx = makeTransaction(&handle); - result = SKY_coin_Transaction_VerifyInput(handle, NULL); - cr_assert( result != SKY_OK ); - coin__UxArray ux; - memset(&ux, 0, sizeof(coin__UxArray)); - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - memset(&ux, 0, sizeof(coin__UxArray)); - ux.data = malloc(3 * sizeof(coin__UxOut)); - cr_assert(ux.data != NULL); - registerMemCleanup(ux.data); - ux.len = 3; - ux.cap = 3; - memset(ux.data, 0, 3 * sizeof(coin__UxOut)); - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - coin__UxOut uxOut; - cipher__SecKey seckey; - cipher__Sig sig; - cipher__SHA256 hash; - - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - memset(&sig, 0, sizeof(cipher__Sig)); - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Invalid Tx Inner Hash - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - memset( ptx->InnerHash, 0, sizeof(cipher__SHA256) ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Ux hash mismatch - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - memset( &uxOut, 0, sizeof(coin__UxOut) ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Invalid signature - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Valid - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result == SKY_OK ); -} - -Test(coin_transactions, TestTransactionSignInputs){ - int result; - coin__Transaction* ptx; - Transaction__Handle handle; - coin__UxOut ux, ux2; - cipher__SecKey seckey, seckey2; - cipher__SHA256 hash, hash2; - cipher__Address addr, addr2; - cipher__PubKey pubkey; - GoUint16 r; - GoSlice keys; - - //Error if txns already signed - ptx = makeEmptyTransaction(&handle); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - - memset( &seckey, 0, sizeof(cipher__SecKey) ); - keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result != SKY_OK ); - - // Panics if not enough keys - ptx = makeEmptyTransaction(&handle); - memset(&seckey, 0, sizeof(cipher__SecKey)); - memset(&seckey2, 0, sizeof(cipher__SecKey)); - result = makeUxOutWithSecret( &ux, &seckey ); - cr_assert( result == SKY_OK ); - result = SKY_coin_UxOut_Hash(&ux, &hash); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result == SKY_OK ); - result = makeUxOutWithSecret( &ux2, &seckey2 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_UxOut_Hash(&ux2, &hash2); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(handle, &hash2, &r); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 40, 80); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Sigs.len == 0 ); - keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result != SKY_OK ); - cr_assert( ptx->Sigs.len == 0 ); - - // Valid signing - result = SKY_coin_Transaction_HashInner( handle, &hash ); - cr_assert( result == SKY_OK ); - keys.data = malloc(2 * sizeof(cipher__SecKey)); - cr_assert( keys.data != NULL ); - registerMemCleanup( keys.data ); - keys.len = keys.cap = 2; - memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); - memcpy(((cipher__SecKey*)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result == SKY_OK ); - cr_assert(ptx->Sigs.len == 2); - result = SKY_coin_Transaction_HashInner( handle, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, hash2) ); - - result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddressFromPubKey( &pubkey, &addr ); - cr_assert( result == SKY_OK ); - result = SKY_cipher_PubKeyFromSecKey(&seckey2, &pubkey); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddressFromPubKey( &pubkey, &addr2 ); - cr_assert( result == SKY_OK ); - - cipher__SHA256 addHash, addHash2; - result = SKY_cipher_AddSHA256(&hash, (cipher__SHA256*)ptx->In.data, &addHash); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256*)ptx->In.data) + 1, &addHash2); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig*)ptx->Sigs.data); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig*)ptx->Sigs.data)+1); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig*)ptx->Sigs.data)+1); - cr_assert( result != SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig*)ptx->Sigs.data); - cr_assert( result != SKY_OK ); -} - -Test(coin_transactions, TestTransactionHashInner){ - int result; - Transaction__Handle handle1 = 0, handle2 = 0; - coin__Transaction* ptx = NULL; - coin__Transaction* ptx2 = NULL; - ptx = makeTransaction(&handle1); - cipher__SHA256 hash, nullHash; - result = SKY_coin_Transaction_HashInner( handle1, &hash ); - cr_assert( result == SKY_OK ); - memset( &nullHash, 0, sizeof(cipher__SHA256) ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); - - // If tx.In is changed, hash should change - ptx2 = copyTransaction( handle1, &handle2 ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); - cr_assert( ptx != ptx2 ); - cr_assert(ptx2->In.len > 0); - coin__UxOut uxOut; - makeUxOut( &uxOut ); - cipher__SHA256* phash = ptx2->In.data; - result = SKY_coin_UxOut_Hash( &uxOut, phash ); - cr_assert( result == SKY_OK ); - cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); - cipher__SHA256 hash1, hash2; - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); - - // If tx.Out is changed, hash should change - handle2 = 0; - ptx2 = copyTransaction( handle1, &handle2 ); - cr_assert( ptx != ptx2 ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); - coin__TransactionOutput* output = ptx2->Out.data; - cipher__Address addr; - makeAddress( &addr ); - memcpy( &output->Address, &addr, sizeof(cipher__Address) ); - cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); - cr_assert(eq(type(cipher__Address), addr, output->Address)); - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); - - // If tx.Head is changed, hash should not change - ptx2 = copyTransaction( handle1, &handle2 ); - int len = ptx2->Sigs.len; - cipher__Sig* newSigs = malloc((len + 1) * sizeof(cipher__Sig)); - cr_assert( newSigs != NULL ); - registerMemCleanup( newSigs ); - memcpy( newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); - result = SKY_coin_Transaction_ResetSignatures(handle2, len + 1); - cr_assert( result == SKY_OK ); - memcpy( ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); - newSigs += len; - memset( newSigs, 0, sizeof(cipher__Sig) ); - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); -} - -Test(coin_transactions, TestTransactionSerialization){ - int result; - coin__Transaction* ptx; - Transaction__Handle handle; - ptx = makeTransaction(&handle); - GoSlice_ data; - memset( &data, 0, sizeof(GoSlice_) ); - result = SKY_coin_Transaction_Serialize( handle, &data ); - cr_assert( result == SKY_OK ); - registerMemCleanup( data.data ); - coin__Transaction* ptx2; - Transaction__Handle handle2; - GoSlice d = {data.data, data.len, data.cap}; - result = SKY_coin_TransactionDeserialize(d, &handle2); - cr_assert( result == SKY_OK ); - result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); - cr_assert( result == SKY_OK ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2) ); -} - -Test(coin_transactions, TestTransactionOutputHours){ - coin__Transaction* ptx; - Transaction__Handle handle; - ptx = makeEmptyTransaction(&handle); - cipher__Address addr; - makeAddress(&addr); - int result; - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 100); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 200); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 500); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0); - cr_assert( result == SKY_OK ); - GoUint64 hours; - result = SKY_coin_Transaction_OutputHours(handle, &hours); - cr_assert( result == SKY_OK ); - cr_assert( hours == 800 ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); - result = SKY_coin_Transaction_OutputHours(handle, &hours); - cr_assert( result != SKY_OK ); -} - -Test(coin_transactions, TestTransactionsHashes){ - int result; - GoSlice_ hashes = {NULL, 0, 0}; - Transactions__Handle hTxns; - result = makeTransactions(4, &hTxns); - cr_assert( result == SKY_OK ); - - result = SKY_coin_Transactions_Hashes(hTxns, &hashes); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Hashes failed" ); - registerMemCleanup( hashes.data ); - cr_assert( hashes.len == 4 ); - cipher__SHA256* ph = hashes.data; - cipher__SHA256 hash; - for(int i = 0; i < 4; i++){ - Transaction__Handle handle; - result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Hash(handle, &hash); - cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], *ph, hash) ); - ph++; - } -} - - -Test(coin_transactions, TestTransactionsTruncateBytesTo){ - int result; - Transactions__Handle h1, h2; - result = makeTransactions(10, &h1); - cr_assert( result == SKY_OK ); - GoInt length; - result = SKY_coin_Transactions_Length(h1, &length); - cr_assert( result == SKY_OK ); - int trunc = 0; - GoInt size; - for(int i = 0; i < length / 2; i++){ - Transaction__Handle handle; - result = SKY_coin_Transactions_GetAt(h1, i, &handle); - registerHandleClose(handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Size(handle, &size); - trunc += size; - cr_assert( result == SKY_OK, "SKY_coin_Transaction_Size failed" ); - } - result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerHandleClose(h2); - - GoInt length2; - result = SKY_coin_Transactions_Length(h2, &length2); - cr_assert( result == SKY_OK ); - cr_assert( length2 == length / 2 ); - result = SKY_coin_Transactions_Size( h2, &size ); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); - cr_assert( trunc == size ); - - trunc++; - result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerHandleClose(h2); - - // Stepping into next boundary has same cutoff, must exceed - result = SKY_coin_Transactions_Length(h2, &length2); - cr_assert( result == SKY_OK ); - cr_assert( length2 == length / 2 ); - result = SKY_coin_Transactions_Size( h2, &size ); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); - cr_assert( trunc - 1 == size ); -} - -typedef struct { - GoUint64 coins; - GoUint64 hours; -} test_ux; - -typedef struct { - test_ux* inUxs; - test_ux* outUxs; - int sizeIn; - int sizeOut; - GoUint64 headTime; - int failure; -} test_case; - -int makeTestCaseArrays(test_ux* elems, int size, coin__UxArray* pArray){ - if(size <= 0){ - pArray->len = 0; - pArray->cap = 0; - pArray->data = NULL; - return SKY_OK; - } - int elems_size = sizeof(coin__UxOut); - void* data; - data = malloc(size * elems_size); - if( data == NULL) - return SKY_ERROR; - registerMemCleanup( data ); - memset(data, 0, size * elems_size); - pArray->data = data; - pArray->len = size; - pArray->cap = size; - coin__UxOut* p = data; - for(int i = 0; i < size; i++){ - p->Body.Coins = elems[i].coins; - p->Body.Hours = elems[i].hours; - p++; - } - return SKY_OK; -} - -Test(coin_transactions, TestVerifyTransactionCoinsSpending){ - GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; - GoUint64 Million = 1000000; - - //Input coins overflow - test_ux in1[] = { - {MaxUint64 - Million + 1, 10}, - {Million, 0} - }; - - //Output coins overflow - test_ux in2[] = { - {10 * Million, 10} - }; - test_ux out2[] = { - {MaxUint64 - 10 * Million + 1, 0}, - {20 * Million, 1} - }; - - //Insufficient coins - test_ux in3[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out3[] = { - {20 * Million, 1}, - {10 * Million, 1} - }; - - //Destroyed coins - test_ux in4[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out4[] = { - {5 * Million, 1}, - {10 * Million, 1} - }; - - //Valid - test_ux in5[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out5[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - test_case tests[] = { - {in1, NULL, 2, 0, 0, 1}, //Input coins overflow - {in2, out2, 1, 2, 0, 1}, //Output coins overflow - {in3, out3, 2, 2, 0, 1}, //Destroyed coins - {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - {in5, out5, 2, 3, 0, 0} //Valid - }; - - coin__UxArray inArray; - coin__UxArray outArray; - int result; - int count = sizeof(tests) / sizeof(tests[0]); - for( int i = 0; i < count; i++){ - result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); - cr_assert(result == SKY_OK); - result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); - cr_assert(result == SKY_OK); - result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); - if( tests[i].failure ) - cr_assert( result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", i+1 ); - else - cr_assert( result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", i+1 ); - } -} - -Test(coin_transactions, TestVerifyTransactionHoursSpending){ - GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; - GoUint64 Million = 1000000; - - //Input hours overflow - test_ux in1[] = { - {3 * Million, MaxUint64 - Million + 1}, - {Million, Million} - }; - - //Insufficient coin hours - test_ux in2[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - - test_ux out2[] = { - {15 * Million, 10}, - {10 * Million, 11} - }; - - //coin hours time calculation overflow - test_ux in3[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - - test_ux out3[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - test_ux in4[] = { - {10 * Million, MaxUint64} - }; - - test_ux out4[] = { - {10 * Million, 1} - }; - - //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) - test_ux in5[] = { - {10 * Million, MaxUint64} - }; - - test_ux out5[] = { - {10 * Million, 0} - }; - - //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) - test_ux in6[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - test_ux out6[] = { - {15 * Million, 10}, - {10 * Million, 11} - }; - - //valid - test_ux in7[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - test_ux out7[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - test_case tests[] = { - {in1, NULL, 2, 0, 0, 1}, //Input hours overflow - {in2, out2, 2, 2, 0, 1}, //Insufficient coin hours - {in3, out3, 2, 3, MaxUint64, 1}, //coin hours time calculation overflow - {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - {in5, out5, 1, 1, 0, 0}, //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) - {in6, out6, 2, 2, 1492707255, 0}, //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) - {in7, out7, 2, 3, 0, 0}, //Valid - }; - coin__UxArray inArray; - coin__UxArray outArray; - int result; - int count = sizeof(tests) / sizeof(tests[0]); - for( int i = 0; i < count; i++){ - result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); - cr_assert(result == SKY_OK); - result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); - cr_assert(result == SKY_OK); - result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, &inArray, &outArray); - if( tests[i].failure ) - cr_assert( result != SKY_OK, "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i+1 ); - else - cr_assert( result == SKY_OK, "SKY_coin_VerifyTransactionHoursSpending failed %d", i+1 ); - } -} - - -/******************************************************* -* Tests not done because of wrapper functions were not created: -* TestTransactionsFees -* TestSortTransactions -********************************************************/ diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 91d1a738a8..665766cbb4 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -12,113 +12,112 @@ #include "skycriterion.h" #include "transutil.h" -Test(coin_transaction, TestTransactionVerify) -{ +Test(coin_transaction, TestTransactionVerify) { int result; - coin__Transaction* ptx; + coin__Transaction *ptx; Transaction__Handle handle; // Mismatch header hash ptx = makeTransaction(&handle); memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // No inputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetInputs(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // No outputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetOutputs(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - //Invalid number of Sigs + // Invalid number of Sigs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); result = SKY_coin_Transaction_ResetSignatures(handle, 20); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); int MaxUint16 = 0xFFFF; // Too many sigs & inputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetSignatures(handle, MaxUint16); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); - + cr_assert(result != SKY_OK); // Duplicate inputs coin__UxOut ux; cipher__SecKey seckey; cipher__SHA256 sha256; - makeUxOutWithSecret( &ux, &seckey ); - ptx = makeTransactionFromUxOut( &ux, &seckey, &handle); + makeUxOutWithSecret(&ux, &seckey); + ptx = makeTransactionFromUxOut(&ux, &seckey, &handle); memcpy(&sha256, ptx->In.data, sizeof(cipher__SHA256)); GoUint16 r; result = SKY_coin_Transaction_PushInput(handle, &sha256, &r); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); GoSlice seckeys; seckeys.data = malloc(sizeof(cipher__SecKey) * 2); - cr_assert( seckeys.data != NULL ); - registerMemCleanup( seckeys.data ); + cr_assert(seckeys.data != NULL); + registerMemCleanup(seckeys.data); seckeys.len = seckeys.cap = 2; - memcpy( seckeys.data, &seckey, sizeof(cipher__SecKey) ); - memcpy( ((cipher__SecKey*)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey) ); - result = SKY_coin_Transaction_SignInputs( handle, seckeys ); + memcpy(seckeys.data, &seckey, sizeof(cipher__SecKey)); + memcpy(((cipher__SecKey *)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey)); + result = SKY_coin_Transaction_SignInputs(handle, seckeys); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - //Duplicate outputs + // Duplicate outputs ptx = makeTransaction(&handle); - coin__TransactionOutput* pOutput = ptx->Out.data; + coin__TransactionOutput *pOutput = ptx->Out.data; cipher__Address addr; memcpy(&addr, &pOutput->Address, sizeof(cipher__Address)); - result = SKY_coin_Transaction_PushOutput(handle, &addr, pOutput->Coins, pOutput->Hours); - cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_PushOutput(handle, &addr, pOutput->Coins, + pOutput->Hours); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // Invalid signature, empty ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // Output coins are 0 ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 0; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow @@ -126,145 +125,140 @@ Test(coin_transaction, TestTransactionVerify) pOutput = ptx->Out.data; pOutput->Coins = MaxUint64 - 3000000; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - // Output coins are not multiples of 1e6 (valid, decimal restriction is not enforced here) + // Output coins are not multiples of 1e6 (valid, decimal restriction is not + // enforced here) ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins += 10; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); cipher__PubKey pubkey; result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - cr_assert( result == SKY_OK ); - seckeys.data = &seckey; seckeys.len = 1; seckeys.cap = 1; + cr_assert(result == SKY_OK); + seckeys.data = &seckey; + seckeys.len = 1; + seckeys.cap = 1; result = SKY_coin_Transaction_SignInputs(handle, seckeys); - cr_assert( result == SKY_OK ); - cr_assert( pOutput->Coins % 1000000 != 0 ); + cr_assert(result == SKY_OK); + cr_assert(pOutput->Coins % 1000000 != 0); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); - //Valid + // Valid ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 10000000; pOutput++; pOutput->Coins = 1000000; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); } - -Test(coin_transaction, TestTransactionPushInput) -{ +Test(coin_transaction, TestTransactionPushInput) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; coin__UxOut ux; ptx = makeEmptyTransaction(&handle); - makeUxOut( &ux ); + makeUxOut(&ux); cipher__SHA256 hash; - result = SKY_coin_UxOut_Hash( &ux, &hash ); - cr_assert( result == SKY_OK ); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); GoUint16 r; result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result == SKY_OK ); - cr_assert( r == 0 ); - cr_assert( ptx->In.len == 1 ); - cipher__SHA256* pIn = ptx->In.data; - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *pIn) ); + cr_assert(result == SKY_OK); + cr_assert(r == 0); + cr_assert(ptx->In.len == 1); + cipher__SHA256 *pIn = ptx->In.data; + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, *pIn)); GoUint16 MaxUint16 = 0xFFFF; int len = ptx->In.len; - void* data = malloc(len * sizeof(cipher__SHA256)); + void *data = malloc(len * sizeof(cipher__SHA256)); cr_assert(data != NULL); registerMemCleanup(data); - memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256) ); + memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256)); result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16 + len); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); memcpy(ptx->In.data, data, len * sizeof(cipher__Sig)); freeRegisteredMemCleanup(data); - makeUxOut( &ux ); - result = SKY_coin_UxOut_Hash( &ux, &hash ); - cr_assert( result == SKY_OK ); + makeUxOut(&ux); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result != SKY_OK ); - + cr_assert(result != SKY_OK); } - -Test(coin_transaction, TestTransactionPushOutput) -{ +Test(coin_transaction, TestTransactionPushOutput) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeEmptyTransaction(&handle); cipher__Address addr; - makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( handle, &addr, 100, 150 ); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Out.len == 1 ); - coin__TransactionOutput* pOutput = ptx->Out.data; + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 100, 150); + cr_assert(result == SKY_OK); + cr_assert(ptx->Out.len == 1); + coin__TransactionOutput *pOutput = ptx->Out.data; coin__TransactionOutput output; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = 100; output.Hours = 150; - cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); - for(int i = 1; i < 20; i++){ - makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( handle, &addr, i * 100, i * 50 ); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Out.len == i + 1 ); + cr_assert(eq(type(coin__TransactionOutput), output, *pOutput)); + for (int i = 1; i < 20; i++) { + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, i * 100, i * 50); + cr_assert(result == SKY_OK); + cr_assert(ptx->Out.len == i + 1); pOutput = ptx->Out.data; pOutput += i; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = i * 100; output.Hours = i * 50; - cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); + cr_assert(eq(type(coin__TransactionOutput), output, *pOutput)); } } -Test(coin_transaction, TestTransactionHash) -{ +Test(coin_transaction, TestTransactionHash) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeEmptyTransaction(&handle); cipher__SHA256 nullHash, hash1, hash2; - memset( &nullHash, 0, sizeof(cipher__SHA256) ); - result = SKY_coin_Transaction_Hash( handle, &hash1 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash1) ) ); - result = SKY_coin_Transaction_HashInner( handle, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash2, hash1) ) ); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + result = SKY_coin_Transaction_Hash(handle, &hash1); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], nullHash, hash1))); + result = SKY_coin_Transaction_HashInner(handle, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash2, hash1))); } - -Test(coin_transaction, TestTransactionUpdateHeader) -{ +Test(coin_transaction, TestTransactionUpdateHeader) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeTransaction(&handle); cipher__SHA256 hash, nullHash, hashInner; memcpy(&hash, &ptx->InnerHash, sizeof(cipher__SHA256)); memset(&ptx->InnerHash, 0, sizeof(cipher__SHA256)); memset(&nullHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash) ) ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash) ); - result = SKY_coin_Transaction_HashInner( handle, &hashInner ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash) ); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash))); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash)); + result = SKY_coin_Transaction_HashInner(handle, &hashInner); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash)); } Test(coin_transaction, TestTransactionsSize) { @@ -289,4 +283,557 @@ Test(coin_transaction, TestTransactionsSize) { result = SKY_coin_Transactions_Size(txns, &sizeTransactions); cr_assert(size != 0); cr_assert(sizeTransactions == size); -} \ No newline at end of file +} + +Test(coin_transactions, TestTransactionVerifyInput) { + int result; + Transaction__Handle handle; + coin__Transaction *ptx; + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_VerifyInput(handle, NULL); + cr_assert(result != SKY_OK); + coin__UxArray ux; + memset(&ux, 0, sizeof(coin__UxArray)); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + memset(&ux, 0, sizeof(coin__UxArray)); + ux.data = malloc(3 * sizeof(coin__UxOut)); + cr_assert(ux.data != NULL); + registerMemCleanup(ux.data); + ux.len = 3; + ux.cap = 3; + memset(ux.data, 0, 3 * sizeof(coin__UxOut)); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + coin__UxOut uxOut; + cipher__SecKey seckey; + cipher__Sig sig; + cipher__SHA256 hash; + + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); + cr_assert(result == SKY_OK); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + memset(&sig, 0, sizeof(cipher__Sig)); + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Invalid Tx Inner Hash + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Ux hash mismatch + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + memset(&uxOut, 0, sizeof(coin__UxOut)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Invalid signature + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Valid + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result == SKY_OK); +} + +Test(coin_transactions, TestTransactionSignInputs) { + int result; + coin__Transaction *ptx; + Transaction__Handle handle; + coin__UxOut ux, ux2; + cipher__SecKey seckey, seckey2; + cipher__SHA256 hash, hash2; + cipher__Address addr, addr2; + cipher__PubKey pubkey; + GoUint16 r; + GoSlice keys; + + // Error if txns already signed + ptx = makeEmptyTransaction(&handle); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + + memset(&seckey, 0, sizeof(cipher__SecKey)); + keys.data = &seckey; + keys.len = 1; + keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result != SKY_OK); + + // Panics if not enough keys + ptx = makeEmptyTransaction(&handle); + memset(&seckey, 0, sizeof(cipher__SecKey)); + memset(&seckey2, 0, sizeof(cipher__SecKey)); + result = makeUxOutWithSecret(&ux, &seckey); + cr_assert(result == SKY_OK); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_PushInput(handle, &hash, &r); + cr_assert(result == SKY_OK); + result = makeUxOutWithSecret(&ux2, &seckey2); + cr_assert(result == SKY_OK); + result = SKY_coin_UxOut_Hash(&ux2, &hash2); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_PushInput(handle, &hash2, &r); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 40, 80); + cr_assert(result == SKY_OK); + cr_assert(ptx->Sigs.len == 0); + keys.data = &seckey; + keys.len = 1; + keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result != SKY_OK); + cr_assert(ptx->Sigs.len == 0); + + // Valid signing + result = SKY_coin_Transaction_HashInner(handle, &hash); + cr_assert(result == SKY_OK); + keys.data = malloc(2 * sizeof(cipher__SecKey)); + cr_assert(keys.data != NULL); + registerMemCleanup(keys.data); + keys.len = keys.cap = 2; + memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); + memcpy(((cipher__SecKey *)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result == SKY_OK); + cr_assert(ptx->Sigs.len == 2); + result = SKY_coin_Transaction_HashInner(handle, &hash2); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, hash2)); + + result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddressFromPubKey(&pubkey, &addr); + cr_assert(result == SKY_OK); + result = SKY_cipher_PubKeyFromSecKey(&seckey2, &pubkey); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddressFromPubKey(&pubkey, &addr2); + cr_assert(result == SKY_OK); + + cipher__SHA256 addHash, addHash2; + result = + SKY_cipher_AddSHA256(&hash, (cipher__SHA256 *)ptx->In.data, &addHash); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256 *)ptx->In.data) + 1, + &addHash2); + cr_assert(result == SKY_OK); + result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig *)ptx->Sigs.data); + cr_assert(result == SKY_OK); + result = + SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig *)ptx->Sigs.data) + 1); + cr_assert(result == SKY_OK); + result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig *)ptx->Sigs.data) + 1); + cr_assert(result != SKY_OK); + result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig *)ptx->Sigs.data); + cr_assert(result != SKY_OK); +} + +Test(coin_transactions, TestTransactionHashInner) { + int result; + Transaction__Handle handle1 = 0, handle2 = 0; + coin__Transaction *ptx = NULL; + coin__Transaction *ptx2 = NULL; + ptx = makeTransaction(&handle1); + cipher__SHA256 hash, nullHash; + result = SKY_coin_Transaction_HashInner(handle1, &hash); + cr_assert(result == SKY_OK); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], nullHash, hash))); + + // If tx.In is changed, hash should change + ptx2 = copyTransaction(handle1, &handle2); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); + cr_assert(ptx != ptx2); + cr_assert(ptx2->In.len > 0); + coin__UxOut uxOut; + makeUxOut(&uxOut); + cipher__SHA256 *phash = ptx2->In.data; + result = SKY_coin_UxOut_Hash(&uxOut, phash); + cr_assert(result == SKY_OK); + cr_assert(not(eq(type(coin__Transaction), *ptx, *ptx2))); + cipher__SHA256 hash1, hash2; + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2))); + + // If tx.Out is changed, hash should change + handle2 = 0; + ptx2 = copyTransaction(handle1, &handle2); + cr_assert(ptx != ptx2); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); + coin__TransactionOutput *output = ptx2->Out.data; + cipher__Address addr; + makeAddress(&addr); + memcpy(&output->Address, &addr, sizeof(cipher__Address)); + cr_assert(not(eq(type(coin__Transaction), *ptx, *ptx2))); + cr_assert(eq(type(cipher__Address), addr, output->Address)); + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2))); + + // If tx.Head is changed, hash should not change + ptx2 = copyTransaction(handle1, &handle2); + int len = ptx2->Sigs.len; + cipher__Sig *newSigs = malloc((len + 1) * sizeof(cipher__Sig)); + cr_assert(newSigs != NULL); + registerMemCleanup(newSigs); + memcpy(newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); + result = SKY_coin_Transaction_ResetSignatures(handle2, len + 1); + cr_assert(result == SKY_OK); + memcpy(ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); + newSigs += len; + memset(newSigs, 0, sizeof(cipher__Sig)); + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)); +} + +Test(coin_transactions, TestTransactionSerialization) { + int result; + coin__Transaction *ptx; + Transaction__Handle handle; + ptx = makeTransaction(&handle); + GoSlice_ data; + memset(&data, 0, sizeof(GoSlice_)); + result = SKY_coin_Transaction_Serialize(handle, &data); + cr_assert(result == SKY_OK); + registerMemCleanup(data.data); + coin__Transaction *ptx2; + Transaction__Handle handle2; + GoSlice d = {data.data, data.len, data.cap}; + result = SKY_coin_TransactionDeserialize(d, &handle2); + cr_assert(result == SKY_OK); + result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); +} + +Test(coin_transactions, TestTransactionOutputHours) { + coin__Transaction *ptx; + Transaction__Handle handle; + ptx = makeEmptyTransaction(&handle); + cipher__Address addr; + makeAddress(&addr); + int result; + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 100); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 200); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 500); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0); + cr_assert(result == SKY_OK); + GoUint64 hours; + result = SKY_coin_Transaction_OutputHours(handle, &hours); + cr_assert(result == SKY_OK); + cr_assert(hours == 800); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, + 0xFFFFFFFFFFFFFFFF - 700); + result = SKY_coin_Transaction_OutputHours(handle, &hours); + cr_assert(result != SKY_OK); +} + +Test(coin_transactions, TestTransactionsHashes) { + int result; + GoSlice_ hashes = {NULL, 0, 0}; + Transactions__Handle hTxns; + result = makeTransactions(4, &hTxns); + cr_assert(result == SKY_OK); + + result = SKY_coin_Transactions_Hashes(hTxns, &hashes); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Hashes failed"); + registerMemCleanup(hashes.data); + cr_assert(hashes.len == 4); + cipher__SHA256 *ph = hashes.data; + cipher__SHA256 hash; + for (int i = 0; i < 4; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_Hash(handle, &hash); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Hash failed"); + cr_assert(eq(u8[sizeof(cipher__SHA256)], *ph, hash)); + ph++; + } +} + +Test(coin_transactions, TestTransactionsTruncateBytesTo) { + int result; + Transactions__Handle h1, h2; + result = makeTransactions(10, &h1); + cr_assert(result == SKY_OK); + GoInt length; + result = SKY_coin_Transactions_Length(h1, &length); + cr_assert(result == SKY_OK); + int trunc = 0; + GoInt size; + for (int i = 0; i < length / 2; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(h1, i, &handle); + registerHandleClose(handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_Size(handle, &size); + trunc += size; + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size failed"); + } + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed"); + registerHandleClose(h2); + + GoInt length2; + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert(result == SKY_OK); + cr_assert(length2 == length / 2); + result = SKY_coin_Transactions_Size(h2, &size); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Size failed"); + cr_assert(trunc == size); + + trunc++; + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed"); + registerHandleClose(h2); + + // Stepping into next boundary has same cutoff, must exceed + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert(result == SKY_OK); + cr_assert(length2 == length / 2); + result = SKY_coin_Transactions_Size(h2, &size); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Size failed"); + cr_assert(trunc - 1 == size); +} + +typedef struct { + GoUint64 coins; + GoUint64 hours; +} test_ux; + +typedef struct { + test_ux *inUxs; + test_ux *outUxs; + int sizeIn; + int sizeOut; + GoUint64 headTime; + int failure; +} test_case; + +int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { + if (size <= 0) { + pArray->len = 0; + pArray->cap = 0; + pArray->data = NULL; + return SKY_OK; + } + int elems_size = sizeof(coin__UxOut); + void *data; + data = malloc(size * elems_size); + if (data == NULL) + return SKY_ERROR; + registerMemCleanup(data); + memset(data, 0, size * elems_size); + pArray->data = data; + pArray->len = size; + pArray->cap = size; + coin__UxOut *p = data; + for (int i = 0; i < size; i++) { + p->Body.Coins = elems[i].coins; + p->Body.Hours = elems[i].hours; + p++; + } + return SKY_OK; +} + +Test(coin_transactions, TestVerifyTransactionCoinsSpending) { + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 Million = 1000000; + + // Input coins overflow + test_ux in1[] = {{MaxUint64 - Million + 1, 10}, {Million, 0}}; + + // Output coins overflow + test_ux in2[] = {{10 * Million, 10}}; + test_ux out2[] = {{MaxUint64 - 10 * Million + 1, 0}, {20 * Million, 1}}; + + // Insufficient coins + test_ux in3[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out3[] = {{20 * Million, 1}, {10 * Million, 1}}; + + // Destroyed coins + test_ux in4[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out4[] = {{5 * Million, 1}, {10 * Million, 1}}; + + // Valid + test_ux in5[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out5[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, // Input coins overflow + {in2, out2, 1, 2, 0, 1}, // Output coins overflow + {in3, out3, 2, 2, 0, 1}, // Destroyed coins + {in4, out4, 1, 1, Million, + 1}, // Invalid (coin hours overflow when adding earned hours, which is + // treated as 0, and now enough coin hours) + {in5, out5, 2, 3, 0, 0} // Valid + }; + + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for (int i = 0; i < count; i++) { + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); + if (tests[i].failure) + cr_assert(result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", + i + 1); + else + cr_assert(result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", + i + 1); + } +} + +Test(coin_transactions, TestVerifyTransactionHoursSpending) { + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 Million = 1000000; + + // Input hours overflow + test_ux in1[] = {{3 * Million, MaxUint64 - Million + 1}, {Million, Million}}; + + // Insufficient coin hours + test_ux in2[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out2[] = {{15 * Million, 10}, {10 * Million, 11}}; + + // coin hours time calculation overflow + test_ux in3[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out3[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + // Invalid (coin hours overflow when adding earned hours, which is treated as + // 0, and now enough coin hours) + test_ux in4[] = {{10 * Million, MaxUint64}}; + + test_ux out4[] = {{10 * Million, 1}}; + + // Valid (coin hours overflow when adding earned hours, which is treated as 0, + // but not sending any hours) + test_ux in5[] = {{10 * Million, MaxUint64}}; + + test_ux out5[] = {{10 * Million, 0}}; + + // Valid (base inputs have insufficient coin hours, but have sufficient after + // adjusting coinhours by headTime) + test_ux in6[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out6[] = {{15 * Million, 10}, {10 * Million, 11}}; + + // valid + test_ux in7[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out7[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, // Input hours overflow + {in2, out2, 2, 2, 0, 1}, // Insufficient coin hours + {in3, out3, 2, 3, MaxUint64, 1}, // coin hours time calculation overflow + {in4, out4, 1, 1, Million, + 1}, // Invalid (coin hours overflow when adding earned hours, which is + // treated as 0, and now enough coin hours) + {in5, out5, 1, 1, 0, + 0}, // Valid (coin hours overflow when adding earned hours, which is + // treated as 0, but not sending any hours) + {in6, out6, 2, 2, 1492707255, + 0}, // Valid (base inputs have insufficient coin hours, but have + // sufficient after adjusting coinhours by headTime) + {in7, out7, 2, 3, 0, 0}, // Valid + }; + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for (int i = 0; i < count; i++) { + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, + &inArray, &outArray); + if (tests[i].failure) + cr_assert(result != SKY_OK, + "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i + 1); + else + cr_assert(result == SKY_OK, + "SKY_coin_VerifyTransactionHoursSpending failed %d", i + 1); + } +} + +/******************************************************* + * Tests not done because of wrapper functions were not created: + * TestTransactionsFees + * TestSortTransactions + ********************************************************/ \ No newline at end of file From a3c411bb4a06a5626f48e10cd12f1f990fd2aec3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 12:00:02 +0000 Subject: [PATCH 078/399] [libc] refs #1191. Removed unneeded typedes. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- include/api.explorer.go.h | 4 +- include/api.webrpc.outputs.go.h | 4 +- include/api.webrpc.status.go.h | 7 +--- include/api.webrpc.webrpc.go.h | 5 --- ...her.chacha20poly1305.chacha20poly1305.go.h | 4 +- include/cipher.encoder.encoder.go.h | 6 +-- ...ipher.encrypt.scrypt_chacha20poly1305.go.h | 8 ---- include/cli.cli.go.h | 14 ------- include/cli.status.go.h | 5 --- include/cli.wallet_history.go.h | 2 +- include/coin.block.go.h | 5 --- include/consensus.blockstat.go.h | 5 +-- include/consensus.consensus.go.h | 6 +-- include/consensus.example.example_gnet.go.h | 4 +- include/daemon.daemon.go.h | 13 +------ include/daemon.gateway.go.h | 14 +------ include/daemon.gnet.message.go.h | 5 +-- include/daemon.gnet.pool.go.h | 2 +- include/daemon.messages.go.h | 30 --------------- include/daemon.pex.peerlist.go.h | 1 - include/daemon.pex.pex.go.h | 9 +---- include/daemon.rpc.go.h | 24 +----------- include/daemon.visor.go.h | 30 +-------------- include/util.logging.formatter.go.h | 13 +------ include/visor.blockchain.go.h | 9 +---- include/visor.blockdb.block_tree.go.h | 3 +- include/visor.blockdb.blockchain.go.h | 4 +- include/visor.blockdb.blocksigs.go.h | 3 +- include/visor.blockdb.unspent.go.h | 10 +---- include/visor.db.go.h | 4 +- include/visor.dbutil.dbutil.go.h | 8 +--- include/visor.historydb.address_txn.go.h | 3 +- include/visor.historydb.address_uxout.go.h | 3 +- include/visor.historydb.history_meta.go.h | 3 +- include/visor.historydb.output.go.h | 18 --------- include/visor.historydb.transaction.go.h | 7 +--- include/visor.readable.go.h | 37 ------------------- include/visor.richlist.go.h | 8 +--- include/visor.unconfirmed.go.h | 12 +----- include/visor.verify.go.h | 7 +--- include/visor.visor.go.h | 9 +---- include/wallet.notes.go.h | 2 - include/wallet.readable.go.h | 7 +--- include/wallet.service.go.h | 7 +--- include/wallet.wallet.go.h | 9 ----- lib/cgo/api.webrpc.webrpc.go | 28 -------------- 46 files changed, 34 insertions(+), 387 deletions(-) delete mode 100644 lib/cgo/api.webrpc.webrpc.go diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h index e80bac62c3..8b13789179 100644 --- a/include/api.explorer.go.h +++ b/include/api.explorer.go.h @@ -1,3 +1 @@ -typedef struct{ - visor__Richlist Richlist; -} api__Richlist; + diff --git a/include/api.webrpc.outputs.go.h b/include/api.webrpc.outputs.go.h index 63833d4494..8b13789179 100644 --- a/include/api.webrpc.outputs.go.h +++ b/include/api.webrpc.outputs.go.h @@ -1,3 +1 @@ -typedef struct{ - visor__ReadableOutputSet Outputs; -} webrpc__OutputsResult; + diff --git a/include/api.webrpc.status.go.h b/include/api.webrpc.status.go.h index 35dcb38e55..8b13789179 100644 --- a/include/api.webrpc.status.go.h +++ b/include/api.webrpc.status.go.h @@ -1,6 +1 @@ -typedef struct{ - BOOL Running; - GoUint64_ BlockNum; - GoString_ LastBlockHash; - GoString_ TimeSinceLastBlock; -} webrpc__StatusResult; + diff --git a/include/api.webrpc.webrpc.go.h b/include/api.webrpc.webrpc.go.h index b2307bfe08..e69de29bb2 100644 --- a/include/api.webrpc.webrpc.go.h +++ b/include/api.webrpc.webrpc.go.h @@ -1,5 +0,0 @@ -typedef struct{ - GoInt_ Code; - GoString_ Message; - GoString_ Data; -} webrpc__RPCError; diff --git a/include/cipher.chacha20poly1305.chacha20poly1305.go.h b/include/cipher.chacha20poly1305.chacha20poly1305.go.h index 22e4917781..8b13789179 100644 --- a/include/cipher.chacha20poly1305.chacha20poly1305.go.h +++ b/include/cipher.chacha20poly1305.chacha20poly1305.go.h @@ -1,3 +1 @@ -typedef struct{ - GoUint8_ key[32]; -} chacha20poly1305__chacha20poly1305; + diff --git a/include/cipher.encoder.encoder.go.h b/include/cipher.encoder.encoder.go.h index 8b70d1b79e..8b13789179 100644 --- a/include/cipher.encoder.encoder.go.h +++ b/include/cipher.encoder.encoder.go.h @@ -1,5 +1 @@ -typedef struct{ - GoSlice_ buf; -} encoder__coder; -typedef encoder__coder encoder__decoder; -typedef encoder__coder encoder__encoder; + diff --git a/include/cipher.encrypt.scrypt_chacha20poly1305.go.h b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h index 8e728cea45..07e1dcd759 100644 --- a/include/cipher.encrypt.scrypt_chacha20poly1305.go.h +++ b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h @@ -4,11 +4,3 @@ typedef struct{ GoInt_ P; GoInt_ KeyLen; } encrypt__ScryptChacha20poly1305; -typedef struct{ - GoInt_ N; - GoInt_ R; - GoInt_ P; - GoInt_ KeyLen; - GoSlice_ Salt; - GoSlice_ Nonce; -} encrypt__meta; diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index a1c7775c4f..aa1ffe590d 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -1,17 +1,3 @@ -typedef struct{ - GoString_ WalletDir; - GoString_ WalletName; - GoString_ DataDir; - GoString_ Coin; - GoString_ RPCAddress; - BOOL UseCSRF; -} cli__Config; -typedef struct{ - GoInt32_ _unnamed; -} cli__WalletLoadError; -typedef struct{ - GoInt32_ _unnamed; -} cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; typedef struct{ } cli__PasswordFromTerm; diff --git a/include/cli.status.go.h b/include/cli.status.go.h index 6086d80849..e69de29bb2 100644 --- a/include/cli.status.go.h +++ b/include/cli.status.go.h @@ -1,5 +0,0 @@ -typedef struct{ - webrpc__StatusResult _unnamed; - GoString_ RPCAddress; - BOOL UseCSRF; -} cli__StatusResult; diff --git a/include/cli.wallet_history.go.h b/include/cli.wallet_history.go.h index 00d158f4a3..8b13789179 100644 --- a/include/cli.wallet_history.go.h +++ b/include/cli.wallet_history.go.h @@ -1 +1 @@ -typedef GoSlice_ cli__byTime; + diff --git a/include/coin.block.go.h b/include/coin.block.go.h index 25b72ee72e..69ff0660de 100644 --- a/include/coin.block.go.h +++ b/include/coin.block.go.h @@ -1,8 +1,3 @@ - -typedef struct{ - cipher__SHA256 Hash; - cipher__SHA256 PreHash; -} coin__HashPair; typedef struct{ GoUint32_ Version; GoUint64_ Time; diff --git a/include/consensus.blockstat.go.h b/include/consensus.blockstat.go.h index 11a947abf9..8b13789179 100644 --- a/include/consensus.blockstat.go.h +++ b/include/consensus.blockstat.go.h @@ -1,4 +1 @@ -typedef GoSlice_ consensus__PriorityQueue; -typedef struct{ - consensus__PriorityQueue queue; -} consensus__BlockStatQueue; + diff --git a/include/consensus.consensus.go.h b/include/consensus.consensus.go.h index 36b52554ea..8b13789179 100644 --- a/include/consensus.consensus.go.h +++ b/include/consensus.consensus.go.h @@ -1,5 +1 @@ -typedef struct{ - cipher__Sig Sig; - cipher__SHA256 Hash; - GoUint64_ Seqno; -} consensus__BlockBase; + diff --git a/include/consensus.example.example_gnet.go.h b/include/consensus.example.example_gnet.go.h index 8413cbfb02..8b13789179 100644 --- a/include/consensus.example.example_gnet.go.h +++ b/include/consensus.example.example_gnet.go.h @@ -1,3 +1 @@ -typedef struct{ - consensus__BlockBase _unnamed; -} main__BlockBaseWrapper; + diff --git a/include/daemon.daemon.go.h b/include/daemon.daemon.go.h index 45c1f89311..8b13789179 100644 --- a/include/daemon.daemon.go.h +++ b/include/daemon.daemon.go.h @@ -1,12 +1 @@ -typedef struct{ - GoString_ Addr; - BOOL Solicited; -} daemon__ConnectEvent; -typedef struct{ - GoString_ Addr; - GoInt32_ Error; -} daemon__ConnectionError; -typedef struct{ - GoString_ Addr; - gnet__DisconnectReason Reason; -} daemon__DisconnectEvent; + diff --git a/include/daemon.gateway.go.h b/include/daemon.gateway.go.h index ad2414ea30..8b13789179 100644 --- a/include/daemon.gateway.go.h +++ b/include/daemon.gateway.go.h @@ -1,13 +1 @@ -typedef struct{ - GoInt_ BufferSize; - BOOL EnableWalletAPI; - BOOL EnableGUI; -} daemon__GatewayConfig; -typedef struct{ - GoSlice_ Txns; -} daemon__TransactionResults; -typedef struct{ - visor__TransactionStatus Status; - GoUint64_ Time; - visor__ReadableTransaction Transaction; -} daemon__TransactionResult; + diff --git a/include/daemon.gnet.message.go.h b/include/daemon.gnet.message.go.h index 17d7861530..8b13789179 100644 --- a/include/daemon.gnet.message.go.h +++ b/include/daemon.gnet.message.go.h @@ -1,4 +1 @@ -typedef struct{ - GoInt_ ConnID; - GoString_ Addr; -} gnet__MessageContext; + diff --git a/include/daemon.gnet.pool.go.h b/include/daemon.gnet.pool.go.h index 522c34ff4a..8b13789179 100644 --- a/include/daemon.gnet.pool.go.h +++ b/include/daemon.gnet.pool.go.h @@ -1 +1 @@ -typedef GoInt32_ gnet__DisconnectReason; + diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h index f133742c8c..e69de29bb2 100644 --- a/include/daemon.messages.go.h +++ b/include/daemon.messages.go.h @@ -1,30 +0,0 @@ -typedef struct{ - GoSlice_ Messages; -} daemon__MessagesConfig; -typedef struct{ - daemon__MessagesConfig Config; - GoUint32_ Mirror; -} daemon__Messages; -typedef struct{ - GoUint32_ IP; - GoUint16_ Port; -} daemon__IPAddr; -typedef struct{ - GoString_ addr; -} daemon__GetPeersMessage; -typedef struct{ -} daemon__PongMessage; -typedef struct{ - GoSlice_ Peers; - gnet__MessageContext * c; -} daemon__GivePeersMessage; -typedef struct{ - GoUint32_ Mirror; - GoUint16_ Port; - GoInt32_ Version; - gnet__MessageContext * c; - BOOL valid; -} daemon__IntroductionMessage; -typedef struct{ - gnet__MessageContext * c; -} daemon__PingMessage; diff --git a/include/daemon.pex.peerlist.go.h b/include/daemon.pex.peerlist.go.h index 8d75a422bb..e69de29bb2 100644 --- a/include/daemon.pex.peerlist.go.h +++ b/include/daemon.pex.peerlist.go.h @@ -1 +0,0 @@ -typedef GoSlice_ pex__Peers; diff --git a/include/daemon.pex.pex.go.h b/include/daemon.pex.pex.go.h index e33ca25204..8b13789179 100644 --- a/include/daemon.pex.pex.go.h +++ b/include/daemon.pex.pex.go.h @@ -1,8 +1 @@ -typedef struct{ - GoString_ Addr; - GoInt64_ LastSeen; - BOOL Private; - BOOL Trusted; - BOOL HasIncomingPort; - GoInt_ RetryTimes; -} pex__Peer; + diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h index 82c934991d..8b13789179 100644 --- a/include/daemon.rpc.go.h +++ b/include/daemon.rpc.go.h @@ -1,23 +1 @@ -typedef struct{ - GoInt_ ID; - GoString_ Addr; - GoInt64_ LastSent; - GoInt64_ LastReceived; - BOOL Outgoing; - BOOL Introduced; - GoUint32_ Mirror; - GoUint16_ ListenPort; -} daemon__Connection; -typedef struct{ - GoSlice_ Connections; -} daemon__Connections; -typedef struct{ - GoUint64_ Current; - GoUint64_ Highest; - GoSlice_ Peers; -} daemon__BlockchainProgress; -typedef struct{ - GoSlice_ Txids; -} daemon__ResendResult; -typedef struct{ -} daemon__RPC; + diff --git a/include/daemon.visor.go.h b/include/daemon.visor.go.h index 8ac65482a7..8b13789179 100644 --- a/include/daemon.visor.go.h +++ b/include/daemon.visor.go.h @@ -1,29 +1 @@ -typedef struct{ - GoString_ Address; - GoUint64_ Height; -} daemon__PeerBlockchainHeight; -typedef struct{ - GoUint64_ LastBlock; - GoUint64_ RequestedBlocks; - gnet__MessageContext * c; -} daemon__GetBlocksMessage; -typedef struct{ - GoSlice_ Blocks; - gnet__MessageContext * c; -} daemon__GiveBlocksMessage; -typedef struct{ - GoUint64_ MaxBkSeq; - gnet__MessageContext * c; -} daemon__AnnounceBlocksMessage; -typedef struct{ - GoSlice_ Txns; - gnet__MessageContext * c; -} daemon__AnnounceTxnsMessage; -typedef struct{ - GoSlice_ Txns; - gnet__MessageContext * c; -} daemon__GetTxnsMessage; -typedef struct{ - coin__Transactions Txns; - gnet__MessageContext * c; -} daemon__GiveTxnsMessage; + diff --git a/include/util.logging.formatter.go.h b/include/util.logging.formatter.go.h index 58f8dab875..8b13789179 100644 --- a/include/util.logging.formatter.go.h +++ b/include/util.logging.formatter.go.h @@ -1,12 +1 @@ -typedef struct{ - GoString_ InfoLevelStyle; - GoString_ WarnLevelStyle; - GoString_ ErrorLevelStyle; - GoString_ FatalLevelStyle; - GoString_ PanicLevelStyle; - GoString_ DebugLevelStyle; - GoString_ PrefixStyle; - GoString_ TimestampStyle; - GoString_ CallContextStyle; - GoString_ CriticalStyle; -} logging__ColorScheme; + diff --git a/include/visor.blockchain.go.h b/include/visor.blockchain.go.h index 33277ba6a8..8b13789179 100644 --- a/include/visor.blockchain.go.h +++ b/include/visor.blockchain.go.h @@ -1,8 +1 @@ -typedef struct{ - BOOL Arbitrating; - cipher__PubKey Pubkey; -} visor__BlockchainConfig; -typedef struct{ - cipher__Sig sig; - cipher__SHA256 hash; -} visor__sigHash; + diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h index deb16ea9ad..8b13789179 100644 --- a/include/visor.blockdb.block_tree.go.h +++ b/include/visor.blockdb.block_tree.go.h @@ -1,2 +1 @@ -typedef struct{ -} blockdb__blockTree; + diff --git a/include/visor.blockdb.blockchain.go.h b/include/visor.blockdb.blockchain.go.h index ade4c24131..8b13789179 100644 --- a/include/visor.blockdb.blockchain.go.h +++ b/include/visor.blockdb.blockchain.go.h @@ -1,3 +1 @@ -typedef struct{ - coin__Block * b; -} blockdb__ErrMissingSignature; + diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h index 29e49599d1..8b13789179 100644 --- a/include/visor.blockdb.blocksigs.go.h +++ b/include/visor.blockdb.blocksigs.go.h @@ -1,2 +1 @@ -typedef struct{ -} blockdb__blockSigs; + diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h index 4606d88f97..8b13789179 100644 --- a/include/visor.blockdb.unspent.go.h +++ b/include/visor.blockdb.unspent.go.h @@ -1,9 +1 @@ -typedef struct{ - GoString_ UxID; -} blockdb__ErrUnspentNotExist; -typedef struct{ -} blockdb__unspentMeta; -typedef struct{ -} blockdb__pool; -typedef struct{ -} blockdb__poolAddrIndex; + diff --git a/include/visor.db.go.h b/include/visor.db.go.h index caa2070624..8b13789179 100644 --- a/include/visor.db.go.h +++ b/include/visor.db.go.h @@ -1,3 +1 @@ -typedef struct{ - GoInt32_ _unnamed; -} visor__ErrCorruptDB; + diff --git a/include/visor.dbutil.dbutil.go.h b/include/visor.dbutil.dbutil.go.h index c86978a042..8b13789179 100644 --- a/include/visor.dbutil.dbutil.go.h +++ b/include/visor.dbutil.dbutil.go.h @@ -1,7 +1 @@ -typedef struct{ - GoString_ Bucket; - GoInt32_ Err; -} dbutil__ErrCreateBucketFailed; -typedef struct{ - GoString_ Bucket; -} dbutil__ErrBucketNotExist; + diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h index 461204b534..8b13789179 100644 --- a/include/visor.historydb.address_txn.go.h +++ b/include/visor.historydb.address_txn.go.h @@ -1,2 +1 @@ -typedef struct{ -} historydb__addressTxns; + diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h index 04a5acd6d4..8b13789179 100644 --- a/include/visor.historydb.address_uxout.go.h +++ b/include/visor.historydb.address_uxout.go.h @@ -1,2 +1 @@ -typedef struct{ -} historydb__addressUx; + diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h index be4cbdf596..8b13789179 100644 --- a/include/visor.historydb.history_meta.go.h +++ b/include/visor.historydb.history_meta.go.h @@ -1,2 +1 @@ -typedef struct{ -} historydb__historyMeta; + diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h index ab77b04b78..e69de29bb2 100644 --- a/include/visor.historydb.output.go.h +++ b/include/visor.historydb.output.go.h @@ -1,18 +0,0 @@ -typedef struct{ - GoString_ Uxid; - GoUint64_ Time; - GoUint64_ SrcBkSeq; - GoString_ SrcTx; - GoString_ OwnerAddress; - GoUint64_ Coins; - GoUint64_ Hours; - GoUint64_ SpentBlockSeq; - GoString_ SpentTxID; -} historydb__UxOutJSON; -typedef struct{ -} historydb__UxOuts; -typedef struct{ - coin__UxOut Out; - cipher__SHA256 SpentTxID; - GoUint64_ SpentBlockSeq; -} historydb__UxOut; diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h index 75c6205bdf..8b13789179 100644 --- a/include/visor.historydb.transaction.go.h +++ b/include/visor.historydb.transaction.go.h @@ -1,6 +1 @@ -typedef struct{ -} historydb__transactions; -typedef struct{ - coin__Transaction Tx; - GoUint64_ BlockSeq; -} historydb__Transaction; + diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h index 86eeb7bed4..46587f7c42 100644 --- a/include/visor.readable.go.h +++ b/include/visor.readable.go.h @@ -1,38 +1 @@ -typedef struct{ - BOOL Confirmed; - BOOL Unconfirmed; - GoUint64_ Height; - GoUint64_ BlockSeq; - BOOL Unknown; -} visor__TransactionStatus; typedef GoSlice_ visor__ReadableOutputs; -typedef struct{ - GoUint32_ Length; - GoUint8_ Type; - GoString_ Hash; - GoString_ InnerHash; - GoUint64_ Timestamp; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} visor__ReadableTransaction; -typedef struct{ - GoUint64_ BkSeq; - GoString_ BlockHash; - GoString_ PreviousBlockHash; - GoUint64_ Time; - GoUint64_ Fee; - GoUint32_ Version; - GoString_ BodyHash; -} visor__ReadableBlockHeader; -typedef struct{ - visor__ReadableOutputs HeadOutputs; - visor__ReadableOutputs OutgoingOutputs; - visor__ReadableOutputs IncomingOutputs; -} visor__ReadableOutputSet; -typedef struct{ - coin__Transaction Txn; - visor__TransactionStatus Status; - GoUint64_ Time; - GoInt_ Size; -} visor__Transaction; diff --git a/include/visor.richlist.go.h b/include/visor.richlist.go.h index 6ad0998e61..8b13789179 100644 --- a/include/visor.richlist.go.h +++ b/include/visor.richlist.go.h @@ -1,7 +1 @@ -typedef struct{ - GoString_ Address; - GoString_ Coins; - BOOL Locked; - GoUint64_ coins; -} visor__RichlistBalance; -typedef GoSlice_ visor__Richlist; + diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h index 7366404211..8b13789179 100644 --- a/include/visor.unconfirmed.go.h +++ b/include/visor.unconfirmed.go.h @@ -1,11 +1 @@ -typedef struct{ -} visor__unconfirmedTxns; -typedef struct{ -} visor__txUnspents; -typedef struct{ - coin__Transaction Txn; - GoInt64_ Received; - GoInt64_ Checked; - GoInt64_ Announced; - GoInt8_ IsValid; -} visor__UnconfirmedTxn; + diff --git a/include/visor.verify.go.h b/include/visor.verify.go.h index 284d1638f1..8b13789179 100644 --- a/include/visor.verify.go.h +++ b/include/visor.verify.go.h @@ -1,6 +1 @@ -typedef struct{ - GoInt32_ Err; -} visor__ErrTxnViolatesHardConstraint; -typedef struct{ - GoInt32_ Err; -} visor__ErrTxnViolatesSoftConstraint; + diff --git a/include/visor.visor.go.h b/include/visor.visor.go.h index 5bb3f2f9a0..8b13789179 100644 --- a/include/visor.visor.go.h +++ b/include/visor.visor.go.h @@ -1,8 +1 @@ -typedef struct{ - GoString_ Version; - GoString_ Commit; - GoString_ Branch; -} visor__BuildInfo; -typedef struct{ - GoSlice_ Addrs; -} visor__addrsFilter; + diff --git a/include/wallet.notes.go.h b/include/wallet.notes.go.h index 7fdce9e75c..2c77c0d365 100644 --- a/include/wallet.notes.go.h +++ b/include/wallet.notes.go.h @@ -1,9 +1,7 @@ -typedef GoSlice_ wallet__Notes; typedef struct{ GoString_ TxID; GoString_ Value; } wallet__Note; -typedef GoSlice_ wallet__ReadableNotes; typedef struct{ GoString_ TransactionID; GoString_ ActualNote; diff --git a/include/wallet.readable.go.h b/include/wallet.readable.go.h index 69057bc363..8b13789179 100644 --- a/include/wallet.readable.go.h +++ b/include/wallet.readable.go.h @@ -1,6 +1 @@ -typedef struct{ - GoString_ Address; - GoString_ Public; - GoString_ Secret; -} wallet__ReadableEntry; -typedef GoSlice_ wallet__ReadableEntries; + diff --git a/include/wallet.service.go.h b/include/wallet.service.go.h index dae4d8cdce..8b13789179 100644 --- a/include/wallet.service.go.h +++ b/include/wallet.service.go.h @@ -1,6 +1 @@ -typedef struct{ - GoString_ WalletDir; - GoString_ CryptoType; - BOOL EnableWalletAPI; - BOOL EnableSeedAPI; -} wallet__Config; + diff --git a/include/wallet.wallet.go.h b/include/wallet.wallet.go.h index fb405c5741..59cef856f8 100644 --- a/include/wallet.wallet.go.h +++ b/include/wallet.wallet.go.h @@ -9,15 +9,6 @@ typedef struct { typedef GoInterface_ wallet__Validator; -typedef struct{ - GoString_ Coin; - GoString_ Label; - GoString_ Seed; - BOOL Encrypt; - GoSlice_ Password; - GoString_ CryptoType; -} wallet__Options; - /** * Intermediate representation of a UxOut for sorting and spend choosing. */ diff --git a/lib/cgo/api.webrpc.webrpc.go b/lib/cgo/api.webrpc.webrpc.go deleted file mode 100644 index be2d44f87c..0000000000 --- a/lib/cgo/api.webrpc.webrpc.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "unsafe" - - webrpc "github.com/skycoin/skycoin/src/api/webrpc" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_webrpc_RPCError_Error -func SKY_webrpc_RPCError_Error(_e *C.webrpc__RPCError, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - e := *(*webrpc.RPCError)(unsafe.Pointer(_e)) - __arg0 := e.Error() - copyString(__arg0, _arg0) - return -} From b2b70d7e14c132737dcd64bf8c53a5df08aa3678 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 12:57:08 +0000 Subject: [PATCH 079/399] [libc] refs #1191. Removed empty header files. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0 . --- include/api.blockchain.go.h | 0 include/api.csrf.go.h | 0 include/api.explorer.go.h | 1 - include/api.gateway.go.h | 0 include/api.health.go.h | 0 include/api.http.go.h | 0 include/api.integration.empty.go.h | 0 include/api.network.go.h | 0 include/api.notes.go.h | 0 include/api.spend.go.h | 0 include/api.transaction.go.h | 0 include/api.uxout.go.h | 0 include/api.wallet.go.h | 1 - include/api.webrpc.block.go.h | 0 include/api.webrpc.client.go.h | 1 - include/api.webrpc.gateway.go.h | 0 include/api.webrpc.outputs.go.h | 1 - include/api.webrpc.status.go.h | 1 - include/api.webrpc.transaction.go.h | 0 include/api.webrpc.uxout.go.h | 1 - include/api.webrpc.webrpc.go.h | 0 include/cipher.base58.base58.go.h | 1 - ...her.chacha20poly1305.chacha20poly1305.go.h | 1 - ...acha20poly1305.chacha20poly1305_amd64.go.h | 0 ...ha20poly1305.chacha20poly1305_generic.go.h | 0 ...acha20poly1305.chacha20poly1305_noasm.go.h | 0 ...1305.internal.chacha20.chacha_generic.go.h | 0 include/cipher.encoder.encoder.go.h | 1 - include/cipher.go-bip39.bip39.go.h | 0 include/cipher.go-bip39.wordlist.go.h | 0 include/cipher.pbkdf2.pbkdf2.go.h | 0 include/cipher.poly1305.poly1305.go.h | 0 include/cipher.poly1305.sum_amd64.go.h | 0 include/cipher.poly1305.sum_arm.go.h | 0 include/cipher.poly1305.sum_ref.go.h | 0 include/cipher.ripemd160.ripemd160block.go.h | 0 include/cipher.ripemd160.ripmd_160.go.h | 0 include/cipher.scrypt.scrypt.go.h | 0 include/cipher.secp256k1-go.secp256_rand.go.h | 0 .../cipher.secp256k1-go.secp256k1-go2.ec.go.h | 0 ...cipher.secp256k1-go.secp256k1-go2.num.go.h | 0 ....secp256k1-go.secp256k1-go2.secp256k1.go.h | 0 ...cipher.secp256k1-go.secp256k1-go2.sig.go.h | 0 ...r.secp256k1-go.secp256k1-go2.z_consts.go.h | 0 ...her.secp256k1-go.secp256k1-go2.z_init.go.h | 0 include/cipher.secp256k1-go.secp256k1.go.h | 0 include/cli.add_private_key.go.h | 0 include/cli.address_gen.go.h | 0 include/cli.blocks.go.h | 0 include/cli.broadcast_rawtx.go.h | 0 include/cli.check_balance.go.h | 1 - include/cli.checkdb.go.h | 0 include/cli.decryptWallet.go.h | 0 include/cli.encrypt_wallet.go.h | 0 include/cli.generate_addrs.go.h | 0 include/cli.generate_wallet.go.h | 0 include/cli.integration.empty.go.h | 0 include/cli.last_blocks.go.h | 0 include/cli.list_addrs.go.h | 0 include/cli.list_wallets.go.h | 0 include/cli.outputs.go.h | 0 include/cli.send.go.h | 0 include/cli.show_seed.go.h | 0 include/cli.status.go.h | 0 include/cli.transaction.go.h | 0 include/cli.verify_address.go.h | 0 include/cli.version.go.h | 0 include/cli.wallet_dir.go.h | 0 include/cli.wallet_history.go.h | 1 - include/coin.math.go.h | 0 include/consensus.blockstat.go.h | 1 - include/consensus.connection_manager.go.h | 0 include/consensus.consensus.go.h | 1 - include/consensus.example.example.go.h | 0 include/consensus.example.example_gnet.go.h | 1 - .../consensus.example.example_minimal.go.h | 0 include/consensus.participant.go.h | 0 ...cast_channel.public_broadcast_channel.go.h | 0 include/daemon.daemon.go.h | 1 - include/daemon.gateway.go.h | 1 - include/daemon.gnet.dispatcher.go.h | 0 include/daemon.gnet.message.go.h | 1 - include/daemon.gnet.pool.go.h | 1 - include/daemon.messages.go.h | 0 include/daemon.pex.peerlist.go.h | 0 include/daemon.pex.pex.go.h | 1 - include/daemon.pool.go.h | 0 include/daemon.rpc.go.h | 1 - include/daemon.storage.go.h | 0 include/daemon.strand.strand.go.h | 0 include/daemon.visor.go.h | 1 - include/skytypes.gen.h | 101 +----------------- include/testutil.assert.assertions.go.h | 0 include/testutil.require.require.go.h | 0 include/testutil.testutil.go.h | 0 include/util.apputil.apputil.go.h | 0 include/util.browser.browser.go.h | 0 include/util.cert.cert.go.h | 0 include/util.droplet.droplet.go.h | 0 include/util.elapse.elapser.go.h | 0 include/util.fee.fee.go.h | 0 include/util.file.file.go.h | 0 include/util.http.error.go.h | 0 include/util.http.handler.go.h | 0 include/util.http.log.go.h | 0 include/util.iputil.iputil.go.h | 0 include/util.logging.formatter.go.h | 1 - include/util.logging.hooks.go.h | 0 include/util.logging.logger.go.h | 0 include/util.logging.logging.go.h | 0 include/util.utc.utc.go.h | 0 include/visor.blockchain.go.h | 1 - include/visor.blockdb.block_tree.go.h | 1 - include/visor.blockdb.blockchain.go.h | 1 - include/visor.blockdb.blocksigs.go.h | 1 - include/visor.blockdb.chain_meta.go.h | 1 - include/visor.blockdb.unspent.go.h | 1 - include/visor.db.go.h | 1 - include/visor.dbutil.dbutil.go.h | 1 - include/visor.distribution.go.h | 0 include/visor.historydb.address_txn.go.h | 1 - include/visor.historydb.address_uxout.go.h | 1 - include/visor.historydb.history_meta.go.h | 1 - include/visor.historydb.historydb.go.h | 0 include/visor.historydb.output.go.h | 0 include/visor.historydb.transaction.go.h | 1 - include/visor.richlist.go.h | 1 - include/visor.unconfirmed.go.h | 1 - include/visor.verify.go.h | 1 - include/visor.visor.go.h | 1 - include/wallet.addresses.go.h | 0 include/wallet.crypto.go.h | 1 - include/wallet.readable.go.h | 1 - include/wallet.secrets.go.h | 0 include/wallet.service.go.h | 1 - include/wallet.wallets.go.h | 0 136 files changed, 2 insertions(+), 140 deletions(-) delete mode 100644 include/api.blockchain.go.h delete mode 100644 include/api.csrf.go.h delete mode 100644 include/api.explorer.go.h delete mode 100644 include/api.gateway.go.h delete mode 100644 include/api.health.go.h delete mode 100644 include/api.http.go.h delete mode 100644 include/api.integration.empty.go.h delete mode 100644 include/api.network.go.h delete mode 100644 include/api.notes.go.h delete mode 100644 include/api.spend.go.h delete mode 100644 include/api.transaction.go.h delete mode 100644 include/api.uxout.go.h delete mode 100644 include/api.wallet.go.h delete mode 100644 include/api.webrpc.block.go.h delete mode 100644 include/api.webrpc.client.go.h delete mode 100644 include/api.webrpc.gateway.go.h delete mode 100644 include/api.webrpc.outputs.go.h delete mode 100644 include/api.webrpc.status.go.h delete mode 100644 include/api.webrpc.transaction.go.h delete mode 100644 include/api.webrpc.uxout.go.h delete mode 100644 include/api.webrpc.webrpc.go.h delete mode 100644 include/cipher.base58.base58.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h delete mode 100644 include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h delete mode 100644 include/cipher.encoder.encoder.go.h delete mode 100644 include/cipher.go-bip39.bip39.go.h delete mode 100644 include/cipher.go-bip39.wordlist.go.h delete mode 100644 include/cipher.pbkdf2.pbkdf2.go.h delete mode 100644 include/cipher.poly1305.poly1305.go.h delete mode 100644 include/cipher.poly1305.sum_amd64.go.h delete mode 100644 include/cipher.poly1305.sum_arm.go.h delete mode 100644 include/cipher.poly1305.sum_ref.go.h delete mode 100644 include/cipher.ripemd160.ripemd160block.go.h delete mode 100644 include/cipher.ripemd160.ripmd_160.go.h delete mode 100644 include/cipher.scrypt.scrypt.go.h delete mode 100644 include/cipher.secp256k1-go.secp256_rand.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.ec.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.num.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.sig.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1.go.h delete mode 100644 include/cli.add_private_key.go.h delete mode 100644 include/cli.address_gen.go.h delete mode 100644 include/cli.blocks.go.h delete mode 100644 include/cli.broadcast_rawtx.go.h delete mode 100644 include/cli.check_balance.go.h delete mode 100644 include/cli.checkdb.go.h delete mode 100644 include/cli.decryptWallet.go.h delete mode 100644 include/cli.encrypt_wallet.go.h delete mode 100644 include/cli.generate_addrs.go.h delete mode 100644 include/cli.generate_wallet.go.h delete mode 100644 include/cli.integration.empty.go.h delete mode 100644 include/cli.last_blocks.go.h delete mode 100644 include/cli.list_addrs.go.h delete mode 100644 include/cli.list_wallets.go.h delete mode 100644 include/cli.outputs.go.h delete mode 100644 include/cli.send.go.h delete mode 100644 include/cli.show_seed.go.h delete mode 100644 include/cli.status.go.h delete mode 100644 include/cli.transaction.go.h delete mode 100644 include/cli.verify_address.go.h delete mode 100644 include/cli.version.go.h delete mode 100644 include/cli.wallet_dir.go.h delete mode 100644 include/cli.wallet_history.go.h delete mode 100644 include/coin.math.go.h delete mode 100644 include/consensus.blockstat.go.h delete mode 100644 include/consensus.connection_manager.go.h delete mode 100644 include/consensus.consensus.go.h delete mode 100644 include/consensus.example.example.go.h delete mode 100644 include/consensus.example.example_gnet.go.h delete mode 100644 include/consensus.example.example_minimal.go.h delete mode 100644 include/consensus.participant.go.h delete mode 100644 include/consensus.public_broadcast_channel.public_broadcast_channel.go.h delete mode 100644 include/daemon.daemon.go.h delete mode 100644 include/daemon.gateway.go.h delete mode 100644 include/daemon.gnet.dispatcher.go.h delete mode 100644 include/daemon.gnet.message.go.h delete mode 100644 include/daemon.gnet.pool.go.h delete mode 100644 include/daemon.messages.go.h delete mode 100644 include/daemon.pex.peerlist.go.h delete mode 100644 include/daemon.pex.pex.go.h delete mode 100644 include/daemon.pool.go.h delete mode 100644 include/daemon.rpc.go.h delete mode 100644 include/daemon.storage.go.h delete mode 100644 include/daemon.strand.strand.go.h delete mode 100644 include/daemon.visor.go.h delete mode 100644 include/testutil.assert.assertions.go.h delete mode 100644 include/testutil.require.require.go.h delete mode 100644 include/testutil.testutil.go.h delete mode 100644 include/util.apputil.apputil.go.h delete mode 100644 include/util.browser.browser.go.h delete mode 100644 include/util.cert.cert.go.h delete mode 100644 include/util.droplet.droplet.go.h delete mode 100644 include/util.elapse.elapser.go.h delete mode 100644 include/util.fee.fee.go.h delete mode 100644 include/util.file.file.go.h delete mode 100644 include/util.http.error.go.h delete mode 100644 include/util.http.handler.go.h delete mode 100644 include/util.http.log.go.h delete mode 100644 include/util.iputil.iputil.go.h delete mode 100644 include/util.logging.formatter.go.h delete mode 100644 include/util.logging.hooks.go.h delete mode 100644 include/util.logging.logger.go.h delete mode 100644 include/util.logging.logging.go.h delete mode 100644 include/util.utc.utc.go.h delete mode 100644 include/visor.blockchain.go.h delete mode 100644 include/visor.blockdb.block_tree.go.h delete mode 100644 include/visor.blockdb.blockchain.go.h delete mode 100644 include/visor.blockdb.blocksigs.go.h delete mode 100644 include/visor.blockdb.chain_meta.go.h delete mode 100644 include/visor.blockdb.unspent.go.h delete mode 100644 include/visor.db.go.h delete mode 100644 include/visor.dbutil.dbutil.go.h delete mode 100644 include/visor.distribution.go.h delete mode 100644 include/visor.historydb.address_txn.go.h delete mode 100644 include/visor.historydb.address_uxout.go.h delete mode 100644 include/visor.historydb.history_meta.go.h delete mode 100644 include/visor.historydb.historydb.go.h delete mode 100644 include/visor.historydb.output.go.h delete mode 100644 include/visor.historydb.transaction.go.h delete mode 100644 include/visor.richlist.go.h delete mode 100644 include/visor.unconfirmed.go.h delete mode 100644 include/visor.verify.go.h delete mode 100644 include/visor.visor.go.h delete mode 100644 include/wallet.addresses.go.h delete mode 100644 include/wallet.crypto.go.h delete mode 100644 include/wallet.readable.go.h delete mode 100644 include/wallet.secrets.go.h delete mode 100644 include/wallet.service.go.h delete mode 100644 include/wallet.wallets.go.h diff --git a/include/api.blockchain.go.h b/include/api.blockchain.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.csrf.go.h b/include/api.csrf.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.explorer.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.gateway.go.h b/include/api.gateway.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.health.go.h b/include/api.health.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.http.go.h b/include/api.http.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.integration.empty.go.h b/include/api.integration.empty.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.network.go.h b/include/api.network.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.notes.go.h b/include/api.notes.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.spend.go.h b/include/api.spend.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.transaction.go.h b/include/api.transaction.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.uxout.go.h b/include/api.uxout.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.wallet.go.h b/include/api.wallet.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.wallet.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.block.go.h b/include/api.webrpc.block.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.webrpc.client.go.h b/include/api.webrpc.client.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.webrpc.client.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.gateway.go.h b/include/api.webrpc.gateway.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.webrpc.outputs.go.h b/include/api.webrpc.outputs.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.webrpc.outputs.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.status.go.h b/include/api.webrpc.status.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.webrpc.status.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.transaction.go.h b/include/api.webrpc.transaction.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.webrpc.uxout.go.h b/include/api.webrpc.uxout.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.webrpc.uxout.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.webrpc.go.h b/include/api.webrpc.webrpc.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.base58.base58.go.h b/include/cipher.base58.base58.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cipher.base58.base58.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/cipher.chacha20poly1305.chacha20poly1305.go.h b/include/cipher.chacha20poly1305.chacha20poly1305.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cipher.chacha20poly1305.chacha20poly1305.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h b/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.encoder.encoder.go.h b/include/cipher.encoder.encoder.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cipher.encoder.encoder.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/cipher.go-bip39.bip39.go.h b/include/cipher.go-bip39.bip39.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.go-bip39.wordlist.go.h b/include/cipher.go-bip39.wordlist.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.pbkdf2.pbkdf2.go.h b/include/cipher.pbkdf2.pbkdf2.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.poly1305.go.h b/include/cipher.poly1305.poly1305.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_amd64.go.h b/include/cipher.poly1305.sum_amd64.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_arm.go.h b/include/cipher.poly1305.sum_arm.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_ref.go.h b/include/cipher.poly1305.sum_ref.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.ripemd160.ripemd160block.go.h b/include/cipher.ripemd160.ripemd160block.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.ripemd160.ripmd_160.go.h b/include/cipher.ripemd160.ripmd_160.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.scrypt.scrypt.go.h b/include/cipher.scrypt.scrypt.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256_rand.go.h b/include/cipher.secp256k1-go.secp256_rand.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h b/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.num.go.h b/include/cipher.secp256k1-go.secp256k1-go2.num.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h b/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.add_private_key.go.h b/include/cli.add_private_key.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.address_gen.go.h b/include/cli.address_gen.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.blocks.go.h b/include/cli.blocks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.broadcast_rawtx.go.h b/include/cli.broadcast_rawtx.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.check_balance.go.h b/include/cli.check_balance.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cli.check_balance.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/cli.checkdb.go.h b/include/cli.checkdb.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.decryptWallet.go.h b/include/cli.decryptWallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.encrypt_wallet.go.h b/include/cli.encrypt_wallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.generate_addrs.go.h b/include/cli.generate_addrs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.generate_wallet.go.h b/include/cli.generate_wallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.integration.empty.go.h b/include/cli.integration.empty.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.last_blocks.go.h b/include/cli.last_blocks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.list_addrs.go.h b/include/cli.list_addrs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.list_wallets.go.h b/include/cli.list_wallets.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.outputs.go.h b/include/cli.outputs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.send.go.h b/include/cli.send.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.show_seed.go.h b/include/cli.show_seed.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.status.go.h b/include/cli.status.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.transaction.go.h b/include/cli.transaction.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.verify_address.go.h b/include/cli.verify_address.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.version.go.h b/include/cli.version.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.wallet_dir.go.h b/include/cli.wallet_dir.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.wallet_history.go.h b/include/cli.wallet_history.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cli.wallet_history.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/coin.math.go.h b/include/coin.math.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.blockstat.go.h b/include/consensus.blockstat.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/consensus.blockstat.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/consensus.connection_manager.go.h b/include/consensus.connection_manager.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.consensus.go.h b/include/consensus.consensus.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/consensus.consensus.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/consensus.example.example.go.h b/include/consensus.example.example.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.example.example_gnet.go.h b/include/consensus.example.example_gnet.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/consensus.example.example_gnet.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/consensus.example.example_minimal.go.h b/include/consensus.example.example_minimal.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.participant.go.h b/include/consensus.participant.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h b/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.daemon.go.h b/include/daemon.daemon.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.daemon.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.gateway.go.h b/include/daemon.gateway.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.gateway.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.gnet.dispatcher.go.h b/include/daemon.gnet.dispatcher.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.gnet.message.go.h b/include/daemon.gnet.message.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.gnet.message.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.gnet.pool.go.h b/include/daemon.gnet.pool.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.gnet.pool.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.pex.peerlist.go.h b/include/daemon.pex.peerlist.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.pex.pex.go.h b/include/daemon.pex.pex.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.pex.pex.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.pool.go.h b/include/daemon.pool.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.rpc.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/daemon.storage.go.h b/include/daemon.storage.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.strand.strand.go.h b/include/daemon.strand.strand.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.visor.go.h b/include/daemon.visor.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/daemon.visor.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/skytypes.gen.h b/include/skytypes.gen.h index 1448d53d94..367e08f86f 100644 --- a/include/skytypes.gen.h +++ b/include/skytypes.gen.h @@ -1,124 +1,27 @@ #include "cipher.hash.go.h" #include "cipher.address.go.h" -#include "cipher.base58.base58.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_generic.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" -#include "cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" #include "cipher.crypto.go.h" -#include "cipher.encoder.encoder.go.h" #include "cipher.encoder.field.go.h" #include "cipher.encrypt.scrypt_chacha20poly1305.go.h" #include "cipher.encrypt.sha256xor.go.h" -#include "cipher.go-bip39.bip39.go.h" -#include "cipher.go-bip39.wordlist.go.h" -#include "cipher.pbkdf2.pbkdf2.go.h" -#include "cipher.poly1305.poly1305.go.h" -#include "cipher.poly1305.sum_amd64.go.h" -#include "cipher.poly1305.sum_arm.go.h" -#include "cipher.poly1305.sum_ref.go.h" -#include "cipher.ripemd160.ripemd160block.go.h" -#include "cipher.ripemd160.ripmd_160.go.h" -#include "cipher.scrypt.scrypt.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.ec.go.h" #include "cipher.secp256k1-go.secp256k1-go2.field.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.num.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.sig.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.z_init.go.h" -#include "cipher.secp256k1-go.secp256k1.go.h" -#include "cipher.secp256k1-go.secp256_rand.go.h" #include "coin.transactions.go.h" #include "coin.block.go.h" #include "coin.outputs.go.h" -#include "consensus.blockstat.go.h" -#include "consensus.connection_manager.go.h" -#include "consensus.consensus.go.h" -#include "consensus.participant.go.h" -#include "consensus.public_broadcast_channel.public_broadcast_channel.go.h" - -#include "testutil.assert.assertions.go.h" -#include "testutil.require.require.go.h" -#include "util.browser.browser.go.h" -#include "util.cert.cert.go.h" -#include "util.droplet.droplet.go.h" -#include "util.elapse.elapser.go.h" -#include "util.fee.fee.go.h" -#include "util.file.file.go.h" -#include "util.http.error.go.h" -#include "util.http.handler.go.h" -#include "util.http.json.go.h" -#include "util.http.log.go.h" -#include "util.iputil.iputil.go.h" -#include "util.logging.formatter.go.h" -#include "util.logging.hooks.go.h" -#include "util.logging.logger.go.h" -#include "util.logging.logging.go.h" -#include "util.utc.utc.go.h" -#include "visor.blockchain.go.h" -#include "visor.visor.go.h" -#include "visor.blockdb.blockchain.go.h" -#include "visor.blockdb.blocksigs.go.h" -#include "visor.blockdb.block_tree.go.h" -#include "visor.blockdb.unspent.go.h" -#include "visor.db.go.h" -#include "visor.distribution.go.h" -#include "visor.historydb.address_txn.go.h" -#include "visor.historydb.address_uxout.go.h" -#include "visor.historydb.historydb.go.h" -#include "visor.historydb.history_meta.go.h" -#include "visor.historydb.output.go.h" -#include "visor.historydb.transaction.go.h" #include "visor.readable.go.h" -#include "visor.richlist.go.h" -#include "visor.unconfirmed.go.h" -#include "visor.verify.go.h" -#include "daemon.gnet.pool.go.h" -#include "daemon.gnet.message.go.h" -#include "daemon.messages.go.h" -#include "daemon.daemon.go.h" -#include "daemon.gateway.go.h" -#include "daemon.gnet.dispatcher.go.h" -#include "daemon.pex.peerlist.go.h" -#include "daemon.pex.pex.go.h" -#include "daemon.pool.go.h" -#include "daemon.rpc.go.h" -#include "daemon.storage.go.h" -#include "daemon.strand.strand.go.h" -#include "daemon.visor.go.h" - -#include "api.webrpc.block.go.h" -#include "api.webrpc.client.go.h" -#include "api.webrpc.gateway.go.h" -#include "api.webrpc.outputs.go.h" -#include "api.webrpc.status.go.h" -#include "api.webrpc.transaction.go.h" -#include "api.webrpc.uxout.go.h" -#include "api.webrpc.webrpc.go.h" -#include "wallet.addresses.go.h" #include "wallet.balance.go.h" -#include "wallet.crypto.go.h" #include "wallet.entry.go.h" #include "wallet.notes.go.h" -#include "wallet.readable.go.h" -#include "wallet.secrets.go.h" -#include "wallet.service.go.h" #include "wallet.wallet.go.h" -#include "wallet.wallets.go.h" #include "api.client.go.h" -#include "api.explorer.go.h" -#include "api.spend.go.h" -#include "api.wallet.go.h" -#include "cli.check_balance.go.h" #include "cli.cli.go.h" -#include "cli.create_rawtx.go.h" \ No newline at end of file +#include "cli.create_rawtx.go.h" +#include "util.http.json.go.h" diff --git a/include/testutil.assert.assertions.go.h b/include/testutil.assert.assertions.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/testutil.require.require.go.h b/include/testutil.require.require.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/testutil.testutil.go.h b/include/testutil.testutil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.apputil.apputil.go.h b/include/util.apputil.apputil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.browser.browser.go.h b/include/util.browser.browser.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.cert.cert.go.h b/include/util.cert.cert.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.droplet.droplet.go.h b/include/util.droplet.droplet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.elapse.elapser.go.h b/include/util.elapse.elapser.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.fee.fee.go.h b/include/util.fee.fee.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.file.file.go.h b/include/util.file.file.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.error.go.h b/include/util.http.error.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.handler.go.h b/include/util.http.handler.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.log.go.h b/include/util.http.log.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.iputil.iputil.go.h b/include/util.iputil.iputil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.formatter.go.h b/include/util.logging.formatter.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/util.logging.formatter.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/util.logging.hooks.go.h b/include/util.logging.hooks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.logger.go.h b/include/util.logging.logger.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.logging.go.h b/include/util.logging.logging.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.utc.utc.go.h b/include/util.utc.utc.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.blockchain.go.h b/include/visor.blockchain.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockchain.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockdb.block_tree.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.blockdb.blockchain.go.h b/include/visor.blockdb.blockchain.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockdb.blockchain.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockdb.blocksigs.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.blockdb.chain_meta.go.h b/include/visor.blockdb.chain_meta.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockdb.chain_meta.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.blockdb.unspent.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.db.go.h b/include/visor.db.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.db.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.dbutil.dbutil.go.h b/include/visor.dbutil.dbutil.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.dbutil.dbutil.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.distribution.go.h b/include/visor.distribution.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.historydb.address_txn.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.historydb.address_uxout.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.historydb.history_meta.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.historydb.historydb.go.h b/include/visor.historydb.historydb.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.historydb.transaction.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.richlist.go.h b/include/visor.richlist.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.richlist.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.unconfirmed.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.verify.go.h b/include/visor.verify.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.verify.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/visor.visor.go.h b/include/visor.visor.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/visor.visor.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/wallet.addresses.go.h b/include/wallet.addresses.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/wallet.crypto.go.h b/include/wallet.crypto.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/wallet.crypto.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/wallet.readable.go.h b/include/wallet.readable.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/wallet.readable.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/wallet.secrets.go.h b/include/wallet.secrets.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/wallet.service.go.h b/include/wallet.service.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/wallet.service.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/wallet.wallets.go.h b/include/wallet.wallets.go.h deleted file mode 100644 index e69de29bb2..0000000000 From cc505745dcc45d40e657f82e082cfbd3e2ecf4a2 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 13:09:27 +0000 Subject: [PATCH 080/399] [libc] refs #1191. Removed empty C library source files. [====] Synthesis: Tested: 126 | Passing: 126 | Failing: 0 | Crashing: 0. --- lib/cgo/api.blockchain.go | 10 ---------- lib/cgo/api.csrf.go | 10 ---------- lib/cgo/api.gateway.go | 10 ---------- lib/cgo/api.health.go | 10 ---------- lib/cgo/api.http.go | 10 ---------- lib/cgo/api.integration.empty.go | 10 ---------- lib/cgo/api.network.go | 10 ---------- lib/cgo/api.notes.go | 10 ---------- lib/cgo/api.transaction.go | 10 ---------- lib/cgo/api.uxout.go | 10 ---------- lib/cgo/api.webrpc.block.go | 10 ---------- lib/cgo/api.webrpc.gateway.go | 10 ---------- lib/cgo/api.webrpc.outputs.go | 10 ---------- lib/cgo/api.webrpc.status.go | 10 ---------- lib/cgo/api.webrpc.transaction.go | 10 ---------- lib/cgo/api.webrpc.uxout.go | 10 ---------- lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go | 10 ---------- lib/cgo/cipher.encoder.encoder.go | 10 ---------- lib/cgo/cipher.go-bip39.wordlist.go | 10 ---------- lib/cgo/cipher.pbkdf2.pbkdf2.go | 10 ---------- lib/cgo/cipher.ripemd160.ripemd160block.go | 10 ---------- lib/cgo/cipher.ripemd160.ripmd_160.go | 10 ---------- lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go | 10 ---------- lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go | 10 ---------- lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go | 10 ---------- lib/cgo/cli.address_gen.go | 10 ---------- lib/cgo/cli.blocks.go | 10 ---------- lib/cgo/cli.broadcast_rawtx.go | 10 ---------- lib/cgo/cli.checkdb.go | 10 ---------- lib/cgo/cli.decryptWallet.go | 10 ---------- lib/cgo/cli.encrypt_wallet.go | 10 ---------- lib/cgo/cli.integration.empty.go | 10 ---------- lib/cgo/cli.last_blocks.go | 10 ---------- lib/cgo/cli.list_addrs.go | 10 ---------- lib/cgo/cli.list_wallets.go | 10 ---------- lib/cgo/cli.send.go | 10 ---------- lib/cgo/cli.show_seed.go | 10 ---------- lib/cgo/cli.status.go | 10 ---------- lib/cgo/cli.transaction.go | 10 ---------- lib/cgo/cli.verify_address.go | 10 ---------- lib/cgo/cli.version.go | 10 ---------- lib/cgo/cli.wallet_dir.go | 10 ---------- lib/cgo/cli.wallet_history.go | 10 ---------- lib/cgo/testutil.assert.assertions.go | 10 ---------- lib/cgo/testutil.require.require.go | 10 ---------- lib/cgo/util.elapse.elapser.go | 10 ---------- lib/cgo/util.http.error.go | 10 ---------- lib/cgo/util.http.handler.go | 10 ---------- lib/cgo/util.http.log.go | 10 ---------- lib/cgo/util.logging.formatter.go | 10 ---------- lib/cgo/util.logging.hooks.go | 10 ---------- lib/cgo/util.logging.logger.go | 10 ---------- lib/cgo/wallet.secrets.go | 10 ---------- lib/cgo/wallet.service.go | 10 ---------- 54 files changed, 540 deletions(-) delete mode 100644 lib/cgo/api.blockchain.go delete mode 100644 lib/cgo/api.csrf.go delete mode 100644 lib/cgo/api.gateway.go delete mode 100644 lib/cgo/api.health.go delete mode 100644 lib/cgo/api.http.go delete mode 100644 lib/cgo/api.integration.empty.go delete mode 100644 lib/cgo/api.network.go delete mode 100644 lib/cgo/api.notes.go delete mode 100644 lib/cgo/api.transaction.go delete mode 100644 lib/cgo/api.uxout.go delete mode 100644 lib/cgo/api.webrpc.block.go delete mode 100644 lib/cgo/api.webrpc.gateway.go delete mode 100644 lib/cgo/api.webrpc.outputs.go delete mode 100644 lib/cgo/api.webrpc.status.go delete mode 100644 lib/cgo/api.webrpc.transaction.go delete mode 100644 lib/cgo/api.webrpc.uxout.go delete mode 100644 lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go delete mode 100644 lib/cgo/cipher.encoder.encoder.go delete mode 100644 lib/cgo/cipher.go-bip39.wordlist.go delete mode 100644 lib/cgo/cipher.pbkdf2.pbkdf2.go delete mode 100644 lib/cgo/cipher.ripemd160.ripemd160block.go delete mode 100644 lib/cgo/cipher.ripemd160.ripmd_160.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go delete mode 100644 lib/cgo/cli.address_gen.go delete mode 100644 lib/cgo/cli.blocks.go delete mode 100644 lib/cgo/cli.broadcast_rawtx.go delete mode 100644 lib/cgo/cli.checkdb.go delete mode 100644 lib/cgo/cli.decryptWallet.go delete mode 100644 lib/cgo/cli.encrypt_wallet.go delete mode 100644 lib/cgo/cli.integration.empty.go delete mode 100644 lib/cgo/cli.last_blocks.go delete mode 100644 lib/cgo/cli.list_addrs.go delete mode 100644 lib/cgo/cli.list_wallets.go delete mode 100644 lib/cgo/cli.send.go delete mode 100644 lib/cgo/cli.show_seed.go delete mode 100644 lib/cgo/cli.status.go delete mode 100644 lib/cgo/cli.transaction.go delete mode 100644 lib/cgo/cli.verify_address.go delete mode 100644 lib/cgo/cli.version.go delete mode 100644 lib/cgo/cli.wallet_dir.go delete mode 100644 lib/cgo/cli.wallet_history.go delete mode 100644 lib/cgo/testutil.assert.assertions.go delete mode 100644 lib/cgo/testutil.require.require.go delete mode 100644 lib/cgo/util.elapse.elapser.go delete mode 100644 lib/cgo/util.http.error.go delete mode 100644 lib/cgo/util.http.handler.go delete mode 100644 lib/cgo/util.http.log.go delete mode 100644 lib/cgo/util.logging.formatter.go delete mode 100644 lib/cgo/util.logging.hooks.go delete mode 100644 lib/cgo/util.logging.logger.go delete mode 100644 lib/cgo/wallet.secrets.go delete mode 100644 lib/cgo/wallet.service.go diff --git a/lib/cgo/api.blockchain.go b/lib/cgo/api.blockchain.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.blockchain.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.csrf.go b/lib/cgo/api.csrf.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.csrf.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.gateway.go b/lib/cgo/api.gateway.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.gateway.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.health.go b/lib/cgo/api.health.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.health.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.http.go b/lib/cgo/api.http.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.http.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.integration.empty.go b/lib/cgo/api.integration.empty.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.integration.empty.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.network.go b/lib/cgo/api.network.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.network.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.notes.go b/lib/cgo/api.notes.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.notes.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.transaction.go b/lib/cgo/api.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.uxout.go b/lib/cgo/api.uxout.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.uxout.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.block.go b/lib/cgo/api.webrpc.block.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.block.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.gateway.go b/lib/cgo/api.webrpc.gateway.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.gateway.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.outputs.go b/lib/cgo/api.webrpc.outputs.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.outputs.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.status.go b/lib/cgo/api.webrpc.status.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.status.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.transaction.go b/lib/cgo/api.webrpc.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.uxout.go b/lib/cgo/api.webrpc.uxout.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.uxout.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go b/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.encoder.encoder.go b/lib/cgo/cipher.encoder.encoder.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.encoder.encoder.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.go-bip39.wordlist.go b/lib/cgo/cipher.go-bip39.wordlist.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.go-bip39.wordlist.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.pbkdf2.pbkdf2.go b/lib/cgo/cipher.pbkdf2.pbkdf2.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.pbkdf2.pbkdf2.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.ripemd160.ripemd160block.go b/lib/cgo/cipher.ripemd160.ripemd160block.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.ripemd160.ripemd160block.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.ripemd160.ripmd_160.go b/lib/cgo/cipher.ripemd160.ripmd_160.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.ripemd160.ripmd_160.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.address_gen.go b/lib/cgo/cli.address_gen.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.address_gen.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.blocks.go b/lib/cgo/cli.blocks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.blocks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.broadcast_rawtx.go b/lib/cgo/cli.broadcast_rawtx.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.broadcast_rawtx.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.checkdb.go b/lib/cgo/cli.checkdb.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.checkdb.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.decryptWallet.go b/lib/cgo/cli.decryptWallet.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.decryptWallet.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.encrypt_wallet.go b/lib/cgo/cli.encrypt_wallet.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.encrypt_wallet.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.integration.empty.go b/lib/cgo/cli.integration.empty.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.integration.empty.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.last_blocks.go b/lib/cgo/cli.last_blocks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.last_blocks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.list_addrs.go b/lib/cgo/cli.list_addrs.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.list_addrs.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.list_wallets.go b/lib/cgo/cli.list_wallets.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.list_wallets.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.send.go b/lib/cgo/cli.send.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.send.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.show_seed.go b/lib/cgo/cli.show_seed.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.show_seed.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.status.go b/lib/cgo/cli.status.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.status.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.transaction.go b/lib/cgo/cli.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.verify_address.go b/lib/cgo/cli.verify_address.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.verify_address.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.version.go b/lib/cgo/cli.version.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.version.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.wallet_dir.go b/lib/cgo/cli.wallet_dir.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.wallet_dir.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.wallet_history.go b/lib/cgo/cli.wallet_history.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.wallet_history.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/testutil.assert.assertions.go b/lib/cgo/testutil.assert.assertions.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/testutil.assert.assertions.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/testutil.require.require.go b/lib/cgo/testutil.require.require.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/testutil.require.require.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.elapse.elapser.go b/lib/cgo/util.elapse.elapser.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.elapse.elapser.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.error.go b/lib/cgo/util.http.error.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.error.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.handler.go b/lib/cgo/util.http.handler.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.handler.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.log.go b/lib/cgo/util.http.log.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.log.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.formatter.go b/lib/cgo/util.logging.formatter.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.formatter.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.hooks.go b/lib/cgo/util.logging.hooks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.hooks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.logger.go b/lib/cgo/util.logging.logger.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.logger.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/wallet.secrets.go b/lib/cgo/wallet.secrets.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/wallet.secrets.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/wallet.service.go b/lib/cgo/wallet.service.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/wallet.service.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" From 7727f49702cbef1dad3cfefaa1968f9b5874e6e5 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 13:20:07 +0000 Subject: [PATCH 081/399] [libc] refs #1191. Removed superfluous change. --- include/wallet.entry.go.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/wallet.entry.go.h b/include/wallet.entry.go.h index 7cf6a23377..362bb76494 100644 --- a/include/wallet.entry.go.h +++ b/include/wallet.entry.go.h @@ -1,4 +1,3 @@ - /** * Wallet entry. */ From cbef0b627956b33a7a8dfd4242d15c41744b7f32 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 24 Jun 2018 14:28:15 +0000 Subject: [PATCH 082/399] [libc] ref #1191. Added function TestGenerateDeterministicKeyPairsUsesAllBytes [====] Synthesis: Tested: 132 | Passing: 132 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.crypto.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 1c3bde3012..1b756f2135 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -733,3 +733,24 @@ Test(cipher_crypto, TestSecKeyHashTest) { errcode = SKY_cipher_TestSecKeyHash(&sk, &h); cr_assert(errcode == SKY_ERROR); } + +Test(cipher_crypto, TestGenerateDeterministicKeyPairsUsesAllBytes) { + // Tests that if a seed >128 bits is used, the generator does not ignore bits + // >128 + GoString seed = {"property diet little foster provide disagree witness " + "mountain alley weekend kitten general", + 90}; +GoSlice seedSlice = {&seed,sizeof(GoString),sizeof(GoString)}; +char buffer_seckeys[1024]; +char buffer_seckeys2[1024]; +cipher__PubKeySlice seckeys={buffer_seckeys,0,0}; +cipher__PubKeySlice seckeys2={buffer_seckeys2,0,0}; + GoInt result; + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys); + cr_assert(result == SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); + seed.n = 16; + GoSlice seedSlice2 = {&seed,sizeof(GoString),sizeof(GoString)}; + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys2); + cr_assert(result==SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); + cr_assert(not(eq(type(GoSlice_),seckeys,seckeys2))); +} \ No newline at end of file From 0ebe735ff7993613897c10626b5bef9ccd099709 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 16:42:10 +0000 Subject: [PATCH 083/399] [libc] refs #1191. Fixed bugs related to not setting GoSlice capacity. Code identation. [====] Synthesis: Tested: 131 | Passing: 131 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_cipher.address.c | 72 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index c91079aa88..e91665526b 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -112,37 +112,37 @@ Test(cipher_address, TestAddressVerify){ } Test(cipher_address,TestAddressString){ -cipher__PubKey p; -cipher__SecKey s1; -GoInt result; -result = SKY_cipher_GenerateKeyPair(&p,&s1); -cr_assert(result==SKY_OK,"SKY_cipher_GenerateKeyPair failed"); - -cipher__Address a; -result = SKY_cipher_AddressFromPubKey(&p,&a); -cr_assert(result==SKY_OK,"SKY_cipher_AddressFromPubKey failed"); -char buffer_s[1024]; -GoString_ s= {buffer_s,0}; -result =SKY_cipher_Address_String(&a,&s); -cr_assert(result==SKY_OK,"SKY_cipher_Address_String failed"); -cipher__Address a2; -char buffer_sConvert[1024]; -GoString sConvert={buffer_sConvert,0}; -toGoString(&s,&sConvert); -result = SKY_cipher_DecodeBase58Address(sConvert,&a2); -cr_assert(result == SKY_OK); -cr_assert(eq(type(cipher__Address),a,a2)); -char buffer_s2[1024]; -GoString_ s2={buffer_s2,0}; -result = SKY_cipher_Address_String(&a2,&s2); -cr_assert(result == SKY_OK,"SKY_cipher_Address_String failed"); -cipher__Address a3; -char buffer_s2Convert[1024]; -GoString s2Convert={buffer_s2Convert,0}; -toGoString(&s2,&s2Convert); -result =SKY_cipher_DecodeBase58Address(s2Convert,&a3); -cr_assert(result == SKY_OK,"SKY_cipher_DecodeBase58Address failed"); -cr_assert(eq(type(cipher__Address),a2,a3)); + cipher__PubKey p; + cipher__SecKey s1; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p,&s1); + cr_assert(result==SKY_OK,"SKY_cipher_GenerateKeyPair failed"); + + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p,&a); + cr_assert(result==SKY_OK,"SKY_cipher_AddressFromPubKey failed"); + char buffer_s[1024]; + GoString_ s= {buffer_s,0}; + result =SKY_cipher_Address_String(&a,&s); + cr_assert(result==SKY_OK,"SKY_cipher_Address_String failed"); + cipher__Address a2; + char buffer_sConvert[1024]; + GoString sConvert={buffer_sConvert,0}; + toGoString(&s,&sConvert); + result = SKY_cipher_DecodeBase58Address(sConvert,&a2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(cipher__Address),a,a2)); + char buffer_s2[1024]; + GoString_ s2={buffer_s2,0}; + result = SKY_cipher_Address_String(&a2,&s2); + cr_assert(result == SKY_OK,"SKY_cipher_Address_String failed"); + cipher__Address a3; + char buffer_s2Convert[1024]; + GoString s2Convert={buffer_s2Convert,0}; + toGoString(&s2,&s2Convert); + result =SKY_cipher_DecodeBase58Address(s2Convert,&a3); + cr_assert(result == SKY_OK,"SKY_cipher_DecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address),a2,a3)); } @@ -379,14 +379,16 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cipher__PubKeySlice pk = {NULL, 0, 0}; result = SKY_cipher_Address_BitcoinBytes(&a, &pk); cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); + registerMemCleanup(pk.data); GoSlice pk_convert = {pk.data, pk.len, pk.cap}; result = SKY_cipher_BitcoinAddressFromBytes(pk_convert, &a2); cr_assert(result == SKY_OK); cr_assert(eq(type(cipher__Address), a2, a)); - cipher__PubKeySlice b; + cipher__PubKeySlice b = {NULL, 0, 0}; result = SKY_cipher_Address_BitcoinBytes(&a, &b); cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes"); + registerMemCleanup(b.data); GoInt_ b_len = b.len; @@ -407,7 +409,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); a.Version = 2; char *buffer[1024]; - cipher__PubKeySlice b1 = {buffer, 0, 0}; + cipher__PubKeySlice b1 = {buffer, 0, 1024}; result = SKY_cipher_Address_BitcoinBytes(&a, &b1); cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); GoSlice b1_convert = {b1.data, b1.len, b1.cap}; @@ -438,7 +440,7 @@ Test(cipher_address, TestMustDecodeBase58Address) { cr_assert(result == SKY_ERROR); char *buff_pks[1024]; - cipher__PubKeySlice b = {buff_pks, 0, 0}; + cipher__PubKeySlice b = {buff_pks, 0, 1024}; result = SKY_cipher_Address_Bytes(&a, &b); cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); int b_len = b.len; @@ -527,7 +529,7 @@ Test(cipher_address,TestAddressRoundtrip){ result = SKY_cipher_AddressFromPubKey(&p, &a); cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); char buffer_aBytes[1024]; - cipher__PubKeySlice aBytes= {buffer_aBytes,0}; + cipher__PubKeySlice aBytes= {buffer_aBytes,0, 1024}; result = SKY_cipher_Address_Bytes(&a, &aBytes); cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); GoSlice aBytesSlice = {aBytes.data, aBytes.len, aBytes.cap}; From 84d6f1d83098d394b0c875ee1e7b4b32e1dd023b Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 24 Jun 2018 16:45:34 +0000 Subject: [PATCH 084/399] [libc] ref #1191. Added function TestMustSumSHA256 [====] Synthesis: Tested: 133 | Passing: 133 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.address.c | 6 +++--- .../tests/check_cipher.encrypt.sha256xor.c | 4 ++-- lib/cgo/tests/check_cipher.hash.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index c91079aa88..3faba377b2 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -407,7 +407,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); a.Version = 2; char *buffer[1024]; - cipher__PubKeySlice b1 = {buffer, 0, 0}; + cipher__PubKeySlice b1 = {buffer, 0, 1024}; result = SKY_cipher_Address_BitcoinBytes(&a, &b1); cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); GoSlice b1_convert = {b1.data, b1.len, b1.cap}; @@ -438,7 +438,7 @@ Test(cipher_address, TestMustDecodeBase58Address) { cr_assert(result == SKY_ERROR); char *buff_pks[1024]; - cipher__PubKeySlice b = {buff_pks, 0, 0}; + cipher__PubKeySlice b = {buff_pks, 0, 1024}; result = SKY_cipher_Address_Bytes(&a, &b); cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); int b_len = b.len; @@ -527,7 +527,7 @@ Test(cipher_address,TestAddressRoundtrip){ result = SKY_cipher_AddressFromPubKey(&p, &a); cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); char buffer_aBytes[1024]; - cipher__PubKeySlice aBytes= {buffer_aBytes,0}; + cipher__PubKeySlice aBytes= {buffer_aBytes,0,1024}; result = SKY_cipher_Address_Bytes(&a, &aBytes); cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); GoSlice aBytesSlice = {aBytes.data, aBytes.len, aBytes.cap}; diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 643fb904d9..4ebe4ecfba 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -142,7 +142,7 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA encrypted->len = size; } -Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ +Test(cipher_encrypt_sha256xor, TestEncrypt){ unsigned char buff[BUFFER_SIZE]; unsigned char encryptedBuffer[BUFFER_SIZE]; unsigned char encryptedText[BUFFER_SIZE]; @@ -251,7 +251,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ } } -Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ +Test(cipher_encrypt_sha256xor, TestDecrypt){ unsigned char buff[BUFFER_SIZE]; unsigned char encrypted_buffer[BUFFER_SIZE]; unsigned char decrypted_buffer[BUFFER_SIZE]; diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 0021920190..f92f488546 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -343,3 +343,22 @@ Test(cipher_hash,TestMerkle){ cr_assert(eq(u8[32], out, h)); } +Test(cipher_hash, TestMustSumSHA256) { + char buffer_b[1024]; + GoSlice b = {buffer_b, 0, 1024}; + randBytes(&b, 128); + GoUint32 result; + cipher__SHA256 h; + memset(&h, 0, sizeof(cipher__SHA256)); + result = SKY_cipher_MustSumSHA256(b, 127, &h); + cr_assert(result == SKY_ERROR); + result = SKY_cipher_MustSumSHA256(b, 129, &h); + cr_assert(result == SKY_ERROR); + result = SKY_cipher_MustSumSHA256(b, 128, &h); + cr_assert(result == SKY_OK); + cipher__SHA256 sha; + cr_assert(not(eq(u8[32], h, sha))); + memset(&sha, 0, sizeof(cipher__SHA256)); + freshSumSHA256(b, &sha); + cr_assert(eq(u8[32], h, sha)); +} \ No newline at end of file From 0025b64907e995606dbeb071575f05d3a3e02985 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 24 Jun 2018 17:11:48 +0000 Subject: [PATCH 085/399] [libc] refs #1191. Added init and teardown functions to transactions test suite. [====] Synthesis: Tested: 131 | Passing: 131 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_coin.transactions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 665766cbb4..785db3bff4 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -12,6 +12,8 @@ #include "skycriterion.h" #include "transutil.h" +TestSuite(coin_transaction, .init = setup, .fini = teardown); + Test(coin_transaction, TestTransactionVerify) { int result; coin__Transaction *ptx; @@ -836,4 +838,4 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { * Tests not done because of wrapper functions were not created: * TestTransactionsFees * TestSortTransactions - ********************************************************/ \ No newline at end of file + ********************************************************/ From fe40f992c1d75d5c3722247b1413f026a4884224 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 25 Jun 2018 11:10:31 +0000 Subject: [PATCH 086/399] [libc] refs #1191. Added handle for Sortable Transactions. Use FeeCalculator callback function for SKY_coin_NewBlock. New exported functions SKY_coin_Transactions_Fees, SKY_coin_SortTransactions, SKY_coin_NewSortableTransactions, SKY_coin_SortableTransactions_Sort. Added tests for new exported functions. Fixed in Transaction criterion compare. [====] Synthesis: Tested: 133 | Passing: 133 | Failing: 0 | Crashing: 0. --- include/feecalc.h | 6 + include/skytypes.h | 11 +- include/transutil.h | 4 + lib/cgo/coin.block.go | 18 +- lib/cgo/coin.transactions.go | 120 ++++++++++++- lib/cgo/libsky_handle.go | 14 ++ lib/cgo/tests/check_coin.block.c | 11 +- lib/cgo/tests/check_coin.transactions.c | 194 ++++++++++++++++++++- lib/cgo/tests/testutils/libsky_criterion.c | 12 +- lib/cgo/tests/testutils/transutils.c | 53 ++++++ 10 files changed, 417 insertions(+), 26 deletions(-) create mode 100644 include/feecalc.h diff --git a/include/feecalc.h b/include/feecalc.h new file mode 100644 index 0000000000..13dacfdd47 --- /dev/null +++ b/include/feecalc.h @@ -0,0 +1,6 @@ +#ifndef CALLFEECALCULATOR +#define CALLFEECALCULATOR +static inline GoUint32_ callFeeCalculator(FeeCalc feeCalc, Transaction__Handle handle, GoUint64_* pFee){ + return feeCalc(handle, pFee); +} +#endif diff --git a/include/skytypes.h b/include/skytypes.h index 80453c3783..325394d06b 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -303,11 +303,17 @@ typedef Handle BalanceResult_Handle; typedef Handle SpendResult_Handle; /** - * Memory handle to access to webrpc.TxnResult + * Memory handle to access to coin.Transactions */ typedef Handle TransactionResult_Handle; +/** + * Memory handle to access to coin.SortableTransactions + */ + +typedef Handle SortableTransactionResult_Handle; + /** * Memory handle to access to wallet.Notes */ @@ -332,6 +338,9 @@ typedef Handle OutputsResult_Handle; typedef Handle StatusResult_Handle; + +typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); + /* #include "cipher.hash.go.h" #include "cipher.crypto.go.h" diff --git a/include/transutil.h b/include/transutil.h index 154cd5c69a..70d7baeb52 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -11,6 +11,8 @@ #include "skytest.h" #include "skytypes.h" +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee); + int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress); int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey); @@ -36,3 +38,5 @@ coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Hand void makeRandHash(cipher__SHA256* phash); int makeUxArray(coin__UxArray* parray, int n); + +int sortTransactions(Transactions__Handle txns_handle, Transactions__Handle* sorted_txns_handle); diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index 08ee6f8ae2..b95aa01bf9 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -1,6 +1,7 @@ package main import ( + "errors" "reflect" "unsafe" @@ -14,13 +15,22 @@ import ( #include #include "skytypes.h" + #include "feecalc.h" */ import "C" //export SKY_coin_NewBlock -func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, _fee uint64, _arg2 *C.Block__Handle) (____error_code uint32) { - feeCalculator := func(t *coin.Transaction) (uint64, error) { - return _fee, nil +func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc C.FeeCalc, _arg2 *C.Block__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction)(uint64, error){ + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } } ____error_code = 0 @@ -38,7 +48,7 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ ____error_code = SKY_ERROR return } - __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalculator) + __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalc) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg2 = registerBlockHandle(__arg2) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 9b73af741f..075f5e9198 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -1,6 +1,7 @@ package main import ( + "errors" "reflect" "unsafe" @@ -14,6 +15,7 @@ import ( #include #include "skytypes.h" + #include "feecalc.h" */ import "C" @@ -449,6 +451,38 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han return } + +//export SKY_coin_Transactions_Fees +func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, _result *uint64) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction)(uint64, error){ + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee); + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + result, err := txns.Fees(feeCalc) + if err != nil { + ____error_code = SKY_ERROR + } else { + *_result = result + } + return +} + //export SKY_coin_Transactions_GetAt func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 @@ -518,36 +552,102 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int return } +//export SKY_coin_SortTransactions +func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.Transactions__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction)(uint64, error){ + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + sorted := coin.SortTransactions(*txns, feeCalc) + *ptsh = registerTransactionsHandle(&sorted) + return +} + +//export SKY_coin_NewSortableTransactions +func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction)(uint64, error){ + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + sorted := coin.NewSortableTransactions(*txns, feeCalc) + *ptsh = registerSortableTransactiontHandle(&sorted) + return SKY_OK +} + //export SKY_coin_SortableTransactions_Sort -func SKY_coin_SortableTransactions_Sort(_txns *C.coin__SortableTransactions) (____error_code uint32) { +func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } txns.Sort() return } //export SKY_coin_SortableTransactions_Len -func SKY_coin_SortableTransactions_Len(_txns *C.coin__SortableTransactions, _arg0 *int) (____error_code uint32) { +func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txns.Len() *_arg0 = __arg0 return } //export SKY_coin_SortableTransactions_Less -func SKY_coin_SortableTransactions_Less(_txns *C.coin__SortableTransactions, _i, _j int, _arg1 *bool) (____error_code uint32) { +func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle, _i, _j int, _arg1 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } i := _i j := _j __arg1 := txns.Less(i, j) @@ -556,12 +656,16 @@ func SKY_coin_SortableTransactions_Less(_txns *C.coin__SortableTransactions, _i, } //export SKY_coin_SortableTransactions_Swap -func SKY_coin_SortableTransactions_Swap(_txns *C.coin__SortableTransactions, _i, _j int) (____error_code uint32) { +func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle, _i, _j int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } i := _i j := _j txns.Swap(i, j) diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index e5491bc9b4..a6d6698b0f 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -398,6 +398,20 @@ func lookupTransactionResultHandle(handle C.TransactionResult_Handle) (*webrpc.T return nil, false } +func registerSortableTransactiontHandle(obj *coin.SortableTransactions) C.SortableTransactionResult_Handle { + return (C.SortableTransactionResult_Handle)(registerHandle(obj)) +} + +func lookupSortableTransactionHandle(handle C.SortableTransactionResult_Handle) (*coin.SortableTransactions, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.SortableTransactions); isOK { + return obj, true + } + } + return nil, false +} + func registerWalletNotesHandle(obj *wallet.Notes) C.WalletNotes_Handle { return (C.WalletNotes_Handle)(registerHandle(obj)) } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 4ba0c1995b..15df03eeec 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -52,12 +52,17 @@ int makeNewBlock(cipher__SHA256* uxHash, Block__Handle* newBlock){ cr_assert(result == SKY_OK, "SKY_coin_Get_Block_Body failed"); result = SKY_coin_BlockBody_Hash(body, &bodyhash); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, 0, newBlock); + result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, zeroFeeCalculator, newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose( *newBlock ); return result; } +GoUint32_ fix121FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 121; + return SKY_OK; +} + Test(coin_block, TestNewBlock) { Block__Handle prevBlock = 0; Block__Handle newBlock = 0; @@ -88,7 +93,7 @@ Test(coin_block, TestNewBlock) { result = SKY_cipher_SumSHA256( slice, &hash ); cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); - result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, 0, &newBlock); + result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, zeroFeeCalculator, &newBlock); cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); registerHandleClose( newBlock ); @@ -105,7 +110,7 @@ Test(coin_block, TestNewBlock) { GoUint64 fee = 121; GoUint64 currentTime = 133; - result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fee, &newBlock); + result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fix121FeeCalculator, &newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose(newBlock); result = SKY_coin_GetBlockObject(newBlock, &pNewBlock); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 785db3bff4..74e7666472 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -14,6 +14,9 @@ TestSuite(coin_transaction, .init = setup, .fini = teardown); +GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; +GoUint64 Million = 1000000; + Test(coin_transaction, TestTransactionVerify) { int result; coin__Transaction *ptx; @@ -708,8 +711,6 @@ int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { } Test(coin_transactions, TestVerifyTransactionCoinsSpending) { - GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; - GoUint64 Million = 1000000; // Input coins overflow test_ux in1[] = {{MaxUint64 - Million + 1, 10}, {Million, 0}}; @@ -834,8 +835,187 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { } } -/******************************************************* - * Tests not done because of wrapper functions were not created: - * TestTransactionsFees - * TestSortTransactions - ********************************************************/ +GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 1; + return SKY_OK; +} + +GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + return SKY_ERROR; +} + +GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 0xFFFFFFFFFFFFFFFF; + return SKY_OK; +} + +Test(coin_transactions, TestTransactionsFees) { + GoUint64 fee; + int result; + Transactions__Handle transactionsHandle = 0; + Transaction__Handle transactionHandle = 0; + + // Nil txns + makeTransactions(0, &transactionsHandle); + result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + cr_assert(result == SKY_OK); + cr_assert(fee == 0); + + makeEmptyTransaction(&transactionHandle); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + makeEmptyTransaction(&transactionHandle); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + // 2 transactions, calc() always returns 1 + result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + cr_assert(result == SKY_OK); + cr_assert(fee == 2); + + // calc error + result = SKY_coin_Transactions_Fees(transactionsHandle, badFeeCalculator, &fee); + cr_assert(result != SKY_OK); + + // summing of calculated fees overflows + result = SKY_coin_Transactions_Fees(transactionsHandle, overflowFeeCalculator, &fee); + cr_assert(result != SKY_OK); +} + +GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee){ + coin__Transaction* pTx; + int result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + return result; +} + +GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 100 * Million; + return SKY_OK; +} + +void assertTransactionsHandleEqual(Transaction__Handle h1, Transaction__Handle h2, + char* testName){ + coin__Transaction *pTx1; + coin__Transaction *pTx2; + int result; + result = SKY_coin_Get_Transaction_Object( h1, &pTx1 ); + cr_assert(result == SKY_OK); + result = SKY_coin_Get_Transaction_Object( h2, &pTx2 ); + cr_assert(result == SKY_OK); + cr_assert(eq(type(coin__Transaction), *pTx1, *pTx2), "Failed SortTransactions test \"%s\"", testName); +} + +void testTransactionSorting(Transactions__Handle hTrans, + int* original_indexes, int original_indexes_count, + int* expected_indexes, int expected_indexes_count, FeeCalc feeCalc, + char* testName + ){ + + int result; + Transactions__Handle transactionsHandle, sortedTxnsHandle; + Transaction__Handle handle; + makeTransactions(0, &transactionsHandle); + for(int i = 0; i < original_indexes_count; i++){ + result = SKY_coin_Transactions_GetAt(hTrans, original_indexes[i], &handle); + cr_assert(result == SKY_OK); + registerHandleClose(handle); + result = SKY_coin_Transactions_Add(transactionsHandle, handle); + cr_assert(result == SKY_OK); + } + result = SKY_coin_SortTransactions(transactionsHandle, feeCalc, &sortedTxnsHandle); + cr_assert(result == SKY_OK, "SKY_coin_SortTransactions"); + registerHandleClose(sortedTxnsHandle); + Transaction__Handle h1, h2; + for(int i = 0; i < expected_indexes_count; i++){ + int expected_index = expected_indexes[i]; + result = SKY_coin_Transactions_GetAt(sortedTxnsHandle, i, &h1); + cr_assert(result == SKY_OK); + registerHandleClose(h1); + result = SKY_coin_Transactions_GetAt(hTrans, expected_index, &h2); + cr_assert(result == SKY_OK); + registerHandleClose(h2); + assertTransactionsHandleEqual(h1, h2, testName); + } +} + + +Test(coin_transactions, TestSortTransactions) { + int n = 6; + int i; + int result; + + Transactions__Handle transactionsHandle = 0; + Transactions__Handle transactionsHandle2 = 0; + Transactions__Handle hashSortedTxnsHandle = 0; + Transactions__Handle sortedTxnsHandle = 0; + Transaction__Handle transactionHandle = 0; + cipher__Address addr; + makeTransactions(0, &transactionsHandle); + cipher__SHA256 thirdHash; + for(i = 0; i < 6; i++){ + makeEmptyTransaction(&transactionHandle); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(transactionHandle, &addr, 1000000, i * 1000); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_UpdateHeader(transactionHandle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + if( i == 2 ){ + result = SKY_coin_Transaction_Hash(transactionHandle, &thirdHash); + cr_assert(result == SKY_OK); + } + } + sortTransactions(transactionsHandle, &hashSortedTxnsHandle); + + int index1[] = {0, 1}; + int expec1[] = {0, 1}; + testTransactionSorting(transactionsHandle, index1, 2, expec1, 2, feeCalculator1, "Already sorted"); + int index2[] = {1, 0}; + int expec2[] = {0, 1}; + testTransactionSorting(transactionsHandle, index2, 2, expec2, 2, feeCalculator1, "reverse sorted"); + testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, feeCalculator2, "hash tiebreaker"); + + GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ *pFee){ + cipher__SHA256 hash; + int result = SKY_coin_Transaction_Hash(handle, &hash); + if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + *pFee = MaxUint64 / 2; + } else { + coin__Transaction* pTx; + result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; + } + int index3[] = {1, 2, 0}; + int expec3[] = {2, 0, 1}; + testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, feeCalculator3, "invalid fee multiplication is capped"); + + GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ *pFee){ + cipher__SHA256 hash; + int result = SKY_coin_Transaction_Hash(handle, &hash); + if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + *pFee = 0; + result = SKY_ERROR; + } else { + coin__Transaction* pTx; + result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; + } + + int index4[] = {1, 2, 0}; + int expec4[] = {0, 1}; + testTransactionSorting(transactionsHandle, index4, 3, expec4, 2, feeCalculator4, "failed fee calc is filtered"); +} diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 0f3c2f32d5..2fde3d9b45 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -3,6 +3,12 @@ #include "skycriterion.h" #include "skystring.h" +int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ + if(slice1->len != slice2->len) + return 0; + return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; +} + int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ if(addr1->Version != addr2->Version) return 0; @@ -183,11 +189,11 @@ int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2){ } if(!cr_user_cipher__SHA256_eq(&x1->InnerHash, &x2->InnerHash)) return 0; - if(!cr_user_GoSlice__eq(&x1->Sigs, &x2->Sigs) ) + if(!equalSlices((GoSlice*)&x1->Sigs, (GoSlice*)&x2->Sigs, sizeof(cipher__Sig))) return 0; - if(!cr_user_GoSlice__eq(&x1->In, &x2->In) ) + if(!equalSlices((GoSlice*)&x1->In, (GoSlice*)&x2->In, sizeof(cipher__SHA256))) return 0; - if(!cr_user_GoSlice__eq(&x1->Out, &x2->Out) ) + if(!equalSlices((GoSlice*)&x1->Out, (GoSlice*)&x2->Out, sizeof(coin__TransactionOutput))) return 0; return 1; } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 5919e244fa..ed9f7fc652 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -11,6 +11,11 @@ #include "skytest.h" #include "transutil.h" +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 0; + return SKY_OK; +} + int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress){ int result; result = SKY_cipher_GenerateKeyPair(ppubkey, pseckey); @@ -154,6 +159,54 @@ int makeTransactions(int n, Transactions__Handle* handle){ return result; } +typedef struct{ + cipher__SHA256 hash; + Transaction__Handle handle; +} TransactionObjectHandle; + +int sortTransactions(Transactions__Handle txns_handle, Transactions__Handle* sorted_txns_handle){ + int result = SKY_coin_Create_Transactions(sorted_txns_handle); + cr_assert(result == SKY_OK); + registerHandleClose(*sorted_txns_handle); + GoInt n, i, j; + result = SKY_coin_Transactions_Length(txns_handle, &n); + cr_assert(result == SKY_OK); + TransactionObjectHandle* pTrans = malloc( n * sizeof(TransactionObjectHandle)); + cr_assert(pTrans != NULL); + registerMemCleanup(pTrans); + memset(pTrans, 0, n * sizeof(TransactionObjectHandle)); + int* indexes = malloc( n * sizeof(int) ); + cr_assert(indexes != NULL); + registerMemCleanup(indexes); + for( i = 0; i < n; i ++){ + indexes[i] = i; + result = SKY_coin_Transactions_GetAt(txns_handle, i, &pTrans[i].handle); + cr_assert(result == SKY_OK); + registerHandleClose(pTrans[i].handle); + result = SKY_coin_Transaction_Hash(pTrans[i].handle, &pTrans[i].hash); + cr_assert(result == SKY_OK); + } + + //Swap sort. + cipher__SHA256 hash1, hash2; + for(i = 0; i < n - 1; i++){ + for(j = i + 1; j < n; j++){ + int cmp = memcmp(&pTrans[indexes[i]].hash, &pTrans[indexes[j]].hash, sizeof(cipher__SHA256)); + if(cmp > 0){ + //Swap + int tmp = indexes[i]; + indexes[i] = indexes[j]; + indexes[j] = tmp; + } + } + } + for( i = 0; i < n; i ++){ + result = SKY_coin_Transactions_Add(*sorted_txns_handle, pTrans[indexes[i]].handle); + cr_assert(result == SKY_OK); + } + return result; +} + coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Handle* handle2){ coin__Transaction* ptransaction = NULL; int result = 0; From ce19e1a7d379db3b7d8f6a93b9a6eba06ed49b84 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 25 Jun 2018 11:42:28 +0000 Subject: [PATCH 087/399] [libc] refs #1191. Fixed bug in coin__Transactions comparision. [====] Synthesis: Tested: 133 | Passing: 133 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 4 +++ lib/cgo/tests/check_coin.block.c | 3 +- lib/cgo/tests/check_coin.outputs.c | 2 +- lib/cgo/tests/testutils/libsky_criterion.c | 36 +++++++++++++--------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/skycriterion.h b/include/skycriterion.h index de2608d925..156745f73c 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -51,6 +51,10 @@ extern int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction extern int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2); extern char* cr_user_coin__Transaction_tostr(coin__Transaction *x1); +extern int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2); +extern int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2); +extern char* cr_user_coin__Transactions_tostr(coin__Transactions *x1); + extern int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); extern int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); extern char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1); diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 15df03eeec..1600702979 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -117,7 +117,8 @@ Test(coin_block, TestNewBlock) { cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); coin__Transactions* pTransactions = NULL; SKY_coin_Get_Transactions_Object(transactions, &pTransactions); - cr_assert( eq( type(GoSlice), *((GoSlice*)&pNewBlock->Body.Transactions), *((GoSlice*)pTransactions)) ); + int equal = cr_user_coin__Transactions_eq(&pNewBlock->Body.Transactions, pTransactions); + cr_assert(equal == 1); cr_assert( eq(pNewBlock->Head.Fee, fee * (GoUint64)( pTransactions->len ))); cr_assert( eq(pNewBlock->Head.Time, currentTime)); cr_assert( eq(pNewBlock->Head.BkSeq, pPrevBlock->Head.BkSeq + 1)); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 66967fe1e7..2685be1dc8 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -315,7 +315,7 @@ Test(coin_outputs, TestUxArraySub){ cr_assert( result == SKY_OK, "cutSlice failed" ); result = concatSlices( &t2, &t3, elems_size, &uxc ); cr_assert( result == SKY_OK, "concatSlices failed" ); - + //TODO: Fix comparision memset(&uxd, 0, arraySize); result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 2fde3d9b45..a5983b129f 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -9,6 +9,20 @@ int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; } +int equalTransactions(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ + if( pTxs1->len != pTxs2->len ) + return 0; + coin__Transaction* pTx1 = pTxs1->data; + coin__Transaction* pTx2 = pTxs2->data; + for(int i = 0; i < pTxs1->len; i++){ + if(!cr_user_coin__Transaction_eq(pTx1, pTx2)) + return 0; + pTx1++; + pTx2++; + } + return 1; +} + int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ if(addr1->Version != addr2->Version) return 0; @@ -134,32 +148,26 @@ int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2 return 1; } -int cr_user_coin__Transactions_eq(coin__Transactions *slice1, coin__Transactions *slice2){ - return - (slice1->len == slice2->len) && - (memcmp(slice1->data, slice2->data, slice1->len)==0); +int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2){ + return equalTransactions(x1, x2); } -int cr_user_coin__Transactions_noteq(coin__Transactions *slice1, coin__Transactions *slice2){ - return - !((slice1->len == slice2->len) && - (memcmp(slice1->data, slice2->data, slice1->len)==0)); +int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2){ + return !equalTransactions(x1, x2); } -char *cr_user_coin__Transactions_tostr(coin__Transactions *slice1) { +char *cr_user_coin__Transactions_tostr(coin__Transactions *x1) { char *out; - cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)x1->data, x1->len, x1->cap); return out; } int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2){ - return - cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); + return equalTransactions(&b1->Transactions, &b2->Transactions); } int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2){ - return - !cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); + return !equalTransactions(&b1->Transactions, &b2->Transactions); } char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) { From 7eae5cb03a9960e15d87310297be3e23e49eca62 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 25 Jun 2018 11:59:37 +0000 Subject: [PATCH 088/399] [libc] refs #1191. Fixed bug in comparision of coin__UxArray. [====] Synthesis: Tested: 133 | Passing: 133 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 4 ++++ lib/cgo/tests/check_coin.block.c | 3 +-- lib/cgo/tests/check_coin.outputs.c | 13 ++++++++----- lib/cgo/tests/testutils/libsky_criterion.c | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/skycriterion.h b/include/skycriterion.h index 156745f73c..093ca9ae55 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -47,6 +47,10 @@ extern int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2); extern int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2); extern char* cr_user_coin__UxOut_tostr(coin__UxOut *x1); +extern int cr_user_coin__UxArray_eq(coin__UxArray *x1, coin__UxArray *x2); +extern int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2); +extern char* cr_user_coin__UxArray_tostr(coin__UxArray *x1); + extern int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2); extern int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2); extern char* cr_user_coin__Transaction_tostr(coin__Transaction *x1); diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 1600702979..0a48e16e61 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -117,8 +117,7 @@ Test(coin_block, TestNewBlock) { cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); coin__Transactions* pTransactions = NULL; SKY_coin_Get_Transactions_Object(transactions, &pTransactions); - int equal = cr_user_coin__Transactions_eq(&pNewBlock->Body.Transactions, pTransactions); - cr_assert(equal == 1); + cr_assert( eq( type(coin__Transactions), pNewBlock->Body.Transactions, *pTransactions ) ); cr_assert( eq(pNewBlock->Head.Fee, fee * (GoUint64)( pTransactions->len ))); cr_assert( eq(pNewBlock->Head.Time, currentTime)); cr_assert( eq(pNewBlock->Head.BkSeq, pPrevBlock->Head.BkSeq + 1)); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 2685be1dc8..31160bf4d4 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -291,7 +291,7 @@ Test(coin_outputs, TestUxArrayHasDupes){ Test(coin_outputs, TestUxArraySub){ - int result; + int result, equal; coin__UxArray uxa, uxb, uxc, uxd; coin__UxArray t1, t2, t3, t4; @@ -320,7 +320,7 @@ Test(coin_outputs, TestUxArraySub){ result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); registerMemCleanup( uxd.data ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&uxb)) ); + cr_assert( eq( type(coin__UxArray), uxd, uxb ) ); memset(&uxd, 0, arraySize); result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); @@ -328,7 +328,8 @@ Test(coin_outputs, TestUxArraySub){ registerMemCleanup( uxd.data ); cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); cutSlice(&uxa, 0, 2, elems_size, &t1); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); + cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); // No intersection memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); @@ -338,8 +339,10 @@ Test(coin_outputs, TestUxArraySub){ result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); registerMemCleanup( t2.data ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); + cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); + cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); } int isUxArraySorted(coin__UxArray* uxa){ diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index a5983b129f..5aeb0548bf 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -236,3 +236,17 @@ char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1){ cr_asprintf(&out, "(coin__TransactionOutput) { Coins : %d, Hours: %d, Address: %s }", x1->Coins, x1->Hours, x1->Address); return out; } + +int cr_user_coin__UxArray_eq(coin__UxArray *x1, coin__UxArray *x2){ + return equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +} + +int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2){ + return !equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +} + +char* cr_user_coin__UxArray_tostr(coin__UxArray *x1){ + char *out; + cr_asprintf(&out, "(coin__UxArray) { Length : %d }", x1->len); + return out; +} From 64501ab38dd99edbba47435e8b1d484fb2815a75 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 25 Jun 2018 12:09:13 +0000 Subject: [PATCH 089/399] [libc] refs #1191. Fixed lint issues. [====] Synthesis: Tested: 133 | Passing: 133 | Failing: 0 | Crashing: 0. --- lib/cgo/coin.block.go | 4 ++-- lib/cgo/coin.transactions.go | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index b95aa01bf9..ecfb158297 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -21,7 +21,7 @@ import "C" //export SKY_coin_NewBlock func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc C.FeeCalc, _arg2 *C.Block__Handle) (____error_code uint32) { - feeCalc := func(pTx *coin.Transaction)(uint64, error){ + feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) result := C.callFeeCalculator(pFeeCalc, handle, &fee) @@ -29,7 +29,7 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ if result == SKY_OK { return uint64(fee), nil } else { - return 0, errors.New("Error calculating fee") + return 0, errors.New("Error calculating fee") } } diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 075f5e9198..f294d2a682 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -451,18 +451,17 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han return } - //export SKY_coin_Transactions_Fees func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, _result *uint64) (____error_code uint32) { - feeCalc := func(pTx *coin.Transaction)(uint64, error){ + feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) - result := C.callFeeCalculator(pFeeCalc, handle, &fee); + result := C.callFeeCalculator(pFeeCalc, handle, &fee) closeHandle(Handle(handle)) if result == SKY_OK { return uint64(fee), nil } else { - return 0, errors.New("Error calculating fee") + return 0, errors.New("Error calculating fee") } } ____error_code = 0 @@ -553,8 +552,8 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int } //export SKY_coin_SortTransactions -func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.Transactions__Handle) (____error_code uint32) { - feeCalc := func(pTx *coin.Transaction)(uint64, error){ +func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.Transactions__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) result := C.callFeeCalculator(pFeeCalc, handle, &fee) @@ -562,7 +561,7 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, p if result == SKY_OK { return uint64(fee), nil } else { - return 0, errors.New("Error calculating fee") + return 0, errors.New("Error calculating fee") } } ____error_code = 0 @@ -580,8 +579,8 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, p } //export SKY_coin_NewSortableTransactions -func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { - feeCalc := func(pTx *coin.Transaction)(uint64, error){ +func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) result := C.callFeeCalculator(pFeeCalc, handle, &fee) @@ -589,7 +588,7 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.Fee if result == SKY_OK { return uint64(fee), nil } else { - return 0, errors.New("Error calculating fee") + return 0, errors.New("Error calculating fee") } } ____error_code = 0 From 51da6d0a5dbe280b2eb058a4ad2651698bd5ce33 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 25 Jun 2018 16:58:28 +0000 Subject: [PATCH 090/399] [libc] refs #1191 Added exported function dealing with coin.AddressUxOuts. Added 5 more tests. [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 6 + lib/cgo/coin.outputs.go | 149 +++++++++++++ lib/cgo/libsky_handle.go | 14 ++ lib/cgo/tests/check_coin.outputs.c | 336 ++++++++++++++++++++++++++++- 4 files changed, 501 insertions(+), 4 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 325394d06b..ca7de0cf5f 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -338,6 +338,12 @@ typedef Handle OutputsResult_Handle; typedef Handle StatusResult_Handle; +/** + * Memory handle to access to coin.AddressUxOuts + */ + +typedef Handle AddressUxOuts_Handle; + typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 4b1aecba16..d093dbe380 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -4,6 +4,7 @@ import ( "reflect" "unsafe" + "github.com/skycoin/skycoin/src/cipher" coin "github.com/skycoin/skycoin/src/coin" ) @@ -198,3 +199,151 @@ func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } + +//export SKY_coin_NewAddressUxOuts +func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + address_outs := coin.NewAddressUxOuts(ua) + *_address_outs = registerAddressUxOutHandle(&address_outs) + return +} + +//export SKY_coin_AddressUxOuts_Keys +func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_ERROR + return + } + keys := (*address_outs).Keys() + copyToGoSlice(reflect.ValueOf(keys), _keys) + return +} + +//export SKY_coin_AddressUxOuts_Flatten +func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_ERROR + return + } + ux := (*address_outs).Flatten() + copyToGoSlice(reflect.ValueOf(ux), _ua) + return +} + +//export SKY_coin_AddressUxOuts_Sub +func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_ERROR + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_ERROR + return + } + auo_result := (*auo1).Sub(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Add +func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_ERROR + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_ERROR + return + } + auo_result := (*auo1).Add(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Get +func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + copyToGoSlice(reflect.ValueOf(uxOuts), _uxOuts) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_HasKey +func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _hasKey *bool) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + _, found := (*a)[key] + *_hasKey = found + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_GetOutputLength +func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _length *int) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + *_length = len(uxOuts) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_Length +func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + *_length = len(*a) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_Set +func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) + (*a)[key] = uxOuts + return SKY_OK + } + return SKY_ERROR +} diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index a6d6698b0f..80df37cb89 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -468,6 +468,20 @@ func lookupStatusResultHandle(handle C.StatusResult_Handle) (*webrpc.StatusResul return nil, false } +func registerAddressUxOutHandle(obj *coin.AddressUxOuts) C.AddressUxOuts_Handle { + return (C.AddressUxOuts_Handle)(registerHandle(obj)) +} + +func lookupAddressUxOutHandle(handle C.AddressUxOuts_Handle) (*coin.AddressUxOuts, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.AddressUxOuts); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 31160bf4d4..74c6f8d390 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -466,7 +466,335 @@ Test(coin_outputs, TestUxArraySwap){ cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); } -/********************************************************** -* 6 Tests involvinf AddressUxOuts were not done -* because the corresponding functions were not exported -*************************************************************/ +Test(coin_outputs, TestAddressUxOutsKeys){ + int result; + int test_count = 3; + coin__UxOut uxs[test_count]; + for(int i = 0; i < 3; i++){ + makeUxOut(&uxs[i]); + } + + coin__UxArray uxa = {uxs, test_count, test_count}; + AddressUxOuts_Handle uxOutsHandle; + result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + GoSlice_ keys = {NULL, 0, 0}; + result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed" ); + registerMemCleanup(keys.data); + cr_assert(keys.len == test_count); + cipher__Address* pKey = keys.data; + for(int i = 0; i < test_count; i++){ + //Check if every key matches uxout + int found = 0; + for(int j = 0; j < test_count; j++){ + if(memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0){ + found = 1; + } + } + cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); + found = 0; + if( i < test_count - 1){ + cipher__Address* pKey2 = pKey; + for(int j = i + 1; j < test_count; j++){ + pKey2++; + if(memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0){ + found = 1; + } + } + } + cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); + pKey++; + } +} + +Test(coin_outputs, TestAddressUxOutsSub){ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut* pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h2); + memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray ux5 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed" ); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + // One address should have been removed, because no elements + cr_assert(length == 2, "Invalid length %d", length); + GoInt8_ hasKey; + result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed" ); + cr_assert(hasKey == 0); + + memset(&ux3, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux3.data); + cr_assert(ux3.len == 1); + coin__UxOut* pData2 = ux3.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 1)) ); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsAdd){ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut* pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h2); + memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray ux5 = {pData + 1, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed" ); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + // One address should have been removed, because no elements + cr_assert(length == 3, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut* pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); + cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+2)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 2)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+3)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+1)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); + cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsFlatten){ + int result; + coin__UxArray uxa, emptyArray; + makeUxArray(&uxa, 3); + coin__UxOut* pData = uxa.data; + memcpy(&(pData+2)->Body.Address, &(pData+1)->Body.Address, sizeof(cipher__Address)); + memset(&emptyArray, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h); + cipher__Address emptyAddr; + makeAddress(&emptyAddr); + coin__UxArray ux1 = {pData, 1, 1}; + coin__UxArray ux2 = {pData+1, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + result = SKY_coin_AddressUxOuts_Set(h, &(pData+1)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray flatArray; + memset(&flatArray, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed" ); + registerMemCleanup( flatArray.data ); + cr_assert( flatArray.len == 3 ); + // emptyAddr should not be in the array + coin__UxOut* pData2 = flatArray.data; + for(int i = 0; i < flatArray.len; pData2++, i++){ + int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); + cr_assert(cmp != 0); + } + pData2 = flatArray.data; + int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); + if(cmp == 0){ + cr_assert( eq( type(coin__UxOut), *pData2, *pData ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+2) ) ); + cr_assert( eq( type(cipher__Address), pData2->Body.Address, pData->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+1)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData+2)->Body.Address ) ); + }else{ + cr_assert( eq( type(coin__UxOut), *pData2, *(pData+1) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+2) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData) ) ); + cr_assert( eq( type(cipher__Address), pData2->Body.Address, (pData+1)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+2)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData)->Body.Address ) ); + } +} + + +Test(coin_outputs, TestNewAddressUxOuts){ + int result; + coin__UxArray uxa, ux2; + makeUxArray(&uxa, 6); + coin__UxOut* pData = uxa.data; + memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 3)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 4)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&uxa, &h); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut* pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData+3)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 3); + pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+2) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+3) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+4) ) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData+5)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+5) ) ); +} From 620307fb1032aba548f3dec60a747cf3d73d4530 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Mon, 25 Jun 2018 18:35:27 +0000 Subject: [PATCH 091/399] [libc] ref #1191. Added function TestSigVerify [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0 --- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index cba38ac40a..4ae8b0caad 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -98,4 +98,65 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); +} + +Test(cipher_secp256k1_sig, TestSigVerify) { + + Number msg; + Signature sig; + secp256k1go__XY key; + + memset(&msg, 0, sizeof(Number)); + memset(&sig, 0, sizeof(Signature)); + memset(&key, 0, sizeof(secp256k1go__XY)); + + GoString str = { + "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA", 64}; + GoUint32 result; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "98F9D784BA6C5C77BB7323D044C0FC9F2B27BAA0A5B0718FE88596CC56681980"; + result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; + result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "7d709f85a331813f9ae6046c56b3a42737abf4eb918b2e7afee285070e968b93"; + result = SKY_secp256k1go_Field_SetHex(&key.X, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + str.p = "26150d1a63b342986c373977b00131950cb5fc194643cad6ea36b5157eba4602"; + result = SKY_secp256k1go_Field_SetHex(&key.Y, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + GoUint8 valid; + result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); + cr_assert(valid, "sig.Verify 1"); + + str.p = "2c43a883f4edc2b66c67a7a355b9312a565bb3d33bb854af36a06669e2028377"; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "6b2fa9344462c958d4a674c2a42fbedf7d6159a5276eb658887e2e1b3915329b"; + result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "eddc6ea7f190c14a0aa74e41519d88d2681314f011d253665f301425caf86b86"; + result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + char buffer_xy[1024]; + cipher__PubKeySlice xy = {buffer_xy, 0, 1024}; + str.p = "02a60d70cfba37177d8239d018185d864b2bdd0caf5e175fd4454cc006fd2d75ac"; + str.n = 66; + result = SKY_base58_String2Hex(str, &xy); + cr_assert(result == SKY_OK, "SKY_base58_String2Hex"); + GoSlice xyConvert = {xy.data, xy.len, xy.cap}; + result = SKY_secp256k1go_XY_ParsePubkey(&key, xyConvert, &valid); + cr_assert(result == SKY_OK && valid, "SKY_secp256k1go_XY_ParsePubkey failed"); + result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); + cr_assert(valid, "sig.Verify 2"); } \ No newline at end of file From ec772ca6c6bac6bc851565a52526929853f0d389 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 26 Jun 2018 09:17:16 +0000 Subject: [PATCH 092/399] [libc] ref #1191. Correcting errors in slice [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 1b756f2135..51c3bd1d4b 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -740,11 +740,11 @@ Test(cipher_crypto, TestGenerateDeterministicKeyPairsUsesAllBytes) { GoString seed = {"property diet little foster provide disagree witness " "mountain alley weekend kitten general", 90}; -GoSlice seedSlice = {&seed,sizeof(GoString),sizeof(GoString)}; +GoSlice seedSlice = {&seed,90,90}; char buffer_seckeys[1024]; char buffer_seckeys2[1024]; -cipher__PubKeySlice seckeys={buffer_seckeys,0,0}; -cipher__PubKeySlice seckeys2={buffer_seckeys2,0,0}; +cipher__PubKeySlice seckeys={buffer_seckeys,0,1024}; +cipher__PubKeySlice seckeys2={buffer_seckeys2,0,1024}; GoInt result; result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys); cr_assert(result == SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); From ca96d29ac81d9ab6850f475d7f95bc27f5f8bb2d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 26 Jun 2018 10:57:25 +0000 Subject: [PATCH 093/399] [libc] refs #1191. Removed commented line. [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0. --- include/base64.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/base64.h b/include/base64.h index 04393042aa..c27c6e0805 100644 --- a/include/base64.h +++ b/include/base64.h @@ -42,5 +42,3 @@ unsigned int b64_encodef(char *InFile, char *OutFile); // Input : filenames // returns size of output int b64_decodef(char *InFile, char *OutFile); - -//unsigned int b64_encode_string(const unsigned char* in, unsigned int in_len, unsigned char* out); From ee68c33c94e851ac6b696197c8eaf9fc93fa6ac1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 26 Jun 2018 11:23:24 +0000 Subject: [PATCH 094/399] [libc] refs #1191. Removed skynumber.h and libsky_number.c because were not used. [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0. --- include/skynumber.h | 8 ------- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 21 +++++++++---------- lib/cgo/tests/testutils/libsky_number.c | 13 ------------ 3 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 include/skynumber.h delete mode 100644 lib/cgo/tests/testutils/libsky_number.c diff --git a/include/skynumber.h b/include/skynumber.h deleted file mode 100644 index f3804d8fb1..0000000000 --- a/include/skynumber.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LIBSKY_NUMBER_H -#define LIBSKY_NUMBER_H - -#include "skytypes.h" - -extern int number_eq(Number* n1, Number* n2); - -#endif \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index 4ae8b0caad..2b36ab3516 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -10,7 +10,6 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#include "skynumber.h" #define BUFFER_SIZE 1024 @@ -34,12 +33,12 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Number msg; secp256k1go__XY pubKey; secp256k1go__XY expected; - + memset(&pubKey, 0, sizeof(secp256k1go__XY)); memset(&expected, 0, sizeof(secp256k1go__XY)); memset(&sig, 0, sizeof(Signature)); memset(&msg, 0, sizeof(Number)); - + GoString R = {R1, strlen(R1)}; GoString S = {S1, strlen(S1)}; GoString MSG = {MSG1, strlen(MSG1)}; @@ -47,7 +46,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ GoString Y = {Y1, strlen(Y1)}; GoInt rid = 0; GoInt8 result; - + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); @@ -58,14 +57,14 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); - + R.p = R2; R.n = strlen(R2); S.p = S2; @@ -77,7 +76,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Y.p = Y2; Y.n = strlen(Y2); rid = 1; - + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); @@ -88,11 +87,11 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - + GoInt8 equal; error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); @@ -159,4 +158,4 @@ Test(cipher_secp256k1_sig, TestSigVerify) { result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); cr_assert(valid, "sig.Verify 2"); -} \ No newline at end of file +} diff --git a/lib/cgo/tests/testutils/libsky_number.c b/lib/cgo/tests/testutils/libsky_number.c deleted file mode 100644 index 5b6c82bc7a..0000000000 --- a/lib/cgo/tests/testutils/libsky_number.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "skynumber.h" - -int number_eq(Number* n1, Number* n2){ - if ( n1->neg != n2->neg ) - return 0; - if ( n1->nat.len != n2->nat.len ) - return 0; - for( int i = 0; i < n1->nat.len; i++){ - if( ((char*)n1->nat.data)[i] != ((char*)n2->nat.data)[i]) - return 0; - } - return 1; -} \ No newline at end of file From eaeaa476f2eec2c3483877f1a49b7bcc75906b96 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 26 Jun 2018 11:40:58 +0000 Subject: [PATCH 095/399] [libc] refs #1191 Removed commented or unneeded code. [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0. --- include/skytest.h | 4 ---- include/skytypes.h | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/include/skytest.h b/include/skytest.h index 98440d43c4..e0dc956c17 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -11,10 +11,6 @@ void * registerMemCleanup(void *p); void fprintbuff(FILE *f, void *buff, size_t n); -void redirectStdOut(); - -int getStdOut(char* str, unsigned int max_size); - json_value* json_get_string(json_value* value, const char* key); int json_set_string(json_value* value, const char* new_string_value); diff --git a/include/skytypes.h b/include/skytypes.h index ca7de0cf5f..2d5dd7848f 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -347,14 +347,4 @@ typedef Handle AddressUxOuts_Handle; typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); -/* -#include "cipher.hash.go.h" -#include "cipher.crypto.go.h" -#include "cipher.address.go.h" -#include "cli.create_rawtx.go.h" -#include "coin.outputs.go.h" -#include "coin.transactions.go.h" -#include "wallet.entry.go.h" -#include "wallet.wallet.go.h" -*/ #endif From 61c225a40b98730a1c482535ff9582e230e94852 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 26 Jun 2018 12:34:31 +0000 Subject: [PATCH 096/399] [libc] refs #1191. Removed typedef Ripem160 and used cipher__Ripem160. [====] Synthesis: Tested: 141 | Passing: 141 | Failing: 0 | Crashing: 0. --- include/skycriterion.h | 6 +++--- include/skytypes.h | 5 ----- lib/cgo/tests/check_cipher.crypto.c | 4 ++-- lib/cgo/tests/testutils/libsky_criterion.c | 10 +++++----- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/skycriterion.h b/include/skycriterion.h index 093ca9ae55..22289385a2 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -20,9 +20,9 @@ extern char *cr_user_GoString__tostr(GoString_ *string) ; extern int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2); extern char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1); -extern int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2); -extern int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2); -extern char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1); +extern int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); +extern int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); +extern char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1); extern int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2); extern char *cr_user_GoSlice_tostr(GoSlice *slice1); diff --git a/include/skytypes.h b/include/skytypes.h index 2d5dd7848f..528c54bdf9 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -194,11 +194,6 @@ typedef struct { GoSlice_ nat; } Number; -/** - * RIPEMD-160 hash. - */ -typedef unsigned char Ripemd160[20]; - typedef struct { //TODO: stdevEclipse Define Signature Number R; diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 51c3bd1d4b..90545d2bd9 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -183,7 +183,7 @@ Test(cipher_crypto, TestPubKeyToAddress) { cipher__PubKey p; cipher__SecKey s; cipher__Address addr; - Ripemd160 h; + cipher__Ripemd160 h; int errcode; SKY_cipher_GenerateKeyPair(&p, &s); @@ -753,4 +753,4 @@ cipher__PubKeySlice seckeys2={buffer_seckeys2,0,1024}; result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys2); cr_assert(result==SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); cr_assert(not(eq(type(GoSlice_),seckeys,seckeys2))); -} \ No newline at end of file +} diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 5aeb0548bf..218e032679 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -79,15 +79,15 @@ char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) } -int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) != 0; +int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) != 0; } -int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) == 0; +int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) == 0; } -char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1) +char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) { char *out; char hexdump[101]; From b5a56401e46197ac6b3ce3b9b110842cfb062cac Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 26 Jun 2018 13:03:17 +0000 Subject: [PATCH 097/399] [libc] ref #1191. Added function TestSigSign [====] Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0 --- include/skycriterion.h | 4 ++ ...check_cipher.secp256k1.secp256k1-go2.sig.c | 63 +++++++++++++++++++ lib/cgo/tests/testutils/libsky_criterion.c | 17 +++++ 3 files changed, 84 insertions(+) diff --git a/include/skycriterion.h b/include/skycriterion.h index 093ca9ae55..2700102679 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -63,4 +63,8 @@ extern int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin_ extern int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); extern char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1); +extern int cr_user_Number_eq(Number *n1, Number *n2); +extern int cr_user_Number_noteq(Number *n1, Number *n2); +extern char* cr_user_Number_tostr(Number *n1); + #endif //LIBCRITERION_H diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index 4ae8b0caad..54d99e5b09 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -26,6 +26,8 @@ #define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" #define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" +#define forceLowS true + TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); Test(cipher_secp256k1_sig, TestSigRecover){ @@ -159,4 +161,65 @@ Test(cipher_secp256k1_sig, TestSigVerify) { result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); cr_assert(valid, "sig.Verify 2"); +} + +Test(cipher_secp256k1_sig, TestSigSign) { + + Number sec; + Number msg; + Number non; + Signature sig; + GoInt recid; + + memset(&sec, 0, sizeof(Number)); + memset(&msg, 0, sizeof(Number)); + memset(&non, 0, sizeof(Number)); + + memset(&sig, 0, sizeof(Signature)); + + GoString str = { + "73641C99F7719F57D8F4BEB11A303AFCD190243A51CED8782CA6D3DBE014D146", 64}; + GoUint32 result; + result = SKY_secp256k1go_Number_SetHex(&sec, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + GoInt res; + + result = SKY_secp256k1go_Signature_Sign(&sig, &sec, &msg, &non, &recid, &res); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); + cr_assert(res == 1, "res failed %d", res); + + if (forceLowS) { + cr_assert(recid == 0, " recid failed %d", recid); + } else { + cr_assert(recid == 1, " recid failed %d", recid); + } + str.p = "98f9d784ba6c5c77bb7323d044c0fc9f2b27baa0a5b0718fe88596cc56681980"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + cr_assert(eq(type(Number), sig.R, non)); + + if (forceLowS) { + str.p = "1ca662aaefd6cc958ba4604fea999db133a75bf34c13334dabac7124ff0cfcc1"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + } else { + str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + } + cr_assert(eq(type(Number), sig.S, non)); } \ No newline at end of file diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 5aeb0548bf..3cafc5b45b 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -250,3 +250,20 @@ char* cr_user_coin__UxArray_tostr(coin__UxArray *x1){ cr_asprintf(&out, "(coin__UxArray) { Length : %d }", x1->len); return out; } + +int cr_user_Number_eq(Number *n1, Number *n2) { + return (equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt)) && + ((GoInt)n1->neg == (GoInt)n2->neg)); +} + +int cr_user_Number_noteq(Number *n1, Number *n2) { + return ( !(equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt))) || + ((GoInt)n1->neg != (GoInt)n2->neg)); +} + +char *cr_user_Number_tostr(Number *n1) { + char *out; + cr_asprintf(&out, "(Number) { nat : [.data %s, .len %d , cap %d] , neg %d }", + (char *)n1->nat.data, n1->nat.len, n1->nat.cap, (GoInt)n1->neg); + return out; +} From 25904f8e6a218784525eac10163d9c643fdbd5d4 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 26 Jun 2018 14:12:00 +0000 Subject: [PATCH 098/399] [libc] refs #1191. Change in TestBitcoinAddressFromBytes test to be like the original test. [====] Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0. --- lib/cgo/tests/check_cipher.address.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 03a650df3e..327f79c180 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -401,7 +401,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { // Invalid checksum b_convert.len = b_len; - ((char *)b_convert.data)[b_convert.len - 1] = '2'; + (((char *)b_convert.data)[b_convert.len - 1])++; cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, "Invalid checksum"); From 5709bd44d595ebe8f66f2c35bc9d5e16796b3e47 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 26 Jun 2018 15:12:43 +0000 Subject: [PATCH 099/399] [libc] ref #1191. Added function TestGejGetX [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0 --- ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c index 31637a6da5..9bd664993c 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c @@ -61,3 +61,46 @@ Test(cipher_secp256k1_xyz, TestXYZDouble){ cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); } + +// TestGejMulLambda not impleme + +Test(cipher_secp256k1_xyz, TestGejGetX) { + secp256k1go__XYZ a; + secp256k1go__Field X; + secp256k1go__Field exp; + GoUint32 result; + memset(&a, 0, sizeof(secp256k1go__XYZ)); + memset(&X, 0, sizeof(secp256k1go__Field)); + memset(&a, 0, sizeof(secp256k1go__Field)); + + GoString str = { + "EB6752420B6BDB40A760AC26ADD7E7BBD080BF1DF6C0B009A0D310E4511BDF49", 64}; + + result = SKY_secp256k1go_Field_SetHex(&a.X, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + str.p = "8E8CEB84E1502FC536FFE67967BC44314270A0B38C79865FFED5A85D138DCA6B"; + result = SKY_secp256k1go_Field_SetHex(&a.Y, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + str.p = "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31"; + result = SKY_secp256k1go_Field_SetHex(&a.Z, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + str.p = "fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b10"; + result = SKY_secp256k1go_Field_SetHex(&exp, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + secp256k1go__Field zi2; + secp256k1go__Field r; + memset(&zi2, 0, sizeof(secp256k1go__Field)); + memset(&r, 0, sizeof(secp256k1go__Field)); + result = SKY_secp256k1go_Field_InvVar(&a.Z, &zi2); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_InvVar failed"); + result = SKY_secp256k1go_Field_Sqr(&zi2, &zi2); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Sqr failed"); + result = SKY_secp256k1go_Field_Mul(&a.X, &X, &zi2); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Mul failed"); + GoUint8 valid; + result = SKY_secp256k1go_Field_Equals(&X, &exp, &valid); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Equals failed"); + cr_assert(valid, "get.get_x() fail"); +} \ No newline at end of file From e8d36d3c02eac959f3235bd70792bf2b34e8e7b5 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Wed, 27 Jun 2018 10:59:21 +0000 Subject: [PATCH 100/399] [libc] ref #1191. Changing SKY_ERROR for its real errors in the library [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.address.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 63952edf35..13e068dbc7 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -396,13 +396,13 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { b.len = b.len - 2; cipher__Address addr2; GoSlice b_convert = {b.data, b.len, b.cap}; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ErrInvalidLength, "Invalid address length"); // Invalid checksum b_convert.len = b_len; (((char *)b_convert.data)[b_convert.len - 1])++; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ErrInvalidChecksum, "Invalid checksum"); result = SKY_cipher_AddressFromPubKey(&p, &a); @@ -414,7 +414,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); GoSlice b1_convert = {b1.data, b1.len, b1.cap}; result = SKY_cipher_BitcoinAddressFromBytes(b1_convert, &addr2); - cr_assert(result == SKY_ERROR, "Invalid version"); + cr_assert(result == SKY_ErrInvalidVersion, "Invalid version"); } Test(cipher_address, TestMustDecodeBase58Address) { From 80a6a61420a382e9d97a495019065dce66ca3063 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 6 Jul 2018 14:11:09 +0000 Subject: [PATCH 101/399] [swig] refs #1568. Added README.me file. --- lib/swig/README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/swig/README.md diff --git a/lib/swig/README.md b/lib/swig/README.md new file mode 100644 index 0000000000..868bba4999 --- /dev/null +++ b/lib/swig/README.md @@ -0,0 +1,52 @@ +#SWIG files + +SWIG interface files for generating skycoin libraries in different languages. + +##Table of Contents + + +- [Requirements] (#requirements) +- [Usage] (#usage) + - [Tips] (#tips) + + +## Requirements + Requires Swig installed. It has been tested with 3.0.10, so that would be the preferred version. + These swig interface files has been tested with Python2.7, and in other languages may not work as expected. It is very important to read SWIG documentation for the specific target language being used, http://www.swig.org/Doc3.0/SWIGDocumentation.html +## Usage + First step would be to apply SWIG to the main interface file (skycoin.i). For example if it is going to be generated for Python it would be like this: + swig -python skycoin.i +Or in the case of C#: + swig -csharp skycoin.i + You will also need to add to this command the include paths where to search for required header files. This path would be skycoin include path. For example if skycoin include path is skycoin/include, then the swig command would be: + swig -csharp -Iskycoin/include skycoin.i + However, doing this will raise an error because SWIG doesn't fully understand a specific line in libksycoin.h. The solution is making a copy of libskycoin and removing the conflicting line. Like this: + grep -v _Complex skycoin/include/libskycoin.h > swig/include/libskycoin.h + swig -csharp -I swig/include -Iskycoin/include skycoin.i + The above command lines will make a copy of libskycoin.h removing lines containing string "_Complex" and execute swig specifying first as include path the path containing the modified copy of libskycoin. +## Tips + It is also important to notice that file structs.i contains inclusions of header files containing type definitions of libskycoin. This file is very similar to skytypes.gen.h but replacing character # with %. + For example skytypes.gen.h being something like this: + + #include "file1.h" + #include "file2.h" + + Then, structs.i would be: + %include "file1.h" + %include "file2.h" + + And this is something that swig can understand. + So, a good idea would be to update structs.i from skytypes.gen.h, just in case there have been modifications to skycoin source code. + Like this: + cp skycoin/include/skytypes.gen.h structs.i + sed -i 's/#/%/g' structs.i + grep -v _Complex skycoin/include/libskycoin.h > swig/include/libskycoin.h + swig -csharp -I swig/include -Iskycoin/include skycoin.i + + Use https://github.com/simelo/pyskycoin/ as a reference. Check Makefile rule build-swig. + This project is used to create a Python extension to access skycoin API from Python. This project contains skycoin repository as git submodule, which is a good idea to make libraries for other languages. + + + + + From dcd8d788ef79e17b37bcc319d17c2ecd5354f8d6 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 6 Jul 2018 15:57:02 +0000 Subject: [PATCH 102/399] [swig] refs #1568. Added overloaded byte and unicode support. --- lib/swig/golang.cgo.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index f4714c66fe..efaa222ff1 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -1,3 +1,8 @@ +%begin %{ +#define SWIG_PYTHON_STRICT_BYTE_CHAR +#define SWIG_PYTHON_STRICT_UNICODE_WCHAR +%} + /*GoSlice in typemap*/ %typemap(in) GoSlice { char* buffer = 0; From 485c4a7eecf90c7bc9eb9281449fc5b4fb0a57f7 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 6 Jul 2018 17:55:36 +0000 Subject: [PATCH 103/399] [swig] refs #1568. Change error message reading Python string from parameter. --- lib/swig/golang.cgo.i | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index efaa222ff1..3d2523197a 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -3,13 +3,14 @@ #define SWIG_PYTHON_STRICT_UNICODE_WCHAR %} + /*GoSlice in typemap*/ %typemap(in) GoSlice { char* buffer = 0; size_t size = 0; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + %argument_fail(res, "byte buffer", $symname, $argnum); } $1.data = buffer; $1.len = size - 1; @@ -34,7 +35,7 @@ /*GoSlice_* as function return typemap*/ %typemap(argout) GoSlice_* { - %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); + %append_output( SWIG_AsCharPtrAndSize( $1->data, $1->len ) ); free( (void*)$1->data ); } @@ -47,7 +48,7 @@ size_t size = 0; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + %argument_fail(res, "byte buffer", $symname, $argnum); } $1.p = buffer; $1.n = size - 1; From efbeccac5e8378f1c8a3143d7d721affc8da914f Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 6 Jul 2018 18:04:15 +0000 Subject: [PATCH 104/399] [swig] refs #1568. Change error message when argument is not of type byte string. --- lib/swig/golang.cgo.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 3d2523197a..d09d22ae2d 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -10,7 +10,7 @@ size_t size = 0; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { - %argument_fail(res, "byte buffer", $symname, $argnum); + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } $1.data = buffer; $1.len = size - 1; @@ -48,7 +48,7 @@ size_t size = 0; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { - %argument_fail(res, "byte buffer", $symname, $argnum); + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } $1.p = buffer; $1.n = size - 1; From d5aad57aef87efe246f4e7ea08d7fd2e43b7f7a3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 6 Jul 2018 18:50:13 +0000 Subject: [PATCH 105/399] [swig] refs #1568. Fixed bug in GoSlice --- lib/swig/golang.cgo.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index d09d22ae2d..fee7460996 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -35,7 +35,7 @@ /*GoSlice_* as function return typemap*/ %typemap(argout) GoSlice_* { - %append_output( SWIG_AsCharPtrAndSize( $1->data, $1->len ) ); + %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); free( (void*)$1->data ); } From 0c3f3f7a829e4f5379652011cd21b1775bccce52 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 6 Jul 2018 20:44:26 -0400 Subject: [PATCH 106/399] [daemon] refs #735 - Send RJCP message back on overflow. Handle it in peer as if it was GIVP --- src/daemon/daemon.go | 2 ++ src/daemon/messages.go | 55 ++++++++++++++++++++++++++----- src/daemon/messages_test.go | 66 ++++++++++++++++++------------------- 3 files changed, 82 insertions(+), 41 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 7e785394f8..bd15aba9d3 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -58,6 +58,8 @@ var ( // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") + // ErrDisconnectPeerlistFull no space in peers pool + ErrDisconnectPeerlistFull gnet.DisconnectReason = errors.New("No space in device pex") logger = logging.MustGetLogger("daemon") ) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 87db98f8ca..eef2f100ea 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -20,6 +20,8 @@ import ( var ( // Every rejection message prefix must start with "RJC" prefix rejectPrefix = [...]byte{82, 74, 67} + // ErrAckRejectWithPeers disconnect since peer sent RJCP message + ErrAckRejectWithPeers gnet.DisconnectReason = errors.New("Disconnect after processing peers") ) // Message represent a packet to be serialized over the network by @@ -239,7 +241,7 @@ type IntroductionMessage struct { Version int32 c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() - valid bool `enc:"-"` // skip it during encoding + validationError error `enc:"-"` // skip it during encoding // Extra would be parsed as blockchain pubkey if it's not empty Extra []byte `enc:",omitempty"` } @@ -345,7 +347,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return nil }() - intro.valid = (err == nil) + intro.validationError = err intro.c = mc if err != nil { @@ -362,7 +364,29 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // Process an event queued by Handle() func (intro *IntroductionMessage) Process(d Daemoner) { d.RemoveFromExpectingIntroductions(intro.c.Addr) - if !intro.valid { + if intro.validationError != nil { + if intro.validationError == pex.ErrPeerlistFull { + // FIXME: Quite similar to NewGivePeersMessage. Merge'em both + peers := d.RandomExchangeable(d.PexConfig().ReplyCount) + ipAddrs := make([]IPAddr, len(peers)) + badAddrs := []string{} + for _, peer := range peers { + ipAddr, err := NewIPAddr(peer.Addr) + if err != nil { + badAddrs = append(badAddrs, peer.Addr) + } else { + ipAddrs = append(ipAddrs, ipAddr) + } + } + if len(badAddrs) > 0 { + logger.Debugf("IntroductionMessage skipping addresses in RJCP peer list %v", badAddrs) + } + if len(ipAddrs) == 0 { + logger.Debug("We have no peers to send in reply") + } + rejectMsg := NewRejectWithPeersMessage(intro, pex.ErrPeerlistFull, "", ipAddrs) + d.SendMessage(intro.c.Addr, rejectMsg) + } return } // Add the remote peer with their chosen listening port @@ -478,14 +502,29 @@ func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers } // Handle an event queued by Handle() -func (msg *RejectWithPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - msg.c = mc - return daemon.(Daemoner).RecordMessageEvent(msg, mc) +func (rpm *RejectWithPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { + rpm.c = mc + return daemon.(Daemoner).RecordMessageEvent(rpm, mc) +} + +// dataMessageForReject returns the data message equivalent to a reject message +func dataMessageForReject(msg gnet.Message) gnet.Message { + switch msg.(type) { + case *RejectWithPeersMessage: + rejectMsg, _ := msg.(*RejectWithPeersMessage) + return &GivePeersMessage{ + Peers: rejectMsg.Peers, + } + default: + return nil + } } // Process Recover from message rejection state -func (msg *RejectWithPeersMessage) Process(d Daemoner) { - // TODO: Implement +func (rpm *RejectWithPeersMessage) Process(d Daemoner) { + gpm, _ := dataMessageForReject(rpm).(*RejectWithPeersMessage) + gpm.Process(d) + d.Disconnect(rpm.c.Addr, ErrAckRejectWithPeers) } // GetBlocksMessage sent to request blocks since LastBlock diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index a6c2260ef0..746412c6e8 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -587,10 +587,10 @@ func TestIntroductionMessage(t *testing.T) { }, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, }, err: nil, }, @@ -606,11 +606,11 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey[:], + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, + Extra: pubkey[:], }, err: nil, }, @@ -626,11 +626,11 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey[:], + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, + Extra: pubkey[:], }, err: nil, }, @@ -646,11 +646,11 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: append(pubkey[:], []byte("additional data")...), + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, + Extra: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -667,11 +667,11 @@ func TestIntroductionMessage(t *testing.T) { disconnectReason: ErrDisconnectBlockchainPubkeyNotMatched, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey2[:], + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, + Extra: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -688,11 +688,11 @@ func TestIntroductionMessage(t *testing.T) { disconnectReason: ErrDisconnectInvalidExtraData, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: []byte("invalid extra data"), + Mirror: 10001, + Port: 6000, + Version: 1, + validationError: nil, + Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, @@ -773,10 +773,10 @@ func TestIntroductionMessage(t *testing.T) { addPeerErr: nil, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 1, - Port: 6000, - valid: true, + Mirror: 10001, + Version: 1, + Port: 6000, + validationError: nil, }, }, { From 662dae15efe42926474dfe9236ae598689b1f3da Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 11:03:37 +0000 Subject: [PATCH 107/399] [swig] refs #1568. Force error to check type of string parameter --- lib/swig/golang.cgo.i | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index fee7460996..9601148c6a 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -46,6 +46,15 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; + if (PyString_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is not unicode string"); + } + else if(PyUnicode_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is unicode unicode"); + } + else { + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', what the hell is this"); + } int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); From 5395c09cfc8d6364fdd835d8a2aa50152ea68e91 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 11:27:24 +0000 Subject: [PATCH 108/399] [swig] refs #1568. Removed forced error. --- lib/swig/golang.cgo.i | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 9601148c6a..fee7460996 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -46,15 +46,6 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; - if (PyString_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is not unicode string"); - } - else if(PyUnicode_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is unicode unicode"); - } - else { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', what the hell is this"); - } int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); From 3f9424498cd361ffa6a3f283d6b8cdaf4db0965b Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 12:08:44 +0000 Subject: [PATCH 109/399] [swig] refs #1568. Raise errors to debug. --- lib/swig/golang.cgo.i | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index fee7460996..d4b0e0870b 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -46,9 +46,44 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; + /*if (PyString_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is not unicode string"); + } + else if(PyUnicode_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is unicode unicode"); + } + else { + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', what the hell is this"); + }*/ + %#if PY_VERSION_HEX>=0x03000000 + %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', received bytes"); + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; + PyBytes_AsStringAndSize($input, &cstr, &len); + buffer = PyBytes_AsString($input); + } + %#else + if (PyUnicode_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', we shouldn't be here"); + } + %#endif + %#else + if (PyString_Check($input)){ + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', received string"); + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; + PyString_AsStringAndSize($input, &cstr, &len); + buffer = SWIG_Python_str_AsChar($input); + } + %#endif int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); + if( res == SWIG_TypeError) + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); + else + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', some unknown error"); } $1.p = buffer; $1.n = size - 1; From 298a1d95055abf6964ad3814e48600c5d705a2ea Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 12:33:10 +0000 Subject: [PATCH 110/399] [swig] refs #1568. Added forced error to debug. --- lib/swig/golang.cgo.i | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index d4b0e0870b..4a2fdcb9fa 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -58,11 +58,14 @@ %#if PY_VERSION_HEX>=0x03000000 %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (PyBytes_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', received bytes"); char *cstr; Py_ssize_t len; int ret = SWIG_OK; PyBytes_AsStringAndSize($input, &cstr, &len); buffer = PyBytes_AsString($input); + if( !buffer ) + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', PyBytes_AsString failed"); + else + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', PyBytes_AsString ok"); } %#else if (PyUnicode_Check($input)){ @@ -71,11 +74,14 @@ %#endif %#else if (PyString_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', received string"); char *cstr; Py_ssize_t len; int ret = SWIG_OK; PyString_AsStringAndSize($input, &cstr, &len); buffer = SWIG_Python_str_AsChar($input); + if( !buffer ) + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', SWIG_Python_str_AsChar failed"); + else + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', SWIG_Python_str_AsChar ok"); } %#endif int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); From 9f069e4e6465ea13afd2515d621867ef5c191490 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 12:39:07 +0000 Subject: [PATCH 111/399] [swig] refs #1568. Removed forced errors. --- lib/swig/golang.cgo.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 4a2fdcb9fa..56a5ece0e8 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -55,6 +55,7 @@ else { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', what the hell is this"); }*/ + /* %#if PY_VERSION_HEX>=0x03000000 %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (PyBytes_Check($input)){ @@ -84,6 +85,7 @@ SWIG_exception_fail(SWIG_TypeError, "in method '$symname', SWIG_Python_str_AsChar ok"); } %#endif + */ int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { if( res == SWIG_TypeError) From 7f1255ae2120e9813c21c93093ff3b062a4e46c1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 12:50:15 +0000 Subject: [PATCH 112/399] [swig] refs #1568. Use alloc argument when calling SWIG_AsCharPtrAndSize --- lib/swig/golang.cgo.i | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 56a5ece0e8..2c10158942 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -86,7 +86,8 @@ } %#endif */ - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int calloc = SWIG_OLDOBJ; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &calloc ); if (!SWIG_IsOK(res)) { if( res == SWIG_TypeError) SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); From ccae873ae3985b95d490c513b5105504a27c6cd5 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 13:05:51 +0000 Subject: [PATCH 113/399] [swig] refs #1568. Use alloc with SWIG_NEWOBJ argument when calling SWIG_AsCharPtrAndSize. --- lib/swig/golang.cgo.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 2c10158942..fef976c15d 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -4,6 +4,11 @@ %} +#if defined(SWIGPYTHON) +#else +#define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize +#endif + /*GoSlice in typemap*/ %typemap(in) GoSlice { char* buffer = 0; @@ -86,7 +91,7 @@ } %#endif */ - int calloc = SWIG_OLDOBJ; + int calloc = SWIG_NEWOBJ; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &calloc ); if (!SWIG_IsOK(res)) { if( res == SWIG_TypeError) From bab49d964317418039e193abaaae2e3c38c43bac Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 13:20:07 +0000 Subject: [PATCH 114/399] [swig] refs #1568. Implement own version of SWIG_AsCharPtrAndSize. --- lib/swig/golang.cgo.i | 67 ++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index fef976c15d..eaca0eda26 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -4,16 +4,34 @@ %} +%inline { #if defined(SWIGPYTHON) +int Wrap_SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +%#if PY_VERSION_HEX>=0x03000000 +if (PyBytes_Check(obj)){ + return PyBytes_AsStringAndSize(obj, cptr, (Py_ssize_t *)psize); +}else{ + return SWIG_TypeError; +} +%#else +if (PyString_Check(obj)){ + return PyString_AsStringAndSize(obj, cptr, (Py_ssize_t *)psize); +} else { + return SWIG_TypeError; +} +%#endif +} #else #define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize #endif +} /*GoSlice in typemap*/ %typemap(in) GoSlice { char* buffer = 0; size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } @@ -26,7 +44,7 @@ %typecheck(SWIG_TYPECHECK_STRING) GoSlice { char* buffer = 0; size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); $1 = SWIG_IsOK(res) ? 1 : 0; } @@ -51,53 +69,10 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; - /*if (PyString_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is not unicode string"); - } - else if(PyUnicode_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', type is unicode unicode"); - } - else { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', what the hell is this"); - }*/ - /* - %#if PY_VERSION_HEX>=0x03000000 - %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_Check($input)){ - char *cstr; Py_ssize_t len; - int ret = SWIG_OK; - PyBytes_AsStringAndSize($input, &cstr, &len); - buffer = PyBytes_AsString($input); - if( !buffer ) - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', PyBytes_AsString failed"); - else - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', PyBytes_AsString ok"); - } - %#else - if (PyUnicode_Check($input)){ - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', we shouldn't be here"); - } - %#endif - %#else - if (PyString_Check($input)){ - char *cstr; Py_ssize_t len; - int ret = SWIG_OK; - PyString_AsStringAndSize($input, &cstr, &len); - buffer = SWIG_Python_str_AsChar($input); - if( !buffer ) - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', SWIG_Python_str_AsChar failed"); - else - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', SWIG_Python_str_AsChar ok"); - } - %#endif - */ - int calloc = SWIG_NEWOBJ; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &calloc ); + int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { if( res == SWIG_TypeError) SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); - else - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', some unknown error"); } $1.p = buffer; $1.n = size - 1; From 5713a4eeabb9d9f392c86692782c1ea599a34074 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 13:39:07 +0000 Subject: [PATCH 115/399] [swig] refs #1568. Avoid using SWIG_PYTHON_STRICT_BYTE_CHAR and use alloc when calling SWIG_AsCharPtrAndSize. --- lib/swig/golang.cgo.i | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index eaca0eda26..dc47447d26 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -1,9 +1,9 @@ %begin %{ -#define SWIG_PYTHON_STRICT_BYTE_CHAR +//#define SWIG_PYTHON_STRICT_BYTE_CHAR #define SWIG_PYTHON_STRICT_UNICODE_WCHAR %} - +/* %inline { #if defined(SWIGPYTHON) int Wrap_SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) @@ -26,6 +26,8 @@ if (PyString_Check(obj)){ #define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize #endif } +*/ +#define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize /*GoSlice in typemap*/ %typemap(in) GoSlice { @@ -69,10 +71,10 @@ if (PyString_Check(obj)){ %typemap(in) GoString { char* buffer = 0; size_t size = 0; - int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int alloc = SWIG_OLDOBJ; + int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { - if( res == SWIG_TypeError) - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } $1.p = buffer; $1.n = size - 1; From a3bdffebb23f1c16ada4219b6bf43e0b1a08e5c4 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 13:46:27 +0000 Subject: [PATCH 116/399] [swig] refs #1568. Removed commented and unneeded code. --- lib/swig/golang.cgo.i | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index dc47447d26..bdea34e83a 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -1,39 +1,12 @@ %begin %{ -//#define SWIG_PYTHON_STRICT_BYTE_CHAR #define SWIG_PYTHON_STRICT_UNICODE_WCHAR %} -/* -%inline { -#if defined(SWIGPYTHON) -int Wrap_SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -{ -%#if PY_VERSION_HEX>=0x03000000 -if (PyBytes_Check(obj)){ - return PyBytes_AsStringAndSize(obj, cptr, (Py_ssize_t *)psize); -}else{ - return SWIG_TypeError; -} -%#else -if (PyString_Check(obj)){ - return PyString_AsStringAndSize(obj, cptr, (Py_ssize_t *)psize); -} else { - return SWIG_TypeError; -} -%#endif -} -#else -#define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize -#endif -} -*/ -#define Wrap_SWIG_AsCharPtrAndSize SWIG_AsCharPtrAndSize - /*GoSlice in typemap*/ %typemap(in) GoSlice { char* buffer = 0; size_t size = 0; - int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } @@ -46,7 +19,7 @@ if (PyString_Check(obj)){ %typecheck(SWIG_TYPECHECK_STRING) GoSlice { char* buffer = 0; size_t size = 0; - int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); $1 = SWIG_IsOK(res) ? 1 : 0; } @@ -72,7 +45,7 @@ if (PyString_Check(obj)){ char* buffer = 0; size_t size = 0; int alloc = SWIG_OLDOBJ; - int res = Wrap_SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); } From 676c5998421d474de2e6c990d75efafc11d4a7e1 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 16:00:08 +0000 Subject: [PATCH 117/399] [swig] refs #1568. Added back SWIG_PYTHON_STRICT_BYTE_CHAR. Use parameter alloca with SWIG_OLDOBJ for SWIG_AsCharPtrAndSize. --- lib/swig/golang.cgo.i | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index bdea34e83a..d44271cf74 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -1,4 +1,5 @@ %begin %{ +#define SWIG_PYTHON_STRICT_BYTE_CHAR #define SWIG_PYTHON_STRICT_UNICODE_WCHAR %} @@ -6,9 +7,10 @@ %typemap(in) GoSlice { char* buffer = 0; size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int alloc = SWIG_OLDOBJ; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); } $1.data = buffer; $1.len = size - 1; @@ -19,7 +21,8 @@ %typecheck(SWIG_TYPECHECK_STRING) GoSlice { char* buffer = 0; size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); + int alloc = SWIG_OLDOBJ; + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); $1 = SWIG_IsOK(res) ? 1 : 0; } @@ -47,7 +50,7 @@ int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting byte string"); + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); } $1.p = buffer; $1.n = size - 1; From e3b330daf636869a0ac0c46646daf380d8334645 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 17:21:30 +0000 Subject: [PATCH 118/399] [swig] refs #1568. Force error in typemap --- lib/swig/golang.cgo.i | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index d44271cf74..ba24fc89c3 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -47,6 +47,7 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; + SWIG_exception_fail(SWIG_TypeError, "in method '$symname', Forced error"); int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { From bb9d2ce80a0ed55acb2c26dfb5ef759d9a5371ba Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 17:30:25 +0000 Subject: [PATCH 119/399] [swig] refs #1568. Removed forced error. --- lib/swig/golang.cgo.i | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index ba24fc89c3..d44271cf74 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -47,7 +47,6 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', Forced error"); int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); if (!SWIG_IsOK(res)) { From 8e2a7f4584fc694b2139a49442731541831ee606 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 20:11:23 +0000 Subject: [PATCH 120/399] [swig] refs #1568. Use SWIG_PYTHON_STRICT_BYTE_CHAR only. Use byte strings, not unicode. --- lib/swig/golang.cgo.i | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index d44271cf74..e83c3098c2 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -1,6 +1,5 @@ %begin %{ #define SWIG_PYTHON_STRICT_BYTE_CHAR -#define SWIG_PYTHON_STRICT_UNICODE_WCHAR %} /*GoSlice in typemap*/ From 022e960adc37a4de3c50555fece42633eb6282eb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 7 Jul 2018 20:24:13 +0000 Subject: [PATCH 121/399] [swig] refs #1568. Avoid using alloc parameter in SWIG_AsCharPtrAndSize. --- lib/swig/golang.cgo.i | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index e83c3098c2..0c9c85ebf7 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -6,8 +6,7 @@ %typemap(in) GoSlice { char* buffer = 0; size_t size = 0; - int alloc = SWIG_OLDOBJ; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); } @@ -20,8 +19,7 @@ %typecheck(SWIG_TYPECHECK_STRING) GoSlice { char* buffer = 0; size_t size = 0; - int alloc = SWIG_OLDOBJ; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); $1 = SWIG_IsOK(res) ? 1 : 0; } @@ -46,8 +44,7 @@ %typemap(in) GoString { char* buffer = 0; size_t size = 0; - int alloc = SWIG_OLDOBJ; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, &alloc ); + int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); } From 9b4b0cbf0a4c06002f832ccfef47c169f342b94e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 10 Jul 2018 18:15:07 +0000 Subject: [PATCH 122/399] [swig] refs #1568. In skytypes.h define __SIZE_TYPE__ if not defined. --- include/skytypes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/skytypes.h b/include/skytypes.h index e5fa28e233..2ae1d4ceb8 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -2,6 +2,10 @@ #ifndef SKYTYPES_H #define SKYTYPES_H +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ unsigned int +#endif + /** * Go 8-bit signed integer values. */ From c4a61aa08cd384b646133fd8508a53ed2c0f5aa6 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 11 Jul 2018 10:26:31 +0000 Subject: [PATCH 123/399] [swig] #1568 When calling SKY_cipher_GenerateDeterministicKeyPairs or SKY_cipher_GenerateDeterministicKeyPairsSeed allocate memory for slice instead of delegating to libskycoin function. --- lib/swig/python_seckeys.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index abd234856c..658adcfb16 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -24,9 +24,9 @@ %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; + data.data = malloc(sizeof(cipher_SecKey) * n); + data.len = n; + data.cap = n; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); if( result == 0){ __out_secKeys->data = data.data; @@ -39,9 +39,9 @@ %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; + data.data = malloc(sizeof(cipher_SecKey) * n); + data.len = n; + data.cap = n; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); if( result == 0){ __out_secKeys->data = data.data; From 1d5f1ec5e8d2d1a364bbdf12123e5ef14d2b50fb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 11 Jul 2018 10:47:45 +0000 Subject: [PATCH 124/399] [swig] refs #1568. When return python list use SWIG_POINTER_OWN to create new objects and Py_DECREF. Use PyList_Append instead of PyList_Set. --- lib/swig/python_seckeys.i | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index 658adcfb16..09c46b34df 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -8,11 +8,12 @@ /*cipher_SecKeys* as function return typemap*/ %typemap(argout) (cipher_SecKeys* __out_secKeys) { int i; - PyObject *list = PyList_New($1->count); + PyObject *list = PyList_New(0); for (i = 0; i < $1->count; i++) { cipher_SecKey* key = &($1->data[i]); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW | 0 ); - PyList_SetItem(list,i,o); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); + PyList_Append(list, o); + Py_DECREF(o); } if( $1->data != NULL) free( (void*)$1->data ); From bcd16618dd5bfdd18d689b00d43c9e2005798a1d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 11 Jul 2018 11:14:56 +0000 Subject: [PATCH 125/399] [swig] refs #1568. Use SWIG_POINTER_NOSHADOW instead of SWIG_POINTER_OWN. --- lib/swig/python_seckeys.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index 09c46b34df..c3820a8ea2 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -11,7 +11,7 @@ PyObject *list = PyList_New(0); for (i = 0; i < $1->count; i++) { cipher_SecKey* key = &($1->data[i]); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW ); PyList_Append(list, o); Py_DECREF(o); } From 9049c86586398d0896f8073c1726838a3d1dce53 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 11 Jul 2018 11:51:09 +0000 Subject: [PATCH 126/399] [swig] refs #1568 Remove conflicting typdef api__createTransactionRequestWallet. --- include/api.spend.go.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/api.spend.go.h b/include/api.spend.go.h index e884eee5aa..93e359f0de 100644 --- a/include/api.spend.go.h +++ b/include/api.spend.go.h @@ -24,11 +24,6 @@ typedef struct{ GoUint64_ Block; GoString_ TxID; } api__CreatedTransactionInput; -typedef struct{ - GoString_ ID; - GoSlice_ Addresses; - GoString_ Password; -} api__createTransactionRequestWallet; typedef struct{ api__CreatedTransaction Transaction; GoString_ EncodedTransaction; From 27350cfff4898bf07d70574b0180df437593b3f9 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Wed, 11 Jul 2018 17:05:12 +0000 Subject: [PATCH 127/399] [libc] ref #1191. Specify the types of errors in coin and cipher [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0 --- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 6 +- .../tests/check_cipher.encrypt.sha256xor.c | 4 +- lib/cgo/tests/check_cipher.scrypt.c | 2 +- .../tests/check_cipher.secp256k1.secp256.c | 4 +- lib/cgo/tests/check_coin.block.c | 2 +- lib/cgo/tests/check_coin.math.c | 4 +- lib/cgo/tests/check_coin.outputs.c | 6 +- lib/cgo/tests/check_coin.transactions.c | 56 +++++++++---------- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c index 3cc4dd4258..341f670a98 100644 --- a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -178,11 +178,11 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ result.cap = result.len = 0; errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray*)&result); - cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); result.cap = result.len = 0; errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, nullData, password2, (coin__UxArray*)&result); - cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null encrypted data."); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null encrypted data."); result.cap = result.len = 0; errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray*)&result); - cr_assert(errcode != SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); } diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 4ebe4ecfba..092d7c4194 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -171,7 +171,7 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); } else { - cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); } if( errcode == SKY_OK ){ cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); @@ -284,7 +284,7 @@ Test(cipher_encrypt_sha256xor, TestDecrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); } else { - cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); } } diff --git a/lib/cgo/tests/check_cipher.scrypt.c b/lib/cgo/tests/check_cipher.scrypt.c index 7863fab99a..4d825c4108 100644 --- a/lib/cgo/tests/check_cipher.scrypt.c +++ b/lib/cgo/tests/check_cipher.scrypt.c @@ -159,6 +159,6 @@ Test(cipher_scrypt, TestKey){ errcode = SKY_scrypt_Key(password, salt, bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, bad_ones[i].keyLength, &key); - cr_assert(errcode != SKY_OK, "SKY_scrypt_Key didn\'t failed"); + cr_assert(errcode == SKY_ERROR, "SKY_scrypt_Key didn\'t failed"); } } \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index c9bb5b178a..bb5c99788b 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -162,9 +162,9 @@ Test(cipher_secp256k1,Test_SignatureVerifySecKey ){ strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); - cr_assert(errorSecKey != SKY_OK); + cr_assert(errorSecKey ==1); GoInt errorPubKey; GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); - cr_assert(errorPubKey != SKY_OK); + cr_assert(errorPubKey == 1); } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 0a48e16e61..2dcef38111 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -94,7 +94,7 @@ Test(coin_block, TestNewBlock) { cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, zeroFeeCalculator, &newBlock); - cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); + cr_assert(result == SKY_ERROR, "SKY_coin_NewBlock has to fail with no transactions"); registerHandleClose( newBlock ); transactions = 0; diff --git a/lib/cgo/tests/check_coin.math.c b/lib/cgo/tests/check_coin.math.c index c570d504e1..16e6b20d91 100644 --- a/lib/cgo/tests/check_coin.math.c +++ b/lib/cgo/tests/check_coin.math.c @@ -20,7 +20,7 @@ Test(coin_math, TestAddUint64){ GoUint64 maxUint64 = 0xFFFFFFFFFFFFFFFF; GoUint64 one = 1; result = SKY_coin_AddUint64(maxUint64, one, &r); - cr_assert( result != SKY_OK ); + cr_assert( result == SKY_ErrUint64AddOverflow ); } typedef struct{ @@ -47,7 +47,7 @@ Test(coin_math, TestUint64ToInt64){ for(int i = 0; i < tests_count; i++){ result = SKY_coin_Uint64ToInt64(tests[i].a, &r); if( tests[i].failure ){ - cr_assert(result != SKY_OK, "Failed test # %d", i + 1); + cr_assert(result == SKY_ErrUint64OverflowsInt64, "Failed test # %d", i + 1); } else { cr_assert(result == SKY_OK, "Failed test # %d", i + 1); cr_assert( tests[i].b == r ); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 74c6f8d390..4b3ef14256 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -220,7 +220,7 @@ Test(coin_outputs, TestUxArrayCoins){ p += 2; p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; result = SKY_coin_UxArray_Coins( &uxs, &coins ); - cr_assert( result != SKY_OK, "SKY_coin_UxArray_Coins should fail with overflow" ); + cr_assert( result == SKY_ERROR, "SKY_coin_UxArray_Coins should fail with overflow" ); } Test(coin_outputs, TestUxArrayCoinHours){ @@ -244,10 +244,10 @@ Test(coin_outputs, TestUxArrayCoinHours){ p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); - cr_assert( result != SKY_OK, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); + cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); - cr_assert( result != SKY_OK, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); + cr_assert( result == SKY_ErrAddEarnedCoinHoursAdditionOverflow, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); } Test(coin_outputs, TestUxArrayHashArray){ diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 74e7666472..58d497ed0d 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -25,7 +25,7 @@ Test(coin_transaction, TestTransactionVerify) { ptx = makeTransaction(&handle); memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // No inputs ptx = makeTransaction(&handle); @@ -34,7 +34,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // No outputs ptx = makeTransaction(&handle); @@ -43,7 +43,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Invalid number of Sigs ptx = makeTransaction(&handle); @@ -52,13 +52,13 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); result = SKY_coin_Transaction_ResetSignatures(handle, 20); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); int MaxUint16 = 0xFFFF; // Too many sigs & inputs @@ -70,7 +70,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Duplicate inputs coin__UxOut ux; @@ -94,7 +94,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Duplicate outputs ptx = makeTransaction(&handle); @@ -107,13 +107,13 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Invalid signature, empty ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Output coins are 0 ptx = makeTransaction(&handle); @@ -122,7 +122,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow @@ -132,7 +132,7 @@ Test(coin_transaction, TestTransactionVerify) { result = SKY_coin_Transaction_UpdateHeader(handle); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Output coins are not multiples of 1e6 (valid, decimal restriction is not // enforced here) @@ -199,7 +199,7 @@ Test(coin_transaction, TestTransactionPushInput) { result = SKY_coin_UxOut_Hash(&ux, &hash); cr_assert(result == SKY_OK); result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); } Test(coin_transaction, TestTransactionPushOutput) { @@ -296,11 +296,11 @@ Test(coin_transactions, TestTransactionVerifyInput) { coin__Transaction *ptx; ptx = makeTransaction(&handle); result = SKY_coin_Transaction_VerifyInput(handle, NULL); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); coin__UxArray ux; memset(&ux, 0, sizeof(coin__UxArray)); result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); memset(&ux, 0, sizeof(coin__UxArray)); ux.data = malloc(3 * sizeof(coin__UxOut)); cr_assert(ux.data != NULL); @@ -309,7 +309,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.cap = 3; memset(ux.data, 0, 3 * sizeof(coin__UxOut)); result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); coin__UxOut uxOut; cipher__SecKey seckey; @@ -326,7 +326,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.len = 1; ux.cap = 1; result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); memset(&sig, 0, sizeof(cipher__Sig)); result = makeUxOutWithSecret(&uxOut, &seckey); @@ -340,7 +340,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.len = 1; ux.cap = 1; result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Invalid Tx Inner Hash result = makeUxOutWithSecret(&uxOut, &seckey); @@ -352,7 +352,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.len = 1; ux.cap = 1; result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Ux hash mismatch result = makeUxOutWithSecret(&uxOut, &seckey); @@ -364,7 +364,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.len = 1; ux.cap = 1; result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Invalid signature result = makeUxOutWithSecret(&uxOut, &seckey); @@ -378,7 +378,7 @@ Test(coin_transactions, TestTransactionVerifyInput) { ux.len = 1; ux.cap = 1; result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Valid result = makeUxOutWithSecret(&uxOut, &seckey); @@ -414,7 +414,7 @@ Test(coin_transactions, TestTransactionSignInputs) { keys.len = 1; keys.cap = 1; result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // Panics if not enough keys ptx = makeEmptyTransaction(&handle); @@ -440,7 +440,7 @@ Test(coin_transactions, TestTransactionSignInputs) { keys.len = 1; keys.cap = 1; result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); cr_assert(ptx->Sigs.len == 0); // Valid signing @@ -481,9 +481,9 @@ Test(coin_transactions, TestTransactionSignInputs) { SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig *)ptx->Sigs.data) + 1); cr_assert(result == SKY_OK); result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig *)ptx->Sigs.data) + 1); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig *)ptx->Sigs.data); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); } Test(coin_transactions, TestTransactionHashInner) { @@ -752,7 +752,7 @@ Test(coin_transactions, TestVerifyTransactionCoinsSpending) { cr_assert(result == SKY_OK); result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); if (tests[i].failure) - cr_assert(result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", + cr_assert(result == SKY_ERROR, "VerifyTransactionCoinsSpending succeeded %d", i + 1); else cr_assert(result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", @@ -827,7 +827,7 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, &inArray, &outArray); if (tests[i].failure) - cr_assert(result != SKY_OK, + cr_assert(result == SKY_ERROR, "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i + 1); else cr_assert(result == SKY_OK, @@ -874,11 +874,11 @@ Test(coin_transactions, TestTransactionsFees) { // calc error result = SKY_coin_Transactions_Fees(transactionsHandle, badFeeCalculator, &fee); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); // summing of calculated fees overflows result = SKY_coin_Transactions_Fees(transactionsHandle, overflowFeeCalculator, &fee); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); } GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee){ From 67195665918da5089bb1480524266c1d873f2487 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 12 Jul 2018 18:50:41 +0000 Subject: [PATCH 128/399] [swig] refs #1568. Try to fix problem of empty structures when compiling in Windows. --- include/cipher.encrypt.sha256xor.go.h | 7 +++++-- include/cli.cli.go.h | 5 +++-- include/daemon.messages.go.h | 5 +++-- include/daemon.rpc.go.h | 5 +++-- include/visor.blockdb.block_tree.go.h | 5 +++-- include/visor.blockdb.blocksigs.go.h | 5 +++-- include/visor.blockdb.unspent.go.h | 15 +++++++++------ include/visor.historydb.address_txn.go.h | 5 +++-- include/visor.historydb.address_uxout.go.h | 5 +++-- include/visor.historydb.history_meta.go.h | 5 +++-- include/visor.historydb.output.go.h | 5 +++-- include/visor.historydb.transaction.go.h | 5 +++-- include/visor.unconfirmed.go.h | 10 ++++++---- 13 files changed, 50 insertions(+), 32 deletions(-) diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h index b306cba549..821c1637a5 100644 --- a/include/cipher.encrypt.sha256xor.go.h +++ b/include/cipher.encrypt.sha256xor.go.h @@ -1,2 +1,5 @@ -typedef struct{ -} encrypt__Sha256Xor; +struct _encrypt__Sha256Xor{ +}; + +typedef struct _encrypt__Sha256Xor encrypt__Sha256Xor; + diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index a1c7775c4f..823241b812 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -13,5 +13,6 @@ typedef struct{ GoInt32_ _unnamed; } cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; -typedef struct{ -} cli__PasswordFromTerm; +struct _cli__PasswordFromTerm{ +}; +typedef struct _cli__PasswordFromTerm cli__PasswordFromTerm; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h index f133742c8c..119c764311 100644 --- a/include/daemon.messages.go.h +++ b/include/daemon.messages.go.h @@ -12,8 +12,9 @@ typedef struct{ typedef struct{ GoString_ addr; } daemon__GetPeersMessage; -typedef struct{ -} daemon__PongMessage; +struct _daemon__PongMessage{ +}; +typedef struct _daemon__PongMessage daemon__PongMessage; typedef struct{ GoSlice_ Peers; gnet__MessageContext * c; diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h index 82c934991d..af60a2c192 100644 --- a/include/daemon.rpc.go.h +++ b/include/daemon.rpc.go.h @@ -19,5 +19,6 @@ typedef struct{ typedef struct{ GoSlice_ Txids; } daemon__ResendResult; -typedef struct{ -} daemon__RPC; +struct _daemon__RPC{ +}; +typedef struct _daemon__RPC daemon__RPC; diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h index deb16ea9ad..2e25e01b3c 100644 --- a/include/visor.blockdb.block_tree.go.h +++ b/include/visor.blockdb.block_tree.go.h @@ -1,2 +1,3 @@ -typedef struct{ -} blockdb__blockTree; +struct _blockdb__blockTree{ +}; +typedef struct _blockdb__blockTree blockdb__blockTree; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h index 29e49599d1..d31df15502 100644 --- a/include/visor.blockdb.blocksigs.go.h +++ b/include/visor.blockdb.blocksigs.go.h @@ -1,2 +1,3 @@ -typedef struct{ -} blockdb__blockSigs; +struct _blockdb__blockSigs{ +}; +typedef struct _blockdb__blockSigs blockdb__blockSigs; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h index 4606d88f97..1248e1566e 100644 --- a/include/visor.blockdb.unspent.go.h +++ b/include/visor.blockdb.unspent.go.h @@ -1,9 +1,12 @@ typedef struct{ GoString_ UxID; } blockdb__ErrUnspentNotExist; -typedef struct{ -} blockdb__unspentMeta; -typedef struct{ -} blockdb__pool; -typedef struct{ -} blockdb__poolAddrIndex; +struct _blockdb__unspentMeta{ +}; +typedef struct _blockdb__unspentMeta blockdb__unspentMeta; +struct _blockdb__pool{ +}; +typedef struct _blockdb__pool blockdb__pool; +struct _blockdb__poolAddrIndex{ +}; +typedef struct _blockdb__poolAddrIndex blockdb__poolAddrIndex; diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h index 461204b534..1823dd2c6a 100644 --- a/include/visor.historydb.address_txn.go.h +++ b/include/visor.historydb.address_txn.go.h @@ -1,2 +1,3 @@ -typedef struct{ -} historydb__addressTxns; +struct _historydb__addressTxns{ +}; +typedef struct _historydb__addressTxns historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h index 04a5acd6d4..d6f14c9133 100644 --- a/include/visor.historydb.address_uxout.go.h +++ b/include/visor.historydb.address_uxout.go.h @@ -1,2 +1,3 @@ -typedef struct{ -} historydb__addressUx; +struct _historydb__addressUx{ +}; +typedef struct _historydb__addressUx historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h index be4cbdf596..fe20b9db0d 100644 --- a/include/visor.historydb.history_meta.go.h +++ b/include/visor.historydb.history_meta.go.h @@ -1,2 +1,3 @@ -typedef struct{ -} historydb__historyMeta; +struct{ +} _historydb__historyMeta; +typedef struct _historydb__historyMeta historydb__historyMeta; diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h index ab77b04b78..51df4b5c42 100644 --- a/include/visor.historydb.output.go.h +++ b/include/visor.historydb.output.go.h @@ -9,8 +9,9 @@ typedef struct{ GoUint64_ SpentBlockSeq; GoString_ SpentTxID; } historydb__UxOutJSON; -typedef struct{ -} historydb__UxOuts; +struct _historydb__UxOuts{ +}; +typedef struct _historydb__UxOuts historydb__UxOuts; typedef struct{ coin__UxOut Out; cipher__SHA256 SpentTxID; diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h index 75c6205bdf..1aef58dc21 100644 --- a/include/visor.historydb.transaction.go.h +++ b/include/visor.historydb.transaction.go.h @@ -1,5 +1,6 @@ -typedef struct{ -} historydb__transactions; +struct _historydb__transactions{ +}; +typedef struct _historydb__transactions historydb__transactions; typedef struct{ coin__Transaction Tx; GoUint64_ BlockSeq; diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h index 7366404211..da254d2a0a 100644 --- a/include/visor.unconfirmed.go.h +++ b/include/visor.unconfirmed.go.h @@ -1,7 +1,9 @@ -typedef struct{ -} visor__unconfirmedTxns; -typedef struct{ -} visor__txUnspents; +struct _visor__unconfirmedTxns{ +}; +typedef struct _visor__unconfirmedTxns visor__unconfirmedTxns; +struct _visor__txUnspents{ +}; +typedef struct _visor__txUnspents visor__txUnspents; typedef struct{ coin__Transaction Txn; GoInt64_ Received; From 63e2ce503634eba3cd127b9005ff116281f9b941 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 12 Jul 2018 19:09:00 +0000 Subject: [PATCH 129/399] [swig] refs #1568. Try to fix problem of empty structures when compiling pyskycoin in Windows. --- include/cipher.encrypt.sha256xor.go.h | 1 + include/cli.cli.go.h | 1 + include/daemon.messages.go.h | 1 + include/daemon.rpc.go.h | 1 + include/visor.blockdb.block_tree.go.h | 1 + include/visor.blockdb.blocksigs.go.h | 1 + include/visor.blockdb.unspent.go.h | 3 +++ include/visor.historydb.address_txn.go.h | 1 + include/visor.historydb.address_uxout.go.h | 1 + include/visor.historydb.history_meta.go.h | 1 + include/visor.historydb.output.go.h | 1 + include/visor.historydb.transaction.go.h | 1 + include/visor.unconfirmed.go.h | 2 ++ 13 files changed, 16 insertions(+) diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h index 821c1637a5..0efdd88a7f 100644 --- a/include/cipher.encrypt.sha256xor.go.h +++ b/include/cipher.encrypt.sha256xor.go.h @@ -1,4 +1,5 @@ struct _encrypt__Sha256Xor{ + char c[0]; }; typedef struct _encrypt__Sha256Xor encrypt__Sha256Xor; diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index 823241b812..bd7ef1b929 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -14,5 +14,6 @@ typedef struct{ } cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; struct _cli__PasswordFromTerm{ + char c[0]; }; typedef struct _cli__PasswordFromTerm cli__PasswordFromTerm; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h index 119c764311..52449d2294 100644 --- a/include/daemon.messages.go.h +++ b/include/daemon.messages.go.h @@ -13,6 +13,7 @@ typedef struct{ GoString_ addr; } daemon__GetPeersMessage; struct _daemon__PongMessage{ + char c[0]; }; typedef struct _daemon__PongMessage daemon__PongMessage; typedef struct{ diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h index af60a2c192..8a2945786a 100644 --- a/include/daemon.rpc.go.h +++ b/include/daemon.rpc.go.h @@ -20,5 +20,6 @@ typedef struct{ GoSlice_ Txids; } daemon__ResendResult; struct _daemon__RPC{ + char c[0]; }; typedef struct _daemon__RPC daemon__RPC; diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h index 2e25e01b3c..ded02cc74e 100644 --- a/include/visor.blockdb.block_tree.go.h +++ b/include/visor.blockdb.block_tree.go.h @@ -1,3 +1,4 @@ struct _blockdb__blockTree{ + char c[0]; }; typedef struct _blockdb__blockTree blockdb__blockTree; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h index d31df15502..ecc123e61b 100644 --- a/include/visor.blockdb.blocksigs.go.h +++ b/include/visor.blockdb.blocksigs.go.h @@ -1,3 +1,4 @@ struct _blockdb__blockSigs{ + char c[0]; }; typedef struct _blockdb__blockSigs blockdb__blockSigs; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h index 1248e1566e..bc398dba43 100644 --- a/include/visor.blockdb.unspent.go.h +++ b/include/visor.blockdb.unspent.go.h @@ -2,11 +2,14 @@ typedef struct{ GoString_ UxID; } blockdb__ErrUnspentNotExist; struct _blockdb__unspentMeta{ + char c[0]; }; typedef struct _blockdb__unspentMeta blockdb__unspentMeta; struct _blockdb__pool{ + char c[0]; }; typedef struct _blockdb__pool blockdb__pool; struct _blockdb__poolAddrIndex{ + char c[0]; }; typedef struct _blockdb__poolAddrIndex blockdb__poolAddrIndex; diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h index 1823dd2c6a..04050b942a 100644 --- a/include/visor.historydb.address_txn.go.h +++ b/include/visor.historydb.address_txn.go.h @@ -1,3 +1,4 @@ struct _historydb__addressTxns{ + char c[0]; }; typedef struct _historydb__addressTxns historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h index d6f14c9133..62864e228e 100644 --- a/include/visor.historydb.address_uxout.go.h +++ b/include/visor.historydb.address_uxout.go.h @@ -1,3 +1,4 @@ struct _historydb__addressUx{ + char c[0]; }; typedef struct _historydb__addressUx historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h index fe20b9db0d..c01ae8998c 100644 --- a/include/visor.historydb.history_meta.go.h +++ b/include/visor.historydb.history_meta.go.h @@ -1,3 +1,4 @@ struct{ + char c[0]; } _historydb__historyMeta; typedef struct _historydb__historyMeta historydb__historyMeta; diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h index 51df4b5c42..4d2e5c1bcd 100644 --- a/include/visor.historydb.output.go.h +++ b/include/visor.historydb.output.go.h @@ -10,6 +10,7 @@ typedef struct{ GoString_ SpentTxID; } historydb__UxOutJSON; struct _historydb__UxOuts{ + char c[0]; }; typedef struct _historydb__UxOuts historydb__UxOuts; typedef struct{ diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h index 1aef58dc21..6b077e7a40 100644 --- a/include/visor.historydb.transaction.go.h +++ b/include/visor.historydb.transaction.go.h @@ -1,4 +1,5 @@ struct _historydb__transactions{ + char c[0]; }; typedef struct _historydb__transactions historydb__transactions; typedef struct{ diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h index da254d2a0a..9e80812326 100644 --- a/include/visor.unconfirmed.go.h +++ b/include/visor.unconfirmed.go.h @@ -1,7 +1,9 @@ struct _visor__unconfirmedTxns{ + char c[0]; }; typedef struct _visor__unconfirmedTxns visor__unconfirmedTxns; struct _visor__txUnspents{ + char c[0]; }; typedef struct _visor__txUnspents visor__txUnspents; typedef struct{ From 10b52f0bf7e7bc3822c148d9e5418302e1d2a023 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 12 Jul 2018 19:19:38 +0000 Subject: [PATCH 130/399] swig] refs #1568. Try to fix problem of empty structures when compiling pyskycoin in Windows. --- include/cipher.encrypt.sha256xor.go.h | 2 +- include/cli.cli.go.h | 2 +- include/daemon.messages.go.h | 2 +- include/visor.blockdb.block_tree.go.h | 2 +- include/visor.blockdb.blocksigs.go.h | 2 +- include/visor.blockdb.unspent.go.h | 6 +++--- include/visor.historydb.address_txn.go.h | 2 +- include/visor.historydb.address_uxout.go.h | 2 +- include/visor.historydb.history_meta.go.h | 2 +- include/visor.historydb.output.go.h | 2 +- include/visor.historydb.transaction.go.h | 2 +- include/visor.unconfirmed.go.h | 4 ++-- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h index 0efdd88a7f..14d25f072a 100644 --- a/include/cipher.encrypt.sha256xor.go.h +++ b/include/cipher.encrypt.sha256xor.go.h @@ -1,5 +1,5 @@ struct _encrypt__Sha256Xor{ - char c[0]; + char c[1]; }; typedef struct _encrypt__Sha256Xor encrypt__Sha256Xor; diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index bd7ef1b929..c14ac27eaf 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -14,6 +14,6 @@ typedef struct{ } cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; struct _cli__PasswordFromTerm{ - char c[0]; + char c[1]; }; typedef struct _cli__PasswordFromTerm cli__PasswordFromTerm; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h index 52449d2294..81e4dde37d 100644 --- a/include/daemon.messages.go.h +++ b/include/daemon.messages.go.h @@ -13,7 +13,7 @@ typedef struct{ GoString_ addr; } daemon__GetPeersMessage; struct _daemon__PongMessage{ - char c[0]; + char c[1]; }; typedef struct _daemon__PongMessage daemon__PongMessage; typedef struct{ diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h index ded02cc74e..519f5ebdb9 100644 --- a/include/visor.blockdb.block_tree.go.h +++ b/include/visor.blockdb.block_tree.go.h @@ -1,4 +1,4 @@ struct _blockdb__blockTree{ - char c[0]; + char c[1]; }; typedef struct _blockdb__blockTree blockdb__blockTree; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h index ecc123e61b..6649cf7ef7 100644 --- a/include/visor.blockdb.blocksigs.go.h +++ b/include/visor.blockdb.blocksigs.go.h @@ -1,4 +1,4 @@ struct _blockdb__blockSigs{ - char c[0]; + char c[1]; }; typedef struct _blockdb__blockSigs blockdb__blockSigs; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h index bc398dba43..5903a039c3 100644 --- a/include/visor.blockdb.unspent.go.h +++ b/include/visor.blockdb.unspent.go.h @@ -2,14 +2,14 @@ typedef struct{ GoString_ UxID; } blockdb__ErrUnspentNotExist; struct _blockdb__unspentMeta{ - char c[0]; + char c[1]; }; typedef struct _blockdb__unspentMeta blockdb__unspentMeta; struct _blockdb__pool{ - char c[0]; + char c[1]; }; typedef struct _blockdb__pool blockdb__pool; struct _blockdb__poolAddrIndex{ - char c[0]; + char c[1]; }; typedef struct _blockdb__poolAddrIndex blockdb__poolAddrIndex; diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h index 04050b942a..bdef6ef0a8 100644 --- a/include/visor.historydb.address_txn.go.h +++ b/include/visor.historydb.address_txn.go.h @@ -1,4 +1,4 @@ struct _historydb__addressTxns{ - char c[0]; + char c[1]; }; typedef struct _historydb__addressTxns historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h index 62864e228e..92162af43d 100644 --- a/include/visor.historydb.address_uxout.go.h +++ b/include/visor.historydb.address_uxout.go.h @@ -1,4 +1,4 @@ struct _historydb__addressUx{ - char c[0]; + char c[1]; }; typedef struct _historydb__addressUx historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h index c01ae8998c..83f1714362 100644 --- a/include/visor.historydb.history_meta.go.h +++ b/include/visor.historydb.history_meta.go.h @@ -1,4 +1,4 @@ struct{ - char c[0]; + char c[1]; } _historydb__historyMeta; typedef struct _historydb__historyMeta historydb__historyMeta; diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h index 4d2e5c1bcd..fe3614113c 100644 --- a/include/visor.historydb.output.go.h +++ b/include/visor.historydb.output.go.h @@ -10,7 +10,7 @@ typedef struct{ GoString_ SpentTxID; } historydb__UxOutJSON; struct _historydb__UxOuts{ - char c[0]; + char c[1]; }; typedef struct _historydb__UxOuts historydb__UxOuts; typedef struct{ diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h index 6b077e7a40..5cc946971b 100644 --- a/include/visor.historydb.transaction.go.h +++ b/include/visor.historydb.transaction.go.h @@ -1,5 +1,5 @@ struct _historydb__transactions{ - char c[0]; + char c[1]; }; typedef struct _historydb__transactions historydb__transactions; typedef struct{ diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h index 9e80812326..ba0f396ae8 100644 --- a/include/visor.unconfirmed.go.h +++ b/include/visor.unconfirmed.go.h @@ -1,9 +1,9 @@ struct _visor__unconfirmedTxns{ - char c[0]; + char c[1]; }; typedef struct _visor__unconfirmedTxns visor__unconfirmedTxns; struct _visor__txUnspents{ - char c[0]; + char c[1]; }; typedef struct _visor__txUnspents visor__txUnspents; typedef struct{ From 401cb488ffbd8579c4bff14b0be69e14efd65b64 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 12 Jul 2018 19:30:19 +0000 Subject: [PATCH 131/399] [swig] refs #1568. Try to fix problem of empty structures when compiling Pyskycoin in Windows. --- include/daemon.rpc.go.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h index 8a2945786a..5db3e24022 100644 --- a/include/daemon.rpc.go.h +++ b/include/daemon.rpc.go.h @@ -20,6 +20,6 @@ typedef struct{ GoSlice_ Txids; } daemon__ResendResult; struct _daemon__RPC{ - char c[0]; + char c[1]; }; typedef struct _daemon__RPC daemon__RPC; From 4df9c1c761c450fc4fafe06753684e7e62d2f52f Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 13 Jul 2018 14:21:25 +0000 Subject: [PATCH 132/399] [swig] refs #1568. Fixed problem with empty structures that had added a field. --- include/cipher.encrypt.sha256xor.go.h | 6 ++---- include/cli.cli.go.h | 5 ++--- include/daemon.messages.go.h | 5 ++--- include/daemon.rpc.go.h | 5 ++--- include/visor.blockdb.block_tree.go.h | 5 ++--- include/visor.blockdb.blocksigs.go.h | 5 ++--- include/visor.blockdb.unspent.go.h | 15 ++++++--------- include/visor.historydb.address_txn.go.h | 5 ++--- include/visor.historydb.address_uxout.go.h | 5 ++--- include/visor.historydb.history_meta.go.h | 5 ++--- include/visor.historydb.output.go.h | 5 ++--- include/visor.historydb.transaction.go.h | 5 ++--- include/visor.unconfirmed.go.h | 10 ++++------ 13 files changed, 32 insertions(+), 49 deletions(-) diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h index 14d25f072a..39bf99ece6 100644 --- a/include/cipher.encrypt.sha256xor.go.h +++ b/include/cipher.encrypt.sha256xor.go.h @@ -1,6 +1,4 @@ -struct _encrypt__Sha256Xor{ +typedef struct { char c[1]; -}; - -typedef struct _encrypt__Sha256Xor encrypt__Sha256Xor; +} encrypt__Sha256Xor; diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index c14ac27eaf..46ce10824d 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -13,7 +13,6 @@ typedef struct{ GoInt32_ _unnamed; } cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; -struct _cli__PasswordFromTerm{ +typedef struct { char c[1]; -}; -typedef struct _cli__PasswordFromTerm cli__PasswordFromTerm; +} cli__PasswordFromTerm; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h index 81e4dde37d..8ab9363bf5 100644 --- a/include/daemon.messages.go.h +++ b/include/daemon.messages.go.h @@ -12,10 +12,9 @@ typedef struct{ typedef struct{ GoString_ addr; } daemon__GetPeersMessage; -struct _daemon__PongMessage{ +typedef struct { char c[1]; -}; -typedef struct _daemon__PongMessage daemon__PongMessage; +} daemon__PongMessage; typedef struct{ GoSlice_ Peers; gnet__MessageContext * c; diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h index 5db3e24022..318b7d2510 100644 --- a/include/daemon.rpc.go.h +++ b/include/daemon.rpc.go.h @@ -19,7 +19,6 @@ typedef struct{ typedef struct{ GoSlice_ Txids; } daemon__ResendResult; -struct _daemon__RPC{ +typedef struct { char c[1]; -}; -typedef struct _daemon__RPC daemon__RPC; +} daemon__RPC; diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h index 519f5ebdb9..fef60a17f2 100644 --- a/include/visor.blockdb.block_tree.go.h +++ b/include/visor.blockdb.block_tree.go.h @@ -1,4 +1,3 @@ -struct _blockdb__blockTree{ +typedef struct { char c[1]; -}; -typedef struct _blockdb__blockTree blockdb__blockTree; +} blockdb__blockTree; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h index 6649cf7ef7..94141edb00 100644 --- a/include/visor.blockdb.blocksigs.go.h +++ b/include/visor.blockdb.blocksigs.go.h @@ -1,4 +1,3 @@ -struct _blockdb__blockSigs{ +typedef struct { char c[1]; -}; -typedef struct _blockdb__blockSigs blockdb__blockSigs; +} blockdb__blockSigs; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h index 5903a039c3..798516865c 100644 --- a/include/visor.blockdb.unspent.go.h +++ b/include/visor.blockdb.unspent.go.h @@ -1,15 +1,12 @@ typedef struct{ GoString_ UxID; } blockdb__ErrUnspentNotExist; -struct _blockdb__unspentMeta{ +typedef struct { char c[1]; -}; -typedef struct _blockdb__unspentMeta blockdb__unspentMeta; -struct _blockdb__pool{ +} blockdb__unspentMeta; +typedef struct { char c[1]; -}; -typedef struct _blockdb__pool blockdb__pool; -struct _blockdb__poolAddrIndex{ +} blockdb__pool; +typedef struct { char c[1]; -}; -typedef struct _blockdb__poolAddrIndex blockdb__poolAddrIndex; +} blockdb__poolAddrIndex; diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h index bdef6ef0a8..5621597cf9 100644 --- a/include/visor.historydb.address_txn.go.h +++ b/include/visor.historydb.address_txn.go.h @@ -1,4 +1,3 @@ -struct _historydb__addressTxns{ +typedef struct { char c[1]; -}; -typedef struct _historydb__addressTxns historydb__addressTxns; +} historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h index 92162af43d..e9c431a7bc 100644 --- a/include/visor.historydb.address_uxout.go.h +++ b/include/visor.historydb.address_uxout.go.h @@ -1,4 +1,3 @@ -struct _historydb__addressUx{ +typedef struct { char c[1]; -}; -typedef struct _historydb__addressUx historydb__addressUx; +} historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h index 83f1714362..e531e845d8 100644 --- a/include/visor.historydb.history_meta.go.h +++ b/include/visor.historydb.history_meta.go.h @@ -1,4 +1,3 @@ -struct{ +typedef struct { char c[1]; -} _historydb__historyMeta; -typedef struct _historydb__historyMeta historydb__historyMeta; +} historydb__historyMeta; diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h index fe3614113c..c78fb11660 100644 --- a/include/visor.historydb.output.go.h +++ b/include/visor.historydb.output.go.h @@ -9,10 +9,9 @@ typedef struct{ GoUint64_ SpentBlockSeq; GoString_ SpentTxID; } historydb__UxOutJSON; -struct _historydb__UxOuts{ +typedef struct { char c[1]; -}; -typedef struct _historydb__UxOuts historydb__UxOuts; +} historydb__UxOuts; typedef struct{ coin__UxOut Out; cipher__SHA256 SpentTxID; diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h index 5cc946971b..1028503b43 100644 --- a/include/visor.historydb.transaction.go.h +++ b/include/visor.historydb.transaction.go.h @@ -1,7 +1,6 @@ -struct _historydb__transactions{ +typedef struct { char c[1]; -}; -typedef struct _historydb__transactions historydb__transactions; +} historydb__transactions; typedef struct{ coin__Transaction Tx; GoUint64_ BlockSeq; diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h index ba0f396ae8..09f029366b 100644 --- a/include/visor.unconfirmed.go.h +++ b/include/visor.unconfirmed.go.h @@ -1,11 +1,9 @@ -struct _visor__unconfirmedTxns{ +typedef struct { char c[1]; -}; -typedef struct _visor__unconfirmedTxns visor__unconfirmedTxns; -struct _visor__txUnspents{ +} visor__unconfirmedTxns; +typedef struct { char c[1]; -}; -typedef struct _visor__txUnspents visor__txUnspents; +} visor__txUnspents; typedef struct{ coin__Transaction Txn; GoInt64_ Received; From 750b6f85e3c39b94084cdc0962bef77f777b8164 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 13 Jul 2018 15:11:04 +0000 Subject: [PATCH 133/399] [swig] refs #1568. Initialize cipher_SecKeys in wrap_SKY_cipher_GenerateDeterministicKeyPairs and wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed. --- lib/swig/python_seckeys.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index c3820a8ea2..6f49c91164 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -24,6 +24,8 @@ %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ + __out_secKeys->data = NULL; + __out_secKeys->count = 0; GoSlice_ data; data.data = malloc(sizeof(cipher_SecKey) * n); data.len = n; @@ -39,6 +41,8 @@ %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ + __out_secKeys->data = NULL; + __out_secKeys->count = 0; GoSlice_ data; data.data = malloc(sizeof(cipher_SecKey) * n); data.len = n; From 1c58c09bf8744b9bec523b1af55ef77946fce4c9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 13 Jul 2018 15:52:34 +0000 Subject: [PATCH 134/399] [swig] refs #1568 Avoid using Py_DECREF when adding to python list. --- lib/swig/python_seckeys.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index 6f49c91164..ca54d79468 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -13,7 +13,7 @@ cipher_SecKey* key = &($1->data[i]); PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW ); PyList_Append(list, o); - Py_DECREF(o); + //Py_DECREF(o); } if( $1->data != NULL) free( (void*)$1->data ); From f2dae52a5b9ae928e9d60d6987f487b783de91b4 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 15 Jul 2018 21:03:50 +0000 Subject: [PATCH 135/399] [libc] refs #1191. Use new BuildInfor_Handle instead of Handle for BuildInfo type. Added exported function to get data from BuildInfo_Handle. --- include/skytypes.h | 5 +++++ lib/cgo/api.client.go | 2 +- lib/cgo/libsky_handle.go | 15 +++++++++++++++ lib/cgo/libsky_handle_helper.go | 13 +++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/skytypes.h b/include/skytypes.h index 528c54bdf9..e0d844929c 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -339,6 +339,11 @@ typedef Handle StatusResult_Handle; typedef Handle AddressUxOuts_Handle; +/** + * Memory handle to access to visor.BuildInfo (BuildInfo) + */ + +typedef Handle BuildInfo_Handle; typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index b2a67db0a7..6d1c864fe1 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -60,7 +60,7 @@ func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod __arg0, ____return_err := c.Version() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerHandle(__arg0) + *_arg0 = registerBuildInfoHandle(__arg0) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 80df37cb89..8522417327 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -17,6 +17,7 @@ import ( "github.com/skycoin/skycoin/src/coin" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" + "github.com/skycoin/skycoin/src/visor" ) type Handle uint64 @@ -482,6 +483,20 @@ func lookupAddressUxOutHandle(handle C.AddressUxOuts_Handle) (*coin.AddressUxOut return nil, false } +func registerBuildInfoHandle(obj *visor.BuildInfo) C.BuildInfo_Handle { + return (C.BuildInfo_Handle)(registerHandle(obj)) +} + +func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*visor.BuildInfo, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.BuildInfo); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index 6391de88fb..0aa551bf3b 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -368,3 +368,16 @@ func SKY_api_Handle_GetWalletLastSeed(handle C.Wallet__Handle, } return SKY_ERROR } + +//export SKY_api_Handle_GetBuildInfoData +func SKY_api_Handle_GetBuildInfoData(handle C.BuildInfo_Handle, + version *C.GoString_, commit *C.GoString_, branch *C.GoString_) uint32 { + bi, ok := lookupBuildInfoHandle(handle) + if ok { + copyString(bi.Version, version) + copyString(bi.Commit, commit) + copyString(bi.Branch, branch) + return SKY_OK + } + return SKY_ERROR +} From f87f361677bacb0a3ee0a6e6cb27f85d1736afd7 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 16 Jul 2018 09:24:29 +0000 Subject: [PATCH 136/399] [libc] refs #1191. Fix lint issue. --- lib/cgo/libsky_handle.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 8522417327..6b6dd861bf 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -15,9 +15,9 @@ import ( webrpc "github.com/skycoin/skycoin/src/api/webrpc" cli "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/visor" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" - "github.com/skycoin/skycoin/src/visor" ) type Handle uint64 From 02a0587d9198d65f206a3a7b143e736e31749bda Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 16 Jul 2018 10:34:29 +0000 Subject: [PATCH 137/399] [swig] refs #1568. Merge with stdevEclipse_t1191_test_libc_cipher_and_coin. --- CHANGELOG.md | 2 + ci-scripts/ui-e2e.sh | 27 + cmd/cipher-testdata/cipher-testdata.go | 6 +- docker/images/dev-cli/Dockerfile | 17 +- docker/images/dev-cli/README.md | 12 + docker/images/dev-docker/Dockerfile | 57 + docker/images/dev-docker/README.md | 84 + .../images/dev-docker/dockerd-entrypoint.sh | 20 + docker/images/dev-docker/modprobe.sh | 20 + electron/compress-standalone-release.sh | 4 +- include/api.blockchain.go.h | 0 include/api.client.go.h | 21 - include/api.csrf.go.h | 0 include/api.explorer.go.h | 23 - include/api.gateway.go.h | 0 include/api.health.go.h | 0 include/api.http.go.h | 0 include/api.integration.empty.go.h | 0 include/api.network.go.h | 0 include/api.notes.go.h | 0 include/api.spend.go.h | 40 - include/api.transaction.go.h | 0 include/api.uxout.go.h | 0 include/api.wallet.go.h | 29 - include/api.webrpc.block.go.h | 0 include/api.webrpc.client.go.h | 1 - include/api.webrpc.gateway.go.h | 0 include/api.webrpc.outputs.go.h | 3 - include/api.webrpc.status.go.h | 6 - include/api.webrpc.transaction.go.h | 6 - include/api.webrpc.uxout.go.h | 4 - include/api.webrpc.webrpc.go.h | 5 - include/base64.h | 2 - include/cipher.base58.base58.go.h | 1 - ...her.chacha20poly1305.chacha20poly1305.go.h | 3 - ...acha20poly1305.chacha20poly1305_amd64.go.h | 0 ...ha20poly1305.chacha20poly1305_generic.go.h | 0 ...acha20poly1305.chacha20poly1305_noasm.go.h | 0 ...1305.internal.chacha20.chacha_generic.go.h | 0 include/cipher.encoder.encoder.go.h | 5 - ...ipher.encrypt.scrypt_chacha20poly1305.go.h | 8 - include/cipher.go-bip39.bip39.go.h | 0 include/cipher.go-bip39.wordlist.go.h | 0 include/cipher.pbkdf2.pbkdf2.go.h | 0 include/cipher.poly1305.poly1305.go.h | 0 include/cipher.poly1305.sum_amd64.go.h | 0 include/cipher.poly1305.sum_arm.go.h | 0 include/cipher.poly1305.sum_ref.go.h | 0 include/cipher.ripemd160.ripemd160block.go.h | 0 include/cipher.ripemd160.ripmd_160.go.h | 0 include/cipher.scrypt.scrypt.go.h | 0 include/cipher.secp256k1-go.secp256_rand.go.h | 0 .../cipher.secp256k1-go.secp256k1-go2.ec.go.h | 0 ...cipher.secp256k1-go.secp256k1-go2.num.go.h | 0 ....secp256k1-go.secp256k1-go2.secp256k1.go.h | 0 ...cipher.secp256k1-go.secp256k1-go2.sig.go.h | 0 ...r.secp256k1-go.secp256k1-go2.z_consts.go.h | 0 ...her.secp256k1-go.secp256k1-go2.z_init.go.h | 0 include/cipher.secp256k1-go.secp256k1.go.h | 0 include/cli.add_private_key.go.h | 0 include/cli.address_gen.go.h | 0 include/cli.blocks.go.h | 0 include/cli.broadcast_rawtx.go.h | 0 include/cli.check_balance.go.h | 16 - include/cli.checkdb.go.h | 0 include/cli.cli.go.h | 14 - include/cli.decryptWallet.go.h | 0 include/cli.encrypt_wallet.go.h | 0 include/cli.generate_addrs.go.h | 0 include/cli.generate_wallet.go.h | 0 include/cli.integration.empty.go.h | 0 include/cli.last_blocks.go.h | 0 include/cli.list_addrs.go.h | 0 include/cli.list_wallets.go.h | 5 - include/cli.outputs.go.h | 0 include/cli.send.go.h | 0 include/cli.show_seed.go.h | 0 include/cli.status.go.h | 5 - include/cli.transaction.go.h | 0 include/cli.verify_address.go.h | 0 include/cli.version.go.h | 0 include/cli.wallet_dir.go.h | 0 include/cli.wallet_history.go.h | 1 - include/coin.block.go.h | 5 - include/coin.math.go.h | 0 include/consensus.blockstat.go.h | 4 - include/consensus.connection_manager.go.h | 0 include/consensus.consensus.go.h | 5 - include/consensus.example.example.go.h | 0 include/consensus.example.example_gnet.go.h | 3 - .../consensus.example.example_minimal.go.h | 0 include/consensus.participant.go.h | 0 ...cast_channel.public_broadcast_channel.go.h | 0 include/daemon.daemon.go.h | 12 - include/daemon.gateway.go.h | 13 - include/daemon.gnet.dispatcher.go.h | 0 include/daemon.gnet.message.go.h | 4 - include/daemon.gnet.pool.go.h | 1 - include/daemon.messages.go.h | 30 - include/daemon.pex.peerlist.go.h | 1 - include/daemon.pex.pex.go.h | 8 - include/daemon.pool.go.h | 0 include/daemon.rpc.go.h | 23 - include/daemon.storage.go.h | 0 include/daemon.strand.strand.go.h | 0 include/daemon.visor.go.h | 29 - include/feecalc.h | 6 + include/skycriterion.h | 18 +- include/skynumber.h | 8 - include/skytest.h | 4 - include/skytypes.gen.h | 101 +- include/skytypes.h | 78 +- include/testutil.assert.assertions.go.h | 0 include/testutil.require.require.go.h | 0 include/testutil.testutil.go.h | 0 include/transutil.h | 4 + include/util.apputil.apputil.go.h | 0 include/util.browser.browser.go.h | 0 include/util.cert.cert.go.h | 0 include/util.droplet.droplet.go.h | 0 include/util.elapse.elapser.go.h | 0 include/util.fee.fee.go.h | 0 include/util.file.file.go.h | 0 include/util.http.error.go.h | 0 include/util.http.handler.go.h | 0 include/util.http.log.go.h | 0 include/util.iputil.iputil.go.h | 0 include/util.logging.formatter.go.h | 12 - include/util.logging.hooks.go.h | 0 include/util.logging.logger.go.h | 0 include/util.logging.logging.go.h | 0 include/util.utc.utc.go.h | 0 include/visor.blockchain.go.h | 8 - include/visor.blockdb.block_tree.go.h | 2 - include/visor.blockdb.blockchain.go.h | 3 - include/visor.blockdb.blocksigs.go.h | 2 - include/visor.blockdb.chain_meta.go.h | 2 - include/visor.blockdb.unspent.go.h | 9 - include/visor.db.go.h | 3 - include/visor.dbutil.dbutil.go.h | 7 - include/visor.distribution.go.h | 0 include/visor.historydb.address_txn.go.h | 2 - include/visor.historydb.address_uxout.go.h | 2 - include/visor.historydb.history_meta.go.h | 2 - include/visor.historydb.historydb.go.h | 0 include/visor.historydb.output.go.h | 18 - include/visor.historydb.transaction.go.h | 6 - include/visor.readable.go.h | 89 - include/visor.richlist.go.h | 7 - include/visor.unconfirmed.go.h | 11 - include/visor.verify.go.h | 6 - include/visor.visor.go.h | 8 - include/wallet.addresses.go.h | 0 include/wallet.crypto.go.h | 1 - include/wallet.entry.go.h | 1 - include/wallet.notes.go.h | 2 - include/wallet.readable.go.h | 6 - include/wallet.secrets.go.h | 0 include/wallet.service.go.h | 6 - include/wallet.wallet.go.h | 9 - include/wallet.wallets.go.h | 0 lib/cgo/api.blockchain.go | 10 - lib/cgo/api.client.go | 10 +- lib/cgo/api.csrf.go | 10 - lib/cgo/api.gateway.go | 10 - lib/cgo/api.health.go | 10 - lib/cgo/api.http.go | 10 - lib/cgo/api.integration.empty.go | 10 - lib/cgo/api.network.go | 10 - lib/cgo/api.notes.go | 10 - lib/cgo/api.spend.go | 4 +- lib/cgo/api.transaction.go | 10 - lib/cgo/api.uxout.go | 10 - lib/cgo/api.webrpc.block.go | 10 - lib/cgo/api.webrpc.client.go | 26 +- lib/cgo/api.webrpc.gateway.go | 10 - lib/cgo/api.webrpc.outputs.go | 10 - lib/cgo/api.webrpc.status.go | 10 - lib/cgo/api.webrpc.transaction.go | 10 - lib/cgo/api.webrpc.uxout.go | 10 - lib/cgo/api.webrpc.webrpc.go | 28 - ...ipher.chacha20poly1305.chacha20poly1305.go | 10 - lib/cgo/cipher.encoder.encoder.go | 10 - lib/cgo/cipher.go-bip39.wordlist.go | 10 - lib/cgo/cipher.pbkdf2.pbkdf2.go | 10 - lib/cgo/cipher.ripemd160.ripemd160block.go | 10 - lib/cgo/cipher.ripemd160.ripmd_160.go | 10 - ...er.secp256k1-go.secp256k1-go2.secp256k1.go | 10 - ...her.secp256k1-go.secp256k1-go2.z_consts.go | 10 - ...ipher.secp256k1-go.secp256k1-go2.z_init.go | 10 - lib/cgo/cli.address_gen.go | 10 - lib/cgo/cli.blocks.go | 10 - lib/cgo/cli.broadcast_rawtx.go | 10 - lib/cgo/cli.check_balance.go | 8 +- lib/cgo/cli.checkdb.go | 10 - lib/cgo/cli.create_rawtx.go | 8 +- lib/cgo/cli.decryptWallet.go | 10 - lib/cgo/cli.encrypt_wallet.go | 10 - lib/cgo/cli.integration.empty.go | 10 - lib/cgo/cli.last_blocks.go | 10 - lib/cgo/cli.list_addrs.go | 10 - lib/cgo/cli.list_wallets.go | 10 - lib/cgo/cli.outputs.go | 10 +- lib/cgo/cli.send.go | 10 - lib/cgo/cli.show_seed.go | 10 - lib/cgo/cli.status.go | 10 - lib/cgo/cli.transaction.go | 10 - lib/cgo/cli.verify_address.go | 10 - lib/cgo/cli.version.go | 10 - lib/cgo/cli.wallet_dir.go | 10 - lib/cgo/cli.wallet_history.go | 10 - lib/cgo/coin.block.go | 18 +- lib/cgo/coin.outputs.go | 149 + lib/cgo/coin.transactions.go | 119 +- lib/cgo/libsky_error.go | 24 +- lib/cgo/libsky_handle.go | 141 + lib/cgo/libsky_handle_helper.go | 13 + lib/cgo/tests/check_cipher.address.c | 235 + lib/cgo/tests/check_cipher.crypto.c | 23 +- .../tests/check_cipher.encrypt.sha256xor.c | 4 +- lib/cgo/tests/check_cipher.hash.c | 19 + ...check_cipher.secp256k1.secp256k1-go2.sig.c | 145 +- lib/cgo/tests/check_coin.block.c | 13 +- lib/cgo/tests/check_coin.outputs.c | 351 +- lib/cgo/tests/check_coin.transaction2.c | 604 -- lib/cgo/tests/check_coin.transactions.c | 971 ++- lib/cgo/tests/testutils/libsky_criterion.c | 89 +- lib/cgo/tests/testutils/libsky_number.c | 13 - lib/cgo/tests/testutils/transutils.c | 53 + lib/cgo/testutil.assert.assertions.go | 10 - lib/cgo/testutil.require.require.go | 10 - lib/cgo/util.elapse.elapser.go | 10 - lib/cgo/util.http.error.go | 10 - lib/cgo/util.http.handler.go | 10 - lib/cgo/util.http.log.go | 10 - lib/cgo/util.logging.formatter.go | 10 - lib/cgo/util.logging.hooks.go | 10 - lib/cgo/util.logging.logger.go | 10 - lib/cgo/wallet.notes.go | 77 +- lib/cgo/wallet.secrets.go | 10 - lib/cgo/wallet.service.go | 10 - lib/cgo/wallet.wallet.go | 28 +- lib/cgo/wallet_option.go | 3 +- .../testsuite/testdata/input-hashes.golden | 16 +- .../testsuite/testdata/many-addresses.golden | 6002 ++++++++--------- .../testsuite/testdata/seed-0000.golden | 262 +- .../testsuite/testdata/seed-0001.golden | 262 +- .../testsuite/testdata/seed-0002.golden | 262 +- .../testsuite/testdata/seed-0003.golden | 262 +- .../testsuite/testdata/seed-0004.golden | 262 +- .../testsuite/testdata/seed-0005.golden | 262 +- .../testsuite/testdata/seed-0006.golden | 262 +- .../testsuite/testdata/seed-0007.golden | 262 +- .../testsuite/testdata/seed-0008.golden | 262 +- .../testsuite/testdata/seed-0009.golden | 262 +- .../testsuite/testdata/seed-0010.golden | 262 +- src/daemon/daemon.go | 312 +- src/daemon/daemoner_mock_test.go | 568 ++ src/daemon/gateway.go | 18 +- src/daemon/gnet/dispatcher.go | 9 +- src/daemon/gnet/dispatcher_test.go | 4 +- src/daemon/messages.go | 167 +- src/daemon/messages_test.go | 293 +- src/gui/static/e2e/app.e2e-spec.ts | 15 - src/gui/static/e2e/app.po.ts | 12 - src/gui/static/e2e/onboarding.e2e-spec.ts | 44 + src/gui/static/e2e/onboarding.po.ts | 93 + src/gui/static/e2e/page.ts | 7 - src/gui/static/e2e/send.e2e-spec.ts | 38 + src/gui/static/e2e/send.po.ts | 68 + src/gui/static/e2e/transactions.e2e-spec.ts | 22 + src/gui/static/e2e/transactions.po.ts | 37 + src/gui/static/e2e/wallets.e2e-spec.ts | 90 + src/gui/static/e2e/wallets.po.ts | 186 + src/gui/static/protractor.conf.js | 9 +- .../transaction-list.component.scss | 3 +- .../static/src/app/services/app.service.ts | 19 +- .../src/app/services/blockchain.service.ts | 33 +- .../static/src/app/services/price.service.ts | 15 +- .../static/src/app/services/wallet.service.ts | 15 +- src/skycoin/skycoin.go | 1 + src/visor/historydb/history_meta.go | 8 +- src/visor/historydb/history_meta_test.go | 10 +- src/visor/historydb/historydb.go | 7 +- src/visor/historyer_mock_test.go | 4 +- src/visor/visor.go | 10 +- 286 files changed, 8940 insertions(+), 6831 deletions(-) create mode 100644 docker/images/dev-docker/Dockerfile create mode 100644 docker/images/dev-docker/README.md create mode 100644 docker/images/dev-docker/dockerd-entrypoint.sh create mode 100644 docker/images/dev-docker/modprobe.sh delete mode 100644 include/api.blockchain.go.h delete mode 100644 include/api.csrf.go.h delete mode 100644 include/api.explorer.go.h delete mode 100644 include/api.gateway.go.h delete mode 100644 include/api.health.go.h delete mode 100644 include/api.http.go.h delete mode 100644 include/api.integration.empty.go.h delete mode 100644 include/api.network.go.h delete mode 100644 include/api.notes.go.h delete mode 100644 include/api.spend.go.h delete mode 100644 include/api.transaction.go.h delete mode 100644 include/api.uxout.go.h delete mode 100644 include/api.wallet.go.h delete mode 100644 include/api.webrpc.block.go.h delete mode 100644 include/api.webrpc.client.go.h delete mode 100644 include/api.webrpc.gateway.go.h delete mode 100644 include/api.webrpc.outputs.go.h delete mode 100644 include/api.webrpc.status.go.h delete mode 100644 include/api.webrpc.transaction.go.h delete mode 100644 include/api.webrpc.uxout.go.h delete mode 100644 include/api.webrpc.webrpc.go.h delete mode 100644 include/cipher.base58.base58.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h delete mode 100644 include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h delete mode 100644 include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h delete mode 100644 include/cipher.encoder.encoder.go.h delete mode 100644 include/cipher.go-bip39.bip39.go.h delete mode 100644 include/cipher.go-bip39.wordlist.go.h delete mode 100644 include/cipher.pbkdf2.pbkdf2.go.h delete mode 100644 include/cipher.poly1305.poly1305.go.h delete mode 100644 include/cipher.poly1305.sum_amd64.go.h delete mode 100644 include/cipher.poly1305.sum_arm.go.h delete mode 100644 include/cipher.poly1305.sum_ref.go.h delete mode 100644 include/cipher.ripemd160.ripemd160block.go.h delete mode 100644 include/cipher.ripemd160.ripmd_160.go.h delete mode 100644 include/cipher.scrypt.scrypt.go.h delete mode 100644 include/cipher.secp256k1-go.secp256_rand.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.ec.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.num.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.sig.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h delete mode 100644 include/cipher.secp256k1-go.secp256k1.go.h delete mode 100644 include/cli.add_private_key.go.h delete mode 100644 include/cli.address_gen.go.h delete mode 100644 include/cli.blocks.go.h delete mode 100644 include/cli.broadcast_rawtx.go.h delete mode 100644 include/cli.check_balance.go.h delete mode 100644 include/cli.checkdb.go.h delete mode 100644 include/cli.decryptWallet.go.h delete mode 100644 include/cli.encrypt_wallet.go.h delete mode 100644 include/cli.generate_addrs.go.h delete mode 100644 include/cli.generate_wallet.go.h delete mode 100644 include/cli.integration.empty.go.h delete mode 100644 include/cli.last_blocks.go.h delete mode 100644 include/cli.list_addrs.go.h delete mode 100644 include/cli.list_wallets.go.h delete mode 100644 include/cli.outputs.go.h delete mode 100644 include/cli.send.go.h delete mode 100644 include/cli.show_seed.go.h delete mode 100644 include/cli.status.go.h delete mode 100644 include/cli.transaction.go.h delete mode 100644 include/cli.verify_address.go.h delete mode 100644 include/cli.version.go.h delete mode 100644 include/cli.wallet_dir.go.h delete mode 100644 include/cli.wallet_history.go.h delete mode 100644 include/coin.math.go.h delete mode 100644 include/consensus.blockstat.go.h delete mode 100644 include/consensus.connection_manager.go.h delete mode 100644 include/consensus.consensus.go.h delete mode 100644 include/consensus.example.example.go.h delete mode 100644 include/consensus.example.example_gnet.go.h delete mode 100644 include/consensus.example.example_minimal.go.h delete mode 100644 include/consensus.participant.go.h delete mode 100644 include/consensus.public_broadcast_channel.public_broadcast_channel.go.h delete mode 100644 include/daemon.daemon.go.h delete mode 100644 include/daemon.gateway.go.h delete mode 100644 include/daemon.gnet.dispatcher.go.h delete mode 100644 include/daemon.gnet.message.go.h delete mode 100644 include/daemon.gnet.pool.go.h delete mode 100644 include/daemon.messages.go.h delete mode 100644 include/daemon.pex.peerlist.go.h delete mode 100644 include/daemon.pex.pex.go.h delete mode 100644 include/daemon.pool.go.h delete mode 100644 include/daemon.rpc.go.h delete mode 100644 include/daemon.storage.go.h delete mode 100644 include/daemon.strand.strand.go.h delete mode 100644 include/daemon.visor.go.h create mode 100644 include/feecalc.h delete mode 100644 include/skynumber.h delete mode 100644 include/testutil.assert.assertions.go.h delete mode 100644 include/testutil.require.require.go.h delete mode 100644 include/testutil.testutil.go.h delete mode 100644 include/util.apputil.apputil.go.h delete mode 100644 include/util.browser.browser.go.h delete mode 100644 include/util.cert.cert.go.h delete mode 100644 include/util.droplet.droplet.go.h delete mode 100644 include/util.elapse.elapser.go.h delete mode 100644 include/util.fee.fee.go.h delete mode 100644 include/util.file.file.go.h delete mode 100644 include/util.http.error.go.h delete mode 100644 include/util.http.handler.go.h delete mode 100644 include/util.http.log.go.h delete mode 100644 include/util.iputil.iputil.go.h delete mode 100644 include/util.logging.formatter.go.h delete mode 100644 include/util.logging.hooks.go.h delete mode 100644 include/util.logging.logger.go.h delete mode 100644 include/util.logging.logging.go.h delete mode 100644 include/util.utc.utc.go.h delete mode 100644 include/visor.blockchain.go.h delete mode 100644 include/visor.blockdb.block_tree.go.h delete mode 100644 include/visor.blockdb.blockchain.go.h delete mode 100644 include/visor.blockdb.blocksigs.go.h delete mode 100644 include/visor.blockdb.chain_meta.go.h delete mode 100644 include/visor.blockdb.unspent.go.h delete mode 100644 include/visor.db.go.h delete mode 100644 include/visor.dbutil.dbutil.go.h delete mode 100644 include/visor.distribution.go.h delete mode 100644 include/visor.historydb.address_txn.go.h delete mode 100644 include/visor.historydb.address_uxout.go.h delete mode 100644 include/visor.historydb.history_meta.go.h delete mode 100644 include/visor.historydb.historydb.go.h delete mode 100644 include/visor.historydb.output.go.h delete mode 100644 include/visor.historydb.transaction.go.h delete mode 100644 include/visor.richlist.go.h delete mode 100644 include/visor.unconfirmed.go.h delete mode 100644 include/visor.verify.go.h delete mode 100644 include/visor.visor.go.h delete mode 100644 include/wallet.addresses.go.h delete mode 100644 include/wallet.crypto.go.h delete mode 100644 include/wallet.readable.go.h delete mode 100644 include/wallet.secrets.go.h delete mode 100644 include/wallet.service.go.h delete mode 100644 include/wallet.wallets.go.h delete mode 100644 lib/cgo/api.blockchain.go delete mode 100644 lib/cgo/api.csrf.go delete mode 100644 lib/cgo/api.gateway.go delete mode 100644 lib/cgo/api.health.go delete mode 100644 lib/cgo/api.http.go delete mode 100644 lib/cgo/api.integration.empty.go delete mode 100644 lib/cgo/api.network.go delete mode 100644 lib/cgo/api.notes.go delete mode 100644 lib/cgo/api.transaction.go delete mode 100644 lib/cgo/api.uxout.go delete mode 100644 lib/cgo/api.webrpc.block.go delete mode 100644 lib/cgo/api.webrpc.gateway.go delete mode 100644 lib/cgo/api.webrpc.outputs.go delete mode 100644 lib/cgo/api.webrpc.status.go delete mode 100644 lib/cgo/api.webrpc.transaction.go delete mode 100644 lib/cgo/api.webrpc.uxout.go delete mode 100644 lib/cgo/api.webrpc.webrpc.go delete mode 100644 lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go delete mode 100644 lib/cgo/cipher.encoder.encoder.go delete mode 100644 lib/cgo/cipher.go-bip39.wordlist.go delete mode 100644 lib/cgo/cipher.pbkdf2.pbkdf2.go delete mode 100644 lib/cgo/cipher.ripemd160.ripemd160block.go delete mode 100644 lib/cgo/cipher.ripemd160.ripmd_160.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go delete mode 100644 lib/cgo/cli.address_gen.go delete mode 100644 lib/cgo/cli.blocks.go delete mode 100644 lib/cgo/cli.broadcast_rawtx.go delete mode 100644 lib/cgo/cli.checkdb.go delete mode 100644 lib/cgo/cli.decryptWallet.go delete mode 100644 lib/cgo/cli.encrypt_wallet.go delete mode 100644 lib/cgo/cli.integration.empty.go delete mode 100644 lib/cgo/cli.last_blocks.go delete mode 100644 lib/cgo/cli.list_addrs.go delete mode 100644 lib/cgo/cli.list_wallets.go delete mode 100644 lib/cgo/cli.send.go delete mode 100644 lib/cgo/cli.show_seed.go delete mode 100644 lib/cgo/cli.status.go delete mode 100644 lib/cgo/cli.transaction.go delete mode 100644 lib/cgo/cli.verify_address.go delete mode 100644 lib/cgo/cli.version.go delete mode 100644 lib/cgo/cli.wallet_dir.go delete mode 100644 lib/cgo/cli.wallet_history.go delete mode 100644 lib/cgo/tests/check_coin.transaction2.c delete mode 100644 lib/cgo/tests/testutils/libsky_number.c delete mode 100644 lib/cgo/testutil.assert.assertions.go delete mode 100644 lib/cgo/testutil.require.require.go delete mode 100644 lib/cgo/util.elapse.elapser.go delete mode 100644 lib/cgo/util.http.error.go delete mode 100644 lib/cgo/util.http.handler.go delete mode 100644 lib/cgo/util.http.log.go delete mode 100644 lib/cgo/util.logging.formatter.go delete mode 100644 lib/cgo/util.logging.hooks.go delete mode 100644 lib/cgo/util.logging.logger.go delete mode 100644 lib/cgo/wallet.secrets.go delete mode 100644 lib/cgo/wallet.service.go create mode 100644 src/daemon/daemoner_mock_test.go delete mode 100644 src/gui/static/e2e/app.e2e-spec.ts delete mode 100644 src/gui/static/e2e/app.po.ts create mode 100644 src/gui/static/e2e/onboarding.e2e-spec.ts create mode 100644 src/gui/static/e2e/onboarding.po.ts delete mode 100644 src/gui/static/e2e/page.ts create mode 100644 src/gui/static/e2e/send.e2e-spec.ts create mode 100644 src/gui/static/e2e/send.po.ts create mode 100644 src/gui/static/e2e/transactions.e2e-spec.ts create mode 100644 src/gui/static/e2e/transactions.po.ts create mode 100644 src/gui/static/e2e/wallets.e2e-spec.ts create mode 100644 src/gui/static/e2e/wallets.po.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 84bfbf884d..294e2d6af8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add `uxouts` to `POST /api/v1/wallet/transaction`, to allow specific unspent outputs to be used in a transaction. - Add Dockerfile in docker/images/dev-cli to build a docker image suitable for development. - Coin creator tool, `cmd/newcoin`, to quickly bootstrap a new fiber coin +- Add Dockerfile in docker/images/dev-dind to build a docker in docker image based on skycoindev-cli. ### Fixed @@ -57,6 +58,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. If you are using the CLI tool or another API client to communicate with the standalone client, use `-web-interface-port=6420` to continue using port 6420. If the program is run from source (e.g. `go run`, `run.sh`, `make run`) there is no change, the API will still be on port 6420. - Change number of outgoing connections to 8 from 16 +- Update version of SWIG to 3.0.12 ### Removed diff --git a/ci-scripts/ui-e2e.sh b/ci-scripts/ui-e2e.sh index 2408822558..b5878b8ca7 100755 --- a/ci-scripts/ui-e2e.sh +++ b/ci-scripts/ui-e2e.sh @@ -29,6 +29,33 @@ if [[ ! "$DATA_DIR" ]]; then exit 1 fi +# Create a dummy wallet with an address existing in the blockchain-180.db dataset +mkdir "$WALLET_DIR" +cat >"${WALLET_DIR}/test_wallet.wlt" <> /etc/subuid \ + && echo 'dockremap:165536:65536' >> /etc/subgid + +ENV DIND_COMMIT 3b5fac462d21ca164b3778647420016315289034 + +RUN set -ex; \ + wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \ + chmod +x /usr/local/bin/dind; + +COPY dockerd-entrypoint.sh /usr/local/bin/ + +RUN ["chmod", "+x", "/usr/local/bin/dockerd-entrypoint.sh","/usr/local/bin/modprobe"] + +VOLUME /var/lib/docker + +EXPOSE 2375 + +#WORKDIR $GOPATH/src/github.com/skycoin +#VOLUME $GOPATH/src/ + +#ENV LD_LIBRARY_PATH=/usr/local/lib + +ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"] +CMD [] diff --git a/docker/images/dev-docker/README.md b/docker/images/dev-docker/README.md new file mode 100644 index 0000000000..47385d726b --- /dev/null +++ b/docker/images/dev-docker/README.md @@ -0,0 +1,84 @@ +# Supported tags and respective `Dockerfile` links + +## Simple Tags + +- [`dind` (*docker/images/devdocker/Dockerfile*)](https://github.com/skycoin/skycoin/tree/develop/docker/images/devdocker/Dockerfile) + +# Skycoin development image including [docker in docker](https://hub.docker.com/_/docker/) + +This image has the necessary tools to build, test, edit, lint and version the Skycoin +source code. It comes with the Vim editor installed, along with some plugins +to ease go development and version control with git, besides it comes with docker installed. + +# How to use this image + +## Initialize your development environment. + +```sh +$ mkdir src +$ docker run --privileged --rm \ + -v src:/go/src skycoin/skycoindev-cli:dind \ + go get github.com/skycoin/skycoin +$ sudo chown -R `whoami` src +``` + +This downloads the skycoin source to src/skycoin/skycoin and changes the owner +to your user. This is necessary, because all processes inside the container run +as root and the files created by it are therefore owned by root. + +If you already have a Go development environment installed, you just need to +mount the src directory from your $GOPATH in the /go/src volume of the +container. + +## Running commands inside the container + +You can run commands by just passing them to the image. Everything is run +in a container and deleted when finished. + +### Running tests + +```sh +$ docker run --rm \ + -v src:/go/src skycoin/skycoindev-cli:dind \ + sh -c "cd skycoin; make test" +``` + +### Running lint + +```sh +$ docker run --rm \ + -v src:/go/src skycoin/skycoindev-cli:dind \ + sh -c "cd skycoin; make lint" +``` + +### Editing code + +```sh +$ docker run --rm \ + -v src:/go/src skycoin/skycoindev-cli:dind \ + vim +``` + +## How to use docker in docker image + +### Start a daemon instance + +```sh +$ docker run --privileged --name some-name -d skycoin/skycoindev-cli:dind +``` + +### Where to store data + +Create a data directory on the host system (outside the container) and mount this to a directory visible from inside the container. + +The downside is that you need to make sure that the directory exists, and that e.g. directory permissions and other security mechanisms on the host system are set up correctly. + +1. Create a data directory on a suitable volume on your host system, e.g. /my/own/var-lib-docker. +2. Start your docker container like this: + +```sh +$ docker run --privileged --name some-name -v /my/own/var-lib-docker:/var/lib/docker \ +-d skycoin/skycoindev-cli:dind +``` + + diff --git a/docker/images/dev-docker/dockerd-entrypoint.sh b/docker/images/dev-docker/dockerd-entrypoint.sh new file mode 100644 index 0000000000..05cc91b7c3 --- /dev/null +++ b/docker/images/dev-docker/dockerd-entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +# no arguments passed +# or first arg is `-f` or `--some-option` +if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then + # add our default arguments + set -- dockerd \ + --host=unix:///var/run/docker.sock \ + --host=tcp://0.0.0.0:2375 \ + "$@" +fi + +if [ "$1" = 'dockerd' ]; then + # if we're running Docker, let's pipe through dind + # (and we'll run dind explicitly with "sh" since its shebang is /bin/bash) + set -- sh "$(which dind)" "$@" +fi + +exec "$@" diff --git a/docker/images/dev-docker/modprobe.sh b/docker/images/dev-docker/modprobe.sh new file mode 100644 index 0000000000..b357d893fd --- /dev/null +++ b/docker/images/dev-docker/modprobe.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -eu + +# "modprobe" without modprobe +# https://twitter.com/lucabruno/status/902934379835662336 + +# this isn't 100% fool-proof, but it'll have a much higher success rate than simply using the "real" modprobe + +# Docker often uses "modprobe -va foo bar baz" +# so we ignore modules that start with "-" +for module; do + if [ "${module#-}" = "$module" ]; then + ip link show "$module" || true + lsmod | grep "$module" || true + fi +done + +# remove /usr/local/... from PATH so we can exec the real modprobe as a last resort +export PATH='/usr/sbin:/usr/bin:/sbin:/bin' +exec modprobe "$@" diff --git a/electron/compress-standalone-release.sh b/electron/compress-standalone-release.sh index 4d17f40b15..3c7d94c91d 100755 --- a/electron/compress-standalone-release.sh +++ b/electron/compress-standalone-release.sh @@ -40,7 +40,7 @@ if [ -e "$WIN64_STL" ]; then fi echo "Zipping $WIN64_STL_ZIP" if [[ "$OSTYPE" == "linux"* ]]; then - zip -r --quiet "$WIN64_STL_ZIP" --owner=0 --group=0 "$WIN64_STL" + zip -r --quiet -X "$WIN64_STL_ZIP" "$WIN64_STL" elif [[ "$OSTYPE" == "darwin"* ]]; then zip -r --quiet "$WIN64_STL_ZIP" "$WIN64_STL" elif [[ "$OSTYPE" == "msys"* ]]; then @@ -57,7 +57,7 @@ if [ -e "$WIN32_STL" ]; then fi echo "Zipping $WIN32_STL_ZIP" if [[ "$OSTYPE" == "linux"* ]]; then - zip -r --quiet "$WIN32_STL_ZIP" --owner=0 --group=0 "$WIN32_STL" + zip -r --quiet -X "$WIN32_STL_ZIP" "$WIN32_STL" elif [[ "$OSTYPE" == "darwin"* ]]; then zip -r --quiet "$WIN32_STL_ZIP" "$WIN32_STL" elif [[ "$OSTYPE" == "msys"* ]]; then diff --git a/include/api.blockchain.go.h b/include/api.blockchain.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.client.go.h b/include/api.client.go.h index 7f5db8a97f..4dfe4e7cf1 100644 --- a/include/api.client.go.h +++ b/include/api.client.go.h @@ -1,25 +1,4 @@ -typedef struct{ - GoString_ ID; - GoSlice_ Addresses; - GoString_ Password; -} api__CreateTransactionRequestWallet; -typedef struct{ - GoString_ Type; - GoString_ Mode; - GoString_ ShareFactor; -} api__HoursSelection; -typedef struct{ - GoString_ Address; - GoString_ Coins; - GoString_ Hours; -} api__Receiver; typedef struct{ GoInt_ N; BOOL IncludeDistribution; } api__RichlistParams; -typedef struct{ - api__HoursSelection HoursSelection; - api__CreateTransactionRequestWallet Wallet; - GoString_ ChangeAddress; - GoSlice_ To; -} api__CreateTransactionRequest; diff --git a/include/api.csrf.go.h b/include/api.csrf.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.explorer.go.h b/include/api.explorer.go.h deleted file mode 100644 index c1ea85d870..0000000000 --- a/include/api.explorer.go.h +++ /dev/null @@ -1,23 +0,0 @@ -/*typedef struct{ - GoString_ CurrentSupply; - GoString_ TotalSupply; - GoString_ MaxSupply; - GoString_ CurrentCoinHourSupply; - GoString_ TotalCoinHourSupply; - GoSlice_ UnlockedAddresses; - GoSlice_ LockedAddresses; -} api__CoinSupply;*/ -typedef struct{ - visor__Richlist Richlist; -} api__Richlist; -typedef struct{ - visor__TransactionStatus Status; - GoUint32_ Length; - GoUint8_ Type; - GoString_ Hash; - GoString_ InnerHash; - GoUint64_ Timestamp; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} api__ReadableTransaction; diff --git a/include/api.gateway.go.h b/include/api.gateway.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.health.go.h b/include/api.health.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.http.go.h b/include/api.http.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.integration.empty.go.h b/include/api.integration.empty.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.network.go.h b/include/api.network.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.notes.go.h b/include/api.notes.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.spend.go.h b/include/api.spend.go.h deleted file mode 100644 index e884eee5aa..0000000000 --- a/include/api.spend.go.h +++ /dev/null @@ -1,40 +0,0 @@ -typedef struct{ - GoUint32_ Length; - GoUint8_ Type; - GoString_ TxID; - GoString_ InnerHash; - GoString_ Fee; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} api__CreatedTransaction; -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; -} api__CreatedTransactionOutput; -typedef struct{ - GoString_ UxID; - GoString_ Address; - GoString_ Coins; - GoString_ Hours; - GoString_ CalculatedHours; - GoUint64_ Time; - GoUint64_ Block; - GoString_ TxID; -} api__CreatedTransactionInput; -typedef struct{ - GoString_ ID; - GoSlice_ Addresses; - GoString_ Password; -} api__createTransactionRequestWallet; -typedef struct{ - api__CreatedTransaction Transaction; - GoString_ EncodedTransaction; -} api__CreateTransactionResponse; -typedef struct{ - httphelper__Address Address; - httphelper__Coins Coins; - httphelper__Hours * Hours; -} api__receiver; diff --git a/include/api.transaction.go.h b/include/api.transaction.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.uxout.go.h b/include/api.uxout.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.wallet.go.h b/include/api.wallet.go.h deleted file mode 100644 index a80d2c1ff4..0000000000 --- a/include/api.wallet.go.h +++ /dev/null @@ -1,29 +0,0 @@ -typedef struct{ - GoSlice_ Transactions; -} api__UnconfirmedTxnsResponse; -typedef struct{ - GoString_ Address; - GoString_ Public; -} api__WalletEntry; -typedef struct{ - GoString_ Coin; - GoString_ Filename; - GoString_ Label; - GoString_ Type; - GoString_ Version; - GoString_ CryptoType; - GoInt64_ Timestamp; - BOOL Encrypted; -} api__WalletMeta; -typedef struct{ - api__WalletMeta Meta; - GoSlice_ Entries; -} api__WalletResponse; -typedef struct{ - GoString_ Address; -} api__WalletFolder; -typedef struct{ - wallet__BalancePair * Balance; - visor__ReadableTransaction * Transaction; - GoString_ Error; -} api__SpendResult; diff --git a/include/api.webrpc.block.go.h b/include/api.webrpc.block.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.webrpc.client.go.h b/include/api.webrpc.client.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/api.webrpc.client.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/api.webrpc.gateway.go.h b/include/api.webrpc.gateway.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/api.webrpc.outputs.go.h b/include/api.webrpc.outputs.go.h deleted file mode 100644 index 63833d4494..0000000000 --- a/include/api.webrpc.outputs.go.h +++ /dev/null @@ -1,3 +0,0 @@ -typedef struct{ - visor__ReadableOutputSet Outputs; -} webrpc__OutputsResult; diff --git a/include/api.webrpc.status.go.h b/include/api.webrpc.status.go.h deleted file mode 100644 index 35dcb38e55..0000000000 --- a/include/api.webrpc.status.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - BOOL Running; - GoUint64_ BlockNum; - GoString_ LastBlockHash; - GoString_ TimeSinceLastBlock; -} webrpc__StatusResult; diff --git a/include/api.webrpc.transaction.go.h b/include/api.webrpc.transaction.go.h deleted file mode 100644 index 5f542a6c66..0000000000 --- a/include/api.webrpc.transaction.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ Txid; -} webrpc__TxIDJson; -typedef struct{ - daemon__TransactionResult * Transaction; -} webrpc__TxnResult; diff --git a/include/api.webrpc.uxout.go.h b/include/api.webrpc.uxout.go.h deleted file mode 100644 index f5540e314e..0000000000 --- a/include/api.webrpc.uxout.go.h +++ /dev/null @@ -1,4 +0,0 @@ -typedef struct{ - GoString_ Address; - GoSlice_ UxOuts; -} webrpc__AddrUxoutResult; diff --git a/include/api.webrpc.webrpc.go.h b/include/api.webrpc.webrpc.go.h deleted file mode 100644 index b2307bfe08..0000000000 --- a/include/api.webrpc.webrpc.go.h +++ /dev/null @@ -1,5 +0,0 @@ -typedef struct{ - GoInt_ Code; - GoString_ Message; - GoString_ Data; -} webrpc__RPCError; diff --git a/include/base64.h b/include/base64.h index 04393042aa..c27c6e0805 100644 --- a/include/base64.h +++ b/include/base64.h @@ -42,5 +42,3 @@ unsigned int b64_encodef(char *InFile, char *OutFile); // Input : filenames // returns size of output int b64_decodef(char *InFile, char *OutFile); - -//unsigned int b64_encode_string(const unsigned char* in, unsigned int in_len, unsigned char* out); diff --git a/include/cipher.base58.base58.go.h b/include/cipher.base58.base58.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/cipher.base58.base58.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/cipher.chacha20poly1305.chacha20poly1305.go.h b/include/cipher.chacha20poly1305.chacha20poly1305.go.h deleted file mode 100644 index 22e4917781..0000000000 --- a/include/cipher.chacha20poly1305.chacha20poly1305.go.h +++ /dev/null @@ -1,3 +0,0 @@ -typedef struct{ - GoUint8_ key[32]; -} chacha20poly1305__chacha20poly1305; diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_amd64.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_generic.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h b/include/cipher.chacha20poly1305.chacha20poly1305_noasm.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h b/include/cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.encoder.encoder.go.h b/include/cipher.encoder.encoder.go.h deleted file mode 100644 index 8b70d1b79e..0000000000 --- a/include/cipher.encoder.encoder.go.h +++ /dev/null @@ -1,5 +0,0 @@ -typedef struct{ - GoSlice_ buf; -} encoder__coder; -typedef encoder__coder encoder__decoder; -typedef encoder__coder encoder__encoder; diff --git a/include/cipher.encrypt.scrypt_chacha20poly1305.go.h b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h index 8e728cea45..07e1dcd759 100644 --- a/include/cipher.encrypt.scrypt_chacha20poly1305.go.h +++ b/include/cipher.encrypt.scrypt_chacha20poly1305.go.h @@ -4,11 +4,3 @@ typedef struct{ GoInt_ P; GoInt_ KeyLen; } encrypt__ScryptChacha20poly1305; -typedef struct{ - GoInt_ N; - GoInt_ R; - GoInt_ P; - GoInt_ KeyLen; - GoSlice_ Salt; - GoSlice_ Nonce; -} encrypt__meta; diff --git a/include/cipher.go-bip39.bip39.go.h b/include/cipher.go-bip39.bip39.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.go-bip39.wordlist.go.h b/include/cipher.go-bip39.wordlist.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.pbkdf2.pbkdf2.go.h b/include/cipher.pbkdf2.pbkdf2.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.poly1305.go.h b/include/cipher.poly1305.poly1305.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_amd64.go.h b/include/cipher.poly1305.sum_amd64.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_arm.go.h b/include/cipher.poly1305.sum_arm.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.poly1305.sum_ref.go.h b/include/cipher.poly1305.sum_ref.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.ripemd160.ripemd160block.go.h b/include/cipher.ripemd160.ripemd160block.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.ripemd160.ripmd_160.go.h b/include/cipher.ripemd160.ripmd_160.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.scrypt.scrypt.go.h b/include/cipher.scrypt.scrypt.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256_rand.go.h b/include/cipher.secp256k1-go.secp256_rand.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h b/include/cipher.secp256k1-go.secp256k1-go2.ec.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.num.go.h b/include/cipher.secp256k1-go.secp256k1-go2.num.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h b/include/cipher.secp256k1-go.secp256k1-go2.sig.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_consts.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h b/include/cipher.secp256k1-go.secp256k1-go2.z_init.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cipher.secp256k1-go.secp256k1.go.h b/include/cipher.secp256k1-go.secp256k1.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.add_private_key.go.h b/include/cli.add_private_key.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.address_gen.go.h b/include/cli.address_gen.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.blocks.go.h b/include/cli.blocks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.broadcast_rawtx.go.h b/include/cli.broadcast_rawtx.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.check_balance.go.h b/include/cli.check_balance.go.h deleted file mode 100644 index ad2218e8d7..0000000000 --- a/include/cli.check_balance.go.h +++ /dev/null @@ -1,16 +0,0 @@ -typedef struct{ - GoString_ Coins; - GoString_ Hours; -} cli__Balance; -typedef struct{ - cli__Balance Confirmed; - cli__Balance Spendable; - cli__Balance Expected; - GoString_ Address; -} cli__AddressBalance; -typedef struct{ - cli__Balance Confirmed; - cli__Balance Spendable; - cli__Balance Expected; - GoSlice_ Addresses; -} cli__BalanceResult; diff --git a/include/cli.checkdb.go.h b/include/cli.checkdb.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index a1c7775c4f..aa1ffe590d 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -1,17 +1,3 @@ -typedef struct{ - GoString_ WalletDir; - GoString_ WalletName; - GoString_ DataDir; - GoString_ Coin; - GoString_ RPCAddress; - BOOL UseCSRF; -} cli__Config; -typedef struct{ - GoInt32_ _unnamed; -} cli__WalletLoadError; -typedef struct{ - GoInt32_ _unnamed; -} cli__WalletSaveError; typedef GoSlice_ cli__PasswordFromBytes; typedef struct{ } cli__PasswordFromTerm; diff --git a/include/cli.decryptWallet.go.h b/include/cli.decryptWallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.encrypt_wallet.go.h b/include/cli.encrypt_wallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.generate_addrs.go.h b/include/cli.generate_addrs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.generate_wallet.go.h b/include/cli.generate_wallet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.integration.empty.go.h b/include/cli.integration.empty.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.last_blocks.go.h b/include/cli.last_blocks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.list_addrs.go.h b/include/cli.list_addrs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.list_wallets.go.h b/include/cli.list_wallets.go.h deleted file mode 100644 index 2650079be5..0000000000 --- a/include/cli.list_wallets.go.h +++ /dev/null @@ -1,5 +0,0 @@ -typedef struct{ - GoString_ Name; - GoString_ Label; - GoInt_ AddressNum; -} cli__WalletEntry; diff --git a/include/cli.outputs.go.h b/include/cli.outputs.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.send.go.h b/include/cli.send.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.show_seed.go.h b/include/cli.show_seed.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.status.go.h b/include/cli.status.go.h deleted file mode 100644 index 6086d80849..0000000000 --- a/include/cli.status.go.h +++ /dev/null @@ -1,5 +0,0 @@ -typedef struct{ - webrpc__StatusResult _unnamed; - GoString_ RPCAddress; - BOOL UseCSRF; -} cli__StatusResult; diff --git a/include/cli.transaction.go.h b/include/cli.transaction.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.verify_address.go.h b/include/cli.verify_address.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.version.go.h b/include/cli.version.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.wallet_dir.go.h b/include/cli.wallet_dir.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/cli.wallet_history.go.h b/include/cli.wallet_history.go.h deleted file mode 100644 index 00d158f4a3..0000000000 --- a/include/cli.wallet_history.go.h +++ /dev/null @@ -1 +0,0 @@ -typedef GoSlice_ cli__byTime; diff --git a/include/coin.block.go.h b/include/coin.block.go.h index 25b72ee72e..69ff0660de 100644 --- a/include/coin.block.go.h +++ b/include/coin.block.go.h @@ -1,8 +1,3 @@ - -typedef struct{ - cipher__SHA256 Hash; - cipher__SHA256 PreHash; -} coin__HashPair; typedef struct{ GoUint32_ Version; GoUint64_ Time; diff --git a/include/coin.math.go.h b/include/coin.math.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.blockstat.go.h b/include/consensus.blockstat.go.h deleted file mode 100644 index 11a947abf9..0000000000 --- a/include/consensus.blockstat.go.h +++ /dev/null @@ -1,4 +0,0 @@ -typedef GoSlice_ consensus__PriorityQueue; -typedef struct{ - consensus__PriorityQueue queue; -} consensus__BlockStatQueue; diff --git a/include/consensus.connection_manager.go.h b/include/consensus.connection_manager.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.consensus.go.h b/include/consensus.consensus.go.h deleted file mode 100644 index 36b52554ea..0000000000 --- a/include/consensus.consensus.go.h +++ /dev/null @@ -1,5 +0,0 @@ -typedef struct{ - cipher__Sig Sig; - cipher__SHA256 Hash; - GoUint64_ Seqno; -} consensus__BlockBase; diff --git a/include/consensus.example.example.go.h b/include/consensus.example.example.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.example.example_gnet.go.h b/include/consensus.example.example_gnet.go.h deleted file mode 100644 index 8413cbfb02..0000000000 --- a/include/consensus.example.example_gnet.go.h +++ /dev/null @@ -1,3 +0,0 @@ -typedef struct{ - consensus__BlockBase _unnamed; -} main__BlockBaseWrapper; diff --git a/include/consensus.example.example_minimal.go.h b/include/consensus.example.example_minimal.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.participant.go.h b/include/consensus.participant.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h b/include/consensus.public_broadcast_channel.public_broadcast_channel.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.daemon.go.h b/include/daemon.daemon.go.h deleted file mode 100644 index 45c1f89311..0000000000 --- a/include/daemon.daemon.go.h +++ /dev/null @@ -1,12 +0,0 @@ -typedef struct{ - GoString_ Addr; - BOOL Solicited; -} daemon__ConnectEvent; -typedef struct{ - GoString_ Addr; - GoInt32_ Error; -} daemon__ConnectionError; -typedef struct{ - GoString_ Addr; - gnet__DisconnectReason Reason; -} daemon__DisconnectEvent; diff --git a/include/daemon.gateway.go.h b/include/daemon.gateway.go.h deleted file mode 100644 index ad2414ea30..0000000000 --- a/include/daemon.gateway.go.h +++ /dev/null @@ -1,13 +0,0 @@ -typedef struct{ - GoInt_ BufferSize; - BOOL EnableWalletAPI; - BOOL EnableGUI; -} daemon__GatewayConfig; -typedef struct{ - GoSlice_ Txns; -} daemon__TransactionResults; -typedef struct{ - visor__TransactionStatus Status; - GoUint64_ Time; - visor__ReadableTransaction Transaction; -} daemon__TransactionResult; diff --git a/include/daemon.gnet.dispatcher.go.h b/include/daemon.gnet.dispatcher.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.gnet.message.go.h b/include/daemon.gnet.message.go.h deleted file mode 100644 index 17d7861530..0000000000 --- a/include/daemon.gnet.message.go.h +++ /dev/null @@ -1,4 +0,0 @@ -typedef struct{ - GoInt_ ConnID; - GoString_ Addr; -} gnet__MessageContext; diff --git a/include/daemon.gnet.pool.go.h b/include/daemon.gnet.pool.go.h deleted file mode 100644 index 522c34ff4a..0000000000 --- a/include/daemon.gnet.pool.go.h +++ /dev/null @@ -1 +0,0 @@ -typedef GoInt32_ gnet__DisconnectReason; diff --git a/include/daemon.messages.go.h b/include/daemon.messages.go.h deleted file mode 100644 index f133742c8c..0000000000 --- a/include/daemon.messages.go.h +++ /dev/null @@ -1,30 +0,0 @@ -typedef struct{ - GoSlice_ Messages; -} daemon__MessagesConfig; -typedef struct{ - daemon__MessagesConfig Config; - GoUint32_ Mirror; -} daemon__Messages; -typedef struct{ - GoUint32_ IP; - GoUint16_ Port; -} daemon__IPAddr; -typedef struct{ - GoString_ addr; -} daemon__GetPeersMessage; -typedef struct{ -} daemon__PongMessage; -typedef struct{ - GoSlice_ Peers; - gnet__MessageContext * c; -} daemon__GivePeersMessage; -typedef struct{ - GoUint32_ Mirror; - GoUint16_ Port; - GoInt32_ Version; - gnet__MessageContext * c; - BOOL valid; -} daemon__IntroductionMessage; -typedef struct{ - gnet__MessageContext * c; -} daemon__PingMessage; diff --git a/include/daemon.pex.peerlist.go.h b/include/daemon.pex.peerlist.go.h deleted file mode 100644 index 8d75a422bb..0000000000 --- a/include/daemon.pex.peerlist.go.h +++ /dev/null @@ -1 +0,0 @@ -typedef GoSlice_ pex__Peers; diff --git a/include/daemon.pex.pex.go.h b/include/daemon.pex.pex.go.h deleted file mode 100644 index e33ca25204..0000000000 --- a/include/daemon.pex.pex.go.h +++ /dev/null @@ -1,8 +0,0 @@ -typedef struct{ - GoString_ Addr; - GoInt64_ LastSeen; - BOOL Private; - BOOL Trusted; - BOOL HasIncomingPort; - GoInt_ RetryTimes; -} pex__Peer; diff --git a/include/daemon.pool.go.h b/include/daemon.pool.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.rpc.go.h b/include/daemon.rpc.go.h deleted file mode 100644 index 82c934991d..0000000000 --- a/include/daemon.rpc.go.h +++ /dev/null @@ -1,23 +0,0 @@ -typedef struct{ - GoInt_ ID; - GoString_ Addr; - GoInt64_ LastSent; - GoInt64_ LastReceived; - BOOL Outgoing; - BOOL Introduced; - GoUint32_ Mirror; - GoUint16_ ListenPort; -} daemon__Connection; -typedef struct{ - GoSlice_ Connections; -} daemon__Connections; -typedef struct{ - GoUint64_ Current; - GoUint64_ Highest; - GoSlice_ Peers; -} daemon__BlockchainProgress; -typedef struct{ - GoSlice_ Txids; -} daemon__ResendResult; -typedef struct{ -} daemon__RPC; diff --git a/include/daemon.storage.go.h b/include/daemon.storage.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.strand.strand.go.h b/include/daemon.strand.strand.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/daemon.visor.go.h b/include/daemon.visor.go.h deleted file mode 100644 index 8ac65482a7..0000000000 --- a/include/daemon.visor.go.h +++ /dev/null @@ -1,29 +0,0 @@ -typedef struct{ - GoString_ Address; - GoUint64_ Height; -} daemon__PeerBlockchainHeight; -typedef struct{ - GoUint64_ LastBlock; - GoUint64_ RequestedBlocks; - gnet__MessageContext * c; -} daemon__GetBlocksMessage; -typedef struct{ - GoSlice_ Blocks; - gnet__MessageContext * c; -} daemon__GiveBlocksMessage; -typedef struct{ - GoUint64_ MaxBkSeq; - gnet__MessageContext * c; -} daemon__AnnounceBlocksMessage; -typedef struct{ - GoSlice_ Txns; - gnet__MessageContext * c; -} daemon__AnnounceTxnsMessage; -typedef struct{ - GoSlice_ Txns; - gnet__MessageContext * c; -} daemon__GetTxnsMessage; -typedef struct{ - coin__Transactions Txns; - gnet__MessageContext * c; -} daemon__GiveTxnsMessage; diff --git a/include/feecalc.h b/include/feecalc.h new file mode 100644 index 0000000000..13dacfdd47 --- /dev/null +++ b/include/feecalc.h @@ -0,0 +1,6 @@ +#ifndef CALLFEECALCULATOR +#define CALLFEECALCULATOR +static inline GoUint32_ callFeeCalculator(FeeCalc feeCalc, Transaction__Handle handle, GoUint64_* pFee){ + return feeCalc(handle, pFee); +} +#endif diff --git a/include/skycriterion.h b/include/skycriterion.h index de2608d925..91f5aa1c64 100644 --- a/include/skycriterion.h +++ b/include/skycriterion.h @@ -20,9 +20,9 @@ extern char *cr_user_GoString__tostr(GoString_ *string) ; extern int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2); extern char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1); -extern int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2); -extern int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2); -extern char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1); +extern int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); +extern int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2); +extern char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1); extern int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2); extern char *cr_user_GoSlice_tostr(GoSlice *slice1); @@ -47,12 +47,24 @@ extern int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2); extern int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2); extern char* cr_user_coin__UxOut_tostr(coin__UxOut *x1); +extern int cr_user_coin__UxArray_eq(coin__UxArray *x1, coin__UxArray *x2); +extern int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2); +extern char* cr_user_coin__UxArray_tostr(coin__UxArray *x1); + extern int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2); extern int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2); extern char* cr_user_coin__Transaction_tostr(coin__Transaction *x1); +extern int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2); +extern int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2); +extern char* cr_user_coin__Transactions_tostr(coin__Transactions *x1); + extern int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); extern int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2); extern char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1); +extern int cr_user_Number_eq(Number *n1, Number *n2); +extern int cr_user_Number_noteq(Number *n1, Number *n2); +extern char* cr_user_Number_tostr(Number *n1); + #endif //LIBCRITERION_H diff --git a/include/skynumber.h b/include/skynumber.h deleted file mode 100644 index f3804d8fb1..0000000000 --- a/include/skynumber.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LIBSKY_NUMBER_H -#define LIBSKY_NUMBER_H - -#include "skytypes.h" - -extern int number_eq(Number* n1, Number* n2); - -#endif \ No newline at end of file diff --git a/include/skytest.h b/include/skytest.h index 98440d43c4..e0dc956c17 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -11,10 +11,6 @@ void * registerMemCleanup(void *p); void fprintbuff(FILE *f, void *buff, size_t n); -void redirectStdOut(); - -int getStdOut(char* str, unsigned int max_size); - json_value* json_get_string(json_value* value, const char* key); int json_set_string(json_value* value, const char* new_string_value); diff --git a/include/skytypes.gen.h b/include/skytypes.gen.h index 1448d53d94..367e08f86f 100644 --- a/include/skytypes.gen.h +++ b/include/skytypes.gen.h @@ -1,124 +1,27 @@ #include "cipher.hash.go.h" #include "cipher.address.go.h" -#include "cipher.base58.base58.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_generic.go.h" -#include "cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" -#include "cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" #include "cipher.crypto.go.h" -#include "cipher.encoder.encoder.go.h" #include "cipher.encoder.field.go.h" #include "cipher.encrypt.scrypt_chacha20poly1305.go.h" #include "cipher.encrypt.sha256xor.go.h" -#include "cipher.go-bip39.bip39.go.h" -#include "cipher.go-bip39.wordlist.go.h" -#include "cipher.pbkdf2.pbkdf2.go.h" -#include "cipher.poly1305.poly1305.go.h" -#include "cipher.poly1305.sum_amd64.go.h" -#include "cipher.poly1305.sum_arm.go.h" -#include "cipher.poly1305.sum_ref.go.h" -#include "cipher.ripemd160.ripemd160block.go.h" -#include "cipher.ripemd160.ripmd_160.go.h" -#include "cipher.scrypt.scrypt.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.ec.go.h" #include "cipher.secp256k1-go.secp256k1-go2.field.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.num.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.sig.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" -#include "cipher.secp256k1-go.secp256k1-go2.z_init.go.h" -#include "cipher.secp256k1-go.secp256k1.go.h" -#include "cipher.secp256k1-go.secp256_rand.go.h" #include "coin.transactions.go.h" #include "coin.block.go.h" #include "coin.outputs.go.h" -#include "consensus.blockstat.go.h" -#include "consensus.connection_manager.go.h" -#include "consensus.consensus.go.h" -#include "consensus.participant.go.h" -#include "consensus.public_broadcast_channel.public_broadcast_channel.go.h" - -#include "testutil.assert.assertions.go.h" -#include "testutil.require.require.go.h" -#include "util.browser.browser.go.h" -#include "util.cert.cert.go.h" -#include "util.droplet.droplet.go.h" -#include "util.elapse.elapser.go.h" -#include "util.fee.fee.go.h" -#include "util.file.file.go.h" -#include "util.http.error.go.h" -#include "util.http.handler.go.h" -#include "util.http.json.go.h" -#include "util.http.log.go.h" -#include "util.iputil.iputil.go.h" -#include "util.logging.formatter.go.h" -#include "util.logging.hooks.go.h" -#include "util.logging.logger.go.h" -#include "util.logging.logging.go.h" -#include "util.utc.utc.go.h" -#include "visor.blockchain.go.h" -#include "visor.visor.go.h" -#include "visor.blockdb.blockchain.go.h" -#include "visor.blockdb.blocksigs.go.h" -#include "visor.blockdb.block_tree.go.h" -#include "visor.blockdb.unspent.go.h" -#include "visor.db.go.h" -#include "visor.distribution.go.h" -#include "visor.historydb.address_txn.go.h" -#include "visor.historydb.address_uxout.go.h" -#include "visor.historydb.historydb.go.h" -#include "visor.historydb.history_meta.go.h" -#include "visor.historydb.output.go.h" -#include "visor.historydb.transaction.go.h" #include "visor.readable.go.h" -#include "visor.richlist.go.h" -#include "visor.unconfirmed.go.h" -#include "visor.verify.go.h" -#include "daemon.gnet.pool.go.h" -#include "daemon.gnet.message.go.h" -#include "daemon.messages.go.h" -#include "daemon.daemon.go.h" -#include "daemon.gateway.go.h" -#include "daemon.gnet.dispatcher.go.h" -#include "daemon.pex.peerlist.go.h" -#include "daemon.pex.pex.go.h" -#include "daemon.pool.go.h" -#include "daemon.rpc.go.h" -#include "daemon.storage.go.h" -#include "daemon.strand.strand.go.h" -#include "daemon.visor.go.h" - -#include "api.webrpc.block.go.h" -#include "api.webrpc.client.go.h" -#include "api.webrpc.gateway.go.h" -#include "api.webrpc.outputs.go.h" -#include "api.webrpc.status.go.h" -#include "api.webrpc.transaction.go.h" -#include "api.webrpc.uxout.go.h" -#include "api.webrpc.webrpc.go.h" -#include "wallet.addresses.go.h" #include "wallet.balance.go.h" -#include "wallet.crypto.go.h" #include "wallet.entry.go.h" #include "wallet.notes.go.h" -#include "wallet.readable.go.h" -#include "wallet.secrets.go.h" -#include "wallet.service.go.h" #include "wallet.wallet.go.h" -#include "wallet.wallets.go.h" #include "api.client.go.h" -#include "api.explorer.go.h" -#include "api.spend.go.h" -#include "api.wallet.go.h" -#include "cli.check_balance.go.h" #include "cli.cli.go.h" -#include "cli.create_rawtx.go.h" \ No newline at end of file +#include "cli.create_rawtx.go.h" +#include "util.http.json.go.h" diff --git a/include/skytypes.h b/include/skytypes.h index e5fa28e233..e0d844929c 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -194,11 +194,6 @@ typedef struct { GoSlice_ nat; } Number; -/** - * RIPEMD-160 hash. - */ -typedef unsigned char Ripemd160[20]; - typedef struct { //TODO: stdevEclipse Define Signature Number R; @@ -289,14 +284,67 @@ typedef Handle SignedBlock__Handle; */ typedef Handle BlockBody__Handle; -/* -#include "cipher.hash.go.h" -#include "cipher.crypto.go.h" -#include "cipher.address.go.h" -#include "cli.create_rawtx.go.h" -#include "coin.outputs.go.h" -#include "coin.transactions.go.h" -#include "wallet.entry.go.h" -#include "wallet.wallet.go.h" -*/ +/** + * Memory handle to access to cli.BalanceResult + */ + +typedef Handle BalanceResult_Handle; + + +/** + * Memory handle to access to api.SpendResult + */ + +typedef Handle SpendResult_Handle; + +/** + * Memory handle to access to coin.Transactions + */ + +typedef Handle TransactionResult_Handle; + +/** + * Memory handle to access to coin.SortableTransactions + */ + +typedef Handle SortableTransactionResult_Handle; + +/** + * Memory handle to access to wallet.Notes + */ + +typedef Handle WalletNotes_Handle; + +/** + * Memory handle to access to wallet.ReadableNotes + */ + +typedef Handle WalletReadableNotes_Handle; + +/** + * Memory handle to access to webrpc.OutputsResult + */ + +typedef Handle OutputsResult_Handle; + +/** + * Memory handle to access to webrpc.StatusResult + */ + +typedef Handle StatusResult_Handle; + +/** + * Memory handle to access to coin.AddressUxOuts + */ + +typedef Handle AddressUxOuts_Handle; + +/** + * Memory handle to access to visor.BuildInfo (BuildInfo) + */ + +typedef Handle BuildInfo_Handle; + +typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); + #endif diff --git a/include/testutil.assert.assertions.go.h b/include/testutil.assert.assertions.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/testutil.require.require.go.h b/include/testutil.require.require.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/testutil.testutil.go.h b/include/testutil.testutil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/transutil.h b/include/transutil.h index 154cd5c69a..70d7baeb52 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -11,6 +11,8 @@ #include "skytest.h" #include "skytypes.h" +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee); + int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress); int makeUxBodyWithSecret(coin__UxBody* puxBody, cipher__SecKey* pseckey); @@ -36,3 +38,5 @@ coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Hand void makeRandHash(cipher__SHA256* phash); int makeUxArray(coin__UxArray* parray, int n); + +int sortTransactions(Transactions__Handle txns_handle, Transactions__Handle* sorted_txns_handle); diff --git a/include/util.apputil.apputil.go.h b/include/util.apputil.apputil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.browser.browser.go.h b/include/util.browser.browser.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.cert.cert.go.h b/include/util.cert.cert.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.droplet.droplet.go.h b/include/util.droplet.droplet.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.elapse.elapser.go.h b/include/util.elapse.elapser.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.fee.fee.go.h b/include/util.fee.fee.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.file.file.go.h b/include/util.file.file.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.error.go.h b/include/util.http.error.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.handler.go.h b/include/util.http.handler.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.http.log.go.h b/include/util.http.log.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.iputil.iputil.go.h b/include/util.iputil.iputil.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.formatter.go.h b/include/util.logging.formatter.go.h deleted file mode 100644 index 58f8dab875..0000000000 --- a/include/util.logging.formatter.go.h +++ /dev/null @@ -1,12 +0,0 @@ -typedef struct{ - GoString_ InfoLevelStyle; - GoString_ WarnLevelStyle; - GoString_ ErrorLevelStyle; - GoString_ FatalLevelStyle; - GoString_ PanicLevelStyle; - GoString_ DebugLevelStyle; - GoString_ PrefixStyle; - GoString_ TimestampStyle; - GoString_ CallContextStyle; - GoString_ CriticalStyle; -} logging__ColorScheme; diff --git a/include/util.logging.hooks.go.h b/include/util.logging.hooks.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.logger.go.h b/include/util.logging.logger.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.logging.logging.go.h b/include/util.logging.logging.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/util.utc.utc.go.h b/include/util.utc.utc.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.blockchain.go.h b/include/visor.blockchain.go.h deleted file mode 100644 index 33277ba6a8..0000000000 --- a/include/visor.blockchain.go.h +++ /dev/null @@ -1,8 +0,0 @@ -typedef struct{ - BOOL Arbitrating; - cipher__PubKey Pubkey; -} visor__BlockchainConfig; -typedef struct{ - cipher__Sig sig; - cipher__SHA256 hash; -} visor__sigHash; diff --git a/include/visor.blockdb.block_tree.go.h b/include/visor.blockdb.block_tree.go.h deleted file mode 100644 index deb16ea9ad..0000000000 --- a/include/visor.blockdb.block_tree.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} blockdb__blockTree; diff --git a/include/visor.blockdb.blockchain.go.h b/include/visor.blockdb.blockchain.go.h deleted file mode 100644 index ade4c24131..0000000000 --- a/include/visor.blockdb.blockchain.go.h +++ /dev/null @@ -1,3 +0,0 @@ -typedef struct{ - coin__Block * b; -} blockdb__ErrMissingSignature; diff --git a/include/visor.blockdb.blocksigs.go.h b/include/visor.blockdb.blocksigs.go.h deleted file mode 100644 index 29e49599d1..0000000000 --- a/include/visor.blockdb.blocksigs.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} blockdb__blockSigs; diff --git a/include/visor.blockdb.chain_meta.go.h b/include/visor.blockdb.chain_meta.go.h deleted file mode 100644 index 7d2cdc3053..0000000000 --- a/include/visor.blockdb.chain_meta.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} blockdb__chainMeta; diff --git a/include/visor.blockdb.unspent.go.h b/include/visor.blockdb.unspent.go.h deleted file mode 100644 index 4606d88f97..0000000000 --- a/include/visor.blockdb.unspent.go.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct{ - GoString_ UxID; -} blockdb__ErrUnspentNotExist; -typedef struct{ -} blockdb__unspentMeta; -typedef struct{ -} blockdb__pool; -typedef struct{ -} blockdb__poolAddrIndex; diff --git a/include/visor.db.go.h b/include/visor.db.go.h deleted file mode 100644 index caa2070624..0000000000 --- a/include/visor.db.go.h +++ /dev/null @@ -1,3 +0,0 @@ -typedef struct{ - GoInt32_ _unnamed; -} visor__ErrCorruptDB; diff --git a/include/visor.dbutil.dbutil.go.h b/include/visor.dbutil.dbutil.go.h deleted file mode 100644 index c86978a042..0000000000 --- a/include/visor.dbutil.dbutil.go.h +++ /dev/null @@ -1,7 +0,0 @@ -typedef struct{ - GoString_ Bucket; - GoInt32_ Err; -} dbutil__ErrCreateBucketFailed; -typedef struct{ - GoString_ Bucket; -} dbutil__ErrBucketNotExist; diff --git a/include/visor.distribution.go.h b/include/visor.distribution.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.historydb.address_txn.go.h b/include/visor.historydb.address_txn.go.h deleted file mode 100644 index 461204b534..0000000000 --- a/include/visor.historydb.address_txn.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} historydb__addressTxns; diff --git a/include/visor.historydb.address_uxout.go.h b/include/visor.historydb.address_uxout.go.h deleted file mode 100644 index 04a5acd6d4..0000000000 --- a/include/visor.historydb.address_uxout.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} historydb__addressUx; diff --git a/include/visor.historydb.history_meta.go.h b/include/visor.historydb.history_meta.go.h deleted file mode 100644 index be4cbdf596..0000000000 --- a/include/visor.historydb.history_meta.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} historydb__historyMeta; diff --git a/include/visor.historydb.historydb.go.h b/include/visor.historydb.historydb.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/visor.historydb.output.go.h b/include/visor.historydb.output.go.h deleted file mode 100644 index ab77b04b78..0000000000 --- a/include/visor.historydb.output.go.h +++ /dev/null @@ -1,18 +0,0 @@ -typedef struct{ - GoString_ Uxid; - GoUint64_ Time; - GoUint64_ SrcBkSeq; - GoString_ SrcTx; - GoString_ OwnerAddress; - GoUint64_ Coins; - GoUint64_ Hours; - GoUint64_ SpentBlockSeq; - GoString_ SpentTxID; -} historydb__UxOutJSON; -typedef struct{ -} historydb__UxOuts; -typedef struct{ - coin__UxOut Out; - cipher__SHA256 SpentTxID; - GoUint64_ SpentBlockSeq; -} historydb__UxOut; diff --git a/include/visor.historydb.transaction.go.h b/include/visor.historydb.transaction.go.h deleted file mode 100644 index 75c6205bdf..0000000000 --- a/include/visor.historydb.transaction.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ -} historydb__transactions; -typedef struct{ - coin__Transaction Tx; - GoUint64_ BlockSeq; -} historydb__Transaction; diff --git a/include/visor.readable.go.h b/include/visor.readable.go.h index bac09f1429..46587f7c42 100644 --- a/include/visor.readable.go.h +++ b/include/visor.readable.go.h @@ -1,90 +1 @@ -typedef struct{ - BOOL Confirmed; - BOOL Unconfirmed; - GoUint64_ Height; - GoUint64_ BlockSeq; - BOOL Unknown; -} visor__TransactionStatus; -typedef struct{ - GoString_ Hash; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__ReadableTransactionOutput; -typedef struct{ - GoString_ Hash; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__ReadableTransactionInput; -typedef struct{ - GoString_ Hash; - GoUint64_ Time; - GoUint64_ BkSeq; - GoString_ SourceTransaction; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; - GoUint64_ CalculatedHours; -} visor__ReadableOutput; typedef GoSlice_ visor__ReadableOutputs; -typedef struct{ - GoUint32_ Length; - GoUint8_ Type; - GoString_ Hash; - GoString_ InnerHash; - GoUint64_ Timestamp; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} visor__ReadableTransaction; -typedef struct{ - GoUint64_ BkSeq; - GoString_ BlockHash; - GoString_ PreviousBlockHash; - GoUint64_ Time; - GoUint64_ Fee; - GoUint32_ Version; - GoString_ BodyHash; -} visor__ReadableBlockHeader; -typedef struct{ - GoSlice_ Transactions; -} visor__ReadableBlockBody; -typedef struct{ - visor__ReadableBlockHeader Head; - visor__ReadableBlockBody Body; - GoInt_ Size; -} visor__ReadableBlock; -typedef struct{ - GoSlice_ Blocks; -} visor__ReadableBlocks; -typedef struct{ - GoString_ Hash; - GoString_ SourceTransaction; - GoString_ Address; - GoString_ Coins; - GoUint64_ Hours; -} visor__TransactionOutputJSON; -typedef struct{ - GoString_ Hash; - GoString_ InnerHash; - GoSlice_ Sigs; - GoSlice_ In; - GoSlice_ Out; -} visor__TransactionJSON; -typedef struct{ - visor__ReadableBlockHeader Head; - GoUint64_ Unspents; - GoUint64_ Unconfirmed; -} visor__BlockchainMetadata; -typedef struct{ - visor__ReadableOutputs HeadOutputs; - visor__ReadableOutputs OutgoingOutputs; - visor__ReadableOutputs IncomingOutputs; -} visor__ReadableOutputSet; -typedef struct{ - coin__Transaction Txn; - visor__TransactionStatus Status; - GoUint64_ Time; - GoInt_ Size; -} visor__Transaction; diff --git a/include/visor.richlist.go.h b/include/visor.richlist.go.h deleted file mode 100644 index 6ad0998e61..0000000000 --- a/include/visor.richlist.go.h +++ /dev/null @@ -1,7 +0,0 @@ -typedef struct{ - GoString_ Address; - GoString_ Coins; - BOOL Locked; - GoUint64_ coins; -} visor__RichlistBalance; -typedef GoSlice_ visor__Richlist; diff --git a/include/visor.unconfirmed.go.h b/include/visor.unconfirmed.go.h deleted file mode 100644 index 7366404211..0000000000 --- a/include/visor.unconfirmed.go.h +++ /dev/null @@ -1,11 +0,0 @@ -typedef struct{ -} visor__unconfirmedTxns; -typedef struct{ -} visor__txUnspents; -typedef struct{ - coin__Transaction Txn; - GoInt64_ Received; - GoInt64_ Checked; - GoInt64_ Announced; - GoInt8_ IsValid; -} visor__UnconfirmedTxn; diff --git a/include/visor.verify.go.h b/include/visor.verify.go.h deleted file mode 100644 index 284d1638f1..0000000000 --- a/include/visor.verify.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - GoInt32_ Err; -} visor__ErrTxnViolatesHardConstraint; -typedef struct{ - GoInt32_ Err; -} visor__ErrTxnViolatesSoftConstraint; diff --git a/include/visor.visor.go.h b/include/visor.visor.go.h deleted file mode 100644 index 5bb3f2f9a0..0000000000 --- a/include/visor.visor.go.h +++ /dev/null @@ -1,8 +0,0 @@ -typedef struct{ - GoString_ Version; - GoString_ Commit; - GoString_ Branch; -} visor__BuildInfo; -typedef struct{ - GoSlice_ Addrs; -} visor__addrsFilter; diff --git a/include/wallet.addresses.go.h b/include/wallet.addresses.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/wallet.crypto.go.h b/include/wallet.crypto.go.h deleted file mode 100644 index 8b13789179..0000000000 --- a/include/wallet.crypto.go.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/wallet.entry.go.h b/include/wallet.entry.go.h index 7cf6a23377..362bb76494 100644 --- a/include/wallet.entry.go.h +++ b/include/wallet.entry.go.h @@ -1,4 +1,3 @@ - /** * Wallet entry. */ diff --git a/include/wallet.notes.go.h b/include/wallet.notes.go.h index 7fdce9e75c..2c77c0d365 100644 --- a/include/wallet.notes.go.h +++ b/include/wallet.notes.go.h @@ -1,9 +1,7 @@ -typedef GoSlice_ wallet__Notes; typedef struct{ GoString_ TxID; GoString_ Value; } wallet__Note; -typedef GoSlice_ wallet__ReadableNotes; typedef struct{ GoString_ TransactionID; GoString_ ActualNote; diff --git a/include/wallet.readable.go.h b/include/wallet.readable.go.h deleted file mode 100644 index 69057bc363..0000000000 --- a/include/wallet.readable.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ Address; - GoString_ Public; - GoString_ Secret; -} wallet__ReadableEntry; -typedef GoSlice_ wallet__ReadableEntries; diff --git a/include/wallet.secrets.go.h b/include/wallet.secrets.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/include/wallet.service.go.h b/include/wallet.service.go.h deleted file mode 100644 index dae4d8cdce..0000000000 --- a/include/wallet.service.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ WalletDir; - GoString_ CryptoType; - BOOL EnableWalletAPI; - BOOL EnableSeedAPI; -} wallet__Config; diff --git a/include/wallet.wallet.go.h b/include/wallet.wallet.go.h index fb405c5741..59cef856f8 100644 --- a/include/wallet.wallet.go.h +++ b/include/wallet.wallet.go.h @@ -9,15 +9,6 @@ typedef struct { typedef GoInterface_ wallet__Validator; -typedef struct{ - GoString_ Coin; - GoString_ Label; - GoString_ Seed; - BOOL Encrypt; - GoSlice_ Password; - GoString_ CryptoType; -} wallet__Options; - /** * Intermediate representation of a UxOut for sorting and spend choosing. */ diff --git a/include/wallet.wallets.go.h b/include/wallet.wallets.go.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/cgo/api.blockchain.go b/lib/cgo/api.blockchain.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.blockchain.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 023f15c23f..6d1c864fe1 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -60,7 +60,7 @@ func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod __arg0, ____return_err := c.Version() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerHandle(__arg0) + *_arg0 = registerBuildInfoHandle(__arg0) } return } @@ -449,7 +449,7 @@ func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wall } //export SKY_api_Client_Spend -func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.api__SpendResult) (____error_code uint32) { +func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.SpendResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -466,13 +466,13 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, __arg3, ____return_err := c.Spend(id, dst, coins, password) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg3 = *(*C.api__SpendResult)(unsafe.Pointer(__arg3)) + *_arg3 = registerSpendResultHandle(__arg3) } return } //export SKY_api_Client_CreateTransaction -func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.api__CreateTransactionResponse) (____error_code uint32) { +func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.CreateTransactionResponse__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -490,7 +490,7 @@ func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 __arg1, ____return_err := c.CreateTransaction(*req) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.api__CreateTransactionResponse)(unsafe.Pointer(__arg1)) + *_arg1 = registerCreateTransactionResponseHandle(__arg1) } return } diff --git a/lib/cgo/api.csrf.go b/lib/cgo/api.csrf.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.csrf.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.gateway.go b/lib/cgo/api.gateway.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.gateway.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.health.go b/lib/cgo/api.health.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.health.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.http.go b/lib/cgo/api.http.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.http.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.integration.empty.go b/lib/cgo/api.integration.empty.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.integration.empty.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.network.go b/lib/cgo/api.network.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.network.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.notes.go b/lib/cgo/api.notes.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.notes.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index c78a63e345..5a65ac3c1f 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -78,7 +78,7 @@ func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _ } //export SKY_api_NewCreatedTransactionOutput -func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.api__CreatedTransactionOutput) (____error_code uint32) { +func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.CreatedTransactionOutput__Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -88,7 +88,7 @@ func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.api__CreatedTransactionOutput)(unsafe.Pointer(__arg2)) + *_arg2 = registerCreatedTransactionOutputHandle(__arg2) } return } diff --git a/lib/cgo/api.transaction.go b/lib/cgo/api.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.uxout.go b/lib/cgo/api.uxout.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.uxout.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.block.go b/lib/cgo/api.webrpc.block.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.block.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 2fa7bdcf71..c933d4facf 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -39,7 +39,7 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.CSRF() @@ -51,7 +51,7 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ } //export SKY_webrpc_Client_GetUnspentOutputs -func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -65,7 +65,7 @@ func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []str __arg1, ____return_err := c.GetUnspentOutputs(addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg1)) + *_arg1 = registerOutputsResultHandle(__arg1) } return } @@ -115,7 +115,7 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transa } //export SKY_webrpc_Client_GetStatus -func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__StatusResult) (____error_code uint32) { +func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -128,13 +128,13 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.webrpc__Sta __arg0, ____return_err := c.GetStatus() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = *(*C.webrpc__StatusResult)(unsafe.Pointer(__arg0)) + *_arg0 = registerStatusResultHandle(__arg0) } return } //export SKY_webrpc_Client_GetTransactionByID -func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.webrpc__TxnResult) (____error_code uint32) { +func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.TransactionResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -148,7 +148,7 @@ func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid strin __arg1, ____return_err := c.GetTransactionByID(txid) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.webrpc__TxnResult)(unsafe.Pointer(__arg1)) + *_arg1 = registerTransactionResultHandle(__arg1) } return } @@ -174,7 +174,7 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri } //export SKY_webrpc_Client_GetBlocks -func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -189,13 +189,13 @@ func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, __arg1, ____return_err := c.GetBlocks(start, end) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } //export SKY_webrpc_Client_GetBlocksBySeq -func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -209,13 +209,13 @@ func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _ __arg1, ____return_err := c.GetBlocksBySeq(ss) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } //export SKY_webrpc_Client_GetLastBlocks -func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.visor__ReadableBlocks) (____error_code uint32) { +func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -229,7 +229,7 @@ func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 __arg1, ____return_err := c.GetLastBlocks(n) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.visor__ReadableBlocks)(unsafe.Pointer(__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) } return } diff --git a/lib/cgo/api.webrpc.gateway.go b/lib/cgo/api.webrpc.gateway.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.gateway.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.outputs.go b/lib/cgo/api.webrpc.outputs.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.outputs.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.status.go b/lib/cgo/api.webrpc.status.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.status.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.transaction.go b/lib/cgo/api.webrpc.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.uxout.go b/lib/cgo/api.webrpc.uxout.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/api.webrpc.uxout.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/api.webrpc.webrpc.go b/lib/cgo/api.webrpc.webrpc.go deleted file mode 100644 index be2d44f87c..0000000000 --- a/lib/cgo/api.webrpc.webrpc.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "unsafe" - - webrpc "github.com/skycoin/skycoin/src/api/webrpc" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_webrpc_RPCError_Error -func SKY_webrpc_RPCError_Error(_e *C.webrpc__RPCError, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - e := *(*webrpc.RPCError)(unsafe.Pointer(_e)) - __arg0 := e.Error() - copyString(__arg0, _arg0) - return -} diff --git a/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go b/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.chacha20poly1305.chacha20poly1305.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.encoder.encoder.go b/lib/cgo/cipher.encoder.encoder.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.encoder.encoder.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.go-bip39.wordlist.go b/lib/cgo/cipher.go-bip39.wordlist.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.go-bip39.wordlist.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.pbkdf2.pbkdf2.go b/lib/cgo/cipher.pbkdf2.pbkdf2.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.pbkdf2.pbkdf2.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.ripemd160.ripemd160block.go b/lib/cgo/cipher.ripemd160.ripemd160block.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.ripemd160.ripemd160block.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.ripemd160.ripmd_160.go b/lib/cgo/cipher.ripemd160.ripmd_160.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.ripemd160.ripmd_160.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.secp256k1.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_consts.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.z_init.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.address_gen.go b/lib/cgo/cli.address_gen.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.address_gen.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.blocks.go b/lib/cgo/cli.blocks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.blocks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.broadcast_rawtx.go b/lib/cgo/cli.broadcast_rawtx.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.broadcast_rawtx.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go index 7cacb580f8..4313be2697 100644 --- a/lib/cgo/cli.check_balance.go +++ b/lib/cgo/cli.check_balance.go @@ -16,7 +16,7 @@ import ( import "C" //export SKY_cli_CheckWalletBalance -func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { +func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -30,13 +30,13 @@ func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _ __arg2, ____return_err := cli.CheckWalletBalance(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerBalanceResultHandle(__arg2) } return } //export SKY_cli_GetBalanceOfAddresses -func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.cli__BalanceResult) (____error_code uint32) { +func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -50,7 +50,7 @@ func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _ __arg2, ____return_err := cli.GetBalanceOfAddresses(c, addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.cli__BalanceResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerBalanceResultHandle(__arg2) } return } diff --git a/lib/cgo/cli.checkdb.go b/lib/cgo/cli.checkdb.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.checkdb.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index d5f7e4c1c4..5f7b4e30fd 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -26,7 +26,7 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } @@ -54,7 +54,7 @@ func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFil }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addr := _addr @@ -82,12 +82,12 @@ func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAd }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } wlt, okwlt := lookupWalletHandle(_wlt) if !okwlt { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } inAddrs := *(*[]string)(unsafe.Pointer(&_inAddrs)) diff --git a/lib/cgo/cli.decryptWallet.go b/lib/cgo/cli.decryptWallet.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.decryptWallet.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.encrypt_wallet.go b/lib/cgo/cli.encrypt_wallet.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.encrypt_wallet.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.integration.empty.go b/lib/cgo/cli.integration.empty.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.integration.empty.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.last_blocks.go b/lib/cgo/cli.last_blocks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.last_blocks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.list_addrs.go b/lib/cgo/cli.list_addrs.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.list_addrs.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.list_wallets.go b/lib/cgo/cli.list_wallets.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.list_wallets.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index f2217a6e4c..b8686bb876 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -1,8 +1,6 @@ package main import ( - "unsafe" - cli "github.com/skycoin/skycoin/src/cli" ) @@ -16,7 +14,7 @@ import ( import "C" //export SKY_cli_GetWalletOutputsFromFile -func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -30,13 +28,13 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerOutputsResultHandle(__arg2) } return } //export SKY_cli_GetWalletOutputs -func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.webrpc__OutputsResult) (____error_code uint32) { +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -54,7 +52,7 @@ func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = *(*C.webrpc__OutputsResult)(unsafe.Pointer(__arg2)) + *_arg2 = registerOutputsResultHandle(__arg2) } return } diff --git a/lib/cgo/cli.send.go b/lib/cgo/cli.send.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.send.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.show_seed.go b/lib/cgo/cli.show_seed.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.show_seed.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.status.go b/lib/cgo/cli.status.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.status.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.transaction.go b/lib/cgo/cli.transaction.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.transaction.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.verify_address.go b/lib/cgo/cli.verify_address.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.verify_address.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.version.go b/lib/cgo/cli.version.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.version.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.wallet_dir.go b/lib/cgo/cli.wallet_dir.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.wallet_dir.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/cli.wallet_history.go b/lib/cgo/cli.wallet_history.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/cli.wallet_history.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index 08ee6f8ae2..ecfb158297 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -1,6 +1,7 @@ package main import ( + "errors" "reflect" "unsafe" @@ -14,13 +15,22 @@ import ( #include #include "skytypes.h" + #include "feecalc.h" */ import "C" //export SKY_coin_NewBlock -func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, _fee uint64, _arg2 *C.Block__Handle) (____error_code uint32) { - feeCalculator := func(t *coin.Transaction) (uint64, error) { - return _fee, nil +func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc C.FeeCalc, _arg2 *C.Block__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } } ____error_code = 0 @@ -38,7 +48,7 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ ____error_code = SKY_ERROR return } - __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalculator) + __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalc) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg2 = registerBlockHandle(__arg2) diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 4b1aecba16..d093dbe380 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -4,6 +4,7 @@ import ( "reflect" "unsafe" + "github.com/skycoin/skycoin/src/cipher" coin "github.com/skycoin/skycoin/src/coin" ) @@ -198,3 +199,151 @@ func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } + +//export SKY_coin_NewAddressUxOuts +func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + address_outs := coin.NewAddressUxOuts(ua) + *_address_outs = registerAddressUxOutHandle(&address_outs) + return +} + +//export SKY_coin_AddressUxOuts_Keys +func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_ERROR + return + } + keys := (*address_outs).Keys() + copyToGoSlice(reflect.ValueOf(keys), _keys) + return +} + +//export SKY_coin_AddressUxOuts_Flatten +func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C.coin__UxArray) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_ERROR + return + } + ux := (*address_outs).Flatten() + copyToGoSlice(reflect.ValueOf(ux), _ua) + return +} + +//export SKY_coin_AddressUxOuts_Sub +func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_ERROR + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_ERROR + return + } + auo_result := (*auo1).Sub(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Add +func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_ERROR + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_ERROR + return + } + auo_result := (*auo1).Add(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Get +func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + copyToGoSlice(reflect.ValueOf(uxOuts), _uxOuts) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_HasKey +func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _hasKey *bool) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + _, found := (*a)[key] + *_hasKey = found + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_GetOutputLength +func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _length *int) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + *_length = len(uxOuts) + return SKY_OK + } + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_Length +func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + *_length = len(*a) + return SKY_OK + } + return SKY_ERROR +} + +//export SKY_coin_AddressUxOuts_Set +func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) uint32 { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) + (*a)[key] = uxOuts + return SKY_OK + } + return SKY_ERROR +} diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 9b73af741f..f294d2a682 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -1,6 +1,7 @@ package main import ( + "errors" "reflect" "unsafe" @@ -14,6 +15,7 @@ import ( #include #include "skytypes.h" + #include "feecalc.h" */ import "C" @@ -449,6 +451,37 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han return } +//export SKY_coin_Transactions_Fees +func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, _result *uint64) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + result, err := txns.Fees(feeCalc) + if err != nil { + ____error_code = SKY_ERROR + } else { + *_result = result + } + return +} + //export SKY_coin_Transactions_GetAt func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { ____error_code = 0 @@ -518,36 +551,102 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int return } +//export SKY_coin_SortTransactions +func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.Transactions__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + sorted := coin.SortTransactions(*txns, feeCalc) + *ptsh = registerTransactionsHandle(&sorted) + return +} + +//export SKY_coin_NewSortableTransactions +func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_ERROR + return + } + sorted := coin.NewSortableTransactions(*txns, feeCalc) + *ptsh = registerSortableTransactiontHandle(&sorted) + return SKY_OK +} + //export SKY_coin_SortableTransactions_Sort -func SKY_coin_SortableTransactions_Sort(_txns *C.coin__SortableTransactions) (____error_code uint32) { +func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } txns.Sort() return } //export SKY_coin_SortableTransactions_Len -func SKY_coin_SortableTransactions_Len(_txns *C.coin__SortableTransactions, _arg0 *int) (____error_code uint32) { +func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, _arg0 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := txns.Len() *_arg0 = __arg0 return } //export SKY_coin_SortableTransactions_Less -func SKY_coin_SortableTransactions_Less(_txns *C.coin__SortableTransactions, _i, _j int, _arg1 *bool) (____error_code uint32) { +func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle, _i, _j int, _arg1 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } i := _i j := _j __arg1 := txns.Less(i, j) @@ -556,12 +655,16 @@ func SKY_coin_SortableTransactions_Less(_txns *C.coin__SortableTransactions, _i, } //export SKY_coin_SortableTransactions_Swap -func SKY_coin_SortableTransactions_Swap(_txns *C.coin__SortableTransactions, _i, _j int) (____error_code uint32) { +func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle, _i, _j int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - txns := *(*coin.SortableTransactions)(unsafe.Pointer(_txns)) + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_ERROR + return + } i := _i j := _j txns.Swap(i, j) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index b0aa4c0b58..55bba32576 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -1,15 +1,35 @@ package main +import ( + "errors" +) + const ( + // SKY_ERROR generic error condition SKY_ERROR = 0xFFFFFFFF - SKY_OK = 0 + // SKY_BAD_HANDLE invalid handle argument + SKY_BAD_HANDLE = 0xFF000001 + // SKY_OK error code is used to report success + SKY_OK = 0 +) + +var ( + ErrorBadHandle = errors.New("Invalid or unknown handle value") + ErrorUnknown = errors.New("Unexpected error") + + errorToCodeMap = map[error]uint32{ + ErrorBadHandle: SKY_BAD_HANDLE, + ErrorUnknown: SKY_ERROR, + } ) func libErrorCode(err error) uint32 { if err == nil { return SKY_OK } - // TODO: Implement error codes + if errcode, isKnownError := errorToCodeMap[err]; isKnownError { + return errcode + } return SKY_ERROR } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index b55575cf51..6b6dd861bf 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -15,6 +15,7 @@ import ( webrpc "github.com/skycoin/skycoin/src/api/webrpc" cli "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/visor" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" ) @@ -356,6 +357,146 @@ func lookupCreateTransactionResponseHandle(handle C.CreateTransactionResponse__H return nil, false } +func registerBalanceResultHandle(obj *cli.BalanceResult) C.BalanceResult_Handle { + return (C.BalanceResult_Handle)(registerHandle(obj)) +} + +func lookupBalanceResultHandle(handle C.BalanceResult_Handle) (*cli.BalanceResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.BalanceResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerSpendResultHandle(obj *api.SpendResult) C.SpendResult_Handle { + return (C.SpendResult_Handle)(registerHandle(obj)) +} + +func lookupSpendResultHandle(handle C.SpendResult_Handle) (*api.SpendResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.SpendResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerTransactionResultHandle(obj *webrpc.TxnResult) C.TransactionResult_Handle { + return (C.TransactionResult_Handle)(registerHandle(obj)) +} + +func lookupTransactionResultHandle(handle C.TransactionResult_Handle) (*webrpc.TxnResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.TxnResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerSortableTransactiontHandle(obj *coin.SortableTransactions) C.SortableTransactionResult_Handle { + return (C.SortableTransactionResult_Handle)(registerHandle(obj)) +} + +func lookupSortableTransactionHandle(handle C.SortableTransactionResult_Handle) (*coin.SortableTransactions, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.SortableTransactions); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletNotesHandle(obj *wallet.Notes) C.WalletNotes_Handle { + return (C.WalletNotes_Handle)(registerHandle(obj)) +} + +func lookupWalletNotesHandle(handle C.WalletNotes_Handle) (*wallet.Notes, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.Notes); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletReadableNotesHandle(obj *wallet.ReadableNotes) C.WalletReadableNotes_Handle { + return (C.WalletReadableNotes_Handle)(registerHandle(obj)) +} + +func lookupWalletReadableNotesHandle(handle C.WalletReadableNotes_Handle) (*wallet.ReadableNotes, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableNotes); isOK { + return obj, true + } + } + return nil, false +} + +func registerOutputsResultHandle(obj *webrpc.OutputsResult) C.OutputsResult_Handle { + return (C.OutputsResult_Handle)(registerHandle(obj)) +} + +func lookupOutputsResultHandle(handle C.OutputsResult_Handle) (*webrpc.OutputsResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.OutputsResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerStatusResultHandle(obj *webrpc.StatusResult) C.StatusResult_Handle { + return (C.StatusResult_Handle)(registerHandle(obj)) +} + +func lookupStatusResultHandle(handle C.StatusResult_Handle) (*webrpc.StatusResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.StatusResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerAddressUxOutHandle(obj *coin.AddressUxOuts) C.AddressUxOuts_Handle { + return (C.AddressUxOuts_Handle)(registerHandle(obj)) +} + +func lookupAddressUxOutHandle(handle C.AddressUxOuts_Handle) (*coin.AddressUxOuts, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.AddressUxOuts); isOK { + return obj, true + } + } + return nil, false +} + +func registerBuildInfoHandle(obj *visor.BuildInfo) C.BuildInfo_Handle { + return (C.BuildInfo_Handle)(registerHandle(obj)) +} + +func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*visor.BuildInfo, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.BuildInfo); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index 6391de88fb..0aa551bf3b 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -368,3 +368,16 @@ func SKY_api_Handle_GetWalletLastSeed(handle C.Wallet__Handle, } return SKY_ERROR } + +//export SKY_api_Handle_GetBuildInfoData +func SKY_api_Handle_GetBuildInfoData(handle C.BuildInfo_Handle, + version *C.GoString_, commit *C.GoString_, branch *C.GoString_) uint32 { + bi, ok := lookupBuildInfoHandle(handle) + if ok { + copyString(bi.Version, version) + copyString(bi.Commit, commit) + copyString(bi.Branch, branch) + return SKY_OK + } + return SKY_ERROR +} diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 6d5d5f5419..327f79c180 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -112,6 +112,37 @@ Test(cipher_address, TestAddressVerify){ } Test(cipher_address,TestAddressString){ + cipher__PubKey p; + cipher__SecKey s1; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p,&s1); + cr_assert(result==SKY_OK,"SKY_cipher_GenerateKeyPair failed"); + + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p,&a); + cr_assert(result==SKY_OK,"SKY_cipher_AddressFromPubKey failed"); + char buffer_s[1024]; + GoString_ s= {buffer_s,0}; + result =SKY_cipher_Address_String(&a,&s); + cr_assert(result==SKY_OK,"SKY_cipher_Address_String failed"); + cipher__Address a2; + char buffer_sConvert[1024]; + GoString sConvert={buffer_sConvert,0}; + toGoString(&s,&sConvert); + result = SKY_cipher_DecodeBase58Address(sConvert,&a2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(cipher__Address),a,a2)); + char buffer_s2[1024]; + GoString_ s2={buffer_s2,0}; + result = SKY_cipher_Address_String(&a2,&s2); + cr_assert(result == SKY_OK,"SKY_cipher_Address_String failed"); + cipher__Address a3; + char buffer_s2Convert[1024]; + GoString s2Convert={buffer_s2Convert,0}; + toGoString(&s2,&s2Convert); + result =SKY_cipher_DecodeBase58Address(s2Convert,&a3); + cr_assert(result == SKY_OK,"SKY_cipher_DecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address),a2,a3)); } @@ -335,3 +366,207 @@ Test(cipher_address, TestAddressBulk){ } +Test(cipher_address, TestBitcoinAddressFromBytes) { + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + cipher__Address a2; + cipher__PubKeySlice pk = {NULL, 0, 0}; + result = SKY_cipher_Address_BitcoinBytes(&a, &pk); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); + registerMemCleanup(pk.data); + GoSlice pk_convert = {pk.data, pk.len, pk.cap}; + result = SKY_cipher_BitcoinAddressFromBytes(pk_convert, &a2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(cipher__Address), a2, a)); + + cipher__PubKeySlice b = {NULL, 0, 0}; + result = SKY_cipher_Address_BitcoinBytes(&a, &b); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes"); + registerMemCleanup(b.data); + + GoInt_ b_len = b.len; + + // Invalid number of bytes + b.len = b.len - 2; + cipher__Address addr2; + GoSlice b_convert = {b.data, b.len, b.cap}; + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + "Invalid address length"); + + // Invalid checksum + b_convert.len = b_len; + (((char *)b_convert.data)[b_convert.len - 1])++; + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ERROR, + "Invalid checksum"); + + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + a.Version = 2; + char *buffer[1024]; + cipher__PubKeySlice b1 = {buffer, 0, 1024}; + result = SKY_cipher_Address_BitcoinBytes(&a, &b1); + cr_assert(result == SKY_OK, "SKY_cipher_Address_BitcoinBytes failed"); + GoSlice b1_convert = {b1.data, b1.len, b1.cap}; + result = SKY_cipher_BitcoinAddressFromBytes(b1_convert, &addr2); + cr_assert(result == SKY_ERROR, "Invalid version"); +} + +Test(cipher_address, TestMustDecodeBase58Address) { + + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + + result = SKY_cipher_Address_Verify(&a, &p); + cr_assert(result == SKY_OK); + GoString str = {"", 0}; + cipher__Address addr; + result = SKY_cipher_MustDecodeBase58Address(str, &addr); + cr_assert(result == SKY_ERROR); + str.p = "cascs"; + str.n = 5; + result = SKY_cipher_MustDecodeBase58Address(str, &addr); + cr_assert(result == SKY_ERROR); + + char *buff_pks[1024]; + cipher__PubKeySlice b = {buff_pks, 0, 1024}; + result = SKY_cipher_Address_Bytes(&a, &b); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); + int b_len = b.len; + b.len = (int)(b_len / 2); + GoSlice bConvert = {&b.data, b.len, b.cap}; + char buffer_h[1024]; + GoString_ h = {buffer_h, 0}; + result = SKY_base58_Hex2Base58String(bConvert, &h); + cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); + char buffer_hConvert[1024]; + GoString hConvert = {buffer_hConvert, 0}; + toGoString(&h, &hConvert); + result = SKY_cipher_MustDecodeBase58Address(hConvert, &addr); + cr_assert(result == SKY_ERROR); + + b.len = b_len; + GoSlice b2Convert = {b.data, b.len, b.cap}; + char buffer_h2[1024]; + GoString_ h2 = {buffer_h2, 0}; + result = SKY_base58_Hex2Base58String(b2Convert, &h2); + cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); + char buffer_h2Convert[1024]; + GoString h2Convert = {buffer_h2, 0}; + toGoString(&h2, &h2Convert); + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &addr); + cr_assert(result == SKY_OK); + + cipher__Address a2; + + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address), a, a2)); + + result = SKY_cipher_Address_String(&a, &h2); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); + toGoString(&h2, &h2Convert); + result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address), a, a2)); + + char strbadAddr[1024]; + char buffer_addrStr[1024]; + GoString_ addStr = {buffer_addrStr, 0}; + result = SKY_cipher_Address_String(&a, &addStr); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); + + // preceding whitespace is invalid + strcpy(strbadAddr, " "); + strncat(strbadAddr, addStr.p, addStr.n); + GoString badAddr = {strbadAddr, strlen(strbadAddr)}; + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // preceding zeroes are invalid + strcpy(strbadAddr, "000"); + strncat(strbadAddr, addStr.p, addStr.n); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // trailing whitespace is invalid + strcpy(strbadAddr, addStr.p); + strcat(strbadAddr, " "); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); + + // trailing zeroes are invalid + strcpy(strbadAddr, addStr.p); + strcat(strbadAddr, "000"); + badAddr.p = strbadAddr; + badAddr.n = strlen(strbadAddr); + result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); + cr_assert(result == SKY_ERROR); +} + +Test(cipher_address,TestAddressRoundtrip){ + cipher__PubKey p; + cipher__SecKey s; + GoInt result; + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair"); + cipher__Address a; + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + char buffer_aBytes[1024]; + cipher__PubKeySlice aBytes= {buffer_aBytes,0,1024}; + result = SKY_cipher_Address_Bytes(&a, &aBytes); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); + GoSlice aBytesSlice = {aBytes.data, aBytes.len, aBytes.cap}; + cipher__Address a2; + result = SKY_cipher_AddressFromBytes(aBytesSlice, &a2); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromBytes failed"); + + cr_assert(eq(type(cipher__Address),a,a2)); + char buffer_aString[1024]; + char buffer_a2String[1024]; + GoString_ aString = {buffer_aString,0}; + GoString_ a2String = {buffer_a2String,0}; + result = SKY_cipher_Address_String(&a,&aString); + result = SKY_cipher_Address_String(&a2,&a2String); + + cr_assert(eq(type(GoString_),a2String,aString)); + +} + +Test(cipher_address, TestAddressNull) { + cipher__Address a; + memset(&a, 0, sizeof(cipher__Address)); + GoUint32 result; + GoUint8 isNull; + result = SKY_cipher_Address_Null(&a, &isNull); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Null"); + cr_assert(isNull == 1); + + cipher__PubKey p; + cipher__SecKey s; + + result = SKY_cipher_GenerateKeyPair(&p, &s); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); + + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); + result = SKY_cipher_Address_Null(&a, &isNull); + cr_assert(result == SKY_OK, "SKY_cipher_Address_Null"); + cr_assert(isNull == 0); +} diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 1c3bde3012..90545d2bd9 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -183,7 +183,7 @@ Test(cipher_crypto, TestPubKeyToAddress) { cipher__PubKey p; cipher__SecKey s; cipher__Address addr; - Ripemd160 h; + cipher__Ripemd160 h; int errcode; SKY_cipher_GenerateKeyPair(&p, &s); @@ -733,3 +733,24 @@ Test(cipher_crypto, TestSecKeyHashTest) { errcode = SKY_cipher_TestSecKeyHash(&sk, &h); cr_assert(errcode == SKY_ERROR); } + +Test(cipher_crypto, TestGenerateDeterministicKeyPairsUsesAllBytes) { + // Tests that if a seed >128 bits is used, the generator does not ignore bits + // >128 + GoString seed = {"property diet little foster provide disagree witness " + "mountain alley weekend kitten general", + 90}; +GoSlice seedSlice = {&seed,90,90}; +char buffer_seckeys[1024]; +char buffer_seckeys2[1024]; +cipher__PubKeySlice seckeys={buffer_seckeys,0,1024}; +cipher__PubKeySlice seckeys2={buffer_seckeys2,0,1024}; + GoInt result; + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys); + cr_assert(result == SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); + seed.n = 16; + GoSlice seedSlice2 = {&seed,sizeof(GoString),sizeof(GoString)}; + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys2); + cr_assert(result==SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); + cr_assert(not(eq(type(GoSlice_),seckeys,seckeys2))); +} diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 643fb904d9..4ebe4ecfba 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -142,7 +142,7 @@ void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxA encrypted->len = size; } -Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ +Test(cipher_encrypt_sha256xor, TestEncrypt){ unsigned char buff[BUFFER_SIZE]; unsigned char encryptedBuffer[BUFFER_SIZE]; unsigned char encryptedText[BUFFER_SIZE]; @@ -251,7 +251,7 @@ Test(cipher_encrypt_sha256xor, TestSha256XorEncrypt){ } } -Test(cipher_encrypt_sha256xor, TestSha256XorDecrypt){ +Test(cipher_encrypt_sha256xor, TestDecrypt){ unsigned char buff[BUFFER_SIZE]; unsigned char encrypted_buffer[BUFFER_SIZE]; unsigned char decrypted_buffer[BUFFER_SIZE]; diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 0021920190..f92f488546 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -343,3 +343,22 @@ Test(cipher_hash,TestMerkle){ cr_assert(eq(u8[32], out, h)); } +Test(cipher_hash, TestMustSumSHA256) { + char buffer_b[1024]; + GoSlice b = {buffer_b, 0, 1024}; + randBytes(&b, 128); + GoUint32 result; + cipher__SHA256 h; + memset(&h, 0, sizeof(cipher__SHA256)); + result = SKY_cipher_MustSumSHA256(b, 127, &h); + cr_assert(result == SKY_ERROR); + result = SKY_cipher_MustSumSHA256(b, 129, &h); + cr_assert(result == SKY_ERROR); + result = SKY_cipher_MustSumSHA256(b, 128, &h); + cr_assert(result == SKY_OK); + cipher__SHA256 sha; + cr_assert(not(eq(u8[32], h, sha))); + memset(&sha, 0, sizeof(cipher__SHA256)); + freshSumSHA256(b, &sha); + cr_assert(eq(u8[32], h, sha)); +} \ No newline at end of file diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index cba38ac40a..bcdfd96432 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -10,7 +10,6 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#include "skynumber.h" #define BUFFER_SIZE 1024 @@ -26,6 +25,8 @@ #define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" #define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" +#define forceLowS true + TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); Test(cipher_secp256k1_sig, TestSigRecover){ @@ -34,12 +35,12 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Number msg; secp256k1go__XY pubKey; secp256k1go__XY expected; - + memset(&pubKey, 0, sizeof(secp256k1go__XY)); memset(&expected, 0, sizeof(secp256k1go__XY)); memset(&sig, 0, sizeof(Signature)); memset(&msg, 0, sizeof(Number)); - + GoString R = {R1, strlen(R1)}; GoString S = {S1, strlen(S1)}; GoString MSG = {MSG1, strlen(MSG1)}; @@ -47,7 +48,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ GoString Y = {Y1, strlen(Y1)}; GoInt rid = 0; GoInt8 result; - + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); @@ -58,14 +59,14 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); - + R.p = R2; R.n = strlen(R2); S.p = S2; @@ -77,7 +78,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Y.p = Y2; Y.n = strlen(Y2); rid = 1; - + error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); @@ -88,14 +89,136 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - + error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - + GoInt8 equal; error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); -} \ No newline at end of file +} + +Test(cipher_secp256k1_sig, TestSigVerify) { + + Number msg; + Signature sig; + secp256k1go__XY key; + + memset(&msg, 0, sizeof(Number)); + memset(&sig, 0, sizeof(Signature)); + memset(&key, 0, sizeof(secp256k1go__XY)); + + GoString str = { + "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA", 64}; + GoUint32 result; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "98F9D784BA6C5C77BB7323D044C0FC9F2B27BAA0A5B0718FE88596CC56681980"; + result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; + result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "7d709f85a331813f9ae6046c56b3a42737abf4eb918b2e7afee285070e968b93"; + result = SKY_secp256k1go_Field_SetHex(&key.X, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + str.p = "26150d1a63b342986c373977b00131950cb5fc194643cad6ea36b5157eba4602"; + result = SKY_secp256k1go_Field_SetHex(&key.Y, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + GoUint8 valid; + result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); + cr_assert(valid, "sig.Verify 1"); + + str.p = "2c43a883f4edc2b66c67a7a355b9312a565bb3d33bb854af36a06669e2028377"; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "6b2fa9344462c958d4a674c2a42fbedf7d6159a5276eb658887e2e1b3915329b"; + result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "eddc6ea7f190c14a0aa74e41519d88d2681314f011d253665f301425caf86b86"; + result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + char buffer_xy[1024]; + cipher__PubKeySlice xy = {buffer_xy, 0, 1024}; + str.p = "02a60d70cfba37177d8239d018185d864b2bdd0caf5e175fd4454cc006fd2d75ac"; + str.n = 66; + result = SKY_base58_String2Hex(str, &xy); + cr_assert(result == SKY_OK, "SKY_base58_String2Hex"); + GoSlice xyConvert = {xy.data, xy.len, xy.cap}; + result = SKY_secp256k1go_XY_ParsePubkey(&key, xyConvert, &valid); + cr_assert(result == SKY_OK && valid, "SKY_secp256k1go_XY_ParsePubkey failed"); + result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); + cr_assert(valid, "sig.Verify 2"); +} + +Test(cipher_secp256k1_sig, TestSigSign) { + + Number sec; + Number msg; + Number non; + Signature sig; + GoInt recid; + + memset(&sec, 0, sizeof(Number)); + memset(&msg, 0, sizeof(Number)); + memset(&non, 0, sizeof(Number)); + + memset(&sig, 0, sizeof(Signature)); + + GoString str = { + "73641C99F7719F57D8F4BEB11A303AFCD190243A51CED8782CA6D3DBE014D146", 64}; + GoUint32 result; + result = SKY_secp256k1go_Number_SetHex(&sec, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&msg, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + str.p = "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + GoInt res; + + result = SKY_secp256k1go_Signature_Sign(&sig, &sec, &msg, &non, &recid, &res); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); + cr_assert(res == 1, "res failed %d", res); + + if (forceLowS) { + cr_assert(recid == 0, " recid failed %d", recid); + } else { + cr_assert(recid == 1, " recid failed %d", recid); + } + str.p = "98f9d784ba6c5c77bb7323d044c0fc9f2b27baa0a5b0718fe88596cc56681980"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + cr_assert(eq(type(Number), sig.R, non)); + + if (forceLowS) { + str.p = "1ca662aaefd6cc958ba4604fea999db133a75bf34c13334dabac7124ff0cfcc1"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + } else { + str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; + str.n = 64; + result = SKY_secp256k1go_Number_SetHex(&non, str); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + } + cr_assert(eq(type(Number), sig.S, non)); +} diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 4ba0c1995b..0a48e16e61 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -52,12 +52,17 @@ int makeNewBlock(cipher__SHA256* uxHash, Block__Handle* newBlock){ cr_assert(result == SKY_OK, "SKY_coin_Get_Block_Body failed"); result = SKY_coin_BlockBody_Hash(body, &bodyhash); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, 0, newBlock); + result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, zeroFeeCalculator, newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose( *newBlock ); return result; } +GoUint32_ fix121FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 121; + return SKY_OK; +} + Test(coin_block, TestNewBlock) { Block__Handle prevBlock = 0; Block__Handle newBlock = 0; @@ -88,7 +93,7 @@ Test(coin_block, TestNewBlock) { result = SKY_cipher_SumSHA256( slice, &hash ); cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); - result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, 0, &newBlock); + result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, zeroFeeCalculator, &newBlock); cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); registerHandleClose( newBlock ); @@ -105,14 +110,14 @@ Test(coin_block, TestNewBlock) { GoUint64 fee = 121; GoUint64 currentTime = 133; - result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fee, &newBlock); + result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fix121FeeCalculator, &newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose(newBlock); result = SKY_coin_GetBlockObject(newBlock, &pNewBlock); cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); coin__Transactions* pTransactions = NULL; SKY_coin_Get_Transactions_Object(transactions, &pTransactions); - cr_assert( eq( type(GoSlice), *((GoSlice*)&pNewBlock->Body.Transactions), *((GoSlice*)pTransactions)) ); + cr_assert( eq( type(coin__Transactions), pNewBlock->Body.Transactions, *pTransactions ) ); cr_assert( eq(pNewBlock->Head.Fee, fee * (GoUint64)( pTransactions->len ))); cr_assert( eq(pNewBlock->Head.Time, currentTime)); cr_assert( eq(pNewBlock->Head.BkSeq, pPrevBlock->Head.BkSeq + 1)); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 66967fe1e7..74c6f8d390 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -291,7 +291,7 @@ Test(coin_outputs, TestUxArrayHasDupes){ Test(coin_outputs, TestUxArraySub){ - int result; + int result, equal; coin__UxArray uxa, uxb, uxc, uxd; coin__UxArray t1, t2, t3, t4; @@ -315,12 +315,12 @@ Test(coin_outputs, TestUxArraySub){ cr_assert( result == SKY_OK, "cutSlice failed" ); result = concatSlices( &t2, &t3, elems_size, &uxc ); cr_assert( result == SKY_OK, "concatSlices failed" ); - + //TODO: Fix comparision memset(&uxd, 0, arraySize); result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); registerMemCleanup( uxd.data ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&uxb)) ); + cr_assert( eq( type(coin__UxArray), uxd, uxb ) ); memset(&uxd, 0, arraySize); result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); @@ -328,7 +328,8 @@ Test(coin_outputs, TestUxArraySub){ registerMemCleanup( uxd.data ); cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); cutSlice(&uxa, 0, 2, elems_size, &t1); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); + cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); // No intersection memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); @@ -338,8 +339,10 @@ Test(coin_outputs, TestUxArraySub){ result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); registerMemCleanup( t2.data ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); - cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); + cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); + cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); + //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); } int isUxArraySorted(coin__UxArray* uxa){ @@ -463,7 +466,335 @@ Test(coin_outputs, TestUxArraySwap){ cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); } -/********************************************************** -* 6 Tests involvinf AddressUxOuts were not done -* because the corresponding functions were not exported -*************************************************************/ +Test(coin_outputs, TestAddressUxOutsKeys){ + int result; + int test_count = 3; + coin__UxOut uxs[test_count]; + for(int i = 0; i < 3; i++){ + makeUxOut(&uxs[i]); + } + + coin__UxArray uxa = {uxs, test_count, test_count}; + AddressUxOuts_Handle uxOutsHandle; + result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + GoSlice_ keys = {NULL, 0, 0}; + result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed" ); + registerMemCleanup(keys.data); + cr_assert(keys.len == test_count); + cipher__Address* pKey = keys.data; + for(int i = 0; i < test_count; i++){ + //Check if every key matches uxout + int found = 0; + for(int j = 0; j < test_count; j++){ + if(memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0){ + found = 1; + } + } + cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); + found = 0; + if( i < test_count - 1){ + cipher__Address* pKey2 = pKey; + for(int j = i + 1; j < test_count; j++){ + pKey2++; + if(memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0){ + found = 1; + } + } + } + cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); + pKey++; + } +} + +Test(coin_outputs, TestAddressUxOutsSub){ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut* pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h2); + memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray ux5 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed" ); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + // One address should have been removed, because no elements + cr_assert(length == 2, "Invalid length %d", length); + GoInt8_ hasKey; + result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed" ); + cr_assert(hasKey == 0); + + memset(&ux3, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux3.data); + cr_assert(ux3.len == 1); + coin__UxOut* pData2 = ux3.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 1)) ); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsAdd){ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut* pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h2); + memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray ux5 = {pData + 1, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed" ); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + // One address should have been removed, because no elements + cr_assert(length == 3, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut* pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); + cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+2)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 2)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+3)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData+1)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + pData2 = ux2.data; + cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); + cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsFlatten){ + int result; + coin__UxArray uxa, emptyArray; + makeUxArray(&uxa, 3); + coin__UxOut* pData = uxa.data; + memcpy(&(pData+2)->Body.Address, &(pData+1)->Body.Address, sizeof(cipher__Address)); + memset(&emptyArray, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h); + cipher__Address emptyAddr; + makeAddress(&emptyAddr); + coin__UxArray ux1 = {pData, 1, 1}; + coin__UxArray ux2 = {pData+1, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + result = SKY_coin_AddressUxOuts_Set(h, &(pData+1)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + + coin__UxArray flatArray; + memset(&flatArray, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed" ); + registerMemCleanup( flatArray.data ); + cr_assert( flatArray.len == 3 ); + // emptyAddr should not be in the array + coin__UxOut* pData2 = flatArray.data; + for(int i = 0; i < flatArray.len; pData2++, i++){ + int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); + cr_assert(cmp != 0); + } + pData2 = flatArray.data; + int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); + if(cmp == 0){ + cr_assert( eq( type(coin__UxOut), *pData2, *pData ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+2) ) ); + cr_assert( eq( type(cipher__Address), pData2->Body.Address, pData->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+1)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData+2)->Body.Address ) ); + }else{ + cr_assert( eq( type(coin__UxOut), *pData2, *(pData+1) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+2) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData) ) ); + cr_assert( eq( type(cipher__Address), pData2->Body.Address, (pData+1)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+2)->Body.Address ) ); + cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData)->Body.Address ) ); + } +} + + +Test(coin_outputs, TestNewAddressUxOuts){ + int result; + coin__UxArray uxa, ux2; + makeUxArray(&uxa, 6); + coin__UxOut* pData = uxa.data; + memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 3)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 4)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&uxa, &h); + cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); + registerHandleClose(h); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h, &length); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); + cr_assert(length == 3); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut* pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData+3)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 3); + pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+2) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+3) ) ); + cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+4) ) ); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData+5)->Body.Address, &ux2); + cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+5) ) ); +} diff --git a/lib/cgo/tests/check_coin.transaction2.c b/lib/cgo/tests/check_coin.transaction2.c deleted file mode 100644 index a79149b296..0000000000 --- a/lib/cgo/tests/check_coin.transaction2.c +++ /dev/null @@ -1,604 +0,0 @@ -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "skycriterion.h" -#include "transutil.h" - -TestSuite(coin_transactions, .init = setup, .fini = teardown); - -Test(coin_transactions, TestTransactionVerifyInput){ - int result; - Transaction__Handle handle; - coin__Transaction* ptx; - ptx = makeTransaction(&handle); - result = SKY_coin_Transaction_VerifyInput(handle, NULL); - cr_assert( result != SKY_OK ); - coin__UxArray ux; - memset(&ux, 0, sizeof(coin__UxArray)); - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - memset(&ux, 0, sizeof(coin__UxArray)); - ux.data = malloc(3 * sizeof(coin__UxOut)); - cr_assert(ux.data != NULL); - registerMemCleanup(ux.data); - ux.len = 3; - ux.cap = 3; - memset(ux.data, 0, 3 * sizeof(coin__UxOut)); - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - coin__UxOut uxOut; - cipher__SecKey seckey; - cipher__Sig sig; - cipher__SHA256 hash; - - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - memset(&sig, 0, sizeof(cipher__Sig)); - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Invalid Tx Inner Hash - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - memset( ptx->InnerHash, 0, sizeof(cipher__SHA256) ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Ux hash mismatch - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - memset( &uxOut, 0, sizeof(coin__UxOut) ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Invalid signature - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result != SKY_OK ); - - //Valid - result = makeUxOutWithSecret(&uxOut, &seckey); - cr_assert( result == SKY_OK ); - ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); - cr_assert( result == SKY_OK ); - ux.data = &uxOut; - ux.len = 1; ux.cap = 1; - result = SKY_coin_Transaction_VerifyInput(handle, &ux); - cr_assert( result == SKY_OK ); -} - -Test(coin_transactions, TestTransactionSignInputs){ - int result; - coin__Transaction* ptx; - Transaction__Handle handle; - coin__UxOut ux, ux2; - cipher__SecKey seckey, seckey2; - cipher__SHA256 hash, hash2; - cipher__Address addr, addr2; - cipher__PubKey pubkey; - GoUint16 r; - GoSlice keys; - - //Error if txns already signed - ptx = makeEmptyTransaction(&handle); - result = SKY_coin_Transaction_ResetSignatures(handle, 1); - cr_assert( result == SKY_OK ); - - memset( &seckey, 0, sizeof(cipher__SecKey) ); - keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result != SKY_OK ); - - // Panics if not enough keys - ptx = makeEmptyTransaction(&handle); - memset(&seckey, 0, sizeof(cipher__SecKey)); - memset(&seckey2, 0, sizeof(cipher__SecKey)); - result = makeUxOutWithSecret( &ux, &seckey ); - cr_assert( result == SKY_OK ); - result = SKY_coin_UxOut_Hash(&ux, &hash); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result == SKY_OK ); - result = makeUxOutWithSecret( &ux2, &seckey2 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_UxOut_Hash(&ux2, &hash2); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_PushInput(handle, &hash2, &r); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 40, 80); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Sigs.len == 0 ); - keys.data = &seckey; keys.len = 1; keys.cap = 1; - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result != SKY_OK ); - cr_assert( ptx->Sigs.len == 0 ); - - // Valid signing - result = SKY_coin_Transaction_HashInner( handle, &hash ); - cr_assert( result == SKY_OK ); - keys.data = malloc(2 * sizeof(cipher__SecKey)); - cr_assert( keys.data != NULL ); - registerMemCleanup( keys.data ); - keys.len = keys.cap = 2; - memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); - memcpy(((cipher__SecKey*)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); - result = SKY_coin_Transaction_SignInputs(handle, keys); - cr_assert( result == SKY_OK ); - cr_assert(ptx->Sigs.len == 2); - result = SKY_coin_Transaction_HashInner( handle, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, hash2) ); - - result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddressFromPubKey( &pubkey, &addr ); - cr_assert( result == SKY_OK ); - result = SKY_cipher_PubKeyFromSecKey(&seckey2, &pubkey); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddressFromPubKey( &pubkey, &addr2 ); - cr_assert( result == SKY_OK ); - - cipher__SHA256 addHash, addHash2; - result = SKY_cipher_AddSHA256(&hash, (cipher__SHA256*)ptx->In.data, &addHash); - cr_assert( result == SKY_OK ); - result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256*)ptx->In.data) + 1, &addHash2); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig*)ptx->Sigs.data); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig*)ptx->Sigs.data)+1); - cr_assert( result == SKY_OK ); - result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig*)ptx->Sigs.data)+1); - cr_assert( result != SKY_OK ); - result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig*)ptx->Sigs.data); - cr_assert( result != SKY_OK ); -} - -Test(coin_transactions, TestTransactionHashInner){ - int result; - Transaction__Handle handle1 = 0, handle2 = 0; - coin__Transaction* ptx = NULL; - coin__Transaction* ptx2 = NULL; - ptx = makeTransaction(&handle1); - cipher__SHA256 hash, nullHash; - result = SKY_coin_Transaction_HashInner( handle1, &hash ); - cr_assert( result == SKY_OK ); - memset( &nullHash, 0, sizeof(cipher__SHA256) ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); - - // If tx.In is changed, hash should change - ptx2 = copyTransaction( handle1, &handle2 ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); - cr_assert( ptx != ptx2 ); - cr_assert(ptx2->In.len > 0); - coin__UxOut uxOut; - makeUxOut( &uxOut ); - cipher__SHA256* phash = ptx2->In.data; - result = SKY_coin_UxOut_Hash( &uxOut, phash ); - cr_assert( result == SKY_OK ); - cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); - cipher__SHA256 hash1, hash2; - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); - - // If tx.Out is changed, hash should change - handle2 = 0; - ptx2 = copyTransaction( handle1, &handle2 ); - cr_assert( ptx != ptx2 ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2 ) ); - coin__TransactionOutput* output = ptx2->Out.data; - cipher__Address addr; - makeAddress( &addr ); - memcpy( &output->Address, &addr, sizeof(cipher__Address) ); - cr_assert( not( eq( type(coin__Transaction), *ptx, *ptx2 ) ) ); - cr_assert(eq(type(cipher__Address), addr, output->Address)); - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) ); - - // If tx.Head is changed, hash should not change - ptx2 = copyTransaction( handle1, &handle2 ); - int len = ptx2->Sigs.len; - cipher__Sig* newSigs = malloc((len + 1) * sizeof(cipher__Sig)); - cr_assert( newSigs != NULL ); - registerMemCleanup( newSigs ); - memcpy( newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); - result = SKY_coin_Transaction_ResetSignatures(handle2, len + 1); - cr_assert( result == SKY_OK ); - memcpy( ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); - newSigs += len; - memset( newSigs, 0, sizeof(cipher__Sig) ); - result = SKY_coin_Transaction_HashInner( handle1, &hash1 ); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_HashInner( handle2, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ); -} - -Test(coin_transactions, TestTransactionSerialization){ - int result; - coin__Transaction* ptx; - Transaction__Handle handle; - ptx = makeTransaction(&handle); - GoSlice_ data; - memset( &data, 0, sizeof(GoSlice_) ); - result = SKY_coin_Transaction_Serialize( handle, &data ); - cr_assert( result == SKY_OK ); - registerMemCleanup( data.data ); - coin__Transaction* ptx2; - Transaction__Handle handle2; - GoSlice d = {data.data, data.len, data.cap}; - result = SKY_coin_TransactionDeserialize(d, &handle2); - cr_assert( result == SKY_OK ); - result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); - cr_assert( result == SKY_OK ); - cr_assert( eq( type(coin__Transaction), *ptx, *ptx2) ); -} - -Test(coin_transactions, TestTransactionOutputHours){ - coin__Transaction* ptx; - Transaction__Handle handle; - ptx = makeEmptyTransaction(&handle); - cipher__Address addr; - makeAddress(&addr); - int result; - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 100); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 200); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 500); - cr_assert( result == SKY_OK ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0); - cr_assert( result == SKY_OK ); - GoUint64 hours; - result = SKY_coin_Transaction_OutputHours(handle, &hours); - cr_assert( result == SKY_OK ); - cr_assert( hours == 800 ); - makeAddress(&addr); - result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); - result = SKY_coin_Transaction_OutputHours(handle, &hours); - cr_assert( result != SKY_OK ); -} - -Test(coin_transactions, TestTransactionsHashes){ - int result; - GoSlice_ hashes = {NULL, 0, 0}; - Transactions__Handle hTxns; - result = makeTransactions(4, &hTxns); - cr_assert( result == SKY_OK ); - - result = SKY_coin_Transactions_Hashes(hTxns, &hashes); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Hashes failed" ); - registerMemCleanup( hashes.data ); - cr_assert( hashes.len == 4 ); - cipher__SHA256* ph = hashes.data; - cipher__SHA256 hash; - for(int i = 0; i < 4; i++){ - Transaction__Handle handle; - result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Hash(handle, &hash); - cr_assert( result == SKY_OK, "SKY_coin_Transaction_Hash failed" ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], *ph, hash) ); - ph++; - } -} - - -Test(coin_transactions, TestTransactionsTruncateBytesTo){ - int result; - Transactions__Handle h1, h2; - result = makeTransactions(10, &h1); - cr_assert( result == SKY_OK ); - GoInt length; - result = SKY_coin_Transactions_Length(h1, &length); - cr_assert( result == SKY_OK ); - int trunc = 0; - GoInt size; - for(int i = 0; i < length / 2; i++){ - Transaction__Handle handle; - result = SKY_coin_Transactions_GetAt(h1, i, &handle); - registerHandleClose(handle); - cr_assert( result == SKY_OK ); - result = SKY_coin_Transaction_Size(handle, &size); - trunc += size; - cr_assert( result == SKY_OK, "SKY_coin_Transaction_Size failed" ); - } - result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerHandleClose(h2); - - GoInt length2; - result = SKY_coin_Transactions_Length(h2, &length2); - cr_assert( result == SKY_OK ); - cr_assert( length2 == length / 2 ); - result = SKY_coin_Transactions_Size( h2, &size ); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); - cr_assert( trunc == size ); - - trunc++; - result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed" ); - registerHandleClose(h2); - - // Stepping into next boundary has same cutoff, must exceed - result = SKY_coin_Transactions_Length(h2, &length2); - cr_assert( result == SKY_OK ); - cr_assert( length2 == length / 2 ); - result = SKY_coin_Transactions_Size( h2, &size ); - cr_assert( result == SKY_OK, "SKY_coin_Transactions_Size failed" ); - cr_assert( trunc - 1 == size ); -} - -typedef struct { - GoUint64 coins; - GoUint64 hours; -} test_ux; - -typedef struct { - test_ux* inUxs; - test_ux* outUxs; - int sizeIn; - int sizeOut; - GoUint64 headTime; - int failure; -} test_case; - -int makeTestCaseArrays(test_ux* elems, int size, coin__UxArray* pArray){ - if(size <= 0){ - pArray->len = 0; - pArray->cap = 0; - pArray->data = NULL; - return SKY_OK; - } - int elems_size = sizeof(coin__UxOut); - void* data; - data = malloc(size * elems_size); - if( data == NULL) - return SKY_ERROR; - registerMemCleanup( data ); - pArray->data = data; - pArray->len = size; - pArray->cap = size; - coin__UxOut* p = data; - for(int i = 0; i < size; i++){ - p->Body.Coins = elems[i].coins; - p->Body.Hours = elems[i].hours; - p++; - } - return SKY_OK; -} - -Test(coin_transactions, TestVerifyTransactionCoinsSpending){ - GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; - GoUint64 Million = 1000000; - - //Input coins overflow - test_ux in1[] = { - {MaxUint64 - Million + 1, 10}, - {Million, 0} - }; - - //Output coins overflow - test_ux in2[] = { - {10 * Million, 10} - }; - test_ux out2[] = { - {MaxUint64 - 10 * Million + 1, 0}, - {20 * Million, 1} - }; - - //Insufficient coins - test_ux in3[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out3[] = { - {20 * Million, 1}, - {10 * Million, 1} - }; - - //Destroyed coins - test_ux in4[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out4[] = { - {5 * Million, 1}, - {10 * Million, 1} - }; - - //Valid - test_ux in5[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - test_ux out5[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - test_case tests[] = { - {in1, NULL, 2, 0, 0, 1}, //Input coins overflow - {in2, out2, 1, 2, 0, 1}, //Output coins overflow - {in3, out3, 2, 2, 0, 1}, //Destroyed coins - {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - {in5, out5, 2, 3, 0, 0} //Valid - }; - - coin__UxArray inArray; - coin__UxArray outArray; - int result; - int count = sizeof(tests) / sizeof(tests[0]); - for( int i = 0; i < count; i++){ - result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); - cr_assert(result == SKY_OK); - result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); - cr_assert(result == SKY_OK); - result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); - if( tests[i].failure ) - cr_assert( result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", i+1 ); - else - cr_assert( result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", i+1 ); - } -} - -Test(coin_transactions, TestVerifyTransactionHoursSpending){ - GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; - GoUint64 Million = 1000000; - - //Input hours overflow - test_ux in1[] = { - {3 * Million, MaxUint64 - Million + 1}, - {Million, Million} - }; - - //Insufficient coin hours - test_ux in2[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - - test_ux out2[] = { - {15 * Million, 10}, - {10 * Million, 11} - }; - - //coin hours time calculation overflow - test_ux in3[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - - test_ux out3[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - test_ux in4[] = { - {10 * Million, MaxUint64} - }; - - test_ux out4[] = { - {10 * Million, 1} - }; - - //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) - test_ux in5[] = { - {10 * Million, MaxUint64} - }; - - test_ux out5[] = { - {10 * Million, 0} - }; - - //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) - test_ux in6[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - test_ux out6[] = { - {15 * Million, 10}, - {10 * Million, 11} - }; - - //valid - test_ux in7[] = { - {10 * Million, 10}, - {15 * Million, 10} - }; - - test_ux out7[] = { - {10 * Million, 11}, - {10 * Million, 1}, - {5 * Million, 0} - }; - - test_case tests[] = { - {in1, NULL, 2, 0, 0, 1}, //Input hours overflow - {in2, out2, 2, 2, 0, 1}, //Insufficient coin hours - {in3, out3, 2, 3, MaxUint64, 1}, //coin hours time calculation overflow - {in4, out4, 1, 1, Million, 1}, //Invalid (coin hours overflow when adding earned hours, which is treated as 0, and now enough coin hours) - {in5, out5, 1, 1, 0, 0}, //Valid (coin hours overflow when adding earned hours, which is treated as 0, but not sending any hours) - {in6, out6, 2, 2, 1492707255, 0}, //Valid (base inputs have insufficient coin hours, but have sufficient after adjusting coinhours by headTime) - {in7, out7, 2, 3, 0, 0}, //Valid - }; - coin__UxArray inArray; - coin__UxArray outArray; - int result; - int count = sizeof(tests) / sizeof(tests[0]); - for( int i = 0; i < count; i++){ - result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); - cr_assert(result == SKY_OK); - result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); - cr_assert(result == SKY_OK); - result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, &inArray, &outArray); - if( tests[i].failure ) - cr_assert( result != SKY_OK, "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i+1 ); - else - cr_assert( result == SKY_OK, "SKY_coin_VerifyTransactionHoursSpending failed %d", i+1 ); - } -} - - -/******************************************************* -* Tests not done because of wrapper functions were not created: -* TestTransactionsFees -* TestSortTransactions -********************************************************/ diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 8574c80878..74e7666472 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -12,113 +12,117 @@ #include "skycriterion.h" #include "transutil.h" -Test(coin_transaction, TestTransactionVerify) -{ +TestSuite(coin_transaction, .init = setup, .fini = teardown); + +GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; +GoUint64 Million = 1000000; + +Test(coin_transaction, TestTransactionVerify) { int result; - coin__Transaction* ptx; + coin__Transaction *ptx; Transaction__Handle handle; // Mismatch header hash ptx = makeTransaction(&handle); memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // No inputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetInputs(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // No outputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetOutputs(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - //Invalid number of Sigs + // Invalid number of Sigs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); result = SKY_coin_Transaction_ResetSignatures(handle, 20); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); int MaxUint16 = 0xFFFF; // Too many sigs & inputs ptx = makeTransaction(&handle); result = SKY_coin_Transaction_ResetSignatures(handle, MaxUint16); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); - + cr_assert(result != SKY_OK); // Duplicate inputs coin__UxOut ux; cipher__SecKey seckey; cipher__SHA256 sha256; - makeUxOutWithSecret( &ux, &seckey ); - ptx = makeTransactionFromUxOut( &ux, &seckey, &handle); + makeUxOutWithSecret(&ux, &seckey); + ptx = makeTransactionFromUxOut(&ux, &seckey, &handle); memcpy(&sha256, ptx->In.data, sizeof(cipher__SHA256)); GoUint16 r; result = SKY_coin_Transaction_PushInput(handle, &sha256, &r); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); GoSlice seckeys; seckeys.data = malloc(sizeof(cipher__SecKey) * 2); - cr_assert( seckeys.data != NULL ); - registerMemCleanup( seckeys.data ); + cr_assert(seckeys.data != NULL); + registerMemCleanup(seckeys.data); seckeys.len = seckeys.cap = 2; - memcpy( seckeys.data, &seckey, sizeof(cipher__SecKey) ); - memcpy( ((cipher__SecKey*)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey) ); - result = SKY_coin_Transaction_SignInputs( handle, seckeys ); + memcpy(seckeys.data, &seckey, sizeof(cipher__SecKey)); + memcpy(((cipher__SecKey *)seckeys.data) + 1, &seckey, sizeof(cipher__SecKey)); + result = SKY_coin_Transaction_SignInputs(handle, seckeys); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - //Duplicate outputs + // Duplicate outputs ptx = makeTransaction(&handle); - coin__TransactionOutput* pOutput = ptx->Out.data; + coin__TransactionOutput *pOutput = ptx->Out.data; cipher__Address addr; memcpy(&addr, &pOutput->Address, sizeof(cipher__Address)); - result = SKY_coin_Transaction_PushOutput(handle, &addr, pOutput->Coins, pOutput->Hours); - cr_assert( result == SKY_OK ); + result = SKY_coin_Transaction_PushOutput(handle, &addr, pOutput->Coins, + pOutput->Hours); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // Invalid signature, empty ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); // Output coins are 0 ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 0; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; // Output coin overflow @@ -126,143 +130,892 @@ Test(coin_transaction, TestTransactionVerify) pOutput = ptx->Out.data; pOutput->Coins = MaxUint64 - 3000000; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result != SKY_OK ); + cr_assert(result != SKY_OK); - // Output coins are not multiples of 1e6 (valid, decimal restriction is not enforced here) + // Output coins are not multiples of 1e6 (valid, decimal restriction is not + // enforced here) ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins += 10; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_ResetSignatures(handle, 0); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); cipher__PubKey pubkey; result = SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - cr_assert( result == SKY_OK ); - seckeys.data = &seckey; seckeys.len = 1; seckeys.cap = 1; + cr_assert(result == SKY_OK); + seckeys.data = &seckey; + seckeys.len = 1; + seckeys.cap = 1; result = SKY_coin_Transaction_SignInputs(handle, seckeys); - cr_assert( result == SKY_OK ); - cr_assert( pOutput->Coins % 1000000 != 0 ); + cr_assert(result == SKY_OK); + cr_assert(pOutput->Coins % 1000000 != 0); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); - //Valid + // Valid ptx = makeTransaction(&handle); pOutput = ptx->Out.data; pOutput->Coins = 10000000; pOutput++; pOutput->Coins = 1000000; result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_Verify(handle); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); } - -Test(coin_transaction, TestTransactionPushInput) -{ +Test(coin_transaction, TestTransactionPushInput) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; coin__UxOut ux; ptx = makeEmptyTransaction(&handle); - makeUxOut( &ux ); + makeUxOut(&ux); cipher__SHA256 hash; - result = SKY_coin_UxOut_Hash( &ux, &hash ); - cr_assert( result == SKY_OK ); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); GoUint16 r; result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result == SKY_OK ); - cr_assert( r == 0 ); - cr_assert( ptx->In.len == 1 ); - cipher__SHA256* pIn = ptx->In.data; - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *pIn) ); + cr_assert(result == SKY_OK); + cr_assert(r == 0); + cr_assert(ptx->In.len == 1); + cipher__SHA256 *pIn = ptx->In.data; + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, *pIn)); GoUint16 MaxUint16 = 0xFFFF; int len = ptx->In.len; - void* data = malloc(len * sizeof(cipher__SHA256)); + void *data = malloc(len * sizeof(cipher__SHA256)); cr_assert(data != NULL); registerMemCleanup(data); - memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256) ); + memcpy(data, ptx->In.data, len * sizeof(cipher__SHA256)); result = SKY_coin_Transaction_ResetInputs(handle, MaxUint16 + len); - cr_assert( result == SKY_OK ); + cr_assert(result == SKY_OK); memcpy(ptx->In.data, data, len * sizeof(cipher__Sig)); freeRegisteredMemCleanup(data); - makeUxOut( &ux ); - result = SKY_coin_UxOut_Hash( &ux, &hash ); - cr_assert( result == SKY_OK ); + makeUxOut(&ux); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); result = SKY_coin_Transaction_PushInput(handle, &hash, &r); - cr_assert( result != SKY_OK ); - + cr_assert(result != SKY_OK); } - -Test(coin_transaction, TestTransactionPushOutput) -{ +Test(coin_transaction, TestTransactionPushOutput) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeEmptyTransaction(&handle); cipher__Address addr; - makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( handle, &addr, 100, 150 ); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Out.len == 1 ); - coin__TransactionOutput* pOutput = ptx->Out.data; + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 100, 150); + cr_assert(result == SKY_OK); + cr_assert(ptx->Out.len == 1); + coin__TransactionOutput *pOutput = ptx->Out.data; coin__TransactionOutput output; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = 100; output.Hours = 150; - cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); - for(int i = 1; i < 20; i++){ - makeAddress( &addr ); - result = SKY_coin_Transaction_PushOutput( handle, &addr, i * 100, i * 50 ); - cr_assert( result == SKY_OK ); - cr_assert( ptx->Out.len == i + 1 ); + cr_assert(eq(type(coin__TransactionOutput), output, *pOutput)); + for (int i = 1; i < 20; i++) { + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, i * 100, i * 50); + cr_assert(result == SKY_OK); + cr_assert(ptx->Out.len == i + 1); pOutput = ptx->Out.data; pOutput += i; memcpy(&output.Address, &addr, sizeof(cipher__Address)); output.Coins = i * 100; output.Hours = i * 50; - cr_assert( eq( type(coin__TransactionOutput), output, *pOutput ) ); + cr_assert(eq(type(coin__TransactionOutput), output, *pOutput)); } } -Test(coin_transaction, TestTransactionHash) -{ +Test(coin_transaction, TestTransactionHash) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeEmptyTransaction(&handle); cipher__SHA256 nullHash, hash1, hash2; - memset( &nullHash, 0, sizeof(cipher__SHA256) ); - result = SKY_coin_Transaction_Hash( handle, &hash1 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], nullHash, hash1) ) ); - result = SKY_coin_Transaction_HashInner( handle, &hash2 ); - cr_assert( result == SKY_OK ); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], hash2, hash1) ) ); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + result = SKY_coin_Transaction_Hash(handle, &hash1); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], nullHash, hash1))); + result = SKY_coin_Transaction_HashInner(handle, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash2, hash1))); } - -Test(coin_transaction, TestTransactionUpdateHeader) -{ +Test(coin_transaction, TestTransactionUpdateHeader) { int result; Transaction__Handle handle; - coin__Transaction* ptx; + coin__Transaction *ptx; ptx = makeTransaction(&handle); cipher__SHA256 hash, nullHash, hashInner; memcpy(&hash, &ptx->InnerHash, sizeof(cipher__SHA256)); memset(&ptx->InnerHash, 0, sizeof(cipher__SHA256)); memset(&nullHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_UpdateHeader(handle); - cr_assert( not ( eq( u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash) ) ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash) ); - result = SKY_coin_Transaction_HashInner( handle, &hashInner ); - cr_assert( result == SKY_OK ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash) ); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], ptx->InnerHash, nullHash))); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, ptx->InnerHash)); + result = SKY_coin_Transaction_HashInner(handle, &hashInner); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash)); +} + +Test(coin_transaction, TestTransactionsSize) { + int result; + Transactions__Handle txns; + result = makeTransactions(10, &txns); + cr_assert(result == SKY_OK); + GoInt size = 0; + for (size_t i = 0; i < 10; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(txns, i, &handle); + registerHandleClose(handle); + cr_assert(result == SKY_OK); + cipher__PubKeySlice p1 = {NULL, 0, 0}; + result = SKY_coin_Transaction_Serialize(handle, &p1); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Serialize failed"); + GoInt count; + size += p1.len; + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size failed"); + } + GoInt sizeTransactions; + result = SKY_coin_Transactions_Size(txns, &sizeTransactions); + cr_assert(size != 0); + cr_assert(sizeTransactions == size); +} + +Test(coin_transactions, TestTransactionVerifyInput) { + int result; + Transaction__Handle handle; + coin__Transaction *ptx; + ptx = makeTransaction(&handle); + result = SKY_coin_Transaction_VerifyInput(handle, NULL); + cr_assert(result != SKY_OK); + coin__UxArray ux; + memset(&ux, 0, sizeof(coin__UxArray)); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + memset(&ux, 0, sizeof(coin__UxArray)); + ux.data = malloc(3 * sizeof(coin__UxOut)); + cr_assert(ux.data != NULL); + registerMemCleanup(ux.data); + ux.len = 3; + ux.cap = 3; + memset(ux.data, 0, 3 * sizeof(coin__UxOut)); + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + coin__UxOut uxOut; + cipher__SecKey seckey; + cipher__Sig sig; + cipher__SHA256 hash; + + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 0); + cr_assert(result == SKY_OK); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + memset(&sig, 0, sizeof(cipher__Sig)); + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + memcpy(ptx->Sigs.data, &sig, sizeof(cipher__Sig)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Invalid Tx Inner Hash + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Ux hash mismatch + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + memset(&uxOut, 0, sizeof(coin__UxOut)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Invalid signature + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result != SKY_OK); + + // Valid + result = makeUxOutWithSecret(&uxOut, &seckey); + cr_assert(result == SKY_OK); + ptx = makeTransactionFromUxOut(&uxOut, &seckey, &handle); + cr_assert(result == SKY_OK); + ux.data = &uxOut; + ux.len = 1; + ux.cap = 1; + result = SKY_coin_Transaction_VerifyInput(handle, &ux); + cr_assert(result == SKY_OK); +} + +Test(coin_transactions, TestTransactionSignInputs) { + int result; + coin__Transaction *ptx; + Transaction__Handle handle; + coin__UxOut ux, ux2; + cipher__SecKey seckey, seckey2; + cipher__SHA256 hash, hash2; + cipher__Address addr, addr2; + cipher__PubKey pubkey; + GoUint16 r; + GoSlice keys; + + // Error if txns already signed + ptx = makeEmptyTransaction(&handle); + result = SKY_coin_Transaction_ResetSignatures(handle, 1); + cr_assert(result == SKY_OK); + + memset(&seckey, 0, sizeof(cipher__SecKey)); + keys.data = &seckey; + keys.len = 1; + keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result != SKY_OK); + + // Panics if not enough keys + ptx = makeEmptyTransaction(&handle); + memset(&seckey, 0, sizeof(cipher__SecKey)); + memset(&seckey2, 0, sizeof(cipher__SecKey)); + result = makeUxOutWithSecret(&ux, &seckey); + cr_assert(result == SKY_OK); + result = SKY_coin_UxOut_Hash(&ux, &hash); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_PushInput(handle, &hash, &r); + cr_assert(result == SKY_OK); + result = makeUxOutWithSecret(&ux2, &seckey2); + cr_assert(result == SKY_OK); + result = SKY_coin_UxOut_Hash(&ux2, &hash2); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_PushInput(handle, &hash2, &r); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 40, 80); + cr_assert(result == SKY_OK); + cr_assert(ptx->Sigs.len == 0); + keys.data = &seckey; + keys.len = 1; + keys.cap = 1; + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result != SKY_OK); + cr_assert(ptx->Sigs.len == 0); + + // Valid signing + result = SKY_coin_Transaction_HashInner(handle, &hash); + cr_assert(result == SKY_OK); + keys.data = malloc(2 * sizeof(cipher__SecKey)); + cr_assert(keys.data != NULL); + registerMemCleanup(keys.data); + keys.len = keys.cap = 2; + memcpy(keys.data, &seckey, sizeof(cipher__SecKey)); + memcpy(((cipher__SecKey *)keys.data) + 1, &seckey2, sizeof(cipher__SecKey)); + result = SKY_coin_Transaction_SignInputs(handle, keys); + cr_assert(result == SKY_OK); + cr_assert(ptx->Sigs.len == 2); + result = SKY_coin_Transaction_HashInner(handle, &hash2); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, hash2)); + + result = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddressFromPubKey(&pubkey, &addr); + cr_assert(result == SKY_OK); + result = SKY_cipher_PubKeyFromSecKey(&seckey2, &pubkey); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddressFromPubKey(&pubkey, &addr2); + cr_assert(result == SKY_OK); + + cipher__SHA256 addHash, addHash2; + result = + SKY_cipher_AddSHA256(&hash, (cipher__SHA256 *)ptx->In.data, &addHash); + cr_assert(result == SKY_OK); + result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256 *)ptx->In.data) + 1, + &addHash2); + cr_assert(result == SKY_OK); + result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig *)ptx->Sigs.data); + cr_assert(result == SKY_OK); + result = + SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig *)ptx->Sigs.data) + 1); + cr_assert(result == SKY_OK); + result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig *)ptx->Sigs.data) + 1); + cr_assert(result != SKY_OK); + result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig *)ptx->Sigs.data); + cr_assert(result != SKY_OK); +} + +Test(coin_transactions, TestTransactionHashInner) { + int result; + Transaction__Handle handle1 = 0, handle2 = 0; + coin__Transaction *ptx = NULL; + coin__Transaction *ptx2 = NULL; + ptx = makeTransaction(&handle1); + cipher__SHA256 hash, nullHash; + result = SKY_coin_Transaction_HashInner(handle1, &hash); + cr_assert(result == SKY_OK); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], nullHash, hash))); + + // If tx.In is changed, hash should change + ptx2 = copyTransaction(handle1, &handle2); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); + cr_assert(ptx != ptx2); + cr_assert(ptx2->In.len > 0); + coin__UxOut uxOut; + makeUxOut(&uxOut); + cipher__SHA256 *phash = ptx2->In.data; + result = SKY_coin_UxOut_Hash(&uxOut, phash); + cr_assert(result == SKY_OK); + cr_assert(not(eq(type(coin__Transaction), *ptx, *ptx2))); + cipher__SHA256 hash1, hash2; + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2))); + + // If tx.Out is changed, hash should change + handle2 = 0; + ptx2 = copyTransaction(handle1, &handle2); + cr_assert(ptx != ptx2); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); + coin__TransactionOutput *output = ptx2->Out.data; + cipher__Address addr; + makeAddress(&addr); + memcpy(&output->Address, &addr, sizeof(cipher__Address)); + cr_assert(not(eq(type(coin__Transaction), *ptx, *ptx2))); + cr_assert(eq(type(cipher__Address), addr, output->Address)); + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2))); + + // If tx.Head is changed, hash should not change + ptx2 = copyTransaction(handle1, &handle2); + int len = ptx2->Sigs.len; + cipher__Sig *newSigs = malloc((len + 1) * sizeof(cipher__Sig)); + cr_assert(newSigs != NULL); + registerMemCleanup(newSigs); + memcpy(newSigs, ptx2->Sigs.data, len * sizeof(cipher__Sig)); + result = SKY_coin_Transaction_ResetSignatures(handle2, len + 1); + cr_assert(result == SKY_OK); + memcpy(ptx2->Sigs.data, newSigs, len * sizeof(cipher__Sig)); + newSigs += len; + memset(newSigs, 0, sizeof(cipher__Sig)); + result = SKY_coin_Transaction_HashInner(handle1, &hash1); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_HashInner(handle2, &hash2); + cr_assert(result == SKY_OK); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)); +} + +Test(coin_transactions, TestTransactionSerialization) { + int result; + coin__Transaction *ptx; + Transaction__Handle handle; + ptx = makeTransaction(&handle); + GoSlice_ data; + memset(&data, 0, sizeof(GoSlice_)); + result = SKY_coin_Transaction_Serialize(handle, &data); + cr_assert(result == SKY_OK); + registerMemCleanup(data.data); + coin__Transaction *ptx2; + Transaction__Handle handle2; + GoSlice d = {data.data, data.len, data.cap}; + result = SKY_coin_TransactionDeserialize(d, &handle2); + cr_assert(result == SKY_OK); + result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); + cr_assert(result == SKY_OK); + cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); +} + +Test(coin_transactions, TestTransactionOutputHours) { + coin__Transaction *ptx; + Transaction__Handle handle; + ptx = makeEmptyTransaction(&handle); + cipher__Address addr; + makeAddress(&addr); + int result; + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 100); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 200); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 500); + cr_assert(result == SKY_OK); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0); + cr_assert(result == SKY_OK); + GoUint64 hours; + result = SKY_coin_Transaction_OutputHours(handle, &hours); + cr_assert(result == SKY_OK); + cr_assert(hours == 800); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, + 0xFFFFFFFFFFFFFFFF - 700); + result = SKY_coin_Transaction_OutputHours(handle, &hours); + cr_assert(result != SKY_OK); +} + +Test(coin_transactions, TestTransactionsHashes) { + int result; + GoSlice_ hashes = {NULL, 0, 0}; + Transactions__Handle hTxns; + result = makeTransactions(4, &hTxns); + cr_assert(result == SKY_OK); + + result = SKY_coin_Transactions_Hashes(hTxns, &hashes); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Hashes failed"); + registerMemCleanup(hashes.data); + cr_assert(hashes.len == 4); + cipher__SHA256 *ph = hashes.data; + cipher__SHA256 hash; + for (int i = 0; i < 4; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_Hash(handle, &hash); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Hash failed"); + cr_assert(eq(u8[sizeof(cipher__SHA256)], *ph, hash)); + ph++; + } +} + +Test(coin_transactions, TestTransactionsTruncateBytesTo) { + int result; + Transactions__Handle h1, h2; + result = makeTransactions(10, &h1); + cr_assert(result == SKY_OK); + GoInt length; + result = SKY_coin_Transactions_Length(h1, &length); + cr_assert(result == SKY_OK); + int trunc = 0; + GoInt size; + for (int i = 0; i < length / 2; i++) { + Transaction__Handle handle; + result = SKY_coin_Transactions_GetAt(h1, i, &handle); + registerHandleClose(handle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_Size(handle, &size); + trunc += size; + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size failed"); + } + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed"); + registerHandleClose(h2); + + GoInt length2; + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert(result == SKY_OK); + cr_assert(length2 == length / 2); + result = SKY_coin_Transactions_Size(h2, &size); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Size failed"); + cr_assert(trunc == size); + + trunc++; + result = SKY_coin_Transactions_TruncateBytesTo(h1, trunc, &h2); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_TruncateBytesTo failed"); + registerHandleClose(h2); + + // Stepping into next boundary has same cutoff, must exceed + result = SKY_coin_Transactions_Length(h2, &length2); + cr_assert(result == SKY_OK); + cr_assert(length2 == length / 2); + result = SKY_coin_Transactions_Size(h2, &size); + cr_assert(result == SKY_OK, "SKY_coin_Transactions_Size failed"); + cr_assert(trunc - 1 == size); +} + +typedef struct { + GoUint64 coins; + GoUint64 hours; +} test_ux; + +typedef struct { + test_ux *inUxs; + test_ux *outUxs; + int sizeIn; + int sizeOut; + GoUint64 headTime; + int failure; +} test_case; + +int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { + if (size <= 0) { + pArray->len = 0; + pArray->cap = 0; + pArray->data = NULL; + return SKY_OK; + } + int elems_size = sizeof(coin__UxOut); + void *data; + data = malloc(size * elems_size); + if (data == NULL) + return SKY_ERROR; + registerMemCleanup(data); + memset(data, 0, size * elems_size); + pArray->data = data; + pArray->len = size; + pArray->cap = size; + coin__UxOut *p = data; + for (int i = 0; i < size; i++) { + p->Body.Coins = elems[i].coins; + p->Body.Hours = elems[i].hours; + p++; + } + return SKY_OK; +} + +Test(coin_transactions, TestVerifyTransactionCoinsSpending) { + + // Input coins overflow + test_ux in1[] = {{MaxUint64 - Million + 1, 10}, {Million, 0}}; + + // Output coins overflow + test_ux in2[] = {{10 * Million, 10}}; + test_ux out2[] = {{MaxUint64 - 10 * Million + 1, 0}, {20 * Million, 1}}; + + // Insufficient coins + test_ux in3[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out3[] = {{20 * Million, 1}, {10 * Million, 1}}; + + // Destroyed coins + test_ux in4[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out4[] = {{5 * Million, 1}, {10 * Million, 1}}; + + // Valid + test_ux in5[] = {{10 * Million, 10}, {15 * Million, 10}}; + test_ux out5[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, // Input coins overflow + {in2, out2, 1, 2, 0, 1}, // Output coins overflow + {in3, out3, 2, 2, 0, 1}, // Destroyed coins + {in4, out4, 1, 1, Million, + 1}, // Invalid (coin hours overflow when adding earned hours, which is + // treated as 0, and now enough coin hours) + {in5, out5, 2, 3, 0, 0} // Valid + }; + + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for (int i = 0; i < count; i++) { + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionCoinsSpending(&inArray, &outArray); + if (tests[i].failure) + cr_assert(result != SKY_OK, "VerifyTransactionCoinsSpending succeeded %d", + i + 1); + else + cr_assert(result == SKY_OK, "VerifyTransactionCoinsSpending failed %d", + i + 1); + } +} + +Test(coin_transactions, TestVerifyTransactionHoursSpending) { + GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; + GoUint64 Million = 1000000; + + // Input hours overflow + test_ux in1[] = {{3 * Million, MaxUint64 - Million + 1}, {Million, Million}}; + + // Insufficient coin hours + test_ux in2[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out2[] = {{15 * Million, 10}, {10 * Million, 11}}; + + // coin hours time calculation overflow + test_ux in3[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out3[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + // Invalid (coin hours overflow when adding earned hours, which is treated as + // 0, and now enough coin hours) + test_ux in4[] = {{10 * Million, MaxUint64}}; + + test_ux out4[] = {{10 * Million, 1}}; + + // Valid (coin hours overflow when adding earned hours, which is treated as 0, + // but not sending any hours) + test_ux in5[] = {{10 * Million, MaxUint64}}; + + test_ux out5[] = {{10 * Million, 0}}; + + // Valid (base inputs have insufficient coin hours, but have sufficient after + // adjusting coinhours by headTime) + test_ux in6[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out6[] = {{15 * Million, 10}, {10 * Million, 11}}; + + // valid + test_ux in7[] = {{10 * Million, 10}, {15 * Million, 10}}; + + test_ux out7[] = {{10 * Million, 11}, {10 * Million, 1}, {5 * Million, 0}}; + + test_case tests[] = { + {in1, NULL, 2, 0, 0, 1}, // Input hours overflow + {in2, out2, 2, 2, 0, 1}, // Insufficient coin hours + {in3, out3, 2, 3, MaxUint64, 1}, // coin hours time calculation overflow + {in4, out4, 1, 1, Million, + 1}, // Invalid (coin hours overflow when adding earned hours, which is + // treated as 0, and now enough coin hours) + {in5, out5, 1, 1, 0, + 0}, // Valid (coin hours overflow when adding earned hours, which is + // treated as 0, but not sending any hours) + {in6, out6, 2, 2, 1492707255, + 0}, // Valid (base inputs have insufficient coin hours, but have + // sufficient after adjusting coinhours by headTime) + {in7, out7, 2, 3, 0, 0}, // Valid + }; + coin__UxArray inArray; + coin__UxArray outArray; + int result; + int count = sizeof(tests) / sizeof(tests[0]); + for (int i = 0; i < count; i++) { + result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); + cr_assert(result == SKY_OK); + result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); + cr_assert(result == SKY_OK); + result = SKY_coin_VerifyTransactionHoursSpending(tests[i].headTime, + &inArray, &outArray); + if (tests[i].failure) + cr_assert(result != SKY_OK, + "SKY_coin_VerifyTransactionHoursSpending succeeded %d", i + 1); + else + cr_assert(result == SKY_OK, + "SKY_coin_VerifyTransactionHoursSpending failed %d", i + 1); + } +} + +GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 1; + return SKY_OK; +} + +GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + return SKY_ERROR; +} + +GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 0xFFFFFFFFFFFFFFFF; + return SKY_OK; +} + +Test(coin_transactions, TestTransactionsFees) { + GoUint64 fee; + int result; + Transactions__Handle transactionsHandle = 0; + Transaction__Handle transactionHandle = 0; + + // Nil txns + makeTransactions(0, &transactionsHandle); + result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + cr_assert(result == SKY_OK); + cr_assert(fee == 0); + + makeEmptyTransaction(&transactionHandle); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + makeEmptyTransaction(&transactionHandle); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + // 2 transactions, calc() always returns 1 + result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + cr_assert(result == SKY_OK); + cr_assert(fee == 2); + + // calc error + result = SKY_coin_Transactions_Fees(transactionsHandle, badFeeCalculator, &fee); + cr_assert(result != SKY_OK); + + // summing of calculated fees overflows + result = SKY_coin_Transactions_Fees(transactionsHandle, overflowFeeCalculator, &fee); + cr_assert(result != SKY_OK); +} + +GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee){ + coin__Transaction* pTx; + int result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + return result; +} + +GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 100 * Million; + return SKY_OK; +} + +void assertTransactionsHandleEqual(Transaction__Handle h1, Transaction__Handle h2, + char* testName){ + coin__Transaction *pTx1; + coin__Transaction *pTx2; + int result; + result = SKY_coin_Get_Transaction_Object( h1, &pTx1 ); + cr_assert(result == SKY_OK); + result = SKY_coin_Get_Transaction_Object( h2, &pTx2 ); + cr_assert(result == SKY_OK); + cr_assert(eq(type(coin__Transaction), *pTx1, *pTx2), "Failed SortTransactions test \"%s\"", testName); +} + +void testTransactionSorting(Transactions__Handle hTrans, + int* original_indexes, int original_indexes_count, + int* expected_indexes, int expected_indexes_count, FeeCalc feeCalc, + char* testName + ){ + + int result; + Transactions__Handle transactionsHandle, sortedTxnsHandle; + Transaction__Handle handle; + makeTransactions(0, &transactionsHandle); + for(int i = 0; i < original_indexes_count; i++){ + result = SKY_coin_Transactions_GetAt(hTrans, original_indexes[i], &handle); + cr_assert(result == SKY_OK); + registerHandleClose(handle); + result = SKY_coin_Transactions_Add(transactionsHandle, handle); + cr_assert(result == SKY_OK); + } + result = SKY_coin_SortTransactions(transactionsHandle, feeCalc, &sortedTxnsHandle); + cr_assert(result == SKY_OK, "SKY_coin_SortTransactions"); + registerHandleClose(sortedTxnsHandle); + Transaction__Handle h1, h2; + for(int i = 0; i < expected_indexes_count; i++){ + int expected_index = expected_indexes[i]; + result = SKY_coin_Transactions_GetAt(sortedTxnsHandle, i, &h1); + cr_assert(result == SKY_OK); + registerHandleClose(h1); + result = SKY_coin_Transactions_GetAt(hTrans, expected_index, &h2); + cr_assert(result == SKY_OK); + registerHandleClose(h2); + assertTransactionsHandleEqual(h1, h2, testName); + } +} + + +Test(coin_transactions, TestSortTransactions) { + int n = 6; + int i; + int result; + + Transactions__Handle transactionsHandle = 0; + Transactions__Handle transactionsHandle2 = 0; + Transactions__Handle hashSortedTxnsHandle = 0; + Transactions__Handle sortedTxnsHandle = 0; + Transaction__Handle transactionHandle = 0; + cipher__Address addr; + makeTransactions(0, &transactionsHandle); + cipher__SHA256 thirdHash; + for(i = 0; i < 6; i++){ + makeEmptyTransaction(&transactionHandle); + makeAddress(&addr); + result = SKY_coin_Transaction_PushOutput(transactionHandle, &addr, 1000000, i * 1000); + cr_assert(result == SKY_OK); + result = SKY_coin_Transaction_UpdateHeader(transactionHandle); + cr_assert(result == SKY_OK); + result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); + cr_assert(result == SKY_OK); + if( i == 2 ){ + result = SKY_coin_Transaction_Hash(transactionHandle, &thirdHash); + cr_assert(result == SKY_OK); + } + } + sortTransactions(transactionsHandle, &hashSortedTxnsHandle); + + int index1[] = {0, 1}; + int expec1[] = {0, 1}; + testTransactionSorting(transactionsHandle, index1, 2, expec1, 2, feeCalculator1, "Already sorted"); + int index2[] = {1, 0}; + int expec2[] = {0, 1}; + testTransactionSorting(transactionsHandle, index2, 2, expec2, 2, feeCalculator1, "reverse sorted"); + testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, feeCalculator2, "hash tiebreaker"); + + GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ *pFee){ + cipher__SHA256 hash; + int result = SKY_coin_Transaction_Hash(handle, &hash); + if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + *pFee = MaxUint64 / 2; + } else { + coin__Transaction* pTx; + result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; + } + int index3[] = {1, 2, 0}; + int expec3[] = {2, 0, 1}; + testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, feeCalculator3, "invalid fee multiplication is capped"); + + GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ *pFee){ + cipher__SHA256 hash; + int result = SKY_coin_Transaction_Hash(handle, &hash); + if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + *pFee = 0; + result = SKY_ERROR; + } else { + coin__Transaction* pTx; + result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + if(result == SKY_OK){ + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; + } + + int index4[] = {1, 2, 0}; + int expec4[] = {0, 1}; + testTransactionSorting(transactionsHandle, index4, 3, expec4, 2, feeCalculator4, "failed fee calc is filtered"); } diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 0f3c2f32d5..52526bc49e 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -3,6 +3,26 @@ #include "skycriterion.h" #include "skystring.h" +int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ + if(slice1->len != slice2->len) + return 0; + return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; +} + +int equalTransactions(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ + if( pTxs1->len != pTxs2->len ) + return 0; + coin__Transaction* pTx1 = pTxs1->data; + coin__Transaction* pTx2 = pTxs2->data; + for(int i = 0; i < pTxs1->len; i++){ + if(!cr_user_coin__Transaction_eq(pTx1, pTx2)) + return 0; + pTx1++; + pTx2++; + } + return 1; +} + int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ if(addr1->Version != addr2->Version) return 0; @@ -59,15 +79,15 @@ char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) } -int cr_user_cipher__Ripemd160_noteq(Ripemd160 *rp1, Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) != 0; +int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) != 0; } -int cr_user_cipher__Ripemd160_eq(Ripemd160 *rp1, Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(Ripemd160)) == 0; +int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ + return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) == 0; } -char *cr_user_cipher__Ripemd160_tostr(Ripemd160 *rp1) +char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) { char *out; char hexdump[101]; @@ -128,32 +148,26 @@ int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2 return 1; } -int cr_user_coin__Transactions_eq(coin__Transactions *slice1, coin__Transactions *slice2){ - return - (slice1->len == slice2->len) && - (memcmp(slice1->data, slice2->data, slice1->len)==0); +int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2){ + return equalTransactions(x1, x2); } -int cr_user_coin__Transactions_noteq(coin__Transactions *slice1, coin__Transactions *slice2){ - return - !((slice1->len == slice2->len) && - (memcmp(slice1->data, slice2->data, slice1->len)==0)); +int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2){ + return !equalTransactions(x1, x2); } -char *cr_user_coin__Transactions_tostr(coin__Transactions *slice1) { +char *cr_user_coin__Transactions_tostr(coin__Transactions *x1) { char *out; - cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)x1->data, x1->len, x1->cap); return out; } int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2){ - return - cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); + return equalTransactions(&b1->Transactions, &b2->Transactions); } int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2){ - return - !cr_user_GoSlice__eq((GoSlice_*)&(b1->Transactions), (GoSlice_*)&(b2->Transactions)); + return !equalTransactions(&b1->Transactions, &b2->Transactions); } char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) { @@ -183,11 +197,11 @@ int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2){ } if(!cr_user_cipher__SHA256_eq(&x1->InnerHash, &x2->InnerHash)) return 0; - if(!cr_user_GoSlice__eq(&x1->Sigs, &x2->Sigs) ) + if(!equalSlices((GoSlice*)&x1->Sigs, (GoSlice*)&x2->Sigs, sizeof(cipher__Sig))) return 0; - if(!cr_user_GoSlice__eq(&x1->In, &x2->In) ) + if(!equalSlices((GoSlice*)&x1->In, (GoSlice*)&x2->In, sizeof(cipher__SHA256))) return 0; - if(!cr_user_GoSlice__eq(&x1->Out, &x2->Out) ) + if(!equalSlices((GoSlice*)&x1->Out, (GoSlice*)&x2->Out, sizeof(coin__TransactionOutput))) return 0; return 1; } @@ -222,3 +236,34 @@ char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1){ cr_asprintf(&out, "(coin__TransactionOutput) { Coins : %d, Hours: %d, Address: %s }", x1->Coins, x1->Hours, x1->Address); return out; } + +int cr_user_coin__UxArray_eq(coin__UxArray *x1, coin__UxArray *x2){ + return equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +} + +int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2){ + return !equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +} + +char* cr_user_coin__UxArray_tostr(coin__UxArray *x1){ + char *out; + cr_asprintf(&out, "(coin__UxArray) { Length : %d }", x1->len); + return out; +} + +int cr_user_Number_eq(Number *n1, Number *n2) { + return (equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt)) && + ((GoInt)n1->neg == (GoInt)n2->neg)); +} + +int cr_user_Number_noteq(Number *n1, Number *n2) { + return ( !(equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt))) || + ((GoInt)n1->neg != (GoInt)n2->neg)); +} + +char *cr_user_Number_tostr(Number *n1) { + char *out; + cr_asprintf(&out, "(Number) { nat : [.data %s, .len %d , cap %d] , neg %d }", + (char *)n1->nat.data, n1->nat.len, n1->nat.cap, (GoInt)n1->neg); + return out; +} diff --git a/lib/cgo/tests/testutils/libsky_number.c b/lib/cgo/tests/testutils/libsky_number.c deleted file mode 100644 index 5b6c82bc7a..0000000000 --- a/lib/cgo/tests/testutils/libsky_number.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "skynumber.h" - -int number_eq(Number* n1, Number* n2){ - if ( n1->neg != n2->neg ) - return 0; - if ( n1->nat.len != n2->nat.len ) - return 0; - for( int i = 0; i < n1->nat.len; i++){ - if( ((char*)n1->nat.data)[i] != ((char*)n2->nat.data)[i]) - return 0; - } - return 1; -} \ No newline at end of file diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 5919e244fa..ed9f7fc652 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -11,6 +11,11 @@ #include "skytest.h" #include "transutil.h" +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ + *pFee = 0; + return SKY_OK; +} + int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress){ int result; result = SKY_cipher_GenerateKeyPair(ppubkey, pseckey); @@ -154,6 +159,54 @@ int makeTransactions(int n, Transactions__Handle* handle){ return result; } +typedef struct{ + cipher__SHA256 hash; + Transaction__Handle handle; +} TransactionObjectHandle; + +int sortTransactions(Transactions__Handle txns_handle, Transactions__Handle* sorted_txns_handle){ + int result = SKY_coin_Create_Transactions(sorted_txns_handle); + cr_assert(result == SKY_OK); + registerHandleClose(*sorted_txns_handle); + GoInt n, i, j; + result = SKY_coin_Transactions_Length(txns_handle, &n); + cr_assert(result == SKY_OK); + TransactionObjectHandle* pTrans = malloc( n * sizeof(TransactionObjectHandle)); + cr_assert(pTrans != NULL); + registerMemCleanup(pTrans); + memset(pTrans, 0, n * sizeof(TransactionObjectHandle)); + int* indexes = malloc( n * sizeof(int) ); + cr_assert(indexes != NULL); + registerMemCleanup(indexes); + for( i = 0; i < n; i ++){ + indexes[i] = i; + result = SKY_coin_Transactions_GetAt(txns_handle, i, &pTrans[i].handle); + cr_assert(result == SKY_OK); + registerHandleClose(pTrans[i].handle); + result = SKY_coin_Transaction_Hash(pTrans[i].handle, &pTrans[i].hash); + cr_assert(result == SKY_OK); + } + + //Swap sort. + cipher__SHA256 hash1, hash2; + for(i = 0; i < n - 1; i++){ + for(j = i + 1; j < n; j++){ + int cmp = memcmp(&pTrans[indexes[i]].hash, &pTrans[indexes[j]].hash, sizeof(cipher__SHA256)); + if(cmp > 0){ + //Swap + int tmp = indexes[i]; + indexes[i] = indexes[j]; + indexes[j] = tmp; + } + } + } + for( i = 0; i < n; i ++){ + result = SKY_coin_Transactions_Add(*sorted_txns_handle, pTrans[indexes[i]].handle); + cr_assert(result == SKY_OK); + } + return result; +} + coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Handle* handle2){ coin__Transaction* ptransaction = NULL; int result = 0; diff --git a/lib/cgo/testutil.assert.assertions.go b/lib/cgo/testutil.assert.assertions.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/testutil.assert.assertions.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/testutil.require.require.go b/lib/cgo/testutil.require.require.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/testutil.require.require.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.elapse.elapser.go b/lib/cgo/util.elapse.elapser.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.elapse.elapser.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.error.go b/lib/cgo/util.http.error.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.error.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.handler.go b/lib/cgo/util.http.handler.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.handler.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.http.log.go b/lib/cgo/util.http.log.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.http.log.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.formatter.go b/lib/cgo/util.logging.formatter.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.formatter.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.hooks.go b/lib/cgo/util.logging.hooks.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.hooks.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/util.logging.logger.go b/lib/cgo/util.logging.logger.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/util.logging.logger.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go index cb527a6ae6..6d6f160ab3 100644 --- a/lib/cgo/wallet.notes.go +++ b/lib/cgo/wallet.notes.go @@ -1,7 +1,6 @@ package main import ( - "reflect" "unsafe" wallet "github.com/skycoin/skycoin/src/wallet" @@ -28,7 +27,7 @@ func SKY_wallet_NewNotesFilename(_arg0 *C.GoString_) (____error_code uint32) { } //export SKY_wallet_LoadNotes -func SKY_wallet_LoadNotes(_dir string, _arg1 *C.wallet__Notes) (____error_code uint32) { +func SKY_wallet_LoadNotes(_dir string, _arg1 *C.WalletNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -37,13 +36,13 @@ func SKY_wallet_LoadNotes(_dir string, _arg1 *C.wallet__Notes) (____error_code u __arg1, ____return_err := wallet.LoadNotes(dir) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.wallet__Notes)(unsafe.Pointer(&__arg1)) + *_arg1 = registerWalletNotesHandle(&__arg1) } return } //export SKY_wallet_LoadReadableNotes -func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -52,18 +51,22 @@ func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.wallet__ReadableNot __arg1, ____return_err := wallet.LoadReadableNotes(filename) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(__arg1)) + *_arg1 = registerWalletReadableNotesHandle(__arg1) } return } //export SKY_wallet_ReadableNotes_Load -func SKY_wallet_ReadableNotes_Load(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { +func SKY_wallet_ReadableNotes_Load(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } filename := _filename ____return_err := rns.Load(filename) ____error_code = libErrorCode(____return_err) @@ -73,27 +76,36 @@ func SKY_wallet_ReadableNotes_Load(_rns *C.wallet__ReadableNotes, _filename stri } //export SKY_wallet_ReadableNotes_ToNotes -func SKY_wallet_ReadableNotes_ToNotes(_rns *C.wallet__ReadableNotes, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_wallet_ReadableNotes_ToNotes(_rns C.WalletReadableNotes_Handle, _arg0 *C.WalletNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := *(*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0, ____return_err := rns.ToNotes() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + notes := wallet.Notes(__arg0) + *_arg0 = registerWalletNotesHandle(¬es) } return } //export SKY_wallet_ReadableNotes_Save -func SKY_wallet_ReadableNotes_Save(_rns *C.wallet__ReadableNotes, _filename string) (____error_code uint32) { +func SKY_wallet_ReadableNotes_Save(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - rns := (*wallet.ReadableNotes)(unsafe.Pointer(_rns)) + rns, ok := lookupWalletReadableNotesHandle(_rns) + if !ok { + ____error_code = SKY_ERROR + return + } filename := _filename ____return_err := rns.Save(filename) ____error_code = libErrorCode(____return_err) @@ -110,29 +122,38 @@ func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__Readable }() note := *(*wallet.Note)(unsafe.Pointer(_note)) __arg1 := wallet.NewReadableNote(note) - *_arg1 = *(*C.wallet__ReadableNote)(unsafe.Pointer(&__arg1)) + copyString(__arg1.TransactionID, &_arg1.TransactionID) + copyString(__arg1.ActualNote, &_arg1.ActualNote) return } //export SKY_wallet_NewReadableNotesFromNotes -func SKY_wallet_NewReadableNotesFromNotes(_w *C.wallet__Notes, _arg1 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_NewReadableNotesFromNotes(_w C.WalletNotes_Handle, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - w := *(*wallet.Notes)(unsafe.Pointer(_w)) - __arg1 := wallet.NewReadableNotesFromNotes(w) - *_arg1 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg1)) + w, ok := lookupWalletNotesHandle(_w) + if !ok { + ____error_code = SKY_ERROR + return + } + __arg1 := wallet.NewReadableNotesFromNotes(*w) + *_arg1 = registerWalletReadableNotesHandle(&__arg1) return } //export SKY_wallet_Notes_Save -func SKY_wallet_Notes_Save(_notes *C.wallet__Notes, _dir string, _fileName string) (____error_code uint32) { +func SKY_wallet_Notes_Save(_notes C.WalletNotes_Handle, _dir string, _fileName string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } dir := _dir fileName := _fileName ____return_err := notes.Save(dir, fileName) @@ -143,12 +164,16 @@ func SKY_wallet_Notes_Save(_notes *C.wallet__Notes, _dir string, _fileName strin } //export SKY_wallet_Notes_SaveNote -func SKY_wallet_Notes_SaveNote(_notes *C.wallet__Notes, _dir string, _note *C.wallet__Note) (____error_code uint32) { +func SKY_wallet_Notes_SaveNote(_notes C.WalletNotes_Handle, _dir string, _note *C.wallet__Note) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := (*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } dir := _dir note := *(*wallet.Note)(unsafe.Pointer(_note)) ____return_err := notes.SaveNote(dir, note) @@ -159,14 +184,18 @@ func SKY_wallet_Notes_SaveNote(_notes *C.wallet__Notes, _dir string, _note *C.wa } //export SKY_wallet_Notes_ToReadable -func SKY_wallet_Notes_ToReadable(_notes *C.wallet__Notes, _arg0 *C.wallet__ReadableNotes) (____error_code uint32) { +func SKY_wallet_Notes_ToReadable(_notes C.WalletNotes_Handle, _arg0 *C.WalletReadableNotes_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - notes := *(*wallet.Notes)(unsafe.Pointer(_notes)) + notes, ok := lookupWalletNotesHandle(_notes) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := notes.ToReadable() - *_arg0 = *(*C.wallet__ReadableNotes)(unsafe.Pointer(&__arg0)) + *_arg0 = registerWalletReadableNotesHandle(&__arg0) return } diff --git a/lib/cgo/wallet.secrets.go b/lib/cgo/wallet.secrets.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/wallet.secrets.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/wallet.service.go b/lib/cgo/wallet.service.go deleted file mode 100644 index ff3967e25a..0000000000 --- a/lib/cgo/wallet.service.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" diff --git a/lib/cgo/wallet.wallet.go b/lib/cgo/wallet.wallet.go index 8d2a1b3203..accac9cc4f 100644 --- a/lib/cgo/wallet.wallet.go +++ b/lib/cgo/wallet.wallet.go @@ -41,7 +41,7 @@ func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wal wltName := _wltName __opts, okopts := lookupOptionsHandle(_opts) if !okopts { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } opts := *__opts @@ -61,7 +61,7 @@ func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType s }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -81,7 +81,7 @@ func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wa }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -116,7 +116,7 @@ func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code ui }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } dir := _dir @@ -135,7 +135,7 @@ func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ____return_err := w.Validate() @@ -153,7 +153,7 @@ func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_ }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.Type() @@ -169,7 +169,7 @@ func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____err }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.Version() @@ -185,7 +185,7 @@ func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____er }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.Filename() @@ -201,7 +201,7 @@ func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.Label() @@ -217,7 +217,7 @@ func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_ }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.IsEncrypted() @@ -233,7 +233,7 @@ func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } num := _num @@ -253,7 +253,7 @@ func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (___ }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := w.GetAddresses() @@ -269,7 +269,7 @@ func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } a := *(*cipher.Address)(unsafe.Pointer(_a)) @@ -287,7 +287,7 @@ func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (_ }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } entry := *(*wallet.Entry)(unsafe.Pointer(_entry)) diff --git a/lib/cgo/wallet_option.go b/lib/cgo/wallet_option.go index f5db19c0df..9a76bd677b 100644 --- a/lib/cgo/wallet_option.go +++ b/lib/cgo/wallet_option.go @@ -13,7 +13,7 @@ import ( import "C" //export SKY_wallet_CreateOptionsHandle -func SKY_wallet_CreateOptionsHandle(coin string, label string, seed string, encrypt bool, pwd string, cryptoType string, scanN uint64, _opts *C.Options__Handle) uint32 { +func SKY_wallet_CreateOptionsHandle(coin string, label string, seed string, encrypt bool, pwd string, cryptoType string, scanN uint64, _opts *C.Options__Handle) { var walletOptions wallet.Options walletOptions.Coin = (wallet.CoinType)(coin) walletOptions.Label = label @@ -23,5 +23,4 @@ func SKY_wallet_CreateOptionsHandle(coin string, label string, seed string, encr walletOptions.CryptoType = (wallet.CryptoType)(cryptoType) walletOptions.ScanN = scanN *_opts = registerOptionsHandle(&walletOptions) - return SKY_OK } diff --git a/src/cipher/testsuite/testdata/input-hashes.golden b/src/cipher/testsuite/testdata/input-hashes.golden index a9649a9705..445d849bec 100644 --- a/src/cipher/testsuite/testdata/input-hashes.golden +++ b/src/cipher/testsuite/testdata/input-hashes.golden @@ -2,13 +2,13 @@ "hashes": [ "66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925", "72cd6e8422c407fb6d098690f1130b7ded7ec2f7f5e1d30bd9d521f015363793", - "1a964cd59841a8a64cf5a6f52da4a963c10fa92983f8694c8ee9a04294dafc92", - "cb142a76adc0893535989da9123848d3c1e97e49de10d86dc3a11a9db9e9b826", - "cc156b421b317e1a8ebfae0018a7dce45b0bfd9604dee57b333e3402350d8caf", - "528b5643c9f042faec41b0c31d341cdbc8531ded12d1d2b2851dd498967913eb", - "ad647b800dc8e21560da7643ee0b8979b22743492bc4bd04ac33d1c6ef3d6ba0", - "2e56c7beb552c2eff3b1ba5955614a8b264475f73a942b523190ea22857497b7", - "d8b005640029bf705a026ddb62f6e79500660044aa8fcf583cdd77c3017add03", - "e9f77b0528611d961c0825a93a3ad3e5be71d3fb5c6376cd87714a0d04098996" + "ae1d9ccf7ce3717a9aa3316c6b7850d0a85bc0466bc1b572545f90ccf1b59130", + "a4cfaddadceb816c4dad0a10d933a1880f9b47b9f943ca93b91cc3a046567fda", + "1d93be8a70df9e7450a0ce98231c58d7353e025cd1e9db32a00c2fd0a1643d96", + "a0c10151fc212bc313332c58aba5e19de1d6787178613819ff8dc6db270c66fc", + "fc54b1c9039285084cec65510329331a82397afff54706a9ac611b95c933f783", + "621484cec82cca5d8fb163d80c361ddf7320913fb294a3855c3e4db60440919b", + "b780c445c161b65c3dc1046cfba900161fe8a5f644907995b077f1afd231b230", + "4eefdc2b82e79d98fd3f323b5c284a1c35f4a8a862d9e83c8b96cd647ca3794d" ] } \ No newline at end of file diff --git a/src/cipher/testsuite/testdata/many-addresses.golden b/src/cipher/testsuite/testdata/many-addresses.golden index ae94fd4ae6..e5e8edcb0f 100644 --- a/src/cipher/testsuite/testdata/many-addresses.golden +++ b/src/cipher/testsuite/testdata/many-addresses.golden @@ -1,5005 +1,5005 @@ { - "seed": "d2luZSBwbGF0ZSBhYmFuZG9uIGFtdXNlZCBsdWdnYWdlIHNwZW5kIGZyYWdpbGUgcmFyZSB2ZW50dXJlIGRvbmF0ZSBzb2Z0IHNoZXJpZmY=", + "seed": "d2lyZSBqdW5rIG9yaWdpbmFsIHN3b3JkIGJyZWFkIGJvdHRvbSBhcm1vciBkb2cgc25vdyBhY2NpZGVudCBpbmZvcm0gcmlnaWQ=", "keys": [ { - "address": "opeMZ6ed98brEVywL7towdbNC5moifuzzd", - "secret": "1b63b9d98be6941fcbbd218ad03b25c03362a0fe499ce6c07372d0224cd83fb5", - "public": "024599359c0e582e5aee6059f122a4949bd72862d76e879da5c08fc11310a483bc" + "address": "2Niqzo12tZ9ioZq5vwPHMVR4g7UVpp9TCmP", + "secret": "e7550f33084a1b8ba935e2a943201adbea065ba9e87ae1e07c5a0b1d87ea8f3e", + "public": "024386ad78055064e65086ab69ae5c1629aca2fc7e4857261d141c181236700ae0" }, { - "address": "etbwG6USD544FmizhsUXbSyq7wBxYkBYLg", - "secret": "8f36c1a4103cecf7e00d8eb39991c23334ff5784d9c313090940c596cab56133", - "public": "0278cfc456f6a065d84ea97f76cb9e3c8d095f3154f476c686ee438e296233e34b" + "address": "2UDzBKnxZf4d9pdrBJAqbtoeH641RFLYKxd", + "secret": "cd6c5e2d56c302496009c0cd8006e9264a69606524fc7f58b45351d2cd883209", + "public": "02b7e753683d5b53b5ce1c800dbfee62594d7d3f1d5f8a2af8f9b9b6d01fac02e3" }, { - "address": "26fSzXs92w8yofxU8tYghB66Rq5EayVAgzp", - "secret": "a4b122e082f7050010dc7b702353149492ccc8d0fe35ffbfb474388933415185", - "public": "035f773d52bea8b20cecb43b8ad4abe30c18bf6f959db01ceec9eeec09cfcf3b38" + "address": "8LbGZ9Z9r7ELNKyrQmAbhLhLvrmLJjfotm", + "secret": "4976bba22c7f481334844d8f6c8d513c573d881f64a55981506b11dab581c39f", + "public": "038c977ea6bdef6f74ab9864cdbfa3065b5aeecfb1b9fc71f2459e3609a242082b" }, { - "address": "2R8eVnYAPbVSq33dx2zFArGSDxPxGJbQsE6", - "secret": "96652a4fbf18e12cd6975b402b0c2b1ae3aa20dc9b014b83b924ce6256addd8f", - "public": "03492d7fcd80f0659f0be0ba156f51b6a2545e6367fc25181780fdcdf3ae735648" + "address": "7KU683yzoPE9rVuuFRQMZVhGwBBtwqTKT2", + "secret": "097669b9fa165f102c4c9aa098ae3ee4ff2554788b875cb5b0aa76d225eaccf5", + "public": "021c52a4b715fc1cdc6ab6d7c8bc8d9e0ace43ae5321a07a950d63eced0b82f8fc" }, { - "address": "qmfSD7JykkxBL7EJ4K3hVKFjxyopm3Z2eD", - "secret": "fcd1fc046efd1d7e93d7459e0f09a87771c48245b474a6848d363e71cc17a1a1", - "public": "024a597feb6f38106552c70cbee93b3c4a39f4ab8bed3ab7ec7186250b8c67ca5f" + "address": "gwgdez9f3BLvQyNE5tMFS75p69zs2i3mRq", + "secret": "52d5cba120ee89ac59506d19900833e0d4d696fa56549f3f2418958791d5f880", + "public": "022e678bb9add17994fb4603914c8fa229b5c0aac6b725e24e256f6533bb185ae7" }, { - "address": "kUXtJz7gJvTCFyzeEGCJGZEHaSoYV3zFbw", - "secret": "e2150d848696f40f8741621423187b616e7010bc65e0a154c67d150d4c932c60", - "public": "02706076d510eeedbb8768031e6f98a9cf60eb1aa12efb3c73a16fa39f823e04f3" + "address": "aSEqXrooiycfyXDc2aLYLGSmjrozJh3jCn", + "secret": "3bd338e8674ca06431eeca83d062f17557402b88afa9daa015783e47788168b1", + "public": "038f4cbfb7b0548f53a8fe25cce2c938acbf2d17ccbea347a10872317cb5168178" }, { - "address": "7BMxHG9iNpbdXvNQsXotQBZSN58d52k5uc", - "secret": "8baeacc584bcc72a7e28180d0a7a0eef4720ed9933c0b86a45706d4152118559", - "public": "0320186b894c883f7e0de28494fc90124d405759a9b0f4f46901524ed5e60a638d" + "address": "2Z6WpR2RoBBF722hZ75ShDp1LVmojSRfAiF", + "secret": "d7f3f12937a4429299e67d5f916a503fdc2ba3064d89b6b39930f5265a8d792a", + "public": "0363044bd9d59c9461dddd3a0aeb5e973d696ff5f1153c1e930263244aa8066a87" }, { - "address": "2W91VxVbMkoGH4VrqJxv62cfYV1tufzCwGC", - "secret": "914c5bf786edfb4730bc9b5f41e3bae8ade940f5162e302894bc67fd6d80fbce", - "public": "0326e8df891d48f02e1086d441d72869e5c457d9fb9584cb2c18af203f90177512" + "address": "25sH1HLTQbr1CR4uxkMFtJY2WLLwFVPqzKQ", + "secret": "2c47f82501fdb00b7d47a545ab5d1e0a148c1ed6d47e8f5630091561465ed40e", + "public": "03992d87f8e40ed2e55304a05e3bf7e12c9e8713498a90acfa51c046c9746d8f0f" }, { - "address": "BSbZGM2CdPBWgUz18cpTJ6oSHpRn8gME7e", - "secret": "b870bc6aec543ac0bc66c5e48a0dc427381748d11cf710dd809714e48c23fe44", - "public": "03bba9959cd8d8143e6b31924145012c9289680f2354de368f348bda052bbc15c4" + "address": "MGiD4Bg65F7bQhaKmhCLsaVKKeEFLuGgA3", + "secret": "fc7f9fb98804537752ec2d2e58618ac316e556af202294a109ddad5747b18d31", + "public": "02f4bb55716f1c7d7bd69e1f0fa7ffc50094fa348be3633a916c8da21298c2db55" }, { - "address": "JiCePA3VqmcQzSqAhSeQFeRiWU2yzsq7PD", - "secret": "bafbb497a39222b54c44face4d5a23c77e4fdb3abadc57847be7b8f933b56845", - "public": "0297e58056473e35035b309b3015ce70b2d5ef994e68acf8b57d538c8061f7a5d8" + "address": "2bYFuBzZ7QiEbpJophC2pFhQLbEFt3YSSJH", + "secret": "c8c40438a94ccfff9b2fe7150ff7a4193341a55893aad88c06f05b904bc2aab3", + "public": "0377b14de3039f77bcf3f5f4ba852a9b36eab3d7618c59c33336aa17870162d446" }, { - "address": "xNuJTKjaRAfSwhCfJfPZpXhREm26vUQgg4", - "secret": "154ee62b4e0da8171b316a0ceef20a1322dd5b9ad85c74807f84320a1c03d850", - "public": "03e71ca648bcc0fe01e5fb96cfeb6bd6964b1b1fced8cac9127df74e196147faa0" + "address": "yExu4fryscnahAEMKa7XV4Wc1mY188KvGw", + "secret": "ccf9b32c1f573a7e1cbdaefb791e515847e857fa6e44a42a4bcb396c5e5e7544", + "public": "0399e8ac882b086491e424a04cd8289e340a5cf132c74950659bd21262db5674a7" }, { - "address": "X5ETTz3CJJShjx1Cd3gA4tJuspMr2ZxcBu", - "secret": "d235dc3a4768be95c97d25e55b1be876b71376521f013e286b874cdc1d2d3836", - "public": "030ff58182ce0acde72d3464444d8a06df93f1b88437ba333514162518e8eec72c" + "address": "23GxEvPcy5vFPuzuP8o3PBag3HgQdoaWyXb", + "secret": "815d3fb815e4cc29c5e17acd597c570a8f1f9108ae955c01fd756ba5564bba4f", + "public": "0370dc9f523c4bef8697e87a59cc6c54f4e89d513a8bf08b1cabab7a357a508957" }, { - "address": "2YQs6tFbBs1mcPEuNmvdFakSLcdePt4FbwZ", - "secret": "e7e2751ea953bf87f9db40c50039b98e2443a513927101ba9b0728d57435b927", - "public": "0375683f035a2f19522e040b1cfcc00daa1a62270178ab20489045058aad45f597" + "address": "2C3JbrfoE4dSjZ5dE4hxrYCmmmrcFEGyiUL", + "secret": "5e01bf90d5331617a5c83afec44ce5b13dadbfc94efa58f2445ac2e9885c867e", + "public": "03761fa32c428788d875e670ad62f128da4ee70ccafc9577b6f1e3ba69a5195137" }, { - "address": "2Qe7Xdaj1gUxRmpKs8q3ZeA1DZQJ7VLHAez", - "secret": "94863b1218c0411acc35a00e61e61c96f883df90e42c66683ded09ed08aed529", - "public": "030d8416cac13f46c83e71b0c27a184fa7ecbc3876b53e98950a133bdef02b7169" + "address": "KE9oA24AuPzDzWBEjhGJu7PHZsQjGXYcww", + "secret": "70a250282d1b56abffee25badeb702c2ca82650c67ffa8be526cd600007406da", + "public": "034e06e04e3c6a32ddbc25c7572343d50a3c4eedd596550ccea33aeb24410d2422" }, { - "address": "2Qb8qN3hGpqYPYQo9xqk9NME7hzqY6DEUjh", - "secret": "528cf2cb513a929e7536c0d7037a4a4362edab80284c652cd4516f966723923f", - "public": "03fde13baa81f76ad36b1e788f317817b8fc7935b88fbdfdff2dce26356460ac65" + "address": "2KnZdRBrVkK7EyzPxFdYrAoZ17MwjxxaCR", + "secret": "4627499983552fea4be50a879b5923f039959baa3af2e0699381a95507f0e6ab", + "public": "02dba9c7be5ea5668554d295027eaec51b69a582f4561d13afa8ee9004b2941b2a" }, { - "address": "Mix2ikaSRzAvSRAFGepGguKzMyexjpgER1", - "secret": "c47035bd36b9a5645037e97164bc806a21a2c1ec744dd932fe98dd3b1101ae47", - "public": "0269871f74b53869346c2cf982b3adc8687c7ddc99eedaa5e98768ae056aff0282" + "address": "2NGNQTdVNxZQPpBvj64ecidwXF3ZhhkX922", + "secret": "76446750f1f12301fed6037803d0560c008a98a2fa34ab5a1ddaa8ff9dcd3a52", + "public": "026341de878a483526cbf90a591fe8b6fa77fa775d3dfabca8ac5be72aa83690ef" }, { - "address": "hMQnLTk8aJdrTiy2CFq1d5rNwiBgu8FrU7", - "secret": "6a033e5d290f1365384ea1d5aed3e0ff9e1ccb56b6e9453751cbd6fb0bda1533", - "public": "028a99849a453965d162a88b2bd0f0c1bd401883314307f6c80046eaa758835076" + "address": "3sNLvvtb5wFLMhoFxhSb9FiySLGoAzNbGd", + "secret": "9f9b67cde19a83f752c9639a86ec935526e1ab8a38dd23a702686e0e9d4e45b0", + "public": "0398a29c3eb0462bb65757990a762f7e5062db04fa228168c8a308348f1ff5903d" }, { - "address": "232kHTZc9uQ35hbYbiyqAwuLE9Bc1vRNEu9", - "secret": "94611ab68a733ff4d57cabe2d5e60e8ba48491b978d0f820d38221232bfa2a84", - "public": "02d59713c65f5c47d1072b82b83be342e550659512409a17d737fafdd892fe9bc9" + "address": "2kaTspbcfCyWNatPbRNZ55Xg8zyp77rNgv7", + "secret": "2ef76df65020b8c65ba9c6d71dd027cac4892e7e8ff1c8b12f87a48be1e117d0", + "public": "02d16798077bb6dc624d3dbbe99c698c7b91b17157beaba72216b6d85b436a3529" }, { - "address": "2TvBHUaGT8k6HDtmvQzY6dKF9oqUfNxgdKq", - "secret": "c41136a7ec8b5f1526391dce6dd2467acd212cdf3dffd48dcf1fa889f1fdb7a3", - "public": "0341cfd2bf80f06ae1007257e2286ec9b76cb6118d5ab66a594b48627fa1ed2a4f" + "address": "2mcYBt3gpiYFjkTZQHP142R3NF4JZimhSzk", + "secret": "7c2e5e465f172630375aad2b57a45b654c10a9a805f0f25b1a34ceec1b420a74", + "public": "024ab0a1303bbe5e09222c39276da19ff1f761cd1a164dabbb48e6f388a7a82f8d" }, { - "address": "HAf77HRCqfTDos7JDjekSFrH4f34EzYedk", - "secret": "7ed21c4ee94d693dd46b859a6812dd870f0e1d8439f8f90ce42cff244c767be7", - "public": "0300250421826b9fc34df1558cdac0053e6512325aae18aafcc0043c796bcece1f" + "address": "d4vFNveNynBj56XWK4M5cHw5JGLdc9arDb", + "secret": "0e956d92efe55a0b6c0b4db9a2f25d370961da54295ebf45fa8cd0bf4d4c3a3e", + "public": "0396a73e38515653a2b58030489cdb85b8dd000293597eab9616dcbfe0d02892a2" }, { - "address": "Zp8Zqivgzhc9pEjmHqTMA6NweWMvFBe9eJ", - "secret": "0ff6dd1bed382e94ee120c2a65f842a85e371dbe2acbdbb459b9d76e156a3273", - "public": "0229e9f8f72a43a91566119961119c2566c386e5bdd8a957e8bf6c12191e87e6ea" + "address": "trJzid787SDzbZke8HGGabsRJxf5UYQ24t", + "secret": "aa3eab38c574d811d2238f88a8db27c3973c5f3454e50224340abbb70510da2f", + "public": "037570e5c30c2cd11af39ef7cfd8d3d1d09bc9a6618fa649b484f76560f27d9fdb" }, { - "address": "2SpuA7C5Cq3nmuVjN1PjuRS6Wi2WHyt68n7", - "secret": "fafad9eb14f7c24fcf180b9b8065301e1bbf16040a6d4fda3c59ba96ef32acd6", - "public": "025c60c99322e351f78b45904a3c514c027a85bba3bcefa73eb32503f0b58ccfb6" + "address": "843rtbppb1fS7GLipW2VdAJ6U3ASNYEYXS", + "secret": "f700853e5a35c9993f7951b5b7c9bcba595f8a0ac6394e233fdb40c2955bafd9", + "public": "027b6f77c26d08e3ad3bed214f8bd450635c3f53879c60ad51560eb877753dccda" }, { - "address": "cVdVyzCBFgk1FCeVbvB15eYk94YjJ1BK44", - "secret": "4e361f495e11a61e44d648d2218c3d0cd72a9fed01472d3b6f72ab31ad186942", - "public": "02ac87c555587c4f342fe1889f309c55fc933e35545693c88d7451a44416d09c93" + "address": "Jn8SM7bRtzC49hb5ndj8RSjbqUUUPqMj3A", + "secret": "dd09b66bc338c831be7d3e781345957e0b04c691cb9e3fec7104202aabc3b949", + "public": "036abfb1f082662fbe2d39ad34c9cfa4f58f57160d77a7ef997c6738ce7cc496fd" }, { - "address": "iZHSRRPbV6XEAJnQXW9gCuydyy2M6Gq1RS", - "secret": "541584667a19be31019014b05a1f9ede0a36ae7c3e3cdc8a2cabf2ff993550c3", - "public": "024b842d1f1f32c061a08a6db26ba0b24871a0a8e839831fe32f0670f6272bee0d" + "address": "2BwTfjCK38ucP4UAdAX1HbzR7etZcBY6FXr", + "secret": "68928b66031781cc596dd42bf1234c6ae315df97791a2f96bd5c74d2251497bb", + "public": "0328b1281495e1547dc27a29fb29f4a1b66b66fb8358e126beafd76dadbc8272c5" }, { - "address": "SBbV6iFxpDcEuYxx4FL5WwLgD6qmJqc91G", - "secret": "56e5d820b080f23087375dbae2fa3494808dceb36fdf60c44d0c391d9be171ba", - "public": "03c421dfb9d00abd60e05844aa1081b5e9d974972efc7e1ad363a43c677258dfed" + "address": "2XRhzqNgRJgT6rNp1FVp2SyZfrDedjSKUWx", + "secret": "8800062e991bed81298c23b773050edc552390bc5d0eefa6abec0237524a1866", + "public": "020c41cb5d5294a18378f8141b7868d39c9f9c7b0ed2d5f862222a103cd9d491e9" }, { - "address": "vGFHgdKqD9gXBobcLfYBh5aP43zaQ8goAG", - "secret": "fbc535ed4ab013002c7c3a2187cbd2c475517e4186d295367e9f81c6d13beb58", - "public": "038d87177e5f7b2dc92e2309bdb7817c39ddca3e7dda935a7f72244de566301d89" + "address": "o8xuJ8PVfeBCSsZkR5hoB12ooBwXJzVztB", + "secret": "7a54ee9f88101d3623b81556b36922b18b6fe2bff154170322544602daa2685a", + "public": "02d8f4e328d0c04218f563ad17edf39af82dcc8b5f8d5639a6ece03239c7695d4e" }, { - "address": "vX9tBsTvxARKda7XtWwr4e7KUCvQcbPvpa", - "secret": "c848d14b6d76376159ec5d010b73d686c57f75b0d83fe9c0af9db6ca206a0a74", - "public": "022aceb310edb83f9893f16949c36755122458c486f90b3951818b8f0f05367b87" + "address": "S49fz7SUwStZvhTM7DuJfN2DKPgkb9bo5r", + "secret": "9cd5662056a5ebfd882c63852c8bcff133d7fdec0c7c51d3cecc4b41dbb9c5aa", + "public": "02bc622382316e90b2dc4c63a6638719f710dad0024818d96a42c67bbf49f49632" }, { - "address": "NU7CaEsbbKVe4tDQGGczxaaF8DjV519pW4", - "secret": "0b65986d019e63f0b4283e35da785a0354e313ce29910a376ec93b78cb8b19f1", - "public": "02bf020f7da43177205987c11ec54a005f722802bebcdb621cd27e95316a26dc5f" + "address": "FZRetm6mneEEkXzZTGhMfWvK4yaSo1rjf4", + "secret": "673a827dc5452987a4e944dd5edfc286f815c3fcaa7a9f219d46cfcbb56b5dd4", + "public": "03abc7caef609535b9bbec78b24c2f0944e2d3cd472021e2e714f5136b757b85c4" }, { - "address": "aEc9jYocBgGcYuLtc9HgHzgtEm3Qufnkzh", - "secret": "da97e7a8eafa85fd50ddf387316215b9a3cf5e5f3b1c39d7fbed3fbdecceaf2a", - "public": "0389b27353c8d273b702c45746033c37e3caa1be46260836d8ac77baaabf2f22a5" + "address": "pC4nG37Nz9VWTfEXJjgSP7wKDRzNkF4bn2", + "secret": "a76c7a8c63a7c65eedf815ec927b0ec4236944d57bd975cbe3b0ba7c15a238a7", + "public": "03e9bf477af127058244bd5ada03d17f966ae1ac35fee464347aeca568643dae4c" }, { - "address": "29f4c2cTPT5p1fWxLZ6ruZHRtkdRe46fYzM", - "secret": "c71f40bf57d9ae05cb70a81ba3aeb10fd44be577012ddfe406f7fa553b1456f1", - "public": "02e48b2ddb10cb1e99d060f2bf8ed37efc339b5a77b603a28cb4e8fb9d1461e795" + "address": "uVfk3t6iE5f37MVCDKrquUewt2KJWZJNTP", + "secret": "f1fada84b0e61f65814ac2647a8e8f776fed9d07659cf5540817e712ee4d603e", + "public": "03ac4c5040d5e6c0fb9536968e4c59b826a5bcded4af44a1c70cb06c2998e772b6" }, { - "address": "2moQHrtRQ3LHo3hriGw7kPKsJNB72hMBmuE", - "secret": "da7de9822edc4efb28e7cd94e8e867171b1243d4ee09ab1d7ec9040d0672a5d1", - "public": "02ebac7301004823696336dbedd696c3ba0303baad65834de8d5104be8e806412d" + "address": "25sESDqRTSKZbq1Z7UUykw1UxnxejaeHKNV", + "secret": "e66fce8a4934642b40de3206937bab985279d043a5dd063e04c2718d93612d00", + "public": "024b1e68e39344b6e3857434c4929f3c0409897725ddf6b82e363446964a5a7f8f" }, { - "address": "2Yd8FcGDptEJpyrSQ2TXsdHnPb6qYvLyKS2", - "secret": "911461c816911fbb3aaccdb12c9a8b5e03352dfbc170a8d69de6a3f90d33f15e", - "public": "02c3a7623a1001131b50d716a6646826c3c65634ac6a2b4695d8dd0b7b0f635f6c" + "address": "agYZZqeEPpHYS2Ks9tmtbBEg6xTCYZVatb", + "secret": "8b111a441d22f5bc465913e318ff99a5dfe7df5cb011c59d8197809209e47ad6", + "public": "03e36c45480e687f6f2ac25608d0b8e75ea8ada441965c927a4b15a78e3f94c82a" }, { - "address": "2WpS4yuqtvQ3kH7puub1btUd372ECoyN9np", - "secret": "0c68957a164c6e458b7e5477c7dd44424d6297b4b2509b5f8915ee8c4e34c609", - "public": "02dc474f7a62f6cd96222078fe0da8a68f9739a1d66e6ad26720774bf2d9536a52" + "address": "2TpoqeGL2tHKnfBzaBpD6oo3E37rA5X74bA", + "secret": "09bc51ed1979b9c3011519f2a6c900762cea345aa1af5c73a2ab94054c0e177c", + "public": "021b11212bd1127d4606e48c36938a92696d115dfb37880e3e81b8d5b59171fde3" }, { - "address": "24gy3TzvjxS7ALJBP8aS4KrrbTc4k1FVJiM", - "secret": "6fb2a2d9137eb22777af26ddb0ead119f06e3a1cf1d3f2961c675619a60acd4d", - "public": "036bffb5cba319ddb12c49c013fb4f567394f67e581bf4d4ef66d300322c96c5cd" + "address": "22y8iKcVhL9337QPXWAM5m68f9eKHcjhU44", + "secret": "af7212e928b268c0c8078fe972dd394cace9551d36b6c0c60fd264542b6b5256", + "public": "02c1147a11a54d5545f696f6c5047d1571e6b432de8a57e3dff461f159f59a88ea" }, { - "address": "7nCvRD5SWTBSts7Y8CL2mW9CgJRC78W8x7", - "secret": "0ff8adebc33006336993459f32729696bfecbc54b9d0527ff9c243f9b845f51a", - "public": "0314ffc5f8d52959f5b9d88359b2add0f9896a5084fed22a3bf7b2d86c00cd53df" + "address": "f1YscDhp9YWMEnYbPtdJE4F7yaV7GsNTPS", + "secret": "d8e41cba017811d71814bd36bcd31eb63fd6ee9745a3b2436eebdd2700f58bc1", + "public": "03346a3a79d5d6eea45ba3abca39284ff97d0ccd4371487d72f3b4767d70a5df79" }, { - "address": "ab9Vj5c3AsdVhgQTwwzDbHxBzqwddSuQK4", - "secret": "99944e26146485cbb09ba647509fe2f39289390bdcc5c09f4edcc2c3be0b415f", - "public": "02b3beeb397d6a1deaff0d470f23fd66f8818c65ad232daaad191a0b6b8eb586ea" + "address": "nHPDziRL3wwDpe9rGsTUEocAQbyRHAJigC", + "secret": "c1bfbcd71db2d80d2cfd1d703a2c77d218cfcf887bdc31e54c8de628b9056fbc", + "public": "038e900f336f7c079594b2932ab6a477c88c0fc15499eca290c1901408ac0f5b6b" }, { - "address": "g6E47cTkdgBLq5Vc7jR3xRdbSKWA4qJCmR", - "secret": "f526418e3e649a6c442f94d775b58b1ca3b179536033c1a698316ca41b08ec12", - "public": "0394c1330dc7988b1b6edcc86a2894ba1f7794f4fa94d21218e93741c40f3d9744" + "address": "bx6Z6THQsmto8ANcgNb9WGhpedQWhvKiPD", + "secret": "909c29237a00742601bd955e68bd816f7e7bc6dd59ce3073c29bd33d541a2bae", + "public": "037b9af02809edd2690be5816a2884c2c13b81dac4664ae9b77955c1311b270116" }, { - "address": "coCXrqd81dPLA4RcECxi5VuJoB8xgNvqDb", - "secret": "7808575de2bdc1ba9077d3ea35eeedc9dac5515669ff4db7c27305325e8ac0f9", - "public": "03d439da9c38df2111004fa11df6f67f5c463d20a19f00c55d0b3922d55836b308" + "address": "2NAfLeTNC19wof25NSBNpKGTtKt1iEZtxDT", + "secret": "2e9162ff3277034514612537d06bff053b0739de417887d3aff7f4cad7234422", + "public": "02210135701345e15b2aaf4deda129cd751c47e3a37911d38c9cc69c2865b69c5f" }, { - "address": "uvnyz6mV4BqNXtFY4jXzihYsHRomkrDb8h", - "secret": "e2d435bfb5a7d50fc77de10ea10f9e32c7624982011b88d621ef64e982a6d2c6", - "public": "033ee683774e88ac682f19dded4f8b83c1502f9a7e17ec6b1fcd94c7f3cc457c19" + "address": "9L2uQrmvmgeQDYSgiPAmczWAgJTWekBG6X", + "secret": "74e851270b94649cc8b53aa56ae2e188de32d43346a17e7e82e492dab1104a3a", + "public": "02adcb621c62eb75c79ea6436017e5d34631cd376aa8e965d760cfd8bf7f9a225a" }, { - "address": "ty1Fzw1LuHTi4CB42bo27AJzgfiHYYaaCx", - "secret": "b99ed62acf727ac1d9b0230012e334bf3e1a5933f96b875532f00755a6c9bc8c", - "public": "02c6cd7ad51d5417a5e22c44dcb4461a6834bc32f461b2f5a37d0e22123f462917" + "address": "8pDsA7hNgcGmugiq9SqbpBAr8LNvqXhYCd", + "secret": "df3557714a662940a82c11d84663c55c8de236095c28a31b9ec1b149b0a7bdfc", + "public": "03f1ea020b8a21dcf7c6fc3540f96ff6444f121f397ae04cadf65cb057848b80c6" }, { - "address": "UHLrgwnQUmSfgrRGmA7qR5NGHWeXPTEmiP", - "secret": "e8633e7e3657f5a8f544b0783ce34da2170333ae897881f804e48dafd04c3f7c", - "public": "02e2266399848c3cd0aa4a8f9570cf416390fd0bf34d182e7886db1ec2bfd69170" + "address": "HDVGBNTJmnVeU1wY4iEiDmT4KoNoJ97DVk", + "secret": "5041f6146dd91ca0213e2df48cf8c9bd0f99c64fc8a0b64726b44fbbc5f547d1", + "public": "031a66ada2536a17a5490072f0aee3d980b13de58700d933b691d2b95491701eaf" }, { - "address": "2GnvsiwYLu3fAzQ2tR87JV1SHxkUsp5k2DP", - "secret": "bad1999e96ba16e6067b92af386a0f594d02745ab893d2e4361a06adfbc7b69c", - "public": "03c14dccaf22a0acc11d0bfb560b488e11659ab95fb5d5023a0c7ae59da54f9781" + "address": "28GUdCt1ACa7Rn8pN9ekxugDh1hWgiY8W5m", + "secret": "a60c4ba7fdf08fd40149620ae0e8fc4286d6283269239f302407cd1281d57580", + "public": "023fecb3e413741c3f97ef44ae34a3c9b1d32bc77ec1cb5d2e0a62c61dbb336248" }, { - "address": "LmULKcUN1zaMr9YySZjr5ai2bknmhePqgt", - "secret": "0df9c6ea4100da41b17fb764a16b303aecf120690ed2b35f8ce334d2b3ee4589", - "public": "027f95b7c189107013f879ca929b8e1a66cc8408adf059db637ab5c79784d158d2" + "address": "zW4yhXcYE1ehseDfsCyRJCfsT9aFJ1P7j9", + "secret": "121b9d7572889ef55b0208dca8a483887c0b2058db5a891196f561210f0fddb4", + "public": "037cfcbe2648f52ff55a77fbd120797beeeb12b3dafa78ad161bcbf539dedbe336" }, { - "address": "25af1ue8rf2xArwSaNdrCi2Doani7SLSowj", - "secret": "b4c952659ec28b86dec2e9523e80ca70f0dda6f203c366c37b1d3812a67bb67e", - "public": "03ca2e046ba8ff73336c22ead6369492946accfbdbe284c58a01e1be628d3b5853" + "address": "8oEmZLjUnFx8DCt6Jpbyz7iNDEfgg5FwXG", + "secret": "4c3c253abc435b410fd2705af8f0f790c3eab26415e25b7209472a40d0b0d1f3", + "public": "028d7c6613d9a95c0eab9698afbc2f2429c2fc67e62380b6536421e1b4cb4cf059" }, { - "address": "YktndPujzPD5SZmP77kpaJnjQgwM64JXWR", - "secret": "d28f2663a77e3cc0d1a484eedd6ba09fde6abf93b3f0ba66a9403b5947a29166", - "public": "03104de538a6e6abb035a75e175c0f07ce5710b2c5b567e8278a30630e2fdf53f5" + "address": "2FxepT5DXPGNW647tuCakM4HxzLPKXA5mnP", + "secret": "a938eed62cfb072cc74404a3133c91cd2cc056ceb466c00f466e000bd466983d", + "public": "03e72d38296b249fe8104308120c09a46155d8a31abb0e1869a56c66bd3e87f7f5" }, { - "address": "NMQKmmyBUYxJZkombBGMnAEm6yceBvPN67", - "secret": "f8a39175c4cfc8c2cb9f8edc7d675415e15ec3b889b160ba11551a01d1de1215", - "public": "02aa9144add85a5b31d64a4db26b4ae4c857de781856836e7904c991b2592fabe2" + "address": "2Rt2P1Vh4o4GK5EwfqF8ndxscxRZErTuyV9", + "secret": "ee422bd4c063752400d45bae49135f9af10fe29d20fd5eca3116377406523de1", + "public": "0314e0b4a496c865dd68c18cf89f19d8f09cfc0fd4f6e94578af99c6325e699802" }, { - "address": "4VHCXeFEbtNwjroTmWbvx9U25EqeE8EYrT", - "secret": "4e4eb4c31abef7242848580c0e13dfae04f254d8f6608615f9910ab57dd9ffd9", - "public": "02c1566748ef0b4c4543970b1eb2e42e85f1c45889402df9d887d1afb81cd23cba" + "address": "Y1g9wuCKZjCArscCAdw2YjyWoiwv5Dgv7U", + "secret": "550c62a0491ad444acf71d6eae431b4b0503df53f9e495d2340f36d4da47e9c4", + "public": "032f92422e238e703eded027945a9836efad0f1007bee51e4c32b457cade288e80" }, { - "address": "2jwGKWaTuBbm57Qb5fKDHfte27YyrYci5EG", - "secret": "11efa922abb9db8370d616f48879e326ce1ca7fa627ea318401d06d8592cf590", - "public": "023d68e91a3d4ca09b091083ee94794dcba7755cd477d15c770ea00ab791848444" + "address": "2Fafftp7czxeoiio5bNHUN3WbfvrJPghVZn", + "secret": "f4a0576bbff57e5d01ca0fc14b26407325ee7f5bc5b7f5f146dee7a6cfb0a31e", + "public": "038f0dadbe3227fae1a18427cacf83a004c63c51dc8860b7028e95cf148d000d57" }, { - "address": "2ZrWmXVD7SVzFofkbQWuYyVwFyhL74SkSge", - "secret": "435b2b1a93f44afe7c4eea7d97f8952d3b262a0ffc9054e84ebf2649b1d6aa54", - "public": "026608e04e00b37ef41000540b4c4b486a4c2bf8b9d84ede5031fd7448f72f4420" + "address": "2W5K63cGj1DsvB7RkjmpM43PgajoJKemynv", + "secret": "f0f2c983402bf6273aa88b42de4f03876f7beda8f8ad4d94ff35cf1c784667b4", + "public": "02d1c067f11e13275865477cdbd4596be460eace6d76a28e2a4190869c2a2ce598" }, { - "address": "25W5d29Zk8vmVUgzj6LqFgy3pvCyMLhPPpK", - "secret": "4e8ca5534bef923bb2554968a9155c474b200076ef705503d3b41674d4dce1af", - "public": "030b53c98565cbaca5e4f593d8293d36502bdc822d70576e579edba87e1763d748" + "address": "2JmV5HRoUcQY4qfBCfUFgg1GKSbAW24iFDP", + "secret": "95d2a4a278f65f262f265a485d0341b5cbadfa913a06fe4ec168a94eb469c78a", + "public": "03b3856f613e7cf421e89c7ed8d9f218835bfff56fc85813a774545d811c4a1d05" }, { - "address": "auKriEwrdKHeGNaBXMzaYRqdXaj1BrnrpZ", - "secret": "c3a2190376c80c68d568f43bcccdfd93080efd510f8c4f7ddb2bf0ef79fc332b", - "public": "0282aa5f90cda13f741cec9ceefb2390f399a5432ab79e914b5390d6c502cc8c45" + "address": "JWyJu3N51syANQWy8CR5H8UyoM1W4zHbja", + "secret": "40709c6b0060a61fcbbff96623330fb65bc38d193ccaaf612ad06157c5135772", + "public": "03bdf149804ccfa96942a0985132dcadba7275b30f7cecff92f36dfff4195c4336" }, { - "address": "5r3uxuVVLAm77yW1NFBMXqPjFg9cqhLPEU", - "secret": "3c84e054fc33dc00f77770c6b49207d92de7f745c88c1857d72fdcb0e582e8f2", - "public": "02c99902bd94aa1ba8dfc8b93d54327f72a849562c73907ad7587d005d2be85271" + "address": "atsx4Dc6dnqoJQHKPDjR6hgjjEtF7cNhSw", + "secret": "c4e95cc86105d81321c5d7c5d93f7ca9956511e621ebe0a92a18e36c333922e9", + "public": "0314ab127f4fc734f7421a4e470f8bd763f6c63c6bd7e27644a0964f50fb736a5a" }, { - "address": "Uw5ob1op4gTYVbYDNk8ub3eA79TQwqFd5H", - "secret": "71c8bce7a963372a9f885af8e2e74d696ab5fe3df2b2acad02ed8ef8ece0119d", - "public": "025adfa3e37526846cf57fc806a0a877880621c80b86fb99316e85b92fd2e567fe" + "address": "G6TVGZhGKttfCybksiQ77EYuQ6QUuXVsFs", + "secret": "5a1e028796d742347c7f17c2cabbcafc47c5d8fef5c34e31bcfa012cca8bb724", + "public": "028f2dc1e3dbb4cd78cdfec0a0a9d8e88d4f7d3a231530136030714b5c82040c2a" }, { - "address": "Dj2SoqU9TqkoduLyPuJdZgoUadogTYENSz", - "secret": "0a2f8447d2e37d6972b564abe3cf51551f205898c2d4d348322cf3c41c6170f1", - "public": "0231a3673fd8aac8be8b451685755cee3694424fd29687722bd36126d874f4d37f" + "address": "tnmiayXaehMjUutwQiMnjfwumiJii3Negi", + "secret": "ad96aca0144c11368637c0a0c204cb54812d2e6e401c35b414ac3b8e020a3d56", + "public": "03aa85be4ad8bde40cdd03f1733cab365ffe8645ac8860c13f8ee98eee7f587a47" }, { - "address": "2Ut5mVpgqcyQz2LqTkQRJo2u97der9RtNQ3", - "secret": "7becdfb775c6982f3dc8677b7effae2b7590d869fd732b65b5c06aea57ca16e4", - "public": "03d1f00f6c01e47873677ce1bf443225d052049de975a622d581c0fcbe7c525782" + "address": "qKBvbpxDrCC13fJih6z786gYkCMfPr4yt9", + "secret": "e62bcf14a9c22421cf790b112a49a41d292abf8f957c595d1604fe242218617f", + "public": "033fb1376285345ea5d55f282239c9ebe6a34b0bdcc2a24fd7e50f2dcd7a9f0323" }, { - "address": "2Y61d4i98BxmpiSfXWn3huFYELshujrtTsU", - "secret": "1740de8db6d7352cc776fbc96df33c8a364c6589ddaf0df6a596f06838b17bee", - "public": "039f8e8babb8939129b22b6212c88ed33e5f8c4e2d7fc00bd1a83ddbc838881fd2" + "address": "2Q3fiiv1VnZq52EXRegs7Zm2uNuN1VqYEr6", + "secret": "402d0cd54cf447d0d1a6edce5b363f6d052ac923ac07880261ab1966323970f3", + "public": "036491f6619e034c7031284cd222785b9ee0873f20019e49eb80e599423050a4f2" }, { - "address": "gu9yT3CFLJCiMKwmQSPSaEjCfqhi8FQz8H", - "secret": "90eddbaab7eb66988aa3d8497bbd368b09ef5dc41695ef70993ce75b354b10bd", - "public": "038471f7b9821d3e8eeb86f2a4e54b90195b661c705296785b957ab07d6f0bf972" + "address": "2XTfvKh4sjavjxWzUpun2aEioprqmjy8DRg", + "secret": "4dccf074e0c8e4d01fb29a41da3b05acea13693c0d83ccef456f78493787de7a", + "public": "023c992a18276d82533dc77c0d12f65668083a75f9b4b8963fc1284f34b1bfd6dd" }, { - "address": "29yWuMDpADgvd3TctgRxpq9tHmjnMbic1Yd", - "secret": "bc1327707a3f44cdb1675853ae793ff1bbdc749fbb62ce8e6c015e38e7361c86", - "public": "03da089930e84a0a61f8b0dbb9ff4c08b80b243b0533efc77f53fb8e2ea4e086df" + "address": "rDdVaVDJhB1idZHPXbQ3PmDFV1ieXp51hq", + "secret": "2fa5575b7df071950d930de9c9e00adfc8d7e41ae4e7731296b938874c4d324f", + "public": "0252de761de10cf981f0cec0171f713090944a85970cc911e35433427991e5381c" }, { - "address": "2GHwiT4iBvzHKNRHEvBnxhJZnb6deuS2hj5", - "secret": "374bfbae309148ed2577ea362f3ab0faea1e20ce27c8cdf1bff64f3485709726", - "public": "020051380e016afabe0e9d0292cf3742458822f9ac5853fe82676d6f9c75fbb7a5" + "address": "5MyhUZ9JkQ8nNh11JManWvm8btNEmBDHm9", + "secret": "12be2aab0d9b3556254e6ac9ec5480f9eeee5a9e9cd48d4ee5b26863cde25694", + "public": "03d0325101940bac1762da47ed2a30916fb381a461474ed6611afaed556d32836b" }, { - "address": "KG314iDK9pH66wmaq43Y5XRRsnZgn8XQ6F", - "secret": "66543bc94dbd7cc6d163559b27feb34c3d1f7bc52ee079d9a9eecb98b984ec8a", - "public": "032b50155e098ca40dfa9475f96437d24fe09a517bcf46c1d6010d56076bd039dd" + "address": "2faGziNRteqfmS2iT2JHrqg3DGJCr7bwPuf", + "secret": "d90f354a51fccdb09f854300ad60d85999062cb716b1f3e8ad706b20e99f6571", + "public": "03637c8155e9858f168a15283d0804840e01b02654ab30dc7505fdf88d7aa88ae4" }, { - "address": "BtiWQ3JrUPtLNKPCVyXggEBsCiyZcAFc32", - "secret": "5176498c7dc5c84d4e2121c5b40b7dbe67697f044d43ebc6e3b288226a6ea0c5", - "public": "03ba05eb7229237d950c71f46822dcdc6a432472d3418328d2e36639a8b52dccee" + "address": "s6nvRxY2XmgzUNxHPhpvZWL7KxgXHjpeEx", + "secret": "caa73fdc76cecdf09c278d82eda4ce9ff40c297580dcdc191a4bd43ac0804d53", + "public": "03af813f6b8137f46ba8b77cc9f1cba50f93689ba7ce5498a7edc59a0e3314c6c4" }, { - "address": "2EMFrxq6wrJCvi2gz2t4oHhnUXNv1LBGzTo", - "secret": "dc0d0a109f0c18001293cc29e7505954cb5d48f8bf93a5eddc05f37763baabff", - "public": "03d5bc2cb20b62d2d980b4e625193f0e80ee4b3bb0add055fb99cf48953ba9b5fe" + "address": "i4NJfp663DS2BKoZqRrwZWyqJmhV49rWVM", + "secret": "5becbb9a2f3dd5ddfe991b5d8d4c7c2d578ae4d612e92fc64fe902a4233a1ee1", + "public": "0237fa3963e2fc18f0f29e323ce3c01a7ec26550a4e17fa5dfbdd748d4a0a9e116" }, { - "address": "GbdYe8rPo2ssuKFVHMgQfqbrFDfxWbf3Mn", - "secret": "7b9cfa572c04eba6e4a6cf166eeb6ea03f723111cbd395107653efb5cf766b9f", - "public": "027377852ac1ada2336beefe3e24467ba12923332f3a00f3837828ab0f3fc98f0b" + "address": "fcvhLM6vswQ1Gv6TjSjiadS6zoE7zDshJa", + "secret": "3dcf4be5fbd7fcec93f17a2a07854e902396f8ee7f0ee136633520c00bf8f26a", + "public": "022c509d2fa07aa98b90d4056497822853c53115f519eef7560aa0b08504c59a73" }, { - "address": "2cZKfMfpuaAUaNSbz3XrDVqiTTArV8N23cW", - "secret": "cc3b684824d433016ca7ec4894c3aa095eb671c7bc32c34806c36356a765f545", - "public": "03f31c7599e40e43cdee0c41aea704428cd5936d45f75e98605c0fdcd75b09672f" + "address": "nfSyJEW2ABm9W8vEQiRsrWEiFu7t68YkYc", + "secret": "26e4d66a9d8a84b8bb249179d360817f042b065ed4f6dbd88ced895efdd660d8", + "public": "025898ccdd8f913077758d97d7dff8704eecbfcdc9d6ed6aac6e46884aeeff1b80" }, { - "address": "NQTidPNot1p5jfLrtJ6tyKoM6JabHHhzj7", - "secret": "e2d856c86d9b39d4bcfeca934a5e627f85857d33eca375f2dd5537ace260d9ca", - "public": "0276c8f3163c995f6c2767c8c86066648ef1fdf1e7ea016cf1fece6e4e2317f81d" + "address": "bQB98uNcaCJXWWeGr6x6xrGq5NMzbSfw7B", + "secret": "e01f466060b0a3ed01a453362d3ffd0f0612ae7dd8f9b5c1d23f3e5df7cc40c2", + "public": "0361f9eb0b245e30d44fe15780b06d67f04d1c175f2ee155e6028a14f6dba72864" }, { - "address": "3tx28G5QdibpjoACz6cSTxzDrCM48AYsxd", - "secret": "8938d3bef22e29f74ebf1bcc4c53f77e53d54a46ecc1b56c1de2b6e55eab7eef", - "public": "02398395262062458eb81ceee0b4885afc07d50e8df61d816b6048f443cc468336" + "address": "242BmWuosWU4Sj5e3kvDQ6ibvzNqZUzZ4de", + "secret": "4730bf793535f544e4c3abe6d54921801305850f769cbcb64bd65f76da1928fd", + "public": "02f311980d0636ff8fe655b6a695d6214fd09d02d03ba426d1da42dce5585802e2" }, { - "address": "Soohaa7ZiGnpNP37qU2HqMipCU8Ucq1Nfc", - "secret": "921ce152a45d25853acf5ede01828b3b171c5f5702d85d0c504b4b504620d9fc", - "public": "03824aaea9bcdc99e0b7e53da6b80d359b92ed125e1882d173fbdb7b24ff1edf2a" + "address": "26BWqf1QCBxGUdnbuonjWRi27LVVLmab2Z3", + "secret": "ea4b5510b9a4fbac1057012004999622d16b0e8b89cadce161ff1196cdb5cd17", + "public": "02080ce1982679c7cc351d36a4f4d4725bec9167c781df0f93de7a63d02117eaa2" }, { - "address": "gvwjXyQaMeMntS6LA5W38r4YkX3FZJoNoc", - "secret": "ec06857ba9b6ae1e1f3b7aea93c86b8babc241b5a0eb662197ce323bebee2a87", - "public": "03cd2a4db9e9b6503bfad1d88c860315904965a6adbd634d474bcee46ab558734a" + "address": "MLXZvSFYD2Q3ST9hWHJK4wgMmoSCBW4cvi", + "secret": "fb0b97b8fcd171b41fd436b8b513794adfda84fdfd2c6f472a40380a49508462", + "public": "0314787b7d974e093a356713a5be01b14586351a91464f8762ed179290e1324f9d" }, { - "address": "2Tj39nmFaYoBcFKa3J8ks3H1xHj5y2u2Tmt", - "secret": "3070ba8dd3f67d37997e1a6687ee15eda59fcce7455391744345212bea56e1f6", - "public": "0236383454d36ae00d9d2b965d71c94f603d9579bf9ce226e01478b635a9afce44" + "address": "wdVZgcdoPVpdEhAM5SBQ4gm3aZQU5rbCjm", + "secret": "4f6c7aa166ebedcf651b11804a969cb0ab939b1bea36bc0c7ca50f0bcb208798", + "public": "03876a421f40c2fc8c6aabc3e4449f882915c2ab5a1d15b5c3329c46e61e417508" }, { - "address": "2kpHENUF2wGgMtcyCjKBJFkNRTUpqW4qurh", - "secret": "b7011ae30595d18a84aff68b94e5e6e04ceeece0e04aafd381a442fa887a5c7c", - "public": "020d9287830ccf63454868c45c1a5315a6910d26509e027bd94fe6f28a45f3855f" + "address": "22z6getjDD2GNjXZqe8tHjt5ypjutAEFoLo", + "secret": "0f3d5966a4dc8b6dc64a338e16de058728c1cf2c3f839b3cb05931bd1745eec6", + "public": "029512639e507dcccabde5d47fc5e8a4a95e222c86f5b62bf210329aec935a63b0" }, { - "address": "T4ayiAnQp3cv5bSqZ5Qjn9VdvnJE6zVfWz", - "secret": "34e4903e75ae47e4ef1a505d284382909151a43ee4bced25397989a846214cea", - "public": "034a9072a5bef24cb0932995e2eb912032d44e3289fa405621c31318bbb077977c" + "address": "2GEFesXK5Uv14hn5Bmqwd61c1CCQGMvbZLh", + "secret": "4cf001cad4d96d2f2a43089246a1c756e1c23729d1d024f5d332de17e7800c53", + "public": "03045c57e07f9a97d650fe10bf7f3fee1ec1fcaa706e4d7438b5dab09198b840a0" }, { - "address": "jouc28dhkdVXCKgghN6mEfcU9EyXnx9jL8", - "secret": "f2468bf8baac7f9a18ed31bd27cfe7fe7a893223ee8957454ddfbf33e063d52c", - "public": "03fceddcdecb0f45ec34b47cf96440c1117ce06c48815295ff8a07a8848069cb27" + "address": "24zxvoEFNb6ww8zDnchMsqdBoJuBL2t6LQD", + "secret": "fdae58716ebdc041a3a15c70b829af15f13560a371f57086a9f44f3a0faa772f", + "public": "025b943230dcdca2a78d9e2ef9b655c310fcc1bbe6493f05f5cb685b8fa4c570b8" }, { - "address": "2aSXE2WPuXx9J9uuAdUC3smc773SNXPo4TY", - "secret": "bd4d3877300c20bbe4657434fcd1e5e6b9454eda9561cec471c1a4cba6ec1101", - "public": "02d93154c02312c751d096c69c512aa9ef749d1c948bdf64220125b736884da1c8" + "address": "2F9PfKBjsUMEViRoM1jKAG55T1fSu6hg1aU", + "secret": "219b0e3e367bb102d9e221b3f9505fb808bc086c9bd39d85f3043d59a0b858e4", + "public": "037cd54ab5c37e03c911ee05f7a06dac32bb55b5a18c8c51a2098905ee4f4d2731" }, { - "address": "hbtfLJJZTqeSNpyaN9sXmbj6iJUeCeYhUK", - "secret": "f63a63cbe3b927e8b5cd366fb736727d15ab7407f055af4b634fac978338ad7d", - "public": "03b890defca5d31f87c6f4525029413f762fd333bbfba7450b6cf709bfa384f285" + "address": "k6s7miNx1cnYVEgUPQD2iqufKzQpRDmzQ", + "secret": "ccc0b397cada9ce4237a0a99697ade6adb57902cb30b7205c1572c377b34b778", + "public": "037bb2652a57a019ba2409b589522ef8a469a140537b33550e161676c0ba609fb4" }, { - "address": "m16jriZv62tDEfXJ8bdGPKvi5S1x5XT69p", - "secret": "0021b2bd05e97f008c9a33f0f428a7796b925bcda2d5831dec5b008e24994a0f", - "public": "0395a1686c1e988a4e9c1d5c87dfade0c97fd3d64c56ff5796a372f6274dfc7ff2" + "address": "S8kVNfBsuRPY8UcwVC44L4JmHF9c2vdoz", + "secret": "02a608c34f19e5f5d48eb3779bc61997c6228d6a83d32ffa21cc5e00c0c66a63", + "public": "0264d8c516969cbe5bf6882187105c72e33c44534203c935cba5bceda4875bd48b" }, { - "address": "2FnyC2kctGNneJWhyd8sL6TthSV8EtFvTGG", - "secret": "b6adfab1b99232d19dc6ec49d42b88c7ec390284d2c4e1f88f63887a572c28bf", - "public": "03e176e5113c8fa889f09ec7fd478de6cf649bc4476df1d83518f278d4fc61094b" + "address": "2ELFHvS8iJs7g9hAYmSQ4d3fPkHPZ7GSYb2", + "secret": "c4d7f23d8df026b38083120e820bc90150557567591f16891de724d1cbef936c", + "public": "02773b43ebe9825f49ffbf9869a63870427c0a2d952e259fb6f14d177100fc918a" }, { - "address": "jH31E38guUDtsc2Gq1n2tF9hjDwnKhXUwC", - "secret": "713cf5f3e51b2a72177eaeee8805ca824cc0da65b6f6f2ce9e0a009477d2a87c", - "public": "03df398971e695553bde3d2e0b02566e7f80ed5afc7008b7de2523701636ef2924" + "address": "hVeQGNagmE3VdB8FAipt4Ya792T7JhXruJ", + "secret": "4197e0ecf350e45e082214b47e17284ecfaf1fea454032595b143a0d89d79aeb", + "public": "037e25ac47ca505d157eb26196263b1747e71548381130bacdf8688c0f31e29d58" }, { - "address": "2Ciqv3XyStpggAhDCZitVwn4uqKx4CLrryR", - "secret": "a1e456f85144a6c13fa59559b6fe37cf269f523781fd7fa10ce356cc8b5902a0", - "public": "03d84d415eece90ccdf6b0d740574de9328d1f17aa452c47b098e6e3fde72e4504" + "address": "2gzCB5wvkKAAjind13d6r4oSm2wasV4aTjA", + "secret": "9e7cdb5242980b321a79f4247362d34c0df1552dcacab20f8dc831c06d4687a1", + "public": "020b81829cd7049a05c9403d9243247b62099a7373b5687300c4f05a3d6996522b" }, { - "address": "2S2hZoU2is1Xa4iD4dH8YJobs92JH6D4rWB", - "secret": "1f575408ec98f8a6f98889d140c2e73764846539e19c16606c2c698d4f984fe2", - "public": "03286a2770393f134b47fe070288ed56b9fa11ffc0abfb312c54e15755031e79be" + "address": "6DhQZL3HQG1Ai4pH9c72G2Svy2ELaozDpH", + "secret": "ea67b633edf994dae447cfbf50852ba075be004e23f4d99962317c62d25be769", + "public": "03e11ab39dadfac039500dd103f7f466b266a08e69ab2b3b0990b620720bafebfe" }, { - "address": "2WWupQRsvMJxsyS6cTTXFFMU1iAdnr1LYjD", - "secret": "58ebe8fbba54f9764334c76c40bc0bf4eee36b6afa41847bab4ac01ef0d5346a", - "public": "03f291f4c0547d670298b3ec411ba896c19126d67f57a18b5347163db132206a0b" + "address": "2Tw4op3FCi2aXuSySqPEkxUxAVHCi8Wyxwp", + "secret": "9a921268064f24b0e07d8740b72cfc658ca198dfe2af0b373ddf643dba4de755", + "public": "02aba206211ca5a9eff06f96823d3214dd21b2b7456de48f7fe51ffe4f7b7074bd" }, { - "address": "2iadQDq3jzhLfq6rVsLshrz56LyCWw3hzo7", - "secret": "4ca0b2797124914be192f7b5028966584eb6d05f201608741de5fe91b32c84ef", - "public": "02e59b030487a57e731726dfe30faffeea6cc62a3e77b3510834d31f492760d141" + "address": "2apYHtvxjoen5tFVrb88XkjPRHp61bnMmYF", + "secret": "7828fe7605bbbf70fc0003d04ec85a860376e8d1d8ea13fda2079be6b11b5c2d", + "public": "02e717897f6b0f94f69a393f895c9df2da0e45d895cddbbe95256f6ae0c433c7fe" }, { - "address": "2cntbm7G5VtvW52BGGWnrWqPTK2vZiMV6wy", - "secret": "7d9505171a380017cc16d4df6db831679c5d0be1626cdd71a6e7d0af0d8cb83f", - "public": "03c280882c3cf0b5171987c20b96b577d398e28572e77cbf0668bab7527a1a6e35" + "address": "1NdzQhMertw6PGza5eSxqfWMhMjGhbYszx", + "secret": "6f539af4e8b9001e591421e2830a3a2508dcb1637f46203e5a80fe84a9952a9b", + "public": "0263b7563c486dcc9ab1f0d46a5c10ceae652339c353031296c9f1d7deb3fd2683" }, { - "address": "aNBA8netFHCJJGNsxcgCBHP1RbN6YXaEHs", - "secret": "5c39be70f85aa87690f9d69b253bdafdbba77671ff5d36f373ebfc8223061f05", - "public": "03fc85cffb734c2625381ba1e01adf73f9c48fc4c006b5390a9e1ba4984451ba3c" + "address": "xQgKsD9dAHf3NAazojsQ8WYzbaAyrJZeVy", + "secret": "ac07ce6a66f23f5ecfd0e0d983297e18a945730cf653405029c2e94cc7975ad6", + "public": "037104e7bbc30d57f60ce85bd56b19ad72507079dbb9befeb524bec6c6f6b35f8f" }, { - "address": "268CXhxUSCCQfC2SAVgJBGEia7A5cHTRkcb", - "secret": "d4536071f834306df6a9ac84fa3f38c7532fb94487c48ec8890a9902879619db", - "public": "037c563c1bc0dea78dc8d7d78a86177bb1ce3d74394a0acaa0ec29eb6a72586e93" + "address": "2SShMG5rU7mJ7v6wsjtFYgxrNB56P3cpdrS", + "secret": "4a59d42ba0cf18052321f70d008820256b790ca132461ec0bbbdbe1e03bcab40", + "public": "0321b0224eae60e8518343b6cc8ac9943561edb276bfc468aac589eed9e1044415" }, { - "address": "zkpzn7kPsZDkqmHoQAEkEwZ6GAjoUtT8Xg", - "secret": "6fc592460f94b834498bd426fb050a611b641cdc9aaf43b0719fb60ff54fe197", - "public": "032644df8ebce685d4f4dd831968b90a70a0b634072ec11fd4748b42229aaba118" + "address": "M6JKu4bqGgnJ9ZFuodqfxdzN7Y4q6yoDYZ", + "secret": "dd8a0861ba597070c6d3b43be005e764dd2960bd12ba86baaec4c914132eff60", + "public": "03b046f7c69dee941ebdd54498386338bc2378ae983c9d6b949e3019205dcc7be6" }, { - "address": "2UCQpm52VGmzvLW1znQbUNLbt1DjUyNP5ef", - "secret": "ab5f69d29a283234de1e606bd3beeda032bd737ce5abd3a2d7d31c43586c93be", - "public": "021240a956a34b4c66881663fadbad6eef12ddecc33b5dc0eaff98e5a7491bf769" + "address": "21vVXWwfSgmhVjMZKzRqQphhHWJhQN9PDmy", + "secret": "29d4bc0900ad68a07c4d4678f9b75155fd06aae8d8c96637a75cce4f2cb332ed", + "public": "029b294458e653d166fddc0f96898b19b74b7ef9f5372c722ac159dcdd7a633557" }, { - "address": "ntXSHUTymfM3us5FinGQiQdEq36wdUATLv", - "secret": "998df20e3e24ccdf02692700dd3b9f4df1854e3f45ee6537bb463a22bc8ef6c2", - "public": "035977e870f6dfc903816e7d365bb676b8e1e2c41516542bc9e4d34ab8e6708296" + "address": "HPju6EpzFnWijK4YF2PKhGw36zpC5MTPqc", + "secret": "c1a77068a552a8183a634ee9aa117b21cb9c9d3d71bf885f747cf45a109f3bb9", + "public": "03b13f40cb83bc0fe2386b36ce0fa0c4426ebe68cca13d969951e019539aaa67dc" }, { - "address": "mcyHaxaCj9YZjLdNtEtrMeCgYZmh3bQk61", - "secret": "c8a7a880727e136104cc52644c2af1f12f8ba69faf50eefb3d028a48f43d40b4", - "public": "02aed4f905820e9f2ee6728a5a1611609645fb1f5906036251bdce3502903e0bcd" + "address": "B4X6nsN8LUFZnyzPU3xuVJvJseVy5QFywn", + "secret": "5eb166ba3ca4da3353078eca2ca23fda60698388b37f860456a84a1317c669d5", + "public": "020d49986dc4f72bbf500b1d334570fbe96938b51b659f2628f51f65a8211e3afc" }, { - "address": "rQhrvGN8XhhAJqdww4VXaKXsz7AZrfkgoo", - "secret": "282290b7e317e9cc2f57c44d260bc64e577f72f1f76c118be56de68126141bb1", - "public": "031586fa255d7cac1b496aff41dedad6e2f8095de393c0727e573d78eba0f9221f" + "address": "rA8hZGYDhU6mpYdXvwJwdMkCijiGHxGG22", + "secret": "d8e8829f9729315b9ba98dc56e4aad0e85464b9f6bbb4728f705c1c40414177c", + "public": "022764a5135d53da5c995b93ec79259ad4895d0252f61020f9244914957ec4e67b" }, { - "address": "2dyaqNZwUQYdVTL6DBcBmbDq7JVzZXcCGvj", - "secret": "6cc81805e7d0298d7e6a0c0a7e8398358dbfbe451d89f1873e3a02c58918f941", - "public": "03ccc834279c2703f6157b9f0445b3be24cbc5bdb8a8b6e228c6de9c478c751042" + "address": "fHnsaH3e5F4iMSAaRBFdDvNuEXWMiG4h6z", + "secret": "01897cda7e654eaa1204a88bdd0cc1a3c97ead4a56d5fdf0392bea2e5e188146", + "public": "03f1ff4bbe86bcd2b9a352f886df871b09b2cdd0820db6ec12473a620e3ab40cab" }, { - "address": "gFckofkk1YmkyhDNSKoucfkVwkGDQguzYM", - "secret": "df2b2c22ea199dddd0d12d2ae9656897e216ce465ef6c5a7128b01930cdd76aa", - "public": "020d075f56acaa9a9b074d15ddae27991a8323b70e55237e34ef03c9a621355715" + "address": "NpcgbvncaoAW2TZDbLvA3SgRBKGKjFBnss", + "secret": "afc18ea7580c9563bac4fad5408e27bed5fa5c3b48f72b71de3771e4f4daa9e5", + "public": "02401f34ac31518444750a1aec8aebbb98396a788bcee54235c62cc8c7f1855d38" }, { - "address": "2ZEzdbfAeMHCGTm3pBbGdTEoUjLuCTsfewN", - "secret": "58b35400e3753d53a907b54248e6a9c8102e18bad2c86785eca0efc45e656f39", - "public": "03d1f0af1eed170fa7398716867e28326e336104a005126d50c251ceca1da53fff" + "address": "7mZibtJzH5BV7nTsk2L2E8ybPJQzXgsjjY", + "secret": "4f8468222e72f899d3eca4bb752e46338430df815ff32dbea405077a970a42a3", + "public": "033c5e16a1857eb18cbdaa0760defc375c11c7a990f22947b32f603127fe8fec81" }, { - "address": "2D7xREAnd86fNZZSDzj2zWkJ2Yf8nBkjV2H", - "secret": "7eb15e957ccce2581257833d157c95fb611b547596e36cf1380211c842b05449", - "public": "026812a43d5757005a6bfcf4a255827b97b855dce0032bcd4a138bf4e4c038e5bf" + "address": "rTrV5jQZ1116ubbxqTD3r9VVgd9bRausbm", + "secret": "f26dfd8767fe4f2d99a006b20dcc1b760a1784e11469f601e33da7413006721d", + "public": "02d53189e1719326ca40f472c452f18bcf499f2eec21e11f39c366ba3cd1693f4d" }, { - "address": "2eRA9EbdekxMoMpdmhXS6MZKKuWc1N7TRmC", - "secret": "5ba475a1697980efe741523f7e21699b8e498af289ad16d73aea05ca4388deaa", - "public": "027899948385e732af5b4e586f6b0d94a578a5038b6623e3736085aaa4b2603db5" + "address": "2HCBvVq4Z7rsJ7o3NdRGoG2DT1KZ5EinoD7", + "secret": "02a404e6b1ef80a48f9339deab225c0ded0b6a80d26b28746e1292ab01413a14", + "public": "025318a298154019bda73f131fde9878ec04832efb78369cf1fc90d2c3a6da74f0" }, { - "address": "2jVw5tT7G4Gn4mVnGxNiCXMJTtLgCDotVkh", - "secret": "a92501e9b688c6d45cb73f5f6101b9d9ced5cb4c93332d39fafb1a50139dae70", - "public": "022be156a98efae3f1fc0f3c62e20411e4d1eeba2a58f480929ab61d0714a45d34" + "address": "2RUhPZhqiAoSiEYBrymsdAJ6t5VkEVV8sTc", + "secret": "4557c781294d893b66792f88bd6c7557ed85bc471d735b0cdaaa9e070dab173f", + "public": "02e2dd3b4e6ba39a59977a0ea678293255b3bc7d29351f0ec053c203a778dcefe2" }, { - "address": "VqCLpn1SW5JtfvNuQWLG4DriWR9EGb7mhF", - "secret": "94afd5ce184c30e707cf346a66a1f73a85cd0de6a0c9c57fc9e2f735d0da5495", - "public": "031e29477cda2c252285890e673be3140ebe23adb5d0337fa50b7fbf0a51c472da" + "address": "Avk4QuxAyeFr7VtchVebEY6Raz4uRs4UZM", + "secret": "c73eb18af7efe89e31f452d912719611f8cab5872fa2d66c61ff376cf57fc9fc", + "public": "03907b52c063332d80a3aa3b9824c2a1873e966caee5a05c495487cd4bd30d2662" }, { - "address": "2XmNR8J51RuBMuRFaddWEM7dL7sfqxT1rNS", - "secret": "4ca37b28909c93af38ff5c180d61c3f43ec4d9f3070ad43205768e0830c56f0e", - "public": "0227ead47014fa4d57a85dfcaec68cc0051af2cbef2564328f7e35e7661fd36427" + "address": "MGgcz3urE7CCqBm7BrUyiv5YgSkzM1zmAk", + "secret": "7ba7d4ae04765fe5f69d8e1072b22dc2bd5d8e89fc7ea9177e51e7407cb80324", + "public": "023ef86e43a831ed5ea3faa6c0b6c92ef447ead071c32085ba186b615af3e7849f" }, { - "address": "2AGNDqnk52ZqcZ2ddJfR3kAsytQKofNbJyA", - "secret": "de28ae55d98678cee8f0babc37798b79230cf77973e65fa6d7c4d132f7f8e1da", - "public": "0381127a7f2f59392eae36ce7dafc312536270a8020c58931cdda3b5e7b262ada3" + "address": "2MYqwgpjcM4KooQG5kPE7nqicqqma8TPoQH", + "secret": "5a26e22f142054c7e91ac5de6e257d341a66dea9b377f5a1524e8733909061be", + "public": "033956c4733f9983bb70877076e9a16da0a3192bb6412fe7285048f1efba2a835d" }, { - "address": "1QJkWsALZBvv1yu9CsPdVjhrFWDcWeSTpu", - "secret": "1dc36e1eca785188605933ecf6b056cb21c00ccdaa4f17af28badeca721f8822", - "public": "031308b1ed28168e6a5d4068796b3ad3688100692c447be548da504da058a5c8a8" + "address": "ae8Ah32GU21Jk2K8ryWB3xdcyBmLZT7Gob", + "secret": "1831d4b0c420224c83020eb30671836d8722e752619e8bbfff631ef4f4d229fb", + "public": "03b88178014789d21bc222e02cd802496baac40ad729b0183fb2da47d6b0bdf879" }, { - "address": "jSwvTH2mbnMrtjSzPZK7qVKNN3mYwXpePh", - "secret": "179b2caba664c573d41c6a0b81f35a3692d4d05a74d9bfef547613971533f742", - "public": "0353b62744a920c41dc885772c305a5790dee402f31869478181a3e9b33b6a2be3" + "address": "Hft6JuhuFhKpQmCteJp4y63GHadLWbtP5m", + "secret": "815d2fdde17cdf80623cb0e4798553f929b247b79faea9cde29cb213be378b56", + "public": "02fb184a0fa61e856f1c3e6324ed6089fe81e211bfc1ab746c89d4962b4ffe525a" }, { - "address": "2VYtLzFgfS7eQDUFqv9WAQuGqwvq9oHGHJW", - "secret": "8b380ee6e579eb6e10452a64fcf6f45a383ae0c8d2c250d82f4263674f7175a4", - "public": "02294d856cfcdcfbe9d9137e7af4427785699873a578e7139f18de58f2911843db" + "address": "dNwZxggozhUJ9Kvfm3ArnH2KDVFi6gkG9z", + "secret": "9547add3c5808753234603f06a90dbee06728be93345d74c6e1a5639341053f0", + "public": "03ba596f4f81a2b4033a557175e9fff808ea41804ebdfb2583bbb7807c1a7242d8" }, { - "address": "67X32T1XeZ3tnZfNvKknjmM3rRGoz6MoF3", - "secret": "ef8d121455a1ae28c58a68b378bb350aaf2e4e8b9b8a42783e2bc520325bea97", - "public": "032d957bed4794157e881e09fdb1392a24d19075c412113aa72cde472c9b77b3ce" + "address": "2LBqp8gpoo7V5Am7ExiaycspCkzwDybmCus", + "secret": "2fefb1881c3102faaa2105597a139f601105fb705f2a7c7a23e12049507b9236", + "public": "035421fe09128dbccb1bb951847800525cfd979006482a0576f3db7983f005b9b9" }, { - "address": "cQwaTY9jSQMJi17MYqdSB68agr5NdpRGVN", - "secret": "0abba1aada510f0e5a10beb3daff04ba0140c6e5a7f1c2a5469afa1cfa78b641", - "public": "02010246b5d19535c94061d3fbe6416cd3cb071f19e8900f8315f4eeaafde077fa" + "address": "CNoWEhb8kKXFWESa5vyqkpnEm37owGLncC", + "secret": "3afab960a2d0fc16cc418946397251ada6243348bfb8cda133157e1932e519e9", + "public": "03e8f8a2ba639a925de7f93538838b6530b68ef53a7ebdafdc399b1e2e6066088e" }, { - "address": "2irZgdr1EwSfph4nAQBtkTde6UUECTJzYVF", - "secret": "c0224da26ac941a4a1325363b051f7682ac06b285dde2b4310ecab981da6f6d5", - "public": "022ca80b934b202244d9b0270d5d95dee56e942ca0e3c41150c075813a47933fdf" + "address": "2jSnuGTDS7fbkfgwjkNErXGyz4Xx8hNT5CX", + "secret": "7c124e22cba0f682a2a2a94144adf670f8e5c09228decab2a1cf531ffa59f82c", + "public": "03f88d2c546d56f7034fdd597f6e2c6cb1c00d54d69b605e3d0bb02b743bd9159b" }, { - "address": "5knmEznc1jvaHddijyqLv9Xxd5vVSGUbPs", - "secret": "7ce9a00efcde70c446a07b5530a92319e856113dd3d1b81b1adae8891f3bfcb2", - "public": "038e9db9ab834e38a693d1eb5c5fa09c471c0a4a6049ee65fc26407183d8772fed" + "address": "BK1sByWwm6ZyCFvt1MYCnuhutEEoVKm1sL", + "secret": "51607221de3b4eede57796c66a418200535af5af75b73b8d48d47effa0d08e9c", + "public": "03efb377e6ee222a37a0d7f73be09a25947c5afc5b0aba90138344b44dce8e11c0" }, { - "address": "GLAovJwWU2rb89HmmWaE8dnytAhW2m5ReM", - "secret": "87230d3da6f119c442995b262bf0e68e4d382a3641cd7f4a91fa33e91545bdce", - "public": "02b90fadc3ff31050db8307263219a9791ce47d6c61b63647ad633322dae9cc7de" + "address": "zmQok3As5KxobevD9YvReWkQDGC6AVNExn", + "secret": "f121104cd3d4fa345efd445fb8a39f52dec4a01d9948805dbe2fb2d8dd1153a0", + "public": "03997df1f0d27b539122782b6612529fdbef763de2ec3142844953b7f1fd91a254" }, { - "address": "2Xuym4wm4b5XDHWysTbx3hqj5HLbXqF69wA", - "secret": "0122f79e224a1def7cf414ee75e6c0b509700675a42f773ab81ed5aadc0a9f51", - "public": "02a388138e6bcdd93436c48ee4060636fd3a6cbe01fa7b541e216fcce4baccfbc9" + "address": "JGRc5N3eEWYhasHmjWpiQ8RqFEQHFsgVev", + "secret": "efe5cb99efa43af9966268472eb5f2836af65d1878e12b3483dee1cd7f5ee967", + "public": "02d3cddc6ceb7eb6bc94244760b1b80e0fd8d32653c762a046f07379473e7a069b" }, { - "address": "DUJYeEbaZc3MyUJjnEqFohoV8xe6KLQQkK", - "secret": "e6b600195cf57802401dc2c58e081e65ea96aebf80f4ab628113b0d3721956be", - "public": "02a4e3076859df05d8901a6f6ce28844284f84b9e929af73f4b890ec4aafae4c72" + "address": "5yDKACKJgXGeMLTJoT9Ak8GMKQrMuZtAXX", + "secret": "311d2ac25e2e93b75e4b221744a0544cd2c61cbed0f2ae9f2d1b96fb685de826", + "public": "03a460ee0fa4ae57cece255da2d237b155ef36add87596945c45ee399d9d092a61" }, { - "address": "WHgHgEKJNvV9wKqndcQoSbJDwhY7HxDuQm", - "secret": "5063faa28fe1b880016984793029f36f44beaf67d4b2e13b84af52a5f3e4829f", - "public": "024d47b97b1c97b3eac8ffd9c228d206f18a907def132d35fe761610c08fca14ca" + "address": "Qt4eK48vohSAe9KL1VguDCdTsRbwqm4Nxi", + "secret": "65e4f0874bed373e927927bcf2c4a0b3695d623dcd9b82699a23e090f4d695ff", + "public": "03cdb9a9ca9e32fa1c21f45f97951d2e86d5801800f0e199a171a5932c46ee59d0" }, { - "address": "ECduAwE3p5hwDn3jeSSoddtPKMmS6dvDBw", - "secret": "3f2303f5a968a98ddf2fbaeabb2c88fc7358037a58b8a6deffd930c31d70e917", - "public": "02dafce43961e5fe849145c0c2b79e8855d6ceb33407a626959202bc951a7ba9e0" + "address": "oDydBKTwxrA5SG8BRXkjgC8p8bCLCKX7CB", + "secret": "532b52c6afc906733f9a8d54f571bb46f8236aedbf99950f9441fd66195869e7", + "public": "033a17e3b255c31d2c462612cf55c7822b462072823c7aebd64d758013eb321ef8" }, { - "address": "2jfKdSYu6sKXGuPKeysVnYP1PEMYHrRsoBR", - "secret": "a7d158ffbde5162c1727b0c61503547588a3596f0afa29c0deedc0da19feea49", - "public": "03ba52f3066d9898b18ded4d3d7cc5ef428d31e01e00004f8cb3fff0991af038cc" + "address": "2mtd6hKNAebgEXs3MKLUZj2Hbw98B6RWVJu", + "secret": "1d5df1bf4861aca59db4601886abf9c14215bb47dd498328d0854f5958e2cd52", + "public": "0217ffc7084bdd74bc7c512251ae2b6875d6dad5e519d6d91a39e9cec457b77b58" }, { - "address": "mcVp8UgE66U6KNYUL24evadRqXu85W3Dh", - "secret": "39061fa49be28a404c90b3ef1deca2f46f993b598ea642272f0c35febb6d19cf", - "public": "03197417963c377172c255ed4493fe636a238d68bc3697bc9ef45fc3018c0b94b2" + "address": "SnSBaGjufieLSyi193EDTNP2nqS3CRuEDr", + "secret": "f22dd87c70e283100b42adafc2d766153ed090247dcd909894e9340b35926464", + "public": "031d9e9e4e86b10f0a32a6af86dfd4c0ab8c1e18e1a2410a3abfbcdc6fa54d74f9" }, { - "address": "PBuwqjvnDAnoqHBdBUJ9G7CaA7ni6VcVUn", - "secret": "87c5a061bee5fca650fd032e2fca658f591fa6e8a5afceef57a5fa25fd65ba11", - "public": "02b170d10c8d05ef32eb6de670694283f7f736380bbbf7a50ac9ba0edc4cbc20f8" + "address": "aBbez48E247uZMtn4vQVCFkac8iuuJZXu3", + "secret": "cd5ccab9036554e4d7d5124393ca441e115d3b681543c1ae0e09e8cdce38ccc8", + "public": "022c1a6fcad7a9a2ae3a66dc2802482f028dcf9e156377de508592b6ddabc84a4a" }, { - "address": "HyKQYF2niduka2CudAKEmCGdziMBy43DxU", - "secret": "1f6c6ea310c19952e1c06b35baba086975495189d3ac39a08676fc7ce0a452cd", - "public": "0305bab783c57c00b4fd81403c1cdd07db0d183f96c63136b70a14d08677b80e14" + "address": "RY9YMTk1PavUEQNbdqyVHdNNVPDDQvisys", + "secret": "7ce9cc17a56b261615d768361a89bd287ea24f845267e5cc5fdd8f8d492e5cf1", + "public": "030ff1f4d7abb8780198d610d84a21bddc57cbea7625b43eab90a612f5e360345f" }, { - "address": "wzFFq9CB4Yn5BpVc51ArQj6ekmtC4G7m42", - "secret": "557612fa8a65bf1bdd6f40fc3aa98c1470159cc694d7d71e613e3e28640f70fc", - "public": "029934612600aab237b79242ae8542f949e6841faa1c315e1ecd2ebaee8bcea83b" + "address": "YVjTfb8TGxDRfXCnqNmZj9WocQ8t48bXid", + "secret": "94594f06051e8d60e315dd05dc7efdd99b033bb01071a48f2c4f0c5d14bfdeb6", + "public": "036d46388cb90f08c49d8c58ceb89b9713f9f28d5e40fc6ebeca7d1ffb628a3b93" }, { - "address": "io8YT82NpDVnPFox5PCyx6WjDWUT9k3dwJ", - "secret": "7a7d07c4000009bf2a90a29053c7ec8786c9102b3e45be48caa5f6b5100f786d", - "public": "023dcfed0fb68948d6e820b5091a6a672006a331e2dcd37b292604b4fe34431d92" + "address": "4y2U1dJwDgL17A919tqmjqEfzXqMN1sfJr", + "secret": "0d845f4f5b6fef53b40bfd07d7175881f96cf26861a298c96d1310969174e9d0", + "public": "0349290922a67e016f3fa308f0a7dbb151b1f86f19be4cbcab6ba870b5075f1fb7" }, { - "address": "2K35BENF5yiXfReADtvSwAGksDdaE6rA7Np", - "secret": "9d38857aea97ace9aedbf8e8f5d8860095dbb787afab7d24f35067639ff3ad5c", - "public": "02abe020d689a8ee12d287088ed7030c1eabfb7c8fbad70156749100a55ae25b22" + "address": "NcapPnAXXQbKGRrxGi83uJJLb5vk2VaRT5", + "secret": "183ceb7edab8ee4a5aa307f66f3cf7a55f1e271f8064e0ed74f2390a954c9005", + "public": "02977fcd738a85253b58b7a2ef2ff36d47a5b3a6aa1aa343bf6bf62954b878b9ed" }, { - "address": "WfdnSjmMmCK6S3FZxEsA2JQRhvrYhC4HSr", - "secret": "3e6ed46e98bd1eb1e6402afb3bb7eed90f5a588407383edf5066dea39af3343a", - "public": "03d9a69c8d75c89cb0ae4020a2afe2252022524e8ea32c611e56aba3a9481c6cfd" + "address": "D8PPZ13Ex6wr5Mn64RRBorPcQnfGYYrpHo", + "secret": "8f619639b6eb91aedd1213d9581e1651fe0b564ddf7a2623cfed817c8c181da6", + "public": "02d41cdbdb8785fd538e887f82752fbef97efc94669001849fae65fc1d68f84f52" }, { - "address": "2hrjn6AYnH6r4AL4pn74nReVytNHSwZStiS", - "secret": "0400e6db51d95a392883eb2fd70ca25970134d348e780cafbcd44e40a22406c6", - "public": "02b60352a15f8b7e653bafc564fb6e4ee4499caddec6784102a7ffe9c35d09350c" + "address": "2d4fGA1RtyybodYc3q7sMiKX1BrznHP53Px", + "secret": "c7eea265a0472d0de21010f87c0db5a88b7f6bbccbb7b2fc89f12bd9198d9f80", + "public": "03b0599b68daa9ec4c330d840517d041f638dcae1ca8cb93bad5c2e83db2a6010b" }, { - "address": "ssP51WNmgC6YCgt1rYH51E61ALn7EpQfTz", - "secret": "0a75d447a9a272a23948f4b0551bb205cf711521b090985b7cb12e3ed91479f1", - "public": "02bdeee463a4f50b11ee82af0daa9c86117f0fe95df89cfc96930ca291a6a73779" + "address": "vaeR4TDLoUiYzJULM7FByv9owEKMkX5cG4", + "secret": "e27f88009bf53b0253ebfeec1c5cfa3831041a6a977a0a1fbaeebcfa3b515ff0", + "public": "0394fbf78b5909af228443f95e3bba853e1669a17e328314e27906637ee3e879c5" }, { - "address": "pmC61cQ5NduocDJtDKsyrogdnKZ31BK9aK", - "secret": "521fbadfef11756fbf17c34c8ed3a2d9643f128234f588c1582777592d0eae23", - "public": "020224ad961230423c66397f95e94c91df5dc951f95b44125e638d7f47c79f9416" + "address": "HHiby3rggQqcvcMWey7B2FFAwn4UPQSsky", + "secret": "0e513ab67bc9eae469626faee07dcdc95d886feee2dba72160cd824dbdcb002f", + "public": "025ac4561cbd4acecd25d95e09d1c0df88f3f181120be234cb182e4c6422090172" }, { - "address": "b1HhAj4BdyN5tYptA1Jbass8KvkMCupemg", - "secret": "eb7c6c90d3a18710f61fbab1703a56f763fa14a99c974a1996a17ed299edacad", - "public": "03b5497e56bad043caf9b404821da6f43f5ca95a5fec60ba5fba493035a668e0c6" + "address": "DRbn4e9kumeadJD6bx5Zwc9hJR33pCJ3Eu", + "secret": "e1a3e5b5f6378bbac69f4c851aba44d5508b6879ae173ed538a7f58eee98c005", + "public": "03b2ec20a6bc7089b22e02f3877648ae92d6a961cbb0764264aff9635cb9b8bc66" }, { - "address": "2SLkcnAmwY3kNM1TdDUhmLgUFJCpgw8Fdvk", - "secret": "158df203b88d525a9c7f6c1174fae4f8c041b8075a4ca558316e4bc6fcc9822b", - "public": "03efe1ac5ea5f215aaa8c624e098fca66d38e73d09613d901c267170cd26a84788" + "address": "eF2QTjnUujZiyEReWFFtgCcF78bseuf2uR", + "secret": "5f9ac6bf76829a442c2e524d424fb91123e2afc9520df6fdeb9fa7985c017e9b", + "public": "021bc1cd131c269c4413aa235851449bf66d433ad2f7a6abe426f3d4251a38b4e3" }, { - "address": "kvBevG1nmV1LCjDYBcVN8vAzfH1VVXwjR3", - "secret": "73dff0cb686399ff8d8d3aaf2ae0f97d442c15246284f00450da144efa8ba280", - "public": "0201e28b923e48fffe12d782e80f6b03a57566c611d434391b5780c2ca3f6b00d5" + "address": "GpdAHSAGjNBLy7f35PSgQd8fvmCYBWDS8k", + "secret": "18fe04699878a57546523dc3076b1c47d63bdb091eeefb2839eec162619fc1d7", + "public": "025d0f942436a465d4f027c00652717f6b77a09485ae5631a7cb0c7c0ac3edb40b" }, { - "address": "2Ts1XJWV8EHqDYFfea3sDQoK6tc6sWsaykj", - "secret": "7a1d4ccee9c58f5decf857fe962a2bd1fe4fb0408f55e5b417cb164c271a8e3c", - "public": "027a8f1dffb6d4684d14586abd98c05ae5c87b37509443baaac5c15ce4579a48f9" + "address": "2epTtuKgNH7hzfbFV6QNSzEvP9vv2uUpfnT", + "secret": "c8755985ea031954c0501c048d8950c35685577cd543adc214c03437af59cf20", + "public": "03c88abdb994b24ea489bda4ab140e4c5cd9fadb95d395a11fb99fe7e790bbc4c0" }, { - "address": "2Qjq38vkLk1R7aKamMgr1cY8JutS3QZpppr", - "secret": "4116be33a40f795859fcbd43eab5ec77d30b409955b1e02e3e728989fff15405", - "public": "0358d0157aa46036534f958ca1fc1eb01afa667f256685d973c40811699c2aa1ee" + "address": "2Qpz4d9HZzb1uaeN5uyjDonR3MR1f5v4qjV", + "secret": "b8ea20e202b9e411ab47c6da122aa0d2b2953567d61a99471a4ce66518bcb8be", + "public": "025c77a070003120f1af15aa42ae9740b44abe229ea7250b77eb1ba0033220a9d2" }, { - "address": "2PxV8Ctfw6BoHkEciHi6ofnzX4vebMPctUU", - "secret": "9ea39e00cd5cfa3b2518b47d095c1f428de4cd75549f76fb1d5a19f8c7c35453", - "public": "03a920eeebc3dac6bf197ce39a7e6e3d37a9992d976fe11209f5deaedf97081e99" + "address": "2iG4Fs82QP6WxCxayVbTfmoTH4M4N7Lvos9", + "secret": "9fcb5c59bf38c087b0e427e6c10db9990056b65560b79402e1fce98f14652cd3", + "public": "031d315e2eb87ee8032dd461a5485876c1139a9c28c7e624cea4a3649f8aef35ec" }, { - "address": "2DbAFMThAJcLMH2QtLTEs9SwiopX5fNDKD2", - "secret": "8da66ac70233ff0200797b39449387f6d9f8ab81e3e6cf54249644836ac6b743", - "public": "029c001465abc80183b0de630376abd42406a22a7b71322108e2d690002fbc5958" + "address": "2NKE64LsSB77PCUPud1heKa8xmjadonV3SU", + "secret": "9b05f64e513868d2388c06a9ad974146a2b036a40910f9ddab77a9d75c11a751", + "public": "03adfe42ccd50b9577fa7620945d72c70a5b096d6c97d0b6fe3a3f25a4fad56f6f" }, { - "address": "VssHdSNQ3ceVQJVzQqktA2jAmVdmXuGZYj", - "secret": "22e7e369a35e1916ea1cbba53e4c7f66107082ca4a391260638bb88b226d8e2e", - "public": "03b57b7b87b35d6e3ceee0aed77df3670df3803dec2e1690ed3375ab5d4c84e75c" + "address": "Aezo2HdLAbaoZguPpszC9ZUxhmJHmAFnfT", + "secret": "c4a375cc88e1b0164a8a6e1d02d309312e256f84b18ea085d31806a1268c98cd", + "public": "03bc9e850dd82d2171f821fe8eeb98497dc0d3864544099ed2df96d26afa407e30" }, { - "address": "26WWUM9KyFgbcCXUuToYinSTfCB74qVHMHu", - "secret": "ab44e1fe0615891b1ed3b8ee0decd67c29267ab77743ae3979d87a8a5abfb0e0", - "public": "02ca7d827f3a362ec44324c97dc625191b94098a35c9d626c0a2638b84899d1edc" + "address": "rhhySrhPyMSZ9DxDHFrHR7ktnEu7AkqB4K", + "secret": "0c41ee6da35751a7dbaca48f0634f69ddc5b69d2586093a1047011cbf10cfde7", + "public": "03b1952ff8bcfd8d1febcd8876e11212108860879eec9e05d8f985951861df81b1" }, { - "address": "2QixqZVgyaFeSuUNxBFWkU9xfj6AaeLp8oW", - "secret": "45efc5dec8728ff2d1c3c44b6a934e804af39881c3adde47eed3c027d82fb231", - "public": "0206ee2aa954c2a61c56c9f6d18402bcbd568d9afd1b5a140d8df3c2d9c71bf08a" + "address": "bxfcnYtu2tJU23uVKmw9qV9CffuN2Lzvu9", + "secret": "a999df119d86f4a42617d53bad1a7536c5241d9bf63600a9d4245f07df3d3bd3", + "public": "0350e14e6de722e11f27ccb942e2a564738748a4678213a640ba3d3af0083f1f92" }, { - "address": "zcSWzUAHLgPHUeqnzWCoZ9tXMmRb342JW5", - "secret": "005917569fb2be8d21d7a2f31ac3f3a8131aa4560e98a4e1327994c27d749ce0", - "public": "0276a1f3fb5a6ab67dbaf9493b97f4d3ab2a663464dd64b8900f1f1646e6715078" + "address": "2m8ndBh1iPqPNBNGJe9vd5gThJ45KzTz4Fd", + "secret": "0523f1e4e57c30371b7f7b7f89f47ee9bb4d2d177c57da5a28d25ebd7ce71a46", + "public": "02e8a36d23ea250088c113d0b6f41ed40d22c3cff4ca3356f50637eb020088aa43" }, { - "address": "2KisiJh4gRKH6kKT6YeW5JNgDUK3YfD6uK1", - "secret": "44ad4315b9a8d128256d072c1be4f4ff6fde268586d4fc2c2e46e6c389132024", - "public": "031290b46da06f5fccd6530dbb13d57091b9157e75bf2a8078d1c153a099887fad" + "address": "PHXhq5ArUzYZJSJ8PiBSUj4ef2sc4zEtW4", + "secret": "afc892144fd61f4c3ad6c1cbc493c317ed007dc43fc414f73a380f08697303a8", + "public": "037ffedafde38ebc382fd26c61622a258a1ed18d2f7a0587a5c37a93b6e48e0f96" }, { - "address": "2VseyjFKdKfTFTseZSvG15CRPeJvMvHPWyh", - "secret": "fdcd481627bf4eb12770611dc778e2e9d011d5d68b79c33366c8a719e59a59f1", - "public": "029286bc58f92a9fddeb9ecb78a342ac8fc6172229a684d4eadb1f771b1a9ecb0c" + "address": "2WCPdhx6QR9RxRxDntTG6iZa1as2ja6btJR", + "secret": "1818a34ac2b005aa1f3f259dc16d189620f76515a3528985766761fe9198c53d", + "public": "027fee0b90497183521704f2929cded0adb3cf7123fc17b929e9de3a45d9927833" }, { - "address": "4USs8ibMQBereYNe8xrJYJdHAe2QR4ZAtB", - "secret": "d0572cea300525a0acfe45ec1e1314cc7dd0202341a2c056e69265d591370bcf", - "public": "028dbc5fa7d8f559b4ef97b2b7209b9acc3e4963a99ec6a0197b313116c0c42c1f" + "address": "2bFrdk6bqR8FLQ6kYF4UPgnVjs2mF1DsfoS", + "secret": "f5c7bd0bd1853186cdf8a529d904f1916076880a1c5cd4a828730674a09817f2", + "public": "02c4e443c03b8c12e140ab0270fc0c67a144144e3dcd02963e107facc5dac5e428" }, { - "address": "2Q7YfU4rqugcGDYzzopNYYYmff81W87XQh2", - "secret": "b47ee0ce77872bc41d9a5dbb9abb1e10ee429a67d64bec7fe93806de973f37aa", - "public": "03c96719ce7f37ef98bdd823d3d2db4e2316ed7607e612c411e197fc02ae082496" + "address": "2cwNZy4SWDT1zX5uJesdCKU2fFKjrcmpzvL", + "secret": "38296af1206f02b7650d5be42b8533ef5870c54c146c39239beabf6d500218e4", + "public": "0290aaa6866d979208b6a7ac2984015813ed4ec47f6a9ac49cc032fbc16b4533f3" }, { - "address": "vTsnv5ANZeviw4c3HCvAZ5bP2oUrwiJ2ie", - "secret": "99444bc148207728941367e4cff6c4f6668c6a5a34d0b7390c5fbeb579ff40cf", - "public": "03005de1bde8d5232c29986aca5a3b8b304ee9c044e637eb5b5b91cf448b4e11e8" + "address": "2bwm9u7aGPMc7pfmHezfhLFabAuH7H6EBTx", + "secret": "c98a3735e47a9c498dabae93f8b40683619eb1a37756e3b786b2d40dd001d7be", + "public": "03b9f0815dd914ef4e71caba76a11cfa41fc8d7063038b337a9c600c9a36273822" }, { - "address": "XoGm9CAj4GSUiH2W5P9vXjcP2M9ZeWq5Y3", - "secret": "ab52e6d65fb290b7fddd81a918fe861d762a6838411656179fe5ab692675661e", - "public": "02e96b8edba94d0c261a3db6bb48db3c3227f5f07b90b89042f32e2cdbc0e70ae2" + "address": "d4i4nQXJnoPiyPXnBFobXGM7nFqR7kJNZe", + "secret": "e3ed12b80054877ae1d5d9ca1be4dfc483d5ad4b44dffb14b331e9b8c07acae0", + "public": "02317c1f881a8f39c9987cf6daa3c8887ca03d91b3bd5f915d3dd3c8eb7dc90c29" }, { - "address": "mENvLN97MCDRdBxGTDuiHFPhPmJA2f9kNh", - "secret": "69a83af10f3eb68d23133f3c27657b151827d664ef9cd3a16b36a21a40f734ed", - "public": "032ed6aaa2b9cb91ecc0448dd368897a26b841b1a1a3280f6354d92cf2a7da02d7" + "address": "2H9VJjLXy8nugAdyLLCRSJi1dwRx8oWxFaU", + "secret": "e296d63f3558df4bd455a9850bd9420e2ac5f3bd2cbf8de148a14369705370a6", + "public": "03b4fec118a0e5409f5c7ae65462f56d5f40f477b0227083f238f49b9f90f8f70b" }, { - "address": "2UNzBNnLk6CS5yNKNhZWQE9Ub6gXWXuDUH9", - "secret": "d723a723b463d888c853cb31f53197440d1fe1d18b84956a78327df3242ca50b", - "public": "022d237afefae6c5c01803c9cc2dd650c2213d6f4a07eb892cc06b288e708ddb4a" + "address": "2Mvc6WgBeU4p7QKaDbKPspwfNvTbncAY5Et", + "secret": "20dd7688888654a5f214bee8d411c5635e0be8c8b13d9ea4719521959e65840f", + "public": "020993b1c2fb2e251064b1c53bcd1e5f18e7f7b5b845d8fca619ff5654de57bab6" }, { - "address": "sY6K9hmMsKmJGvXKLcSurD9hJM6Y2kSVyg", - "secret": "c310086ea420d10da97ea4f3e06b1a315883782ea6656e506120ff42a27b5107", - "public": "03077dfdde7f8c51153aa776b6012806e3410338e08540713eecb29123128c7dd5" + "address": "2UjjeJqwrL8zhL9hiQHsfyQS1ACo7oQQnsE", + "secret": "8dad55ff69be245c2f6714dd514338118b4e18f4743b65c1a318b8ae8acafae4", + "public": "0294b9b8baa6b0f15f00f707a02c5f4002074bd9461982c6153b87573c7e2176ec" }, { - "address": "mfBm6EU2KSHzUL43rubtE5YwcyMi8KFZzT", - "secret": "2f114164f514d31fc9c040d46791ef3c15cec0ae30211233c2167878a5f8e153", - "public": "02db198ee3f0a5f5645c063da0edc43eed8c35afca062a008932445abb66caa1a0" + "address": "2N5b3ujSAFtGPbAVvZ5PSMtirXPAGxXDbzm", + "secret": "0c878e067cb6dbecf3af796ea802d685a6bd463f24b84a3ef973797596081e52", + "public": "033df20062b208d521babdbc6105e65e02f40283132af33fea83aaf1e41b9a5c23" }, { - "address": "2jfYbseyTxNEUfKiBsYK5JVnihaReHV9a2q", - "secret": "f0653b687dcb73fe908ceca07be09714adc6f1f0ef417fd88ede8fd46ac0fc73", - "public": "021d6b438ef4980ce23954e0663c3bdcdfe9093ad07c23a21037074f7bd6d85075" + "address": "2LD16WXviY1JcFLL3Zz1Amcb4NPhMAzeqCB", + "secret": "aa9f09e643003c1227741d2c7c031d84cc4bc78269e988576a1e96ad94ab7baf", + "public": "037f33fdad8e27e15217a7c5a9b9ad7072439ee03176fd747c16a240938fe855dd" }, { - "address": "2bo1ucbri4d7p3gbj7RiRVhJazUWfkBSrTx", - "secret": "5371793f27e0a25df240bce65aa81d56a9e67c6ed59cf8338a151e70bca90cab", - "public": "0274eeef89c74aae87dd41159374169da840ef0d9107b6d0ddb1c2bdc819f27783" + "address": "NRA6Li4MRknBbKaNEhRoxkP8g6r94r2Gnm", + "secret": "4c44a49639f2885c2e2897a98a4d1135255a8a5fcfd17cec0f452571f547d7f0", + "public": "0334f64e4c6af2e283a7a994132ac8d6f652b1de0442540028c168e36007c998ac" }, { - "address": "9mXPYAXJMep84FQGjEVe1Q7e3JYZLJNtgT", - "secret": "fd56b930536ec4ed6d9b6c9a0449340d121e3ee9c6dc97384964c1a14196cabd", - "public": "036cfd17c1cb299b9c5b8e327888321af50356b498a86e3c03d802598ac52b2041" + "address": "2hnM4BQEaaNjdyGDcRe5yRVXE9i3oLDUxY2", + "secret": "fc1b2dd7770ff800de4fee7eb01ec6c06499939dd9c4ae6ac51047dc803f177d", + "public": "036c44f8a8ba59edcccf49a6dee7d22ddda61272fff258ba19614a529768105dc9" }, { - "address": "ZuPbj2DYsrXaYxuLtmsL8J3aBG7q4cEAmo", - "secret": "78bdea0579d039add25a8b3e51ddb28a3cd6b7b4b7f9ae9b20330fcc40bd8547", - "public": "037829b6364c79bb201f559ddec42ea39c2dcd960725afca29814af7b821bbff62" + "address": "LZh8LgTSoTo1YgRpSkh5etREEyFgkLtQyh", + "secret": "08d6246e2b3ae9ead57557f64d369507f2c6de10823864c33b68ab824229b7a0", + "public": "038f5db7aef3d2086f0e4f5fa6fb84057b8a7ad37eff06ee446911a385fd8197f1" }, { - "address": "AKgKxPh8AhLmtd8xE4XUqWn5JDmMwWbvF9", - "secret": "c544266105866b1c16f6245c375dc921886370368605b70849f2d251648cd031", - "public": "032fd517894e6eb23c24cad46727efedb0f2031fd80159f2d1c300fbf92b8d2a86" + "address": "KGToyy5gNPmoSxM4hUu4HDYjEVEv7kf7xQ", + "secret": "ad4a60e329f80e0b3ed882b9497f5078f61e15168c92181c4cf6c86142cabfd2", + "public": "036e48c7dd1294354ec1181c1c41f55211c5c27069fa98c2c192c1fb6f1095fc23" }, { - "address": "cK9kHZv3QwatXuVxszuy19GWDvfuUko4Ub", - "secret": "adc5db877134a932165da3b41281bdfd27255aeaf707efc53f7cde692736aea7", - "public": "031c36e6100e38a883642790ce941e1eb3ccdf4fc2c899c60fa9d13750115555eb" + "address": "2eVWTrgYXbDZnke76xyAFdFZeRWykNf8SFx", + "secret": "3e2680dc4b231fe0c8f51b8a2c134b1fbde1f03ef8967011c1eac2054f65c741", + "public": "03c40c4d319aecf727e8b79e8b5dd2bba74d2d97d8da3486bf0e7df85458c3e7ab" }, { - "address": "2BfSppfaHSgKpWJC2jFDTGTBST65Cb9wsBq", - "secret": "66634628b7920c345277bb057bb921e2c1c2ec381e50821d1008456ee78a11df", - "public": "035b39e3801b0418b1f0a3b4ca589ba0b9c0c54e89836539d099c2393c7e22e7c4" + "address": "EXeNXEayVMot8oAPsa4moaMyZ7ZqTNHdKN", + "secret": "bb4b593aac3b8938757e975b5f2f1ea203d56d4072c53e80f9b605ab35a70d55", + "public": "037a7744437290765a6024781596087b7554387227430c1feb5829879d242e3409" }, { - "address": "CxkE4tAAJNwhvEzDSQD88T3sFnCE4CoRoq", - "secret": "5765d7fcb1a6d73b9985f35daa634688571b1a759d1bc30760a3c4597dde2dca", - "public": "028db00848f7d9a5a1907c5f5ea9185c31de865a75fb048d8917399f817fb10428" + "address": "2Vt7Jv3tRKuTKu3H7eBffotFssGtcmxeUGG", + "secret": "5c6e8086199ecec957180e2bc5ddc894f91cb2ff118f10815358766dd6ce03d7", + "public": "0227df153973f5468a6b601b0aec4bf6c4f50ad3293b705d47fbc767dfe112cfdc" }, { - "address": "2S6vX5KSnJfB2aNQJv9ohk3QJiKwKiyWrmW", - "secret": "b4331100506d4a0ae71631fdf51ac1dfc2e58299c9a79cbfe4cbd1141e997e95", - "public": "03fcfe1a1c3de208efafb3067af100fb88bf4732412927c021ec0ea5cbb995cb79" + "address": "2anB6NqHTEP4MZ1kBf25m1AoZPaF5HCRNf2", + "secret": "f458a9a6f1345679295b52660daaab2e6c2ddfd9eec96de1309d29b8645de564", + "public": "030651edf0fa34aa2a8bd48f55304c30fa3156636ab22b72978fa2ede9c035238d" }, { - "address": "22rUmJ8E28CkQAy1kpZY4vpKw8vjjKFfV8q", - "secret": "f63adf4091ffb07dfbdd088be07ad433b737493a7ed5f92f1f9cdd499de3dc6b", - "public": "03a0cbad4e85665b0da9358f95987a9ba2d421316429bda85b204f58443d930396" + "address": "2MR9xtMD2fVReBmXauYAomuaMgjvgnuBzit", + "secret": "97150bc09d496aac364d1e9dd497a082b8671d47c1fa3479f55131bcdbdd9e02", + "public": "02ff32925ac8e230d9652d112b61908ae00ced09d71b9353bfa8eba16c328e772d" }, { - "address": "kSVjC85BJtLW2EAa2uTtz3bcauf37byP5w", - "secret": "ca17c81063d58508caccaa27b3742b78fef320d8944d3fbddb16d19297d87a58", - "public": "038f7830e420f8406027af720edc9219040e7d5398c584c57f6d850436c97269ef" + "address": "2iRSWoCyw9nNSkcWzV1ntHZDzq4g5d7EjpM", + "secret": "4d60df4c11698ccd0ee61e1df48016f37bf4f2f5bb14518003b1d69b1397bcd5", + "public": "03907ffdf7c2ce2d673625e03967b9bb40b5ecdee8143f92a61bc5f8e46cafeaa1" }, { - "address": "2kgdyMpVHu7MXg1ZNfDbZZ5xJbiVLViy8Ns", - "secret": "9c385c75ade38c1cf490d0ca0bffd96a61449db170534b36a9c76544b4225ee0", - "public": "03d3b834f7d3b0f6ed9504b88242d2fc2a3d2c7507de94f461b7eedaabb75ed814" + "address": "Up9XUznLumQuJ6waAJAYCCvFimKkStGJ8", + "secret": "5519a06420ba5c073901876d3b1f11a9fb8b5be9766e0f05c025e525fc0a1ab2", + "public": "022463fb3a5fc5a850c12fa1da8a7c6b23f604a60136600234ea6a5ce7224e0735" }, { - "address": "xW38EtgvY8KeD9nMQCisTbhHvCjjfNWbG", - "secret": "04a34fc6b665d204a030f09e6d95828e1e62d9f706d85b51477ad0e7b97c1a72", - "public": "0260f524765ad1c9034146b0c2943264383b734b40066f8d81f8a5ce5589770cdf" + "address": "2LQzzLF1wzgXVJGfrJwbj8fbCCKHsYPcpdk", + "secret": "ee48e87aa610c69d99b3257bcc5359730d16e6afc06b9b9a9757c277c0c94c47", + "public": "02da4067d72fe2d00b13d22843fac5d8b6153eed2cbed55810c22416906f7072b0" }, { - "address": "RohLjxRGPS3hkcMz4b1J2vFNW5CwcVEJQ6", - "secret": "fb9c6ab5f736e9a6b875a2dec1936b36973cd37cd6bf6a9147a1c79df9f8ab28", - "public": "02a1edf2dbec518b0fb7b094e2eaeeffdaafbfe21f12ea3701ab1c1858456bf423" + "address": "LKziTaWPqm1mqcuuFy25uk3nPgjQCeKpG9", + "secret": "6222fdf0802f55ca91e656fe74408245aa477486acc16a1dff9bec220f26c3c1", + "public": "023298ce81f51ba19e8b93442cdebb4d34c5d25e82ed9cf89da090a6919bac92a4" }, { - "address": "hTQXTnMVSay9BvLsZKf47oDVVz1zLW9fhr", - "secret": "8e55a1e4802f5f1eba1d3fc6d790535cd93522e529a7509563dcbd7ac74d055f", - "public": "02bd51aa8e8b621f0f9ea1f72a7b3b2bd8126d3eacef58bb345a3b44b3984802b6" + "address": "2KJ5NEvapzdghqB7b8gVdU9eaYMk5Tgy2Me", + "secret": "6aa4dc4a06ef5063e3ebc083430def90f28cd90a05b13ce4ccbff29661340547", + "public": "0391782a7b3a5d8d2b34f7d2d0220a8471c1bf049ec51ea87712ba8f24a735f0fc" }, { - "address": "124qNCQdQYbTW9aDwwG5NarDo2cncoa24h", - "secret": "a05ee5d4ccf6cb21c40bdfb9ae84f99635721be02402035baf9b982b23071925", - "public": "030059d698fef2b5d9a2f77608c0d061225b3942b4cf551e0dc4732cccb1da5d81" + "address": "wteD4LYHyxZSBfnaik89dbELxBWoQubkB7", + "secret": "03f083aced4af42b6aab54b7aa648825fbee5fe9b5b6c61535e9f6017142e256", + "public": "027c3406cfff5e4af70371660b31bc6cacca686299f24eb69becbdf30c991c8510" }, { - "address": "29YY3y3jWi3WyuogaGzQDA5Mkf6Z8VGnfuu", - "secret": "18ddb6d2000e2100b29d57474523445902cea54e8a83b1ed28c0f6e3ca3f0e35", - "public": "02e173d7305dddb57ba5f989cce324cf424d4fbe25b2ae63c6f3ce2391792c3de8" + "address": "2L1CsK1CdeAG7tkwa27y5QVkHPLxzizcdTC", + "secret": "c92dbefc11b3067762d632b5c0dfb335de6503ec5611599a98021ffccc72f3e4", + "public": "03910aaf182abbfb2cab0b137c90c2069451858ba4178f8e3b37ef395514581943" }, { - "address": "yJD3BJ9v5LdmqXBHATwGoyduoNyt4BcVZd", - "secret": "0a9bea82ef2cc6c95af414fd435381d40cf1cd2d23b18a0261c9c66f3c8f8f50", - "public": "0312c705101ee4c95198fda5cea1cdb89c87c2b7f8cf013c031915e92b80463bfc" + "address": "2Hba4NtNTJNhCPbbPTgiXNf7zGiuN22WDhC", + "secret": "9ee66eee2ed4f0025c5f83e6042eebe189eaa46bfe6f6670bc0b32400cc46e98", + "public": "03fac3efccaad9eb1302982d97e76d0b675752e98f37d7b6bbf7a014bfa373a292" }, { - "address": "2LpyHUrsdMKuMDvSu95QNBp7pAVd3wzUax6", - "secret": "09116eb78ec3cfb665c74be881f99df3379dddf431b9b7e9233e3a83547fd29a", - "public": "02707b77258dad4046799a383bba83b7dfda4b424c2ea028da8042c7402762a5bc" + "address": "Fct5xp4TiAfoVj53FsVgz2Xvfu3VoSoGwh", + "secret": "68533cfb6e102c1218d07c468bc0111e378ee524438c7493f0c6599280885cff", + "public": "034f00bfef452bdbdcdd0c55cf0e328acd67c9769dff7c8097f968734598c512d9" }, { - "address": "s3sGGbZQULBRA5jxcjRGKoaYaYC4SctZJQ", - "secret": "7a8fb457af979e991d29e1af779acd70fc2c8495a95f0b5a17f1f95f02c0cbec", - "public": "03207d0efe17a3fb0ad9a61eee652e18a3f13c47a4c52c99963dc0fd301c0b647b" + "address": "22n8VjKLqCBWMBrsmorJL4LwN3tezm5gEmS", + "secret": "4412597ea62ba47aa723023684be9f579628c79c40df98b139400304c4b32429", + "public": "037334c374d9ab761d5d9b738b07a48434444156f3fe293f222ee621615a008cd0" }, { - "address": "bkizEr1oTRAXxFZX7dzzzAV77QKPSz4jmV", - "secret": "755286ed46226d6b89bbfefd1db2ba89a77cee5cc2844fe686b6288fde4d919d", - "public": "032ac363c1a8a51cce7e0629dd00ccabf909ebc553ea09c6be4696d6641baef2f2" + "address": "ZpBxiDKig7YMP4kpb26aGHyL2smaebcEHr", + "secret": "d941ba613cdc2b87609c336d2063bf612e540875a4dc904ea4e63d9db4210650", + "public": "036c7bc521bf8a4700a2629a0643dcd1d157959284aed13b74339a0006357838df" }, { - "address": "sjLAWTJxn3jBsCuH69zpjy3gLQ7xtiA88s", - "secret": "6349cfd2808fca958ad3caa09b79ad1575602fe72bb81e4fd12b81ad26f36166", - "public": "030bbce50875261f40851691f700f4fee47b070659293c20cb5fe3dbdc580a60cd" + "address": "2P6fGBjKESXhkpCPmij9e6A1NerU2ryy3xV", + "secret": "5a6082c021c71535cacc07a5df04fc0e8a6eacebbdbd454ebeec87be95309c7f", + "public": "03c981d0bc997b4ab838a0f2009fa4e3211b2073b4b15a12a711ded2895bd69f9d" }, { - "address": "25wjCMbbyrNWmZhne5AuiCVAihLafUQDcVS", - "secret": "10fc90643760680d93fa2eac0d8566534df891e2f490bfa29c94159bc849d9b1", - "public": "02f060c984487161a1f475641edf07c5bdbc5ff86c0d122091e2d229ae509f4bce" + "address": "gByzB6sPJ7RmVpk1md1sXm6HLGKU8knjWi", + "secret": "e4f6298b83374823d72aa3796d7a4054a669c377090f61d1a11521390ce56745", + "public": "0227e1fd95615063c435c4f9ebe82c2d5dea86491c8b412d60b56a7e48bfbd9a4a" }, { - "address": "25WK7iSZxeANZ3z2PeLXiAkULp2CPAzzkwh", - "secret": "06478cac650ebbd51c3b46fa7144ad4309591e60c7c57d5d90de2831a0b8bdde", - "public": "02048f775348b720c1abb5b70f8c155ddc51d1380dfc8bbe6417048cd838065932" + "address": "CwbKzRpBo1KMi4hrBBhQpfRbYqp4V8Zbf4", + "secret": "688f61a4f695771ec1bc1329c86d057b551cf5aff926b184be538846483028ce", + "public": "03407a7bf3e89de64044ff4d28d289a54651c3320edf98640dfa479501b5c67de3" }, { - "address": "95MP1du98XptnaBqmBhet6oRk59i7kJJCt", - "secret": "3cf1051e85d162287c7136c09a2da5d121752047d76530d3cbd2cc3c63daa066", - "public": "030d4bd6d76b52add8e9b4f2f26b51d922d0541a0cdc1d7e3cfc237f09542efcfd" + "address": "HvvEsysCjqffVAu4YWubvfv5yYYzf57Vnw", + "secret": "08b6180067c0e32854776a2b70c226abc9bccbb9c03b718ebfe625563d139d4a", + "public": "03015c8f13f0029cd5f666211955f1a1208735844256cf32ca32486853175c2abb" }, { - "address": "2jkJnLY221945QDAZbL5YKDf2h2fJbdV963", - "secret": "a2349f15919a5d758e9f86a7b76fa23c12528355affb18293dabff9498f52e6d", - "public": "029dfacc865fdc8d17debd210d9a1d23dd91868ffd25ebc3900f9be3a431a171d9" + "address": "nVyEuvxiTYTzN6QqcmRj9wU17fHMa4VJta", + "secret": "98bb4aea9cdc25f26e9ea16f0c17f171fc2b52645c25c72ebc02e2be0b561b86", + "public": "03b557c6cdb5bf376a38d06f53450b3fd5a9925e73f1c3ce03daf7702f98040621" }, { - "address": "xiJyhxfSoGhTG64zHidNvbd9g5zhq1JMRB", - "secret": "6e42edb6458431d6ec8dd1088c83e7fb42d6a206d9206a5a1dac845d033549d7", - "public": "03617f0423bec7ae18133d66d67d360a338b6a04077a96731d03e84ba67a9b3b5b" + "address": "2Swcj8nQBcNTtpExUnDLxhfYuvgo1ZPzX2N", + "secret": "c3f23a6efd8d79499b054bf933460d843aa62ff66dfdaf69306ad92ceb0b63f8", + "public": "0256bee55434ce76ae429e74b63cf7c3c7961bb1c702203200f08ab063f1f895dc" }, { - "address": "2Ajf925XCPCZLmDRoVat4wtNUvKNRqsFN3m", - "secret": "5a7d41ac6f096c9f1b86c2659ce09985c8ade5cc7b32e8902fd7eba8d29cd400", - "public": "02c5de2cbde83a2ce7e5deab67201001449c582aedb468cad3cbb54a84027044a6" + "address": "fYMS9Gw91GaQcUNS8yCSVR8aWXC7RCJ79H", + "secret": "64ef7e0063f803ec119a6afc327c4a4df9d196ecec2deac3e4c64b418a72fb79", + "public": "02ac29f3444911103ce467990640372b23c2f1a98e8495e193ac576686eeee6948" }, { - "address": "2ZmyCB7Gni4isVuj8SMYeitZxHjkW66Crga", - "secret": "20605e74a47a8a1ef1b7bb05ae6f63f98a46c660beb2b8d359cd0837e5262a33", - "public": "021cca2129e4302adf2757b199ca8c9bc296938a79d34890229cb66c108fb9a5a0" + "address": "AsNPg1CrLTFKNa1vviV5HkMJSZ38NXvVev", + "secret": "68d3bec66658ca2f4723d3c514a3ff65cab561e75e694204849b5c1b4733def2", + "public": "03c8d03e195092d202c6f75bd17c26d30c9841df9266a450e5a153bbb85951c2a8" }, { - "address": "gT9xbQxW2ctP5GpCvckrXCDH9BYBcjg1eW", - "secret": "71c1cab54b3fc507e7b6ea5050bec444bd952385f36ee1306dadb5318d502ad2", - "public": "02f3eafe6bb70ac438a2debe96525f8be2361b02834f606f503f9936e74c304eaf" + "address": "uomhwkEj2mEc9JNvZTFpufDuxpornqcLr4", + "secret": "b0b2c25646387fad2336a3abd66d20fc7fd261b5a776e4e510e46975d5678034", + "public": "02047af97b315e20bb41c74427bf67feb838eca34bd82d8a1a78631c6450409a36" }, { - "address": "sna2tcYuhhorJw5jWJnD3tjY9535Q6Fq2", - "secret": "de2beb74ddfd890c66a3f80a016739170340ba8c32f5c60f7f9f995cff7168c7", - "public": "03477239f97de26325dbcf445467047c2888384576d62b385c77f52f20edbfa476" + "address": "288trEspbRwW1NXhMUG6zSMmn1z1Yupss7K", + "secret": "248d74d293a4689cb6a0160b4d3368b4ed8dd7a850587b3b23d069ea1e61039b", + "public": "03b65684d345fb8b319d50f4cffb672e9fd2ef99cbabf8ed13db898a1b40c2eb54" }, { - "address": "2bgxxpAaWPBHgfuDJaZ336DZDAKrxJ5ZU4T", - "secret": "bfc8b26a7991337cb1d6a9ea37b5fd16c889630813ce781a500a8b227b469af8", - "public": "024d8fb93ff3bf7ac5b4f280c256c65e8268272378940d3432c07cd1bdbbd9eda3" + "address": "mC5F53X8PeJTqw8C8oAmbG6AcYA7zHTpWv", + "secret": "f88ee9fd93b3ef3bbc3e0abc31c0e14132079f91877bf27fc45fc612a11c8d04", + "public": "02ffacc6e508e69889db4b3df93b5c04f9ee20655bca13c0c76ae7d442d9a824a2" }, { - "address": "zbNQtz2BMUBuAExpnzHoMhKzz66wR9A8Dw", - "secret": "46e8ad0db5510a2112e53e8708ecaf27ff2f32ec86971f2a72784a86acc3b49e", - "public": "02983f52e36048f6e7dfe41f374db08720ff265056c65978e7b36b58292bbe07bd" + "address": "2N9TR5jDQWfSPvf2UTneWTTPzAzGixTUbxt", + "secret": "4e8e791dd29ea7842d682b42a7e1236be9c787706dd5f130de9b2262f4aac59b", + "public": "03e1288e0f91cc983220bbde8a8eedcf82e0727670fe746d54ccad7aad336919ee" }, { - "address": "XBjzgp45opdC2i1CyDaw1jbKTgsHyhagWn", - "secret": "82b5bf791290f0cc92b3a51d47d054a4d6370d8bcff226c6b67e9e8e68a6daac", - "public": "033d8792761e4ad5a74bf58cdbd3bbae6f87fd76aa64365f41bb1cd5034a8a1eff" + "address": "xQZoBgh6s3YEkaWxJcBJJj1caCqEr3qs18", + "secret": "09e91887df03369c64df32b6c05c19d4eab03760c6949586173b8df7f55e5528", + "public": "026e4ee5352bd39ed09ccc6b4f1f6893b450b6c554680277af3127d66925aa29ff" }, { - "address": "27ECgmE3DUB2ojj7avrBmLSzbh1umpMLTe5", - "secret": "7417d51e1f21caee15648d24f2ce85ec841ac442ee84d28537c2a586c1eaf07d", - "public": "02bd1846ecf3279aa984ecf9bf10be46d4d7adca19eef2273842dc4bd290fe857b" + "address": "o1DeUpx1vAjsgz6xwdHQmjpVPsmaeArGYy", + "secret": "eb76ba401eb1ce6f42a8a9b24766f98add7e717c96197b79806c5ae08c7fc36f", + "public": "03a5931787aa1f2e1bc5f03c160b1e72c42f00cc8ed5a6f78181ae26cf016699f4" }, { - "address": "CsE3azpmEDjxwpFAeWKR3HeG1K43MHYQ92", - "secret": "60cb52054b5144cebca2416e75fadce1bb3325b74466de270bc0ec8658beb0f8", - "public": "03b6804de0c79588e50281ccd691a5913c236ef51fabf46bb60297727b29985d95" + "address": "26uyax1suGxdRZ7gJUjFKH3t8ptAnB3f1Ab", + "secret": "42b0c6d8afdc6c266e6afd7feec00f6fbc4298bf4b3e63e2c20a29c736b7ee3e", + "public": "02be4b56afdba2426151e542100fdb523271e8d0ca4fff3dde46a5ef90a2010bed" }, { - "address": "cELewZjh5u2Qm9xvoMeHPWvzuWvTd4MEgb", - "secret": "31a4c46376e23ed3545f722614b8c1e8ea131c98aa8d4bd9a1c98d63004f4d99", - "public": "02a7a9945ed36d37e82a717ada7c8859c46a7cfc2498b07da404fe96f77b54bd9d" + "address": "2GYqEYdWH4wd3aeCxWnAXAVBvfMiYL1rRpk", + "secret": "8662f1b8d3ca64d2eb00eebe3e245e99054d4bcb67d8bf7aad5f928516885e09", + "public": "0307c321ea95fd65d2e6b3985155d0d9899b6818bd7892347ffe8c261862da2b23" }, { - "address": "zRPHySgfUSXotuJzmJrhZvEx4bQeWukeV7", - "secret": "13cae108e39fb982b20a86f4c28bba3162a5814d789e6ec52bf073bfdbfe5cb1", - "public": "02f8b738ee6c4829ce379ace83a64402a623cd80c0812e05c871c129b0973b2a9f" + "address": "Xp5R1dYx4haxYjmZDpjBTUaGAqYTU6jRtP", + "secret": "f5c6a132ec483f08b48d7965fa5c034a26247f1e55d77e6dc4ebccc781902680", + "public": "03245b41ed7ac350d9993fa89a6afddaf52d61244229a8b89c653af757054b9516" }, { - "address": "otJVx2MG4txEZRxbg6roLTJHBJbJdjJW4N", - "secret": "1e8865a07cdd832858ee0f0c4c77990767bc0cc3bc3e050a1531c759a1bd2253", - "public": "03833ce21e00df1b66e320e7903ed63c7a9e388de91a0dd3f135fc3c1355f42e85" + "address": "ZLwQzFUw75sbsMWTLS8H9jA2m3czji6hop", + "secret": "1f05950172c640ab56ec5752c11139569f7c76736f00b94b397cad2c4f4977c8", + "public": "03b8b5bc8dd2c640e69c5f88c98f6ac0bed85f8119409147e7638b80c3931a2313" }, { - "address": "SyCDoLEWYVkGwt6bcU651oVNVmuZ6yBmzm", - "secret": "a048ba21069c124abf8c2d49aa6512af5ce8aaeb15490465a7814fdd485c7efe", - "public": "0214a86ad2e8bbc6b6dbef34121b5a8c7bafdf3ec23cdae49f020a402b2626a7c9" + "address": "mLP32Fyc39JZxnvp2ZsEDK2xVKUv4YSQ49", + "secret": "8d74584cca5c9941d4306ed7061a4d5632546d22635f0aaf54fabf4081078c10", + "public": "03bca03957963890c237254b7a6293d398df43f275d1705d9d2ee81dcad889163e" }, { - "address": "2E4sTGNTCLtAwprPpzujNqoML5Vg8BKybBB", - "secret": "488caa556b1545aff156d75729d3d3a6961ad8c55c4ffc05a2d8fd32f2a3e1fc", - "public": "02826f399ea0d9183433fbd0bb826312f271b49a7c186599962f637446f18185ef" + "address": "9H2rHSAsnEPey7Q9reVfQjFcn6HeuA6nZU", + "secret": "f57f5c41a54b051c24195e9fda9e17c69ada46354ad0e100358db1153c15219c", + "public": "0294cac47535ba46b16380074e5a20b2e106eda46ef58d8588b34ffdda2b649753" }, { - "address": "R1ZmBfKDeCEUTu6hZtebwZcgRzoW5GdcT7", - "secret": "f8223dd53a5f641ceb8e915a4254219d6381202e8169cc7af408bc738cc663ca", - "public": "03419629255bd5f431f4a399e13ebb530aa677ef2efb9e844f8ac25c94e3d1d5fa" + "address": "RWeWyPo5jMW3RTQZhi4umoomc26asiQg71", + "secret": "3dcce71b3d62e7e9d60a8b0a7e7db415d2f29dabbbf9a90d9e4d028f5a2526d5", + "public": "0255f81c8260bb65c55b53ad5fcacfe14542dbb1478230bfc465f74d35f63d2ef7" }, { - "address": "XcjVfuCxx54z4wxbyGC21xcHpcTYE55K3F", - "secret": "dfa7444e3dc102ea89e2fd820a13717a7bb5c3f6e5838335a50d6159e7c538df", - "public": "03e3760b4ee677d224645dd0292268bc41f0f58bf373b85160cccbebe906be3025" + "address": "489PcrGj1QQtFvdnrLYpabE99gVhK7CZDb", + "secret": "25e23bc3379bb160ee17faeb169d5b10e378cd4ff0c241ea47639d5ca5e3393b", + "public": "02351b30079c2adcc588fd1c50a68ca4c6b217129f0605f35057668eaf8528563b" }, { - "address": "5YkbR3FHdPrEppiZYorvvwdBHJjG9tjTt7", - "secret": "f2f2762c9633192b92afe8bd0e9d1a9cdf0dde0cb5ee433406ca9b7135eb7bb7", - "public": "0361d15884d15bba80325e1c8dcd6ebbc762099e5f79f60a671615bb6848f2f86a" + "address": "fvAjpa6JpTXEEbuDLVd7fbaxyRpS97a35S", + "secret": "52724a60664d7b0d1b3f463324910c2b1924450be5b05e8d7a2db4bc53d453eb", + "public": "0209f0eb2cf37d24b74f01d385e77200d75e5ee67b2977c578443c8310fb9b2d7a" }, { - "address": "2YdZKQTnaxdsvsksdNCaFV1gzoaHeUXAPpw", - "secret": "d9edd6086a90da5fcbafd85af4bf3660f0c1658c23673ed16b23d1b03227871c", - "public": "038c3904cbeffc710c83828449637d2fd3b23cdfe9df39cec787689acd1c6136c3" + "address": "ZCV1g67KVwHfSGNfafFSSQBUHYeERkPNas", + "secret": "d6a7110de3a1ad13e9c01390c665810a596d8c6d1d4941532b32260b6defe285", + "public": "03b765ba10a5e030c8da62982214f549120fe18358f18f60855325939adad24c4e" }, { - "address": "Ads3CxZreYxF7gKUJYDEDhuw7miC81ewYR", - "secret": "1c4dddc5f252d6df1fd16704197894b2ce82f88e5ce2dfd7bdaa3caf80135f8c", - "public": "02ad351f1b296f48ab154f14e629743ed8d1dcc61f06db2e11c439fc99710e7079" + "address": "2UQ9bjUN8YBtaLZrXFoFgdEz6H3PqfQRPnJ", + "secret": "8312de52989274e63b461bcd89cf9341b8014d3324892b8424146f3538e2ee27", + "public": "0318382d608f7da849b65e058db3afa32136f3b893f90b678001f0241a196ab325" }, { - "address": "2kuyePuGQN3Ar5iZYKo1VGiPDNVLVYoStRJ", - "secret": "07bd34f85338d8809d738d1213bda26d06cecda37ea3a620e538ff5d949024b2", - "public": "03bad53d6c4232f3ee529e46da547ff20ba367e1d290bb30f3c3930879edae17d4" + "address": "2MdhNzpmAJxHnHBqsGmvSJVLzVYmMiX2qVq", + "secret": "fe3cd4f2731045ae184501ce477eb7745300158369ee44c3fdf5a87a2d5b8952", + "public": "039c452532ea6ca6af3eb68772172d42778c090cd199ba3e7009c06b0cb6c51b1f" }, { - "address": "p16icrAozApdgyCMw7zZ4dqigzGm7J3zEh", - "secret": "3317ca696799b62d094dcec24ca654caa8cfdab38c5d8eb631b68c66bfa5f5c3", - "public": "03545ced3f79612fdf7bf4d1ebc97d8bc4c218b08dce66536dae4b7332c7022e31" + "address": "816Gwzyu248U21D6f46r75pnVuv3AtHWrF", + "secret": "a71958850157ca5af9430ac1f7150f12970a3e5cc49f2b2f0b250f7262ee657e", + "public": "023385b52bd7cb2b0e5a749b59f1402237ddc355258a36011e03b860679e4b2728" }, { - "address": "KubrcsFUbzfcEi9Fsa12dv1ieWEtJR8j85", - "secret": "92aa0265e71fe33547d2ad0927754ed3e796525048224d83371be55d719cca3d", - "public": "023d3ba263b4ea1228040cdd4426c815c62fcbf87c995caf56cc20f0c52dd9cc70" + "address": "NKYP3ZvpAa6ad2SvENi6T5HKwHeLbrVYT4", + "secret": "01ca13b25a13f4fc7d4712b11861bba3d213e4ccb65d06e0572cdc7d14ce15a6", + "public": "02b313de4985803a1d054804fba3e723f88e64c6a2ec7fbe44303d1c4652c98c3c" }, { - "address": "HRz8NA1S18iNdtcByyQuknQroPgYGVC19k", - "secret": "a7a2d48d2a866f511044ec9c9f1b6ab94eaec7354b50712a7473588307259077", - "public": "02d86e0875d8af32f8b599efc14285d49cff11a169b7d45fc3fe2164ceb3697246" + "address": "2VjJfmxYideGu2ypmZJfLJZhVv3yxYED7of", + "secret": "f58e7c75269761d1cbd1c9c034afb754434f05f327e291ba96ca8ed727caa66e", + "public": "02be84a327e37a6d8267bc626c38bed05d2950e2ca1e4349905704f7f5c404ebeb" }, { - "address": "GMJjnuJe5UDfwMCnyWborw7KRRS4brBhWK", - "secret": "e5124b866453ce8443369f8f99c5d90d912e8f448240e755a7acf8dd3351b3f0", - "public": "03fe72de13f18b39d96f4a2df6c102a1bb45313dd147dcf4e1ff48a5afec1f3dae" + "address": "eAPpk64h74tsYepanFtSFzPzr82B2avcDT", + "secret": "7a0d7756af1ceb796d4aa202b10dd626bae3b530b714a3c90e075a2f0e301ab1", + "public": "0280324942ed3da9244cc0fec7fc32240792529d313e565c5f7cc8fb3dd38f453e" }, { - "address": "zwwderKGp47kE8k2dcw4FFrcUdkPBjXYFa", - "secret": "f5fa12e5bc862dc1126dcda85de8b05142d88b34747886f27476f5925883875c", - "public": "035fdcbf18fbbc0de61bcde4c3eac60b34f6daf77eb349db4a9f973edd39cb6695" + "address": "dT9rzRU52tZEUGohPpibWgGwZHSe7H5xjG", + "secret": "39b16997962b2a8749203fc137aaa5bc3ed17f0202f6e7965a60c2dd7302f4b2", + "public": "02c35a4dc1a33451a49ff10a38cf2e040054d775df92749f98c220d9665de0d3b4" }, { - "address": "uS7vCEJKGNzq68JX3d5G1cYZmrDpnKpqeS", - "secret": "78e2bcdfdd682a6d0a449328ca4db2ab1087bc422a135a56bcdc208b606c051d", - "public": "03d6322f70a8504b973c048383676e79c6e122f9a571a3c2da1c0049704d33452a" + "address": "2NJ6w1Q7oKUnLPZ4rkdFqxoSXSh7jPdkPMg", + "secret": "cfb00a95d0bfbb4a1f2f5fbaab246b537ce130006f503dd3ed6108cb2f6fc25e", + "public": "03628ab3111affac3e804cca531c6392f25cb9accad0bc3439bc3fa3396c075756" }, { - "address": "XjcZ6s63WT4MNrQCHS81pnCdMejTo3yFpu", - "secret": "87106a97708b025e8d76c2b0d662bd629c3db0df24a6ca7d9bddf97227a64802", - "public": "03d6124cc9669f3db7d0cda6fc75c129706007c3f7bda72eb2fcff2cdc0a929d92" + "address": "sdrAWYjVrewkKMcpmxvcfS8NpFVoz8mQta", + "secret": "122f3a66ae026891431a535ecd4a7ce87b766b36ee06cc982bae63d55b48840d", + "public": "03856a4861a9d5d1d0dcbce11fccfd15b14e621965577d7f84ad44a008a3a82488" }, { - "address": "q9HspQ47safK7xc4hFLPzBmnCvfGV4bREp", - "secret": "c2461c9660c4b9edbcbd2d0bb17be57414216acd3bd56d302ac479de5a39e3b8", - "public": "028c1b711ce789b9a1f564dc61f6ba1f3bf7fb3ec12191b5b4e09c2f3c2e53c343" + "address": "AtpEoDv9QzZ1msqRpS67AfKmNUYMdZqtWR", + "secret": "ad22f66b3f09fe8150b318dc2bf070c0e994a7a303eea67e5c784dc91cf93781", + "public": "03c43d4d1115804698e7f1e154b93537c91a61e579044682385b38abf606fc13f3" }, { - "address": "fPbDXGQmEJykVp1Kyrmghak9iAZBQNMQKX", - "secret": "66ef744b4d6a45bbe6f68898968bc3804c8f0400d9e8c0a044c918a0df46f79c", - "public": "035d136fda6059b5d7bd090ca05737cf7144dd884532ac41e83c9ce73dcde0f4a4" + "address": "2RJsEraWYadfeoBhfJrBrvidi3u9VxTYpow", + "secret": "828c57ebac860ef0f55510655de61e642aa329bd0ef90a0a407ad88a4cdb6c2f", + "public": "0200ba05a1798468845e97875530a31317ed9a428393f972f4f0bad6786cb77d77" }, { - "address": "28zxLJLA8MZnJAgeMCzwAUsQRtNHsKWKKRm", - "secret": "e6b64bb1bf79f14d5ae8a02edeedbff48f1fbd87dc297da79ed69f1d54bc9cc3", - "public": "03cfa8c624cff38acab17880ed2d7ab1bc840ac0e1b6253357069f68b08ef3ddaa" + "address": "8hjVBQTV9x3eL7MRXgqV9UM64rYur64iJt", + "secret": "202190f9d8a5adbc1ba486df7f076fba0338440a97595a88c49c870e4f1cc39b", + "public": "02d25d29264dab7b03d48aa58091d249de7ce2ccad2db54bf18949bf19b2c9eb05" }, { - "address": "2E3RpYKVAree5biwDodFXF577uYTf9rALbh", - "secret": "76c897ed01c0f675e3b1a7d263fc28f101f50f8c8270d06190f736c63bd25429", - "public": "02625e1bba2a8eaa5ec2ed82cb498f21f8cba7556ea5a1ec6bf65bf6bb3b4caf19" + "address": "PEq6dSumPciu9yo98jMQdHQ8msF2JbfnXc", + "secret": "fb4a81bfb954ec7bdc5f6c6ccb2bc18d00428be1a64ad095154939ea8d945449", + "public": "02fc4697cb9d1a8c364b685342894127d162ef5d7a3b7b9b26a0d9931247a4d549" }, { - "address": "1AaNE19EJTUr5C3KuGDWCuJNLxG3c3Dm3T", - "secret": "7a61b8a5ca74c37ef3c3f3383c950182a590c7db552b5ff74656a687ea585e35", - "public": "024a1f96eb9dd29786fcdb02203ed806691545b48af1c9cfcbd481046cd854a4a6" + "address": "2VV5BMupLapDN23JrhZu1rbS97zcYBbqkgU", + "secret": "6970bfcd764f98f6095604f78a59ede3b079fdc7b9b369c28617405def807d85", + "public": "02a25a01476d6ea82a58c4022a8b5a379f4257a1aed8bee8968cbf3c162c84a16d" }, { - "address": "b7NkETYNxppZCkwDzdZtfP4Q9NwjQzu6Lr", - "secret": "349a59259dca5ab24771247a5831daebc8683036df81856531fcf1db8670a5ee", - "public": "03e6f86bd6078c909f77f750da3f557131b1afe8241055ca93907ec7c86f4d2cf8" + "address": "QcQpkqG2fRxcQsirLKHGJ2sYs5HTYrf7v9", + "secret": "1aa78e544b013fba58e38ae786767d93384cd75e02f3d4d059fcd0a099e34ae5", + "public": "0310f3a6b1152884ecc8d16417f0b9de900d86c29707538900f1fed76a8388af64" }, { - "address": "2bwDZpdxYH2grJTmPpAFByPXQGSSKiY9e2Z", - "secret": "9aa8367581de4e8d9c7ba57efadda12070cfc9185e9ef39c90b6c7e39d758b30", - "public": "0379c6814788fd8e0be9f994054894c2f8bfc6edd9d008945db2ae72d9f9620cea" + "address": "GEir5to36spsZ5uzSTck3pdLCFG2Tuq1p8", + "secret": "f48ba7c9a2b190d50b093a4bda6b0979dd4110cfd7fb3405c965805aebe44b67", + "public": "02c20825470a7658c012e38b3901631f41d4371b0048653f62975cfb0fbdd2c867" }, { - "address": "28zTkY199uRw3Amc6poTh775AarcsshpsW3", - "secret": "4e33f7599c6b50dfaec6ad6e17e7bca88b59396e87a5307c31f9bc96077699f3", - "public": "021ca13990783a781eaa61eec4cb889f6dfaf3257db5c7272e9ba7d9633a716707" + "address": "8KM9nD2XJTrSSff2vfuFYVvZcGbLj8eA7u", + "secret": "f274cd6a8279bab87069888a3d1dbf029ff46be4fd2e57d1a2fc82643a99878e", + "public": "0234e5b6d95fe79d493d0ecec613e9e0f0bc738c36ba1b77addf4b1f2fa6b71c67" }, { - "address": "E7qqTNoa4opn7Yght14BjnvrZWdGm76qCw", - "secret": "f5bb6f7934d1c7024d5c6c79f4a8ac5b9963015efbf5a37ff037982cf2e7eb69", - "public": "03c16f8586d14bec82d68fbd88638edb8857c64e5b53912f3b1b8399955465ac52" + "address": "2XaPonNm8z6upuKv5xtQpd7WmeRKTPUuoKH", + "secret": "b866d4cac48a0670f498e9b4c10edbc27560db7fb0701e4ff87a13f6e24f9f19", + "public": "0321c3fb78a69728088f6b7316e03795bc487b41ba87a5cb92c3be85377ae95871" }, { - "address": "WuUXZWF3dwsyvgCXEjDTQUPHaQuDdJgDGC", - "secret": "80bce750d5afb0c54fa4ef905ac67612e91f3d53523e6ab2aa633e55094b41db", - "public": "0256bdeb3472db4d481718bf50be9d905f8cae681bad91a59042547dbc59cd6f95" + "address": "iN2qYbja7wU1Gp2JnoMUH5QiSammUC7baZ", + "secret": "588ceb37fe6370051d4cdabce2bf19035fd8ad9e8dfd334322d43fc2e16acae0", + "public": "02e3132cdd81d56c6628cd5d851cea5930f0f53e5ffc6a5e35d87a9f85186d823a" }, { - "address": "39T1cXopncNEUTxyvRwzWrJoFLWZ1LH5dw", - "secret": "b2d2707e8fbc918a167784132559ef925c814ebd8e85e6de129af6f13d315f2b", - "public": "020da5ec5e635e2f0321e5f4fc56bbc4b18fd2d453abe9cf62d421a0a8c356f4c6" + "address": "GbTRDoRiK7FrTca2MVEbQ9r9TK9PGqLhLX", + "secret": "89898c1b41e26fcd6a41e97c27f560f5db50c92e6830377379d84d767e6b6a3c", + "public": "03bfb7365227b03415f2f4e56821a7ad1baeae87b7c35b3e4bd393e7ff5218c392" }, { - "address": "c3DQ1zvR6dhzTcUAA1y7zz3mKDVjSSuUk7", - "secret": "6ccc25bb6c3a2e6086b7aded1d55ffdb1dca4b31b36fb00e2825e45887fe3440", - "public": "03bd2758b22a2ac51f366c36e56ef3efd2f2b9d5d9455c2b1938dc9ccadcfacff8" + "address": "SnfWDBRmDkshVcSgLfw5cYoAgmKVFygyS", + "secret": "26030f3717e988f6739b27292401aaf8f9f7731c016fa1f5e1a7af384f22db2e", + "public": "03c754deb4f25d2d81cba3b6f0bdfa68907a37d9d87b7f5127f477cf3b1446d567" }, { - "address": "fekcUHu6dEiQpWZ4NW8ywDs71AdzGLaH2E", - "secret": "902a9b83e921bc2031fe3ce69191a731dd5035ed2377596ea76920392b489d47", - "public": "03844be42604541d34b3f74aa2bffb4a6e2d4edfa62f1f4416324775bb1124ae2d" + "address": "3SLNRTzvWE2qxPJH3zJdFZmZSNu2gnpXwr", + "secret": "bf33312864090d552a1f1c17435fab813d9dcfc5000f9b2a7aa693355856fef0", + "public": "02f684e4edc5d1dfeb37a770e08e57dd6a49cd8bda524631b7b208d6523c29b0ba" }, { - "address": "8RPJ5gFnvifbQorRNstTXHFLT9pZLub2go", - "secret": "8d4ee71e7477370fe1ec281ec4a774081ede02fd7f7dd3f3dd187fee76da8a89", - "public": "02c2702fb43893277fa7182b8bff8adecbcaa4b700aa8299a444af18d0c93a4ef0" + "address": "rsnD7sxaPfXqbqYXPggvLnWYQ9FTTERHYA", + "secret": "aae8981a907d7e0e5bd0baf1919f8dc663504a215223c3ed57cf70c823a3cacd", + "public": "03d18f871b16e48337b99fa6d9cee89212e53bb26eae9d73017ec796a09480fe64" }, { - "address": "iw9JaPcdiEM6EcF71BcE3R8Cj4kuG74f7f", - "secret": "f8a0128c5bb9d37edb58120148ece18e0fee587f06b30f21441f2da2e3a468ce", - "public": "0385e8a729d90ec2d9e53b5406ba0e61cef586d69181b1a518d9e586140aeb483c" + "address": "2Ni5D2DznHv38gyn6E5Hc8mqBkrMQ1VfKq3", + "secret": "7673157ecbf104fec8687bebc5d8ad81dd5e93a0a8b92bbfcbee246dc7d3c7ef", + "public": "02bac8f5f1120987cb3fd7ffd4958cdc50e3906ffdd6062fd9ef4b96c7ff769970" }, { - "address": "2jocDBqoSPKjS5BKr5sps6Q8imktxFjyUWN", - "secret": "821360e349326bb14c28aeeee2b0db0aaefa8e8e34fdc7e001c07eb6238a5191", - "public": "036e006fc0c5d545c3e439900dc511f510f500400f5e643936d10e94963cbd993f" + "address": "2bso1AeKwYVDgZuiN8XLjNKx3xBHMm7M7xo", + "secret": "c41954726c0d4369932006758b39f1afdded0d309ff99d8c1772f993570f267f", + "public": "039c3f264f985f26dd31cff7b0830c2bcc58ce13f54c191fce6d45fb827500ae83" }, { - "address": "2Xe9fL1ZnHNvT2GBzH4piWJGdN8txSntptH", - "secret": "a8b33c8d5d4b0eb9edc1bdb2c6cdff39c304be00197bd32986e929f185c11613", - "public": "02df1e5504b3b4ce95f1a6dd42b35eb9492d4262b25155f1fc21d3a6bd258da9c4" + "address": "2kooXVM5k6vn4y4jJcmgCJPnoqB4ydkTtUo", + "secret": "4db9d88541c0efd0cdb9fa3acbb3b6e0ab3db4010a59aa78dd1488ad8c28ed14", + "public": "03bed7e9a58022dd6b2727439e1993b03088a61f2518a78436e4208efa19c4883e" }, { - "address": "2ZurYV48no3YXdX2LMWp2zsH9PcfWTqgQ9Q", - "secret": "a027184377a18c42412bf87aacfee7e8ff901428027c71f871f6134d79015c74", - "public": "0345fdb00ddb418b38479fcce0c7b2276965fee245412a2161e78ab42752d8508e" + "address": "2QiJF7CCM1tf6ESVHzrJbVckHcehKtGKAXP", + "secret": "d530371a1e54014249b716d0f58ea68ca94a8c29cc2c77766032f9ee7675d076", + "public": "021bec8c0d092baf315dc4f51bb6a74ab276f3366a7f5a9aa72da8531b6dfdc93a" }, { - "address": "wuxQzPkvfLTJZVJba4UP8QUuv2yNfd223c", - "secret": "1a657ed555279ee4fa38172f510a7d1e40cf4f41bbd3c924797dd3a62327f9ec", - "public": "025762c760c0d3d5073a9b0d4c415a498420efc69f26ff09f1671689f7465b39bf" + "address": "2ZFwFc7gPebsz3329NMpZPdrbSdTCvioRjn", + "secret": "7bae0524fb5739792d1ca70ff661eee59d193113d2959308472efad7f745abc0", + "public": "02a497a0c6534627babf9ac0c9613702bf0774e3c663faa3a173daa489cfe9c032" }, { - "address": "2hzvgj7X643sj2J7jSG8mpcQX8xJfMn5T1o", - "secret": "839b67292bc30629a15e1f5cd14557076ddecffd56313633fdf93a53e784288a", - "public": "024e4409a400d0e3504477441179c8b5e670c625370f2a60b2a5ac86a29a6e28a4" + "address": "2crTgsFrcHwrx96qTgNd5v2eZRhDSGwD9KU", + "secret": "0144fa3a146902f05d05ce1ea93d7f9f7740cd9515463541234b035ac7c13c10", + "public": "02a749c44375ac2f409ccade010712fc0b7108faedc9066e52656df90713407c1f" }, { - "address": "2daa1pFP3J99RVT1PX9FAEjwe6pC2v2R4x8", - "secret": "6ffd6360580dfc63ea299f39f3ef9c9b3befc0307136976406775a97066fe348", - "public": "02dab8eef19825058f0e600a23034f130ce7af803a3ee5771cf836b9f0db8db846" + "address": "WTGdQJWnTZJy8BheAdohn9bDj1S1CJbcMK", + "secret": "320fff3d17aee027ab0a021d62984dc71e20e2a313d550d6bc71a7037da76ad4", + "public": "030b6ffda04d9048c4bcc32a2746f994eefde6b4a1707b5b2f4148503115227cbc" }, { - "address": "k5yuz7BHkAPFBvKdrN3BcoNwxzznkCKjbG", - "secret": "23fdfe574f0d37e3d724609b72eddd24d5dd8c2d08e9f3037783f7b88e4efcb9", - "public": "03712f41c3939b4a1f76b19709ebd699c69136c9fd5bb4f06879c5fee7e8df24ab" + "address": "28JuPfNb5KQcTbMZorM5ffH5Z6dnqYoH5rs", + "secret": "5bf42214cfb2fb2b370dde6c400b89659c5b10d82623d5fb37051082be4dbc69", + "public": "03f727682db76736b93347b8f31414520db4fbfa8de36864ec33a5e397ced943de" }, { - "address": "MVnnpqf7WsfHaRc2V829m7kJWK4tgzocCJ", - "secret": "7c6c7f11ff61cf5ab69151af2a68b26037e8928803b7897b4b21bf5b871c71dc", - "public": "0213097b5a212742afa8b2ec382b6b1a5d9940d982dc4a2486800883e3d0237cbc" + "address": "2jYZCimvDikD1etTuiwNVkYdDVYoRkW5ajL", + "secret": "05140478b6c6839636564892946b45df6b3019681672f9b104c86ccfad644f1e", + "public": "02b04c95e8face2cb50c64526ca0d7c804811e4ca45ccd34ccc954d86692a39537" }, { - "address": "22a9fcWSbjt1Nh6W1x13z6mcEHExLmzgeKj", - "secret": "52c071afc4db9ffef0881306c9bbf573f05d33a818b88fda6556c43f47e65a74", - "public": "03c459553cd6e2ce2108cf8d1a861e1b3602be6a96040cb464cede5cd852269cd2" + "address": "2Ws2CbP8zi2rmDoTV5wxXHYiBSgC4FcFbDH", + "secret": "2bd204df49886647bad2806269730ca62d071fc446f42881cd2b4f1fcc98d00a", + "public": "022aa6887280a4006676f44589b4b74a0e8358b627e797964f4d9ac466b35cf42d" }, { - "address": "2SV45tuexCYrnQsi2SZmo24NZFK7uRKfPQH", - "secret": "79a4d637af97d3edd862d2383a6409d5056781e8a06658e003fc32e1a25155e5", - "public": "020d41ed194c73a8ba088214f13469b6185f8ff2c66ed387a7b82dc25870b1b60b" + "address": "eZLF5WNWovZ5N4KC8vZtS38K2A4u4BQs7w", + "secret": "e7a78096dcea1a150b559775f643908650d1eac4bcca20de411a2764790ab1f5", + "public": "03ee354b340b4a723fdcb1ba2c11331bda62c40fd1c0f0cc52c5f876c66c95ff58" }, { - "address": "gxKhD1z45PDZYHHF4zA6s5D3mVcdrvXFWF", - "secret": "27cdb96386470d574b0ed2b993a081adc2fffb4005866dea491a1567b9e96c1f", - "public": "02494cd8c2251c8bf94ded369b3600187fc618dee80800f76082f7e6c6982de367" + "address": "fadbXiZAhdLmL4DPDPFYGyqsZJxhDGrBnv", + "secret": "c05043fe99c3315c8354326c6a7e38410372f2b27f68eab88e74d6f73f170993", + "public": "02a96ee70543de38766532aa7d58eb3d36ec7846ff57f3ac251e2522ff072cf046" }, { - "address": "2EoL3izjNeWQnDSMYeTdfL1dMSmc4JQJmb2", - "secret": "3ddca363e921af5928b55d783777a923f6470ba1b04ff1624647af6da5dd6a95", - "public": "032f6ea4796f0066af3fd2b631f2588a56ac61829554334fc47fe9676972a6c2cf" + "address": "dmEhj2EdVXyP6gTmNVwAv9cg1jsHNFR9kG", + "secret": "a09c86ebcaff266c7213d42a8fa98c1ffbbe12b91559a0d0b6a7936b3e16503f", + "public": "039dbf5a286018aa46bb4714984cdce0ae4eee0f35803495ca595b69adc5e07769" }, { - "address": "SNprnv7NsqXUhieu6JvQQQRJsJsbNm4Xfv", - "secret": "21411c569b9ec0f150873244e83284b7d8cf92c68f8db54173d4a944e2573a9b", - "public": "022368bcf68e60fe395265cea45314111db17ce8abfe5a2628127da43ef2d0bad4" + "address": "6MyEQAeTLFjYYxG52FPgpNrHDasYFrjXgy", + "secret": "7a37469469c1063b3ec2ff3504df6e7a6a91aa1055a998dcc11e2781168b3797", + "public": "02980f6dc6efc5b1a259b1c588fb27b9c01ce6c366da9dacba815616351d62afc6" }, { - "address": "21BDxLyGPsU6DHKdkVd5ArQfJCDMyphGAYX", - "secret": "5e44f002b5063e8365fcf9aea0a1602af73a3b21a519b5cd56927357538f7eb4", - "public": "038366c846b4e5ff27ee6bf5634aee22dd46da60415dcc8de97ec2382ad59a60c4" + "address": "2Qh8ycrQGRuDaTmqjtJ6GQQCjL5KRCpAE7L", + "secret": "53c278e573892656e5ebc94420ad4f4460f368c2c9ea6a89b3534414d5cd8635", + "public": "021543e5108cd46d6038eb2f2274c59cc2670ac395b73611b0f381734f2acf6641" }, { - "address": "9aP3bqUKS8rYeQtTNjX3oGCh5S2Gswi15N", - "secret": "d028e47f17ecc5d93cde0300a7f5bbf7b4fe6e43eeebf68aefc64be7c856618f", - "public": "022afc614a97e26ad30b48aa423303c4267dfc24f9406334088b3814bcc33eaa08" + "address": "2aceT88Aq7FHfqxo2aBoiyDDw7rB57QsWtn", + "secret": "d30bc636046b7fd619fa64d056c7bcae6d183b1e64e003ce9a358bd9be3ef3bc", + "public": "02f7c3b95e046785f21c280ead0a1eb3db86e87ba56a95671d1c44b5f72e93cb32" }, { - "address": "AGCRkJREiD6o7JPF9sjw8x79woPFF1Vz7F", - "secret": "d8d6ac06ba310ec681868bea7998656fdb971cbfe63b912930a333d7efebddf8", - "public": "03d87a31d0f255fcb19352cf738a85934ed4e8981fff2262f5f49ed7efb40abe92" + "address": "4Smrr2YzK2W52cxZxiCLoJhgPi81mSSZ2U", + "secret": "0641dcb8d208b0012909b8e7705ec077fd485e43778e4b8dbcaef8eb925c42cc", + "public": "023143e54417d2df738825c2d521e283ba6b2ef611b3d53bb4fa0ec09ca33671f7" }, { - "address": "2hZwVKcuvDAu3y8M59eSs3sykMTeJKmFJg3", - "secret": "842d38d173297c679197a2f86b973e18b1b2c3058980b67dfbf1818d245d6a59", - "public": "03fe425810195d57f0d3014427ffab8ed0d87db9f7f38454427bcca97194ccb2f8" + "address": "2b7YVEDW5WkLzrqfoZrkxzhuESHEwHF3xph", + "secret": "77ebcdd32c08a25ff00b56603fbacb18d44eb869107e1b0a5b34f85bdcbb1672", + "public": "033c0e22d985b797c944acb9d176ff51200446aeed5a31cbd452b8aaa3f0364e1c" }, { - "address": "cbXhfvwhLSkxYRa9d5apAujrvarfUxRaXa", - "secret": "d1b81614a5cd2aa89785ff293abd0d9cd036e0a9f9800dcff90a0160fb10242c", - "public": "0345a92f9b11e05d783e9801ee3c3e76e6af7bb042c3fa5ad25d036e9a52742c7f" + "address": "JaR22JZKMWEBSPNFiDKKCM8gatkWo9LVrJ", + "secret": "e31e98a9043ecbb6ffa15fd480e0f1f169d86ffc440a56581f2cb994b887f71f", + "public": "02d604d042b35e8882515b5bb6d3c3a8f66b0fc816fa6dac3b88aa97ea9a8c8442" }, { - "address": "FHM4LbKcWowSF4vNrEGrZcZzQMBGpStXow", - "secret": "abd4e54e66bc68bf728e18052119c20b1bdbc62402ffa59cf8c00431b94acd7c", - "public": "030b4254fb4507da9aca8c89b6178df1d56657854653bf320cb927a3484ed2d58b" + "address": "2j5pAjhg9yPyLuzBJnG6jPFq8Moi58Db1Fy", + "secret": "7ca8e3dec55937eb12e1abce3ae262ae1ecba643c69d4268c0b39b7c38e902f8", + "public": "0321f9d1f269d36138604eb84dc1087ac7b06e3bd0511a1f1128c089fc6b61dcb2" }, { - "address": "Ki3ADKmUqrf6HGEYJd1ddt7dAndmBDbJpa", - "secret": "bc8894f9e35ad7ad7628b5d01687343722cdaafd88915d2f0dd723cf2b068db8", - "public": "03b9d7e47425d9234028a966c71840c5dc29ff136c3d8b36f68809dd8143185c60" + "address": "25PWupb7kLuFdM3UQK8tvcT98h7i5UDHkXT", + "secret": "15c148fca7434a18c484b539830abfd9ee169d39c3bf95e13cec5877ae5137bc", + "public": "023ba5a705ac79594261ebe524de80c022dfd42bda9094e8a4fa69889e6ccfcac2" }, { - "address": "CTaYftQ6vYEpYVZpqpgwKyxT9sE7QzQtBL", - "secret": "801a600e1f84aadbb6aa4759fc36ad73ffada4d92cb16302b5f9cc6e6016a107", - "public": "03f8e5632eb3536d3c523ee88799f30cfd8679bee7d30ecef01449c40db1e3b0de" + "address": "2LWHyVRV3AEtYLvN6TwUzbFE7g2ccmhTVEm", + "secret": "3bd05a85518a0596564796356e6ef267e99e8de6aa529a0bb70a992dfbd1abfe", + "public": "023f07f1368ace33dab9fdf039e05137b8df01ac5864723a8e913d7c74eed72c3a" }, { - "address": "2a1MJEq8UXnYbuQvJXb4RoEXyj3bhabjZSQ", - "secret": "68862a0df8d462a3e61a383f46d4a3872d352d75f7d3d65b5d1dd7aecf1d3bb1", - "public": "03e29ad2debc4e2fa026592c0a1427345a2d4018b857032a61296acd8b942895ff" + "address": "2mJ7HbAJiYmNahgLpCSmxWg8HbAx15XPkzy", + "secret": "4929beb2e5e57a9a5f1679b3a60bd6d20dbcd7b2a2527dd55f036d6e0a0eede7", + "public": "03ecbda83c01407aaf4f4856865fdbf082c12884a82e787ec0ce3d9c02bd6fa565" }, { - "address": "3hf4nGcovkaPtJEAQNUbkDcdBMYdiqYs5F", - "secret": "9231f481b5345d84ed8cfbcab12fea3239aa80824cbc35e28b1c581859a7fe18", - "public": "036d16a16589c0a85497a2112cdf734a380f3d8c527c982a49e88c5ab08f1938c7" + "address": "rVg9n43dSffZoVYdPyhpNemNbHDcZcnFnh", + "secret": "c564ddbf95b83a7806655aed2277f7aab9b7fb14bb106baa03f497dbf3d7882f", + "public": "03972a262ab0052092640c9ab72b82617883a49b58df548f00b627286dd658efea" }, { - "address": "2KGXCDtqprmvXvqyp3KdH9M8Jj941wFLCtM", - "secret": "848fc303a8207db06dc1950550f8ab57734755df4d90f0c03de7e888218e8fc0", - "public": "02725b8e006b940a728f0d031fd52da2242860c14a4ad3445cc65e15edbd92310c" + "address": "BvURWh8mAbBBqpqN6YcaVMo4xaqABPkjAK", + "secret": "53f6d7e20bab00854fe7cb1671eac9ce35f997ccef7a5c68088a60709ba3598a", + "public": "02b92fba69673ce455c828a6eb473a185a3b5739fd928bbdf0e017c85bf973a084" }, { - "address": "2GimCWpBhQWdEGn28hsxErTozh9bWxNeUCQ", - "secret": "71ed83a0c0c80ce98ea58e9cb5d9d36508fe4d121337804fb5c8582e2e9334ca", - "public": "037732d5f0d717c8d47fdbf256ba71ece8b3a0d19271b2202cad7b3eac018bbd6a" + "address": "298GYxeyvXBFpA9b32nf838vHz2L5bGQoKs", + "secret": "e30820c25276c84d31b3048597f19f42b3eb204572d8d275c8f5f76788c9d3f5", + "public": "0278dc9c5578ed235bf491b5ce0fb47afcb1a1a57f73db7cc9f303055a124ba7e9" }, { - "address": "2FQdLCrXGQbkKVNKXeWraDRZyYrdKbaTeLo", - "secret": "92986faceb4fdd504aba034c3cb5e2fcb8d21e55b430fb6d4c661b2bc48dd556", - "public": "02b1cdee4b0308057339c10315e0c9108c114c1221dc8e7ab86462736975b50b36" + "address": "nRJwAXzpr766ne9BbdgX4wtf3vCkb6FFe", + "secret": "70ca6ef64244fd4f00651ed245f1f87390320b79ef721bdb6d87c14b52693c6e", + "public": "0362e369ee21ff7d59208212a8b9b696c617dda85821e4ef42194aa96c3581549c" }, { - "address": "6v4vNbMYgqGhNvA5nJqFRoHQR8JDnov3Gj", - "secret": "4ddfb393721ebca7594580959f624224fb61dd5a3cae399cda3873f28d488c20", - "public": "02d1af5029b94afa2919388a20ba67f2dc0745f3b2cf9abc63933e157e223ea4e3" + "address": "TCXZMKsbdqy5yMnkuWgpVA5h8rZdK6odrS", + "secret": "6d5b53a3cd6e1b4b6cdfc44989627c71d5fe406dda8043eee286e40d4691890e", + "public": "037a95a70a38f2371799bc3cf2f329986d6f64bcad8455b93ec368c619696df252" }, { - "address": "2R15sUHFfwHi5BPBmm6rvWoVoQ1K3AiJ4CP", - "secret": "6b4ec79120d68d5c04b977e84f47e74b0a5bc43e76840ed1df838632b28aea7f", - "public": "03fbe76a6657d81b05547121003c121a318343d86c87c769c3b32aa4ee3537ab32" + "address": "yUMbbPX3JyD4oSA6L9cYDiEHpRqM5DZzEK", + "secret": "ac9c752c92b9fab9859f41d4df2799ba3083c0d0261557d1563ce10ba2c14763", + "public": "027c5e3452c791d2d21e9a11f2362fc86258ea4470d3271422cfea29aa18d65e0d" }, { - "address": "2GufjFJD1LFdiuL4cvd4tFWB49exyK2N54k", - "secret": "cae6b580c2693a2ef7f6018b12057c3073438fa4d352ddcbbe39b27fb77ae02d", - "public": "039052f0a3d85ec7ef5dce9ca57c5a6984a3be8d714fde8d01ea34f012916ca928" + "address": "22LAVaqjZaQk66dw8thM5eN9883pfwxF7ve", + "secret": "1da6d30d4fed6353c051770fa8df8bb25073d2a65c83be50516c7ece3407b698", + "public": "0333620b3e2078bcd027a76ffe66baa972baea3b1eefe02ed76b9a17ccc7d995b1" }, { - "address": "2GNDPeQ3xx1R9fZ82816wSbcs2HPVp4frw", - "secret": "ceccd48dccf475eee40caed42571cba01439f45ef90fbc790a07d6f7b04032fe", - "public": "02516e0975af70ccbd347c255972ba3c29ce7a7b13b023a95bd252f23ed60d7473" + "address": "Gn9QCBzKVxHHh8SGb66wpu84BZuCw7PHbm", + "secret": "16b00b79e3747c8e166120fe366546c32799aee2bab5ad442227b5c2173dc94f", + "public": "024726f46895b7ac02795bd5bea795ba7a51dc2ffd53a90c840c73657b25680c63" }, { - "address": "rutfw2DoPUrvRyPK296632ubTjRz2APRzL", - "secret": "6f68331ea3e530e33d8e32dd8e3bd1a27f01e8233fafa6d0180af4d822982f91", - "public": "0394932055b0bea5accbcb71ff45b1906f60d52f9d8bf5299bd88bd075aac15882" + "address": "2kT2ZUiL7vzt446hY8Xc2Nx2ohGzcFjtZwM", + "secret": "f0daf3cfa005eb279b7244beb2ea779ac76b1ea77045cf00c7379b75aad4805a", + "public": "03a8f0fef09af25c1f30e8267af7759b02942875d12e265a3896e7ef6399cf43af" }, { - "address": "24vHEULfWDssh6rDex8VQs7tQDfvjLwXXX2", - "secret": "42e94df88107526dc3e456094af07507ab228a1e52f7ea625ae58bf84744dd52", - "public": "03c0030e362fd38747936f3a74aacc6838e1fb7780de5a35cd7eb20840a0989a05" + "address": "2g7bpFrHiyyZhjFr8NNLoVoEL1HLcGyfXFP", + "secret": "42e7c043b5bad590914cabd9da1c64fd95ba0e3618cf217c9e56e2cda849a1dd", + "public": "03d315900f1fa2b0363971f66067cb95b5e062799542417861acce3905ef009924" }, { - "address": "27V7t8qzJ2GVYP4HD4MdPLQHrJzPHUJCdw2", - "secret": "e02573d5210bfe02ae41321bcd7b40e0c800ae713ff3f731bf71006a97e75f1a", - "public": "0294162e4b3afaa056b1c7765de051e9945a5f33c3b82f7000e8c2ae9a1ef2286a" + "address": "2aFx6zgr764yaew5kBJL83xKvJXtaFYrNe5", + "secret": "609ef2d18c07a72423ae24c2c0de839b900dd660106a4d2352606be503ab887f", + "public": "03070b88d231d49d34e46cf719e47fb0abd2d9b9db9dd571931cd0e33e9a21f251" }, { - "address": "BLCQ7CJpwL6FUiqEVy6W3STNS1r5VebKfJ", - "secret": "5bf3a940c1129e6c0911a6bc466b29d02d40aa100ad1452bff56665af8547d93", - "public": "03101585a60e6935a8fd78f068240ebf4b27014be0de27903acf90247174fe3cae" + "address": "2axw8SpzvpY6QJze48DubE7SVwhpfEdTt1e", + "secret": "3ae1e46578207468ba3ff0dc9e8670d3e92361eb8e4bdc7f372096a10fdea1fd", + "public": "02bda68d95c5516ec84e5e8ce328f6354a7f3fa1e8e0376b8708d570dc4e7cb551" }, { - "address": "5FzJHRP1gYR8911NxNnbM6cmpwwBbc9wFs", - "secret": "65b1a0e7273488a142bfad711df87b83e332d0e749625abebd0fbe4805f18232", - "public": "033667b7a8dac8f836564755bb1db4ab353777acfd3447f52572cdee8a41d5f816" + "address": "y8DV3nCwaDs9PtsQbiZnueVcbqB5FNho3h", + "secret": "c4c7d8f99d6df9127b6ce974e4b5791619b7a6d9230bd7ea494ddd5321c3b02d", + "public": "032da1fe104a466b03731eb9fd85709ee31a91b3eaedbaca165413526ecdd87dd9" }, { - "address": "2P9BkpEyw1GyHnfFo4isxdxiWB26Y9sZvH8", - "secret": "47b163698b120acaf8f0535fbbf76c50275878faee627627b4b7225d67be235a", - "public": "025ba389f48234e075fdc70575a6bc8b5eaa9c5913c3a6c179bed759ec0419a8af" + "address": "eJHjp2SLL6ZUtYHhfEMNdN3c49k6QU8W1k", + "secret": "fc4c34570ee70911601b48a8881e93c713d9552cb9499c871454b1247619f7f1", + "public": "036cbcc6c350ae878de0382b4d4a998f85490f6ccd288aa37356730eae31e1d3e4" }, { - "address": "25wT49Tw7emEwsARuWnw2GzKu6kuwcsfCJE", - "secret": "6bd0b56c14c96699c593f05b2460698d514742af7ee056913fb8848ae6c36c25", - "public": "02630516ef1b2c91e6084fe5d8bea4fbc8631cb5dd1e1acbf4ccc16fd3b19ce2ee" + "address": "ZBRYcydEtrkGHYVFRmHQpzVwfDimNC7rfj", + "secret": "2df0754861dd3c563c5c1a3efb75befff40774022fd74835abe23fae37c03f49", + "public": "03f5e7d8028debaee9b5f29b2196c652cc7dbeb05f6dfd2ff19e1a7934febac699" }, { - "address": "8wNLXzi2F1QD6n887Jr549E48BmQ43mhtP", - "secret": "8a1bccab8e4a339593965d277d7c04a92a2156943c1fe11eed18b5af66e187f9", - "public": "0337798d5b74f5f4ecfec22c406a8b762cc952b6d5ba297abe10de7ecb59f7bcf1" + "address": "J2Lu6gP8zXyq6EjayWtV8cDmdi6M73Jn5B", + "secret": "4f82d68560df1e74999982c4087955f02eadadce6502054ec431a2a2958c27d5", + "public": "038494fb1ea6767a31005b3e2018500644fe5f9229d1facc6d3cbd086c1434a120" }, { - "address": "2WyCgjNCMHcPX57xxXF3DYoWJZ775Ra3ifz", - "secret": "202521ad355ebc5cbd881d23ff56de3b42e40b2c195a5e6e612b33a301917bc0", - "public": "033eae27df5f2baeb81ca43a8207d0bdb89021881bf1c152517864028ecf756ac1" + "address": "kXVPezUrC5jjzS1bcVEUgaXfqqPYpPG3jQ", + "secret": "72b9f75282bcfaf7c3e468f7a090bb3322ea4dceb96449a0e02d25826e242dcb", + "public": "0335224bb5460f92b2afc546fac694cc6af797543dbddc491235fe9469c269b5a8" }, { - "address": "KGyjPVhxy3nvXYdQC7W8wmQQ7MnHquhLgx", - "secret": "7abeb9e6500de53f1e888b76ce0d99a9d54a030db750ce59ded976092045b952", - "public": "0292fa66a5642b5a7badf6c5bae9134c5eb03f02fa4b3c83e4a75a94973df7dea7" + "address": "sfBsXAZBz5VynyFGyEx1TA1EVA2SNS4Q3S", + "secret": "599c05c64d67fbf675b01219f15e82a4837acdefa30d714a7d9162550604ed51", + "public": "025eef68fc3790f499996747cf941398c8f90f57a47d8ec93cccbea84081b51058" }, { - "address": "K26e8U26WH1kNyHG1PEJnhonBqTSdaWdYr", - "secret": "ce9f551c1ad36b8c88a51916552ae3807efcabbc84d09a095f86d9ad7b1ac101", - "public": "0358ace997e5e49b59032d21816a2580ec2587e9686c1bfa5ed8c0a807e6f6ca41" + "address": "2Q6guBQ4Mota7bUYx2TD3xwWd9oMRScu8q4", + "secret": "34378458342db0df22be23ec49aa0f0e911900447c6c7f8ee2e69b79d6e9d309", + "public": "029cb1684854b84198bc61cc8fd7f42d39d259912c6f7e65d228bef8846433720f" }, { - "address": "8KCzt8q1VnDiy763wg1wRUpY6HVTmePxkN", - "secret": "5fe95ddbcc1a62057c6e0d71075891f96500f49f3b26bb4ed8aa8bb026789ad6", - "public": "0231e2428e43dd9a63de5a13b8f637d2a27d03cfdf3a4eb49160b02cf04ab9b4c8" + "address": "9DqzJkWCWK5kCVaqY1cXszUtNdwvNZJSJd", + "secret": "e381d7d02fc85b55ef129e13a10d5e7980bf88ecb631d55a9564085b6955f7cb", + "public": "033005b5aac2fdba5442c2d30adf6bac3bef6989b8f71530c91a28a7fe76908a78" }, { - "address": "8yCYLa4QgFKD4E8ksqshcZeYpbgfmXdcto", - "secret": "76c2e82d95c70f24cadba5a4c49e75f722e5f27dd372de9f57c1272b11afaf83", - "public": "03bbdc3881770ff529d200570b8e1b8e147008c2751e6226ba1a99a4a05653ea9e" + "address": "CitkJhr47JTB2gTQhwcYXBsJrxLiHqixK4", + "secret": "7c776045c28bc10641f50461d4e985d6f28687f01a6635fb52406e2c073837b4", + "public": "0251c6fff14db8af2f982a840921ab6b228bab890ffcb2047ca9999029aa26f068" }, { - "address": "SzviHkFiES3sT426sGek5HHA7PCVxk4b4M", - "secret": "ca5eba999d1d770d245d5c7fa49863214ac8b67d0e5b4206a07b24264f8b0e54", - "public": "0345d3d4cba209f0cac437b44f0b6c4917700cbe9e77abb72d8b455970505fb566" + "address": "vFUe7fcmLXGhF2fKRF8zfWCLUujDEgLVAn", + "secret": "f643dfd7a3fa2b46e5ea2ec8d63e1fa81aa0124f24cec7902b55e8090f354867", + "public": "03cd6e4e5cc5779262e293938773a1fe3537e8bd0da18f8353a002c516a491a364" }, { - "address": "wJWauZR17dVBEXnBtyVc9NZj1HBbeko9FY", - "secret": "cd2b37d744e95f4af0fb55dcb521b5779236e876ab6fd8cd5637a0ff56cf8f2f", - "public": "02834ae947348699855f015f10ded9ff1b7640d6a748bdde0c006ca5f6b7a8d154" + "address": "bNM3CoJCTquonnV3fGAHSHjkXU4VVXAtnm", + "secret": "b1303503a813b58803536d68466a197b1bb3a101ec9a1bf8fbd2369d49b364db", + "public": "02a1e47b9d9f2438582fb53aeb049c715b7a061ec5f5ff0a4390a27c1c9fb5daee" }, { - "address": "2Kihkcmk8fndj9kTyB5euTLibfkCAkmUXLR", - "secret": "ab1790bc552bf7b71489d63066441c454a4aeae881b510185352176d7471ed79", - "public": "03582bd55f8ce192546855da7d3fcc07adfb2a8c2fd3d92b35c2fdd58362586615" + "address": "2BDGGpDt5TeQqtxJiwCsYfUqSH3RnDaJvrT", + "secret": "62ae0cb5fb989bac7245e194d13deb83bbe7997b316a13b384afaab7d8160c27", + "public": "02285851f4a07f8247d0e718dfc9ba3c0739eb0384025bd1088e5b2fc5075cb544" }, { - "address": "A3x62hdkeHnYk6FZ14Kqzr2prugRKSwAxr", - "secret": "614d09b0bbb851156b437a210f56533fae5c7f4332055df4880ae95bc9d89db2", - "public": "0306eb8beb7917f10013ecbba233815e84a0eeb6e6307c2cc520f1866d8d5c41be" + "address": "WPP7JbSpJbHy13p3tAtSxFgKg15tna37nz", + "secret": "81158f1ca73b5b92e88e35864c2cc32a7e6dc4aa1dc69549b69488be0f939210", + "public": "0399c5c339ea989ac64e6c0b8c46088241e654ea12be19055b0f3602185f59113c" }, { - "address": "2HJXxjDQJSQc8QxNxiLnvTP5aPowGuGAdcC", - "secret": "b5719b3b375f33dce99a396348511898ea0b3605217238128e82336cda113bd9", - "public": "03b064908d055470082a7a19d0072bc8bacdc8bb95ceba00ebf52e4936fdd48b62" + "address": "CLWUkduHRQ3VDqWCtLPu73CWRuyYRcywUh", + "secret": "a2e2f95581ae88117371cbae30bfe82ab85b16ab30ee792c99815515f4b03144", + "public": "021025967d1d2d7cd6bae8259ade3dbec5c5c7340f7cc96ef9faa98a4e8e89356b" }, { - "address": "pxAjRbn1QSqtp13wk9aaP2SFBcpwYepkLd", - "secret": "d9a11522edb8aa0bcec071af2c8edd355ed5778345460a18abbc67a470bdcbd3", - "public": "0239184d88147d22f7b276de7bdbfeb74d716744ab5d9dfe8266704549be851a4a" + "address": "2hsch7LCnK94zgFRBbL6N5nSwHHoZLv55iY", + "secret": "919e0a2d7d8f4ebb28bb9f8f4725433850e5e3d3ec90ba4f2b8bed56b736b095", + "public": "021da1eacfee5cf2ad3c323953c8ee5be4ef8ee23fb2abe88b2cb4114c24402ac1" }, { - "address": "2YCUjELthMAMZYFnNqSn7wY2q6crBAxH6xD", - "secret": "c50ee12d0c6075c8189f1dacceccff28be72c7cc0142a9ef624fca355477873b", - "public": "0261e640137906974d8c6565d510a4b73b1962d24c9b6726fdba0c3db02be35d0e" + "address": "GJLtCoZnL4di3kHwvkJtR8CW92iN8Vjmcv", + "secret": "e7102c8e401b2d30627764d44d7233d37ad7f5e83f935499581c4118e7c3e545", + "public": "0297dd6e1b2b55a29022578bcb8f2a97c4ebd1f04e14004c83742948baf15db34a" }, { - "address": "cPnmUaJtiGtUgds5VhYJ8KpBrNhp8Bhm8i", - "secret": "b58fc2426bde95b24911ab20a158b12b29cbbeeef311f7c30d8771e52de2a331", - "public": "03b160dbdfb30e9c3d631789197bf479b88215bef48e5dba89ab116b35fb90d518" + "address": "dF5jq7t2pMQJbacvfPFbxbiTRYi8dt8Mh2", + "secret": "aa520684df5e3db05607e59f3e1a039348113fa32f844473c5a3b5be8cba448b", + "public": "039230da7d6b4324dbab6315c9268dec4c913e9eb2fc2cc59daf29e2195ba0c0fb" }, { - "address": "o9XimuESccoSnah9ZwASditsEQQa33Nuv2", - "secret": "196b50f23ad6b27b180759d380ec93187fc899ad2b0abbcbc87411db8a1ed7b7", - "public": "02a4279766e841db2868f0f6a67e13f7829adb71a8a9a11673e64a90a558a51171" + "address": "W1DHb2MP4dfnLYgS7YmTGrwT3jGkyYzTaV", + "secret": "4dc879f1a4d782bfcd3921714deb2371da5df3b2f46537283ccbfe919a21ee3f", + "public": "02a1596f4f937a01189f494ed81fb8354101e1c5f633d34ab6e6b189c99bfd5d95" }, { - "address": "2DRgCPh34dUdoNxVRa6Jx6e3dV7c57WWc7W", - "secret": "628a6c27eb21b30d0a2a4949cdb62d2e1a3463e4270dd33cd4ce3e038aab9e68", - "public": "024bcfdc9875b67b43fc5e00b3acbda1c8293e7dd4e53d5a1bf12500c0d11735a2" + "address": "14Dzj9AmYcmqHADtmZaiaGAAYPTJF5iu3Q", + "secret": "3179eab44f64ab0e35f3b4842112eb6cbb18ccba16b7668866adcda6ddac4882", + "public": "0395997101d2d8ca8ab15058f8e465d4b87a422ab825aaa8616dc62373f01c81ec" }, { - "address": "21B33ekAYumcQ7wN7xUTXFEEtWY49HiR3TZ", - "secret": "9178b901ed7f092b1668f650c215d4a1652679aa5c423e0d3eb10f47b263ba78", - "public": "03efcc0b6571c7309bf15b4320291667cc9e3491e8a2610dd6f22eebabe5094450" + "address": "Qt3q3oPi1HN4v6iPj3EbfaaV9kMU6Qb9hh", + "secret": "ea350bd2044b3a9352393f5169c3881d8146a5577da478c0e2185b56d7e84e59", + "public": "028959d6882142bb5dec9fdd5b4a2c93b2762df2923598e056622b899ed332f062" }, { - "address": "6TXKQPsMAYhwJqzoj6ef79oUAkfomwekuq", - "secret": "4342299c1d2836e4220b83119921d162382800471266a76a6fc3c63cfdb8f0d3", - "public": "022c83047caa0cc48e844b9b2489b36719b79febf29c2e44a6c23effab5df9f7cd" + "address": "2LdwMr8hZ7MeQ6uS5e89Jwq3KjqvWQguXpN", + "secret": "2e145d25d59f1e5314ba3f290a81ccd6d71dfe6b998352688dda120aafeb2b4c", + "public": "02e0a927394aa47473cf544a5ef5a21985d14204adb5e1bea315096f41d5d38307" }, { - "address": "PkY1K28S5MEbzKyjxD6pi4kQC8PrXPEG2W", - "secret": "78cdb21b235a6b61c8eee1bcb4a9f594df093bc4f77a705276416ac26cea53ed", - "public": "03b9f103995b424833c0d237df6ffe34b9437ac38c12d9369b7f66721d2c3c96ab" + "address": "6z7d9KEtvBw8q2VZqz7PBSwHaCAYD9SBiz", + "secret": "ec9dc327f748b8a02b7b931d761e41f9406fa1ef637113acfea60a395f07f703", + "public": "03610bf697e09ce02f54c830792678c008542d19fca2e625706fada2eb5012a3a8" }, { - "address": "4ihmAMPAmzfsbzihzGDx9fRSxcyDjwoDed", - "secret": "4cb68c67ce5f4bccb8daf83d350e993dd820a9add2ce32d07c1cb3be21614387", - "public": "0328d1f37abcf0b40c8546c802d764f8431d6b664625c79218e980d0dabd9ba1fd" + "address": "SeECPVtog2nqdBuhCASpu5GFW7kAQ2aWse", + "secret": "45cf169176971687dd96d56d544dd4739b3c3c7b24eef38e2b2eec449259fa09", + "public": "02f2ecfb3e58709626fdc9de870bb11d8a5ada1b5088af73b0d49ee2397ebdadfc" }, { - "address": "2Gs5sbw9bypHi5paHugczreRYZzLpmy9jjf", - "secret": "c5c0927d5c2890662c9be7403d68ceb7a05e8d7606f0361f9f66f4df1238974a", - "public": "0200261b57b8eac74d26ed0b672c5c9126e11af9c3659c8ccd686f73a48f0a5ee6" + "address": "2RfMB8P2jTG5dLcrLus4CTZZH6mke47G1yF", + "secret": "72082e472815e974af51c5ca2611dbd65be5d498305616aeff0e21845eb2f6fb", + "public": "022736c896b113689d8891ee1dadd6e90a357d25143199202223637127c1c082be" }, { - "address": "2Qey4TfBwkHfHH6RxLpaUxPNbTLMonjCexY", - "secret": "d95972c45ae05b7d9b19c4867968adb213df0d095aa2501cf2555356e11f2398", - "public": "0392333b2d1a2da60ac73c7e9d2936d145055eef4801834b1e70fa5c1a15b981b1" + "address": "jsHspZyTeoWLQ5R3GAXPDmMdXiWMos8Lfr", + "secret": "d3b02aa4038b4c0a71588a45d9f75a670c35e28c600cee1d2de7d2a04bdb720f", + "public": "03a2ddc1d41e53f6b73967a1b47a6928be2bd29a3c0729a267d71ef8df83b4a05f" }, { - "address": "YkPaxcnPo79Z7dQoJskqpBASe2AZ6TUesf", - "secret": "547afe52c9a255e90f6182b351c1852169f1f0d68dcf9845d08b92b5953e584b", - "public": "030a61e74306a9a180c338724857a363701a0b72c81b520734afaa569d04715e91" + "address": "25CSv2NqfsHSodz2cRueFGwAbdzUiuHHLxb", + "secret": "f556a089f138f59e3000571593b7f9559c1f546b5f9d1f475bcf6768611c9baa", + "public": "0305705d3549479c977fed1227e84c0bb1e349c6fa2374e4f8931c7592f1e980d5" }, { - "address": "2kwYGZbjYb6qfFobbNHNiAtRkjwoEPK5Nep", - "secret": "6ed634a435ba51c86f5ba509e4fdacf78309df91ffeed255f1b9f61fa32cbb16", - "public": "02143171a159f31fa2461060a26a4827ab13213ce52dcc12dd8f57e6ef4538a069" + "address": "2SitgCMQcxkiCF9Jf4pACRa5H5z1Y78BQ87", + "secret": "219e289fee89a7afeb2fc1316e8399953bf879f607cbebab264bbe1927cf7527", + "public": "027a4480740e264da975b95df8333c4877180c546e26cd4ef280de97822491b479" }, { - "address": "FJoYYpFyzuxoAduGWS7uKcJAR2XhYaVFnB", - "secret": "02ceadfbeadfe2add3f24638034e1be240b86bbfb60d9f99521604ed5529f531", - "public": "02ae5c8713da3f3743c1d1ee42fa3d17e65a81341bf9865feba0cc409095cb5a36" + "address": "Gr1aAJwLcHgR2bumhPAyS9en2VnRFZz278", + "secret": "9980f094f2582e0810ce8cbf488c44d68ed60f6a45b94d4a5a56f4dd95ee0954", + "public": "02554006809341e915b01dc0e9687efab3f00b274b47bb61febfb2b5898128b95b" }, { - "address": "reaq98DwEcGAxwX6kJsXAapGs6KGwEP6Mh", - "secret": "063497c947a0acef5594ee7b4c7746ccf3001386d79202a27f6a516181d81377", - "public": "02652e07ab0a4a784f42ddb4e3c529949ffa0e6e6f603f10f7e0457ed84844fae7" + "address": "22k2EBqKnNRAbuGRdSCoL9EkrfvocHs2w8j", + "secret": "8382c706a7533cff4bca93e5dd7428eef94df089461c3fb11c9dc9a0ee3b4bd6", + "public": "023f7dc5cbc6164735acf1e0abab395d99a41fb4ed26056be2f7844c31a03c48f4" }, { - "address": "WabyTsMNUA98goKjSguqCHMfFXTUvKDCU6", - "secret": "f3a0565773eae361906b19755ee3343fdc1f44ee739f186ae3aa2273225085dd", - "public": "0349832fd0e3257feed2eda8415dde7de20212dc5ba3051e5c24c34ccc8888a7fa" + "address": "N31RqZUYjL4e4VFFR14rtN7DqgrnZwqbC3", + "secret": "2b6c4d56af2d787de889eaad0d97a07f209851a2b6589edf5a1c7a3a4f33e09f", + "public": "0312eccb8c1542b4c5d108538da52ddc5850175df7a7de3b1398155614e792cc7e" }, { - "address": "Ypg3ygxFMGMPGh7Bs1EXnNAmXbuzYBENWj", - "secret": "ed5036ab60ebadc0472938b9afe79afb53c45809c7745b07e5cbc345e82642e6", - "public": "038c7f467d6f99675415eb7c4774b959f019e2ea79ed507c1ba5816067c77b2108" + "address": "9Pkybqiwz1EmDy2b9L9Nkc88mc6zvPRsWT", + "secret": "1c055ba9e77726033ebfe32237bd425a140110549d82e2311d086bb48af1608c", + "public": "035304c818e2c5c93aa671d150ec763a193064d9cd95d8711254a77c8995e3f52f" }, { - "address": "2mR9Rs2EhuvEKAvFtbSHgGA5b6f1C7mAF1E", - "secret": "f066d8d4cc864daa5ffe86fb2340157965035ae59f15537c2c03bb275079f64c", - "public": "02dd0802dc3a77bab154aa6778cd5476a988df806554e41559257fa4ed69f9cfbe" + "address": "BKvj6kmqdx2j35qJdJ5DPAKjJR8vzLU9q9", + "secret": "30130b623de1c08e1cb7ad95a1dd87a3a321f402b9712229e6ce62b7e1efc501", + "public": "026878a7175b2fc3d0ef5a458079eeb1b63d1a63505ac71fa0667239efb3a348da" }, { - "address": "PuhyQBVeNugrEDzy3NP371531ZptugqjH6", - "secret": "9750ea9c6ee9730a91840ccd73a32a91e3abdc77ff5c705a090faecf90d8c80d", - "public": "02a9c39ccd14e30c2da5851dc02c0e4c0c9cd98b3c5ea5dfbca53abea4862c2349" + "address": "RFR4UhmnBPFZb5sg7zyQrr3Jw4So1u7tmv", + "secret": "bb50fcc6980cdcd78fb3e58dd73b9a0adf6fc4539c7e56b8af9f04437f740b10", + "public": "034aac6f55a6ec5e87ace89ae7823b04ef43851316eb3bf85b52a783cb9f97927a" }, { - "address": "1FVuCw95qv3fEwxvBJEoTFcdJ7M5FmDcqM", - "secret": "366b17992b67e687836c8e8bcba9256aac5d06ee2bf3180854262d6ca258729e", - "public": "02ac58db88f793ef4a7fc34caf7baeb36b3fa870a8a13234967e7e764dd8ff512b" + "address": "2W81p8QoSnMKvTdnBqb91J2aucdtjwVNUFo", + "secret": "b3e1914296ef75748cc4cc7772880186b0ea31afea9f36a92836c3d03d66b28b", + "public": "03d9677912768e36ebab0aecb6849c9e09b161e689521bb93e3cfd5687d5eea42b" }, { - "address": "P82tum2W7K8S88xpKgNSr4X33pkr3kdpo5", - "secret": "50ce093b5c4c78a8cbc3101426db3c8345d1405c8633742ee42a1a3a436e989e", - "public": "037c04d52562fa1918a328e86cb1760370513718c87e7a0d18b2a5d69f5fa57d97" + "address": "rLjhyJVYUrqpgimkycfCdPfi77GGTerroe", + "secret": "192af09cc5032ee7dc03652c72ef0936efc1a413eb74c3b98acb50ccac9a97a8", + "public": "032eb1861040be977bd41a7ddfb8230e6d9f0ecc53b43dc6bfe3f873455011ac45" }, { - "address": "uzHkvW9gHRcNojwnP9EoMSMSJkpoa5wmax", - "secret": "f5198ad11bee1520632fbe15ea6b5e9d6359d3ba6d1394d8b62b079208dcd830", - "public": "02df92fd387da42466e021cbfdf4bb03e038575d7d2e75958c189553402ab2d1ac" + "address": "2GahVFLmUyYWycDo9eXvq51ekc32VgxKwRs", + "secret": "536ee03f10031d63eb4c1f4433598dfa587a9edf031c162770eb76ea300b2410", + "public": "02be4a70bcb626976057df5e8a87f2727c6dc6dec80c1a5aa63e14d14a606387ac" }, { - "address": "kBT8dFTXRpCxjRvbMmY9TdAecTquxBp4LD", - "secret": "5126a62910c87b26094ee29fd14b9380f572093c2a059b2aa9149af203241b94", - "public": "02eb49a3a826c9164aa15789f7de2223927fcdb57c954fbd45221debca9c5b46b3" + "address": "23CNqwuhjigvmeGq1MABeYoTceo6PMFndun", + "secret": "89a4c39206bfe84ee531233692ec4d7da526f15e24fe66b06c0f539920620f87", + "public": "028b954910c22532fc7a3af3b5b3b03460209711c048c19d46e756312c06f6bf44" }, { - "address": "D3w3X4s4nrYsXpqH7xwmzmPkUNSitvbNDd", - "secret": "bed4c8ef2c8c929725a3634f00706bd76d82edb884235fef730eb60d138b3997", - "public": "02830d6567f9843755efb2743c9de56b544346e522ba235cdb8c7094cf183dd757" + "address": "2M7tTKyESdcKE66Q4gJpvbDGAxryCM2MfjF", + "secret": "72c021662645cc9b8b2177ad62e0f5211ade182742976a8fbbea55a44c26dba4", + "public": "031bfaf003af08ef951f3ce58096fb09eeb6935b6e3e7e5a230b70c963652f9d40" }, { - "address": "3UFQe9Mc6XESH2qWgDAtp5LURBFZsKezVK", - "secret": "20fe560954e886ec67de69be6d20ea3d7bf65fb5faebf23605f0518ebfb0c40b", - "public": "03a9dc1a57d64c2cec5255ddcee426d2beb3bcb8ac7566d099043f9bab5f40a997" + "address": "2A8vRNeRFyB423goYsfaf2XJfFnwLVBEogG", + "secret": "3f193e4554fd7e6755b017b7db495c2d290351cb65ef3cce34c69e340cfaf177", + "public": "030b4d89c711efc08d9392c4cfa106bc1313c478826453fdcbc115d69866a6d896" }, { - "address": "2F8Rei8XE6vcG5FkErMMBxgH5khbg1u3iyR", - "secret": "d2bc720ac44827682685c83ba0117d96db1cb491cc0d6854a108260644c804bf", - "public": "0365b37c593bda43c7f7ed5a889e16db37336ef6d17428a2a6e7f604ee3b5136c4" + "address": "2QRYen7D9tDdLeJD5bXuKfuYKBbo23o4ABo", + "secret": "69da90dc5871fc04146acf8a1e4121de64e55b97e1629cee8d0bba6b464f6a8d", + "public": "0203ffa8dfeb26dda72992ef3d4126c989651cd6279d4e738110296ab9b90b2515" }, { - "address": "2bDE51WGsQZ1ZCjaUA3PdgePQVkBU8dW4oK", - "secret": "6d55e9ad956dcc6047db6d4de43241179aeaf429d9584a78ba61173758d6d7be", - "public": "02484a0b0c7b8a6118a904c38751e53feb13d6d8d68c69bc9b1fc8b28f0e22e2e1" + "address": "2SkcSFj97J2BQU5hd4QTm5onBeXiwRsVtmd", + "secret": "3d3e5bbba89085b9f3925abf1a892d4e6be4f459e935e05a71ad04ea88fe6ddc", + "public": "03c1cafc2eae3d0f3b109f942234d1fd83489e040373477dba9e27a801b3bd6588" }, { - "address": "2fmeC4F1XVfFrrqq6aVVkfBF4BPAW1s3ASh", - "secret": "14144f15b5a3d4514faf919141f24c47e3755287e3a679484d0930e7ee7e031b", - "public": "021bab73700d0a10cdafcd5def8adfd26e6af5e02e3c55fda148ce3e67f779c97d" + "address": "fA4ByNSX3amgkeVF3ZFQ44gAsDybhD1urU", + "secret": "68a10f706545aa984a8df888700d822793d8ddf9c1999e329ea6a579bbc33175", + "public": "02cd9aaccfabadcc58ae9612cc034054595a8004401c05b314121a4d83fd966339" }, { - "address": "uex69PfTjujj7wj7oq33kBG4kMBjXJ9XXB", - "secret": "f1e5c138e9b9f650d38280a7eceb118106617138ccb0a3457b7ada0179df51cd", - "public": "034aed7eebf9f6b0d5f0636f783442060e163a8201d6ea64e6b70fad0d57dbf30f" + "address": "2m6BdfcCCGxbSXELzBjGNnAMxPoej35TLwt", + "secret": "bafb45146ecd2536e463c08c6b3b18534dff04f03d2a2828c889792b83b2b6b7", + "public": "039ae122d8357f4d6053be5d29a3d9ea72926c6c3fe6b586179fb11808e561c0b9" }, { - "address": "2LicfnLapFqG8TdYJk1XYrFotXb9itgJh18", - "secret": "f3b854e85c2943a1b73abb9fa84e617848e6325dc947929a5b36a1d57fd850c0", - "public": "036a12cfee0ff09ca88876e2059eb72a62d386d0821bd9079b1313138e1f21335c" + "address": "f9hJHRytfpoEa8B4BpNs8gvT1unMjvTFpf", + "secret": "ed643cc27ce09053207c7b8eacb7ab98cff341217f2d398dc80728ba3dbc319a", + "public": "029e91944afc94461da0b314b75f07e1aca7de0af053329bf9eca191f5e9480471" }, { - "address": "Zv1ZveyZHVV1mZfB3L1uwdkMJTik9VffSa", - "secret": "acb6884bc1e7eb7017c434acd8ff8154482e8d20aea2f604c9b1626824000292", - "public": "03bca933a9029bc15c22777e423fd4f5bc6f267810ed87e52e38ca57f0a41a7a5e" + "address": "26F9aPSV1mHR2wmqWtiY2FdXwiZG6GC1WxZ", + "secret": "5207daceea9d884ed6e35ce719fbb356a33d6a2013e1d1159d021da4cbc4ebf1", + "public": "03d41debc510d99b3be9a3fd290ed44cb6edbd4c94fd6e18cef6faacaf8a931e1f" }, { - "address": "7BjGSxFgiKQVpqWf9n65mbywtctJ69rqyr", - "secret": "fbff55b34d0373be194e3e113ffacfc33422e87a72c1947bab3c7a5d3b920680", - "public": "02a0333360ccb58a0d7e1ec32073abf5239ccdda493f53372698318965716e5fc5" + "address": "62mX2aD2aDNfh5zCrrLAyw5bPPoVtsmsaS", + "secret": "c702c01d2a48e072f21d811535ec30edf8d1940957ec61bca0082e3959f6b2fe", + "public": "03b1daa11a074fee7dda44270d842753c49eb916c19066e85bf5bd0608409060aa" }, { - "address": "EkcbxAYNeU6Z8eUTi2UBkmgLcu55mdHmGh", - "secret": "f0bdf9cfccd66d85d872c4590db2d6809e087b5202f45389e90657a87e51913e", - "public": "039e1671eb2280a8831380d7d26a6c1f1c9072e10f152f57b41ce585f9f2e50b9a" + "address": "QroU1WomNFwEpKNooGfSVqJhaPepn82jx7", + "secret": "21e0c30a0af7930ebbab4de7723849b2c712c670d8caa66c7a600c44774b1f30", + "public": "0379bef14165a6c65fc2bd41d11077d25fd4701afffb0e3203422cdc85d0cd2b88" }, { - "address": "jZd8it6WgqbPwwBCXzGXwxjZj8JRqfPvjj", - "secret": "2a55c9ee6f01fc8a5399546bf4a67edb2560edb7af976e900b1a46d98030086b", - "public": "034700377c3890cc4e0063bf383b46bd00b6eeb131ae87622249761fa2d771a761" + "address": "B2qurPj5Vosgdb3vMF9tNSbzvCwQvZT6Vt", + "secret": "67538ed445290e3552443d4b0b5def55ce9e14127055b89ca1a58a21589896e7", + "public": "0374a42e90a4336a0c7147d624f69070ac3ad046a3c2540fac75d874a518f2ef6e" }, { - "address": "2TWbGBYMxWste7HNS1sUP4zbFDj9g1Qod8V", - "secret": "d1acdf4bf54454aee0c0ab274ff3ed139f8edb47fa0ec490a72cbd61c2a6cc53", - "public": "032f9e798ebccff29a3b1fbdf2c842c665cdc3f5dd981ed365726e3a2bf650d258" + "address": "rKR2aYWXsKdPe7TfeLCKpC99zZe9KrTjMK", + "secret": "4249267d631619da0bcbb7296779c2c74df42c3a21e7fb0241e9e45ebdf31bef", + "public": "03d0abd9eeb44e08e9e57f2c750657113eca20b16bf0ad63c46834bf526b9c7067" }, { - "address": "23txDrCRE6PDB1MCBLs3qPcgtwXx2eQxtiV", - "secret": "6be50123bb1b3188f88a78ca19f727fc6321ce9d68d1bd8bb659677b2a1e5195", - "public": "0388c8e32971a6b386abb808f8e5a98ba8bea846814f563384a3b1caca0023271f" + "address": "2fH2mNcRGcwTqUhi6yBhieXGuU45AiR1rSA", + "secret": "c1bbea6cb9ae73181b273c5f5bd7918b4c28d0e3902efe8eefa837a03c8b6f61", + "public": "03289894de48c672ca592a35fd083859bbb1d991d77cfef8d20b0fed1159e80e3b" }, { - "address": "23Reh56nVmMzXLrTWx5QEbyi57Rrh3eBApF", - "secret": "a4371d7ab2f1c162c633d28da151a06486fb42758b90943d1a49b1eede2f5983", - "public": "0237d27e7bbf75a02073153953d77b1d5334d0428d6a686b0dd9753fadf811b223" + "address": "61w9ZrrWmSXprKv87Nt4QRVf7vy6xZxx3S", + "secret": "9473ca381c03ece2f1895ca34c58ebd8ecfd6469e486d8e15baff9badbb8798c", + "public": "03095b664426e488732806e0c08b4b7e5cd49a2653c029eee6931b93cb361130e4" }, { - "address": "2N1v7QCVT89DKouz8EBZMNMW33W6UQXFnDJ", - "secret": "0148b33009a22aeb79a89d6cd953caf5d193ff565b925893264d40a6b49a7c63", - "public": "02bfc450110d89785f01a37b8ba83c43e81779247cf85c041224a279eefe5fdf82" + "address": "EiRhqw7RKPTSwmkEUzmWTB9anAfxB2u3HT", + "secret": "847acc35d8932f3f0d2e9fbc57557b949be580e93a7228a4e6b8fb154f448208", + "public": "033f3d37b184bac7eccb3fbe9bb6f3fc1416f7234b8670b67b65f8948e8f8fec16" }, { - "address": "rssziBGdwmk8juBBEUtqqewRFhNzexhQ7C", - "secret": "c61aa914873577b093b8671364ae882efcdd43baa7abb9d72814036a42da95cc", - "public": "02f82e72e9f29b9d3d7c857196dcb668046b17c9e2965de88c9e538a90ca9fc8ec" + "address": "2SNQebSnRZUyMKRyEZyemuRZWPiiN4iSUSu", + "secret": "b065935a2dc91950e4381a88907ea5bcb081eb9115e88e573c8ee73baa3bdce2", + "public": "030d9f84a7af08f7d8b104113e72e1bf56efa5cf8f9bec50356f442ac71fbcf767" }, { - "address": "kvbtjZWvad5MWZ4Exc53v9G74E3yX5NXks", - "secret": "3669c8db48e9aff4aba573131290e2b8d5157e06fa247fd14b22c87d29629811", - "public": "03e5261487a2bc7f5ac4d8f9656e46ca126f5babd97694a6983758cc15857e3c9c" + "address": "FuBAryyosutbMmanUFRzJyqwXkwh7kdGEU", + "secret": "0ff066fed0235320963798399f2a8def41aa9700d2f84205f6caa63422ba6dcf", + "public": "0333e807c0be00d228199cb50869176b8d3021e58faf2f3e0403a09bd010216f28" }, { - "address": "2CAwDtDfYR9UrWmAhecfCjoXMgA7isoQ841", - "secret": "0f5c9180707a9bbd78a0ba64a60787eb76b8bc06305e876298b9e53ed6e1869c", - "public": "02957eaa7fb8c7356127d10b1a41e0088894d1c436d46796addb33de769fb28218" + "address": "ovUyGnQCsAFCY4CzfNGPfpBNe4L1yXoPS7", + "secret": "cab4652334411dc9504f420b936d5ac85a6a50c4bc5245cec04e08898ae6a236", + "public": "030ef30e7219e020b9f9e77240fed42739b5b47063373b8e5fa2a4cd19cab80d9c" }, { - "address": "Ja4Yf26Ku1KHJJEZVbAx1dsD1gB5UKPhJQ", - "secret": "79b2cf6c0ac8ac1f92c9a09a9acb94e53ab88452f772187ad4585c6ec646f121", - "public": "03842c2b37483f17c904684e622e531b2bea8543962a1462c33b3965f580923ea2" + "address": "z8EFc9WUA6Z4PnWDHC1rcby6mMxR6yq8uj", + "secret": "396b40376a1f66fe79b8050d8c2b7fd72c5442429cea1de9c3e9b7b10b93c36c", + "public": "032194941eefbd5480556832f47fc9495f2dd4daee52153fe4bca687f13e102c54" }, { - "address": "hT5qhdj8JsEEmoKtVSEhFn1cD5c7HJhT7C", - "secret": "b24cc029bc5194d75bb3ea8a4f0d4dc8547ea3a635b75412e1c51d1c031d7e07", - "public": "035dabaa2d52d5cfb9a9e4da8435798d467c7e0553a6f0ea492bffbce9ccc5a1cf" + "address": "2cgrysvL5TgPD3Zo1bQ7atHePjU7pBbi5HM", + "secret": "66dd774702819987b97c150b2baef6ca69d7fa77b474ae6b827b434a4a22190e", + "public": "02e84cfcfbaae65066fc96271c87c2a74f6af8870cd5f90b19003abb2695bceef0" }, { - "address": "H7uD31vYomiByzi53ixQe9FCMR2BT93NQD", - "secret": "ed5705dfbe969d012227d9e4d7328ec8fd4bd2b18c212b06349d50a430f708dd", - "public": "025d70d461f681385d04d17ff2132dc333b7c133e1ca45afbe4236a5281d5c0aee" + "address": "CBC3XTB4jQeeQiw1K25MBVy665AmN7ndcS", + "secret": "dec7e76355a27ffaaf7d706091b3321a877bff8acd255fda5a34a21819b413c0", + "public": "02c7e48a9e20852a8e25ea0670ac9a320c682d4a2f1602c1ff4b00e00bde283e91" }, { - "address": "H6WRooKtGkG5NVzxeNAZw9HvfYqbfUu5TS", - "secret": "7e8aad1021f4b3a18c0a3a163714ef1eec457de9785b62a59c8d34541efb463a", - "public": "038f813422869a88920abed8550ba004e2c662c2bf3b2c4e7dafa4bbd04e0176e3" + "address": "x8Amv5taKJPoBogmVgNJjtyddz21hYeGzY", + "secret": "a11279a7533f382fe1c4797a35ca4c8e62577de9d32be5002037abb63c917937", + "public": "037d4322a6cedd200aeb6403700b5f723b8a4aea1f922527657572ae7da751dc8f" }, { - "address": "pf7F9pnXPnE22wZjcrS9HfKu8XcQb8FF9t", - "secret": "6e6375587af8f6478ddd864074782b5511078e2d3995efa0d0a685897daffd1e", - "public": "03140ce19a14c0f2eb24172e660999debe285ae2e9bb03b35893af59c6b2305dff" + "address": "2f5JG9tVG1eJsCV6MiSAXXn9z2qLu1WwPBZ", + "secret": "63cb1ce295c72df8d9a5cdf619aaab3f6531a6f8f428fb61676f319f6443b1ba", + "public": "028e3738fa11f56333e6c6319de2acc192d998767100b079dec938c66c33447d10" }, { - "address": "pWnmcuLpd3RDGE7F6ocwb331k5ttYYa2Vn", - "secret": "436261fa28766ea586a3fff616ec4fd4546c23da7c09698b897f5008d9cc33a6", - "public": "021d9e351c4bae41bb8b307c3d876739fb5db6d156af6efb5b966b37f42f41b452" + "address": "2YnwtL7Eax6ALym5ZhtbZc5mVi69SAQa7qW", + "secret": "fabc193d52d4bf936067eadd28c936e7c4bbf5b65bdf904e00cc80e7aad8aec4", + "public": "037e8be0c5076b7b7d9aafcbbeb1deaa872bde340171362dca6a32595c08a71501" }, { - "address": "LoTsNAfYkKS4C1Pz5oJ1ncfj9piADHEzXQ", - "secret": "cc87f9795ecd6cb31004635a46cc6f0f40514ef8f0a27a65177c7e7c6f83df2a", - "public": "024018f113a979859a19c895d70e650bb6f07fc587e43959688d22cfd33dfce05c" + "address": "n8VxbBynsNFRjMpjx2PoyCsqCobNd3tTGy", + "secret": "d3b704c0fa85c62df383ef4c5d691920cb56f8a2eb0c676662349f592b2fda35", + "public": "0223c0bdc26f80f6b8689286475a1f6a1462b3f763368c8926681dc212e8a49d37" }, { - "address": "2FuufDKYiWrbLBvjoCwSLm4GNRsiWAVCRSe", - "secret": "ba5999cf3d0209bd4ac6ea0365d094f0dea4787eeaa8bd7d0c5b936607e7efa0", - "public": "02479dd8cb397a78af8d017c75525544aab7ac40fa8e86ce0f2e0654cdb6681f78" + "address": "2GcfeP65kgZJsQxgjTnAbUDNXUX5pMS6qwA", + "secret": "3084c64edd34f827750497f7ae3c432484bc86ec1ee03c236c83c10c2189100f", + "public": "02cd4aed33c68c2380060d807b2eae38c8460bcb494a68882b3560e5e917808150" }, { - "address": "77q35wRWsZjemF2RAiCshixKFkRm6UV7fU", - "secret": "b3442950b018802c026750f830204998b5ab33aa6640263ea01bd9dcb7f3e0be", - "public": "037a6de75049d9d9f938c92492aeb66be7042d491329b65804cd9d0da120453725" + "address": "SC23LSoVTHMLfdsy1dZA4ysYzLWYwLe3VW", + "secret": "04c3536aec2531dbab08bd614adfd9839150b82b8f15cb7a7228b04171cf9310", + "public": "0357e08cbc0fae044ee6109394bb70675c05effee3d0bc76c95cd1f3814498dcb2" }, { - "address": "2GNwcsPtRbZn9nfDPaW6sUNcXiAf38KjueS", - "secret": "a0593ba3f80e4f0314d411f10f5f6dca5c15ab965d2b71ad25f657e4ebd9518f", - "public": "024767c17c48f5d33ba5119e9eff52d6fe73e01f785b3d287c8455821aaf56e92f" + "address": "2mBQma7LZa74M3WFJCws6dwZKn3YQBMg6rA", + "secret": "aa5e825ace5471708b05f3f50929c180f85e8cc19db9975bc02934a3e0469cd2", + "public": "03474646c2920067a9fe223c1ba7411afe48327370afa1298fdf08b8077d9ee19e" }, { - "address": "26HzFUQgSM9cTERcQaHBSJd7dCePZLuxVem", - "secret": "9d32a596e73a7581129589bdafc7a8c19ca0ba930250537d046e2d77729f2ee4", - "public": "034d0cf3e9b870087124734bdc3ca24931363c33a6f18e7ba012b91a0de0f139fa" + "address": "2FxdQDCLe7c1mhtKGJEnj5sTmcyoEuQwit4", + "secret": "5732ba0920c7688da18a7d2313c982cb4f05de6c8f8cd953b57883c64d19d01f", + "public": "020bd054f35df3619681e88b8f5b1e02d16e92136067ea29d0e944065bc17febe8" }, { - "address": "njcQr267E48GHt3BZ82YpDRayNJCgktkky", - "secret": "2ed81c483236f463a6cf86e3f3be7f6efe0b184ccad8a66065cba55ade46800a", - "public": "022b9b8250f8ee8c16f15eb5836d86ff0edf0e089db630300d2cebae668611478b" + "address": "opjMWDaZnfGytaigCzDS1WZcMRCZQEvDSh", + "secret": "960c1024d6b803bb61d729f56edaca88bebd8dd25d611cd90f8c1553d72cc23f", + "public": "02c6ca3390d4ca5b9f9d8ffa81f217438b371505f7943f1b821ccaf267502896c7" }, { - "address": "fXFs1kqeEx5ptGghkPz2jzzfrn6XnkYBA4", - "secret": "90f45b38407bbd13650a9992e48cc0142f998b0acfb439e2c5b153bf29790b1b", - "public": "02af1077d4d97f1abf77c3c278de63df8a1d0d46f42fca1dcb975f34bc3f0debb4" + "address": "287avDBot4sKcLa6uVHX6CEActGrW5z9W8J", + "secret": "0b7f4c468e9b57a69e7af6887e055ff0bc9b6c0dbd236c738b8d83e515eba25d", + "public": "0297142932f8df1b0e6def85fad14db4f5e99cc34a2bdaf9e1d4d94d5d43ff09b6" }, { - "address": "9sbdFWiUAC3G3zTJtLvDKyBgCCHiqPprc9", - "secret": "836cd03d1adcf241d3053d0c5ae7fb384ed9ef4c384bc8d225405a2874281408", - "public": "03828f052631c9c393686633e7b6bf6affd4ac6cca98264fab139251d4bc0c8cb0" + "address": "VDkbYkMPHKbXHs3hLyh4XC5ohQVUeyhw91", + "secret": "92e524d5eaeea948e6d5562488d971f0e4dc45d2a5f94dd4af7191bb91b93fb6", + "public": "02a5d4694d6485b3b9bc18e875d04773fd35eb4bd68cfa10bcc6e9348b5c845965" }, { - "address": "w9sUCDLCiXfxzvsgg832gSRDKSigBL5wM2", - "secret": "b6bb1b8365d950b6b2096b42597b4b7d112ebc1d899c743f53526a368a60ff74", - "public": "039422fbe50c869d75894d1912fa8179e6057dcfa6176c3a3019bafbcad1d56921" + "address": "mAtUfYshMbtEJzjuKYcU2t6T3dZe4y2khb", + "secret": "c553186bcc8b7b6da5dcff3f522153b6a5af4df9e358f028e3fab1b02d7a7dd9", + "public": "039a29f469d54ff46f32bc5f246aa5c3714480304984e3232b723838c4d06dad0a" }, { - "address": "2U6gYSCXkDX5juK7PJm6fAn1zmhdeukRB7D", - "secret": "fe5f5822c0c85e26a07c029c2b5d9b57f14e2d0b08b2bcf157fdd156bce29e28", - "public": "03394d05c2444769740f80f1e3d5231c906225d1667512fececda259a51f498d27" + "address": "2NAdsgf4ZJJt5mFNw8at8hCR5RMQDNzwiwJ", + "secret": "652f9b2e81b4882b0a3ed0acad1870f906c47b741f3264e9437578270a77fd6f", + "public": "0224d49247228129e7e7ac57aa56be2d2a318dc57841975d5d11400ec226101326" }, { - "address": "cAYmbpBWAPAfUPhTYaKuM2zM85adPRi9uM", - "secret": "3a923bca740756d44dd4f54a81b040317d08af95189dbc6274f51bac4a4b968d", - "public": "0365085348d12b43d62f344e033d8d7523720a3acd57bccbe1c584fdb24267067b" + "address": "vcGe4piafnmA7HooScfnaPoMeAUzkGV2es", + "secret": "3d36f0ff8d896a4e29ee908c90269ef4da1950f5d43d709d46ebef82b42ec902", + "public": "0232b6196f9a91a97bcef66cefd06ced834b6e57962915762b7f3d93347eb7512a" }, { - "address": "3uotTQcvLKJY4RHS3wzVoKqP2J5Rr8LQZi", - "secret": "9127fd2dd60da20401b0241caec3bd099c50535c4fec4183b74d4bbff4091bc0", - "public": "03ff37e678d75d4bc79b64b91b11a8caff348c6e9bd3070c1f9b971f2535aea232" + "address": "TU2RS7a9ZDUuj1X7fTBXhqo9jJpa5wRGEh", + "secret": "3404371d8a927f2b948ad1050a085d8c152051e6ee97aedb77c44ed3f6c0a86b", + "public": "029b1d98a32c56d68abb0c7b74f5508b4b0cbb23ffe2d6c53e7859c8fc047ac16f" }, { - "address": "GgPu7jacFuCkG5kVw5BzsvPTZ1fQ33GtWJ", - "secret": "c0291dd3f4d6c2db33a9165f95dc9a37b7246ae683a94ca831680d31aa33641a", - "public": "0265d5f2a7c6ff249d2f28a432c151038efee8218efa60d9e903f14b1b02b396b4" + "address": "2d7H8CquSYs2nin9jaZ13hGZta5FsStFZo8", + "secret": "5039e52f7321bfa5b97ea5b6bc585df9e54d5e5d1a27758135cc842b65898882", + "public": "03e9ea87ac0e016f2fe8b789bbfa4a941c3cfcfdbadae82c4c5fdb13b5ba7389f7" }, { - "address": "mijeLgg3fyEGbSAeThbswsB8i2Ck8cCxGT", - "secret": "1695f852f76b1843a4f67707134bfb094b0c703d3cd006989d25e4b5da2702da", - "public": "0220439f8a4919b1be290db7f7d7a8b2b6d802038bfce7997a76b13143bf3f10f4" + "address": "AvV5YY5QUnFLLSJMKhu9DsuxxrZt5wpvdQ", + "secret": "a75da19d2e65a262e1a3560376e2d292a741f3a4b679fc3b86a6f342c41f7595", + "public": "03388b89a69105f3fbad86cff7edbbda8c7a6b65f670bd1ea65c1bd29ab8927794" }, { - "address": "jbeUZjsxFtxToxvu64VBdJifpcT7qTE5z5", - "secret": "9585cf9697ead1b6ff4b7e92cb64ecb1583010e3bf9884e5e6ac59058e1c1ff8", - "public": "02ec5e8d8a82cadce5dc0828f3632e89cf1577cf9097baf3eee7dd4c7237fe8aff" + "address": "ZnvGRWPCyM8BVpFWNMwAuNJu3W9Qu4EcjM", + "secret": "b36e756f2985b372c860d9c8ee82d701446a99df55369a09d9245cebffb7f6fc", + "public": "03211ffaccb7fc6be9ec8dfca941bd18a24834ce783071324e7797167966c169dd" }, { - "address": "obqA6AKgKQA2dohdzRDuG6a6vaZKnxZs61", - "secret": "495d697e4c8b2491d5b45d55298614e4664687d3c0919350b10e83bbe497589d", - "public": "02524d2b7dd645ff5644bec2cafa0cd40dff680ccded1e3a57886c5bba4538424e" + "address": "qoVWHHmz3cst7ejrDs5Ak1veNqXvc6bKNs", + "secret": "6d9ba763e4b5ece32546a46271be8024627663f8a05eb90cf7ff10aad43bb0b4", + "public": "03ae2573c7cac526eed1b7ea204d98b57b905ccfa565317562903238d9047318b6" }, { - "address": "djC8u6SX9uiBW5gtide2rpvyMYsZQaxfD3", - "secret": "31c185b9248310aacd9589e458e6718e3b67c12741de232f5e54cf0089289668", - "public": "031039f35de9d5b818bc83e6e5306e1a2fbf873083762cc37d62020e0e37134fc8" + "address": "27WSr8SckJGeSd9wZeuWmEXhkwZagupQBhQ", + "secret": "0eed689ddc8783a2d7405b3c7b727f5e283adf51a79c00633e06f4d7af69ea71", + "public": "03e01b17ede565155704d1d38b169772189c572f3d8daf7217bf10cfdec744f00e" }, { - "address": "acEZHe9DNL9X9NsitJ1cwWL7v3LNhFHSit", - "secret": "213d122034161c7711f002e984f197eb3d73315a670c4b9737c7ce58a18b27e0", - "public": "036eecaa97c31374fed0284c0e9edcb4d507bc40b3561f1f147ca63b260fd9d599" + "address": "jfHgeppkfWrLrfLDefT1ubVcX8CZtEHrxd", + "secret": "ac6093af30358cd772157c99144ca77b8b51374d4d42d16ff4c044a79f659d1b", + "public": "0244bb127e905e68ac4f77a02d36f8bd43a180fdfda205c5dde80c216027fe5d3d" }, { - "address": "2346A3Kgnp5ef9uFR6beqqs4jA32s2qFD5f", - "secret": "0eb087374ea7ddef64016f51d61319636518755d7c4a78daac65f90e1524060c", - "public": "025c26f8aeaca9e01a7a90dbf93a8575275438b26f68307a7effa58e3aea3ece85" + "address": "7kUKMbna5G2BnYdRaUNguDcRxZqU4DJE5Y", + "secret": "aeb2ba2cd9a26758c46ff42fdd59fa2e109a57a2a7e0b6a71cd929cfb7d3c734", + "public": "02020ceac637c2e0a627a5b495991925432b2f38b278a39972c6ae3e77b5cf72dd" }, { - "address": "BAuWH23AGFEbtMxpJ2gEzf2JZBzE7XAPwe", - "secret": "c17a482128d6913e53cab08123a00784003f13da0d383eaa3190c340ed87b35b", - "public": "02061df5ac721bbb04b361024ff1d187bffc3847fbcbef00d81a9da21bd8196db9" + "address": "uXumjBr72CzvyStXFAcQZ7KyHazCGC7bYF", + "secret": "3e1745a1032a59a4f381389fb0371169a87286a29f9d7697d095b5d65cca2457", + "public": "02da2344d15c5d43d19b9f350b1c725c636004934f087b67b240fb44d674344af7" }, { - "address": "28YgcfitzycymG2nkNBDN28Aqrs6caNYE7p", - "secret": "545ca7b9ee4f24f1fc948cd9eb07a1b9ae8f66e2e92321fdd18b190bbbaf432f", - "public": "0282331b51a3dd2ba70325290391685664823d907eb9f76d79c630b9d4162442fb" + "address": "2cjZgqBybtHQNio2h1hmb8W1VuNHZ9CiJMo", + "secret": "866bb52ec8c6e51e52120b64bc42277b0123c5d200ea17d20cf365eb0f343087", + "public": "039391283693aa699e839a7ac00962bc23dbb563882d1b5db5774418a5d16093d4" }, { - "address": "2eZHDEmDxKLqAaeZZZn49DFWktLzjpF2Bkz", - "secret": "e3a483ee018191c6cbaeefb247fcd8ef597c3199fcbfc7cf62dcf44bee16ae7c", - "public": "02341d74c90d947d161449b9f985c1272ce8d4904e95023fa22189466da5841b4f" + "address": "2KuhVZmuxygrtPKYXygnzWmrJxyth7aHmHo", + "secret": "114e79415b9b6162578bd08983fde25c8708fbc204669e32d244761adf81be6d", + "public": "034f94c72ad911244a5dae6a7d2cafd9e1e88edf87d244fb8478ebfcc607c8b5c0" }, { - "address": "23QQPVsMKbJj9YYLY53kpRxEZQwGmEa2Ww4", - "secret": "dc7bf8e954f7fd01eca6174e95874d8b92049aaa8f3d3b4d653bcf75c86f86c9", - "public": "03a51c6614e0b9f675609ae56b082ebc3ead9986114f3af0ff02c9d2d529f370b0" + "address": "9f51KEwdZ2k6fbJKw2No5QcEZfh1FcQT99", + "secret": "e36c8f6818e4f3a759b1f1c22339cb7a1a560bee4b590270ecde2789990280a1", + "public": "02dec657da3437d526c7bec71d91cbe3ebb9993e7cbb69b5844fe8d02c035a29dc" }, { - "address": "VJ7XfDxoryUyT5DhiJiMQuqGpphu1W34nm", - "secret": "527522685755323bcb145be4451d8fb4b0f36381e021b27908862649c231b004", - "public": "0287ce545346c0715946597ff90365542233df89ee5fb4f47d182bbf40824f20c6" + "address": "CUFdMUnVtSmLtXAC5ktYSSywEaQ9uxUivn", + "secret": "f8c15fcb6c56e3d1a5f13b02f3d6f3d751c9f113ec3837ac9ca49986e5c79938", + "public": "032e56e60227fdc1c4e7100e1a5bb8853c102efd072f7e3d3b255d98da7645e7ff" }, { - "address": "27szR4bg3WfKoz6NH5XTyUYrrL6PneuNved", - "secret": "367e4d9e1997b7ed7590690e55b855f40da9d08fb5ca271a2ddcf108d766fd36", - "public": "034d08ad377e9716fd8d786092b7c9d2d924e10730ffb8820820c975d69fc493a4" + "address": "2QVfVHQ7c81vSHQjXwjfueUxmycPXeSoh8p", + "secret": "dd71cbe703a2aafbd6e4e9e33d5dd9845d432ca8c16dd0076330cd2aad1ea18a", + "public": "029f3682ffb06648d5ccae4e579920840a162e884cf18ea1c76f7861038d41c715" }, { - "address": "EhgmjLxtZd5EMHcS9UBjvU3WXh7ksWURwJ", - "secret": "280c944e87a339aa729c95b779d3ff137534228985684e98f73fd3b274630d24", - "public": "02cffa21d4cd173d5bcfb0947faa2c73c3b01814f1226467ef53a674e77238595f" + "address": "2aT8vQA3MncGyw2XfhqisJUuTeL8gt67r7N", + "secret": "6f4002a5258fd36acfca3ffca8f46148788346ba97e290ce1580e3f0e40a67ed", + "public": "039ca89216842186b5d4c3d8824d9a62aa7e6a7258c51fbbde2b7582c6ab3cfd61" }, { - "address": "NURd6kXsfaNSYoNbCGUzcGjDKmZCXEFrmq", - "secret": "0090a11f795a00740d58e9238c9bfcf14efab4821a8580e055e94c10a9d5f092", - "public": "025ef245e82b2a0195e3162d7b7c385cc8fdc6714426fddc9a619f7f1b428a47a9" + "address": "2LjJYUvxEeiuSHdmqa6WriCcrVMUgbYsC4g", + "secret": "9d5b1907abaf169e86622e520f46530b15016a3c56e6473980783eb9e7e3bb1f", + "public": "03d47c7a4ba64efd5ceec1d90370dcb79c4a5792334f2a8fb3f816ab3de0aba6f3" }, { - "address": "8LBjEujMbYyVkZjxboBXDmsthw7ESreTjP", - "secret": "9bc84c2ba99d6cb3eb052f3543306747c228e081b2bf24dec8f20604df67b57d", - "public": "02822955d0d41710ca5790a4010b0f1f4a09158bc43f2fe08421e42d18d993f753" + "address": "H8WyRMJiyuttgg7raK3MHvuaP1sYYVt2GR", + "secret": "d8d258e9d6ac67a32b2bbdb2fe56c753a3d4b2c45370c2081f539c87119db3e8", + "public": "0237505507f545ffb6e5762d3ee5ba7b2dbe03e1cb0b73454538331009dbb06474" }, { - "address": "ZKHzevB1jtnqMQJVKx7rebnCv3MBakFfgr", - "secret": "bcca3111d8f0657b6590d5f6238b963bb17f26cace15d31f64e2fe58b79c91ae", - "public": "02f1154728f687a7e345c633e61b3f78f45ddfe9c1bd87ae83dc19a50375ff4d6c" + "address": "RnvXdAurMy5aeEpGKfanQsphVYXtvPvyws", + "secret": "b3767d3cb4903870b7c40b50d235366e58fb24c7a2e5ac1607ced94126d308e8", + "public": "02cf83f66d10e315d6d84644682cd792e45cbad330704c7fc8951176c301ce6a09" }, { - "address": "2HpwZn5YRyrZs2fTPHcko1sC7Akt8cubLKV", - "secret": "0d0f42758773a67031eb147bad43f2735b4b72e411fea513791a5ed98ff75b3c", - "public": "03975a556327aa397e56e72b54e5431fc2136dff3ad50874bb9fe39652f41471b8" + "address": "2EGguQkd9xNM6rz43bQpPH5SUBbyPCypu2Y", + "secret": "544b281008d4de4530b39b3cbfa257b8d6c7df865fadb0f3ff875f0a024f16ad", + "public": "03b2d7195dabc09a3ed2ac92d44436ad57e5150d02be25db571fa2a9db513c72ed" }, { - "address": "24p2aWzQjimJxPN9ehjDpohSz5WTbKzGNv8", - "secret": "fcd0a0c2e70f42e8910fb6da1ad0af8f708b2863b1b4d3c9355138def177f2ff", - "public": "032c7a43b07f395a1c7d9a870754d2e8151aa013beb670a626d2fcef32afa81930" + "address": "2Zo7LMedeibm88xHbD6BihxYF9VbxueAsww", + "secret": "10cb3fc3bfe1039921b82dd2be1a036ae7d989ac5f1308441e7cb27bfa999706", + "public": "02b69743fab8f7ef1c5572ed9efded6802054e8668c8372a718a1ed231f376e9eb" }, { - "address": "2QeJcMBXkMMGYTvEAi9PjKBGFGZcPthc28a", - "secret": "20e4eeea233ad5ea91229371a374c2c4d169e35d64d570d2f9f3f58f68ce3135", - "public": "031e12a6f2a279c551a5f74427cde04bf282637130cb8f5e69a2beabda772ac25f" + "address": "Er7xL49Yz8yTdxTHZ2aWF899fZwuBcN2w9", + "secret": "ee2dd1b1a27c83e12f78fd0eacb66c0b9ee63f71f49f62f2163cacaf24c96724", + "public": "037c596ce52db6b28e1a9080c0e8d0914768e7f7cb4c1b56ae01437602d91c14bf" }, { - "address": "26m8PBWzYbanLVGjsitVbxbVZcPSUoAYZtW", - "secret": "7e133ff2aa02fae4c34620c110aa305fc540723bf0cd6e7533f22982315b7d6b", - "public": "02daaf606496f6ce2778ec5a754806812e9fed6a86405b73f547549fea10c33afe" + "address": "Ssu5YEgifibQKpoPKNZmwPVAKEt6gdqXrS", + "secret": "94c8c227b8cef1971f0c88b79742da648da391682eaaaf72639bfc516024ce14", + "public": "03e6aa8cd03076584a0664a1d61609e20ea12e900eba179c7c0f1c935ae90faf52" }, { - "address": "G56yXcBxR3J8TS7yGb8LpxhMBZYsaa4pKn", - "secret": "4d94f34dd7fb68e5eeedd744e3bb53b30b9a822b3fe03b0cdf09c379cfd1db44", - "public": "03f9140cba4667f6743cbf5d47a2c6ac8a426202cf414873c6e2a6c296c6dc5b9c" + "address": "6ZEir4GMrZ9dCu3LjF1txAyKxmHP1Z6B64", + "secret": "567c951ab4d83106e0ec0dfcabf84d9d4f553e828a8bf29ba3ebe2c3f2f6a6df", + "public": "026eb292c89a292a5386cf84cc0150b9d246b80e7993b15bdb63ac6ad84ff3ebcb" }, { - "address": "2fZEPPfd3fyoPdHLLz1pu6JGZUgRcbCyXyC", - "secret": "fd9a07fc5c6753e639ca3736674fd500ed583a9c4a6b5af8e2da59d071be471a", - "public": "0208b66afedd9d8d7511fbbd55a632d799764e61d2393c2339c9707aa1880f0a9d" + "address": "uF1CcstJsQwissNWqN6HUzbedUVHeWN919", + "secret": "3063086d76d5cb9e8a6b5fb1cfe9cb962dec10b02f84b52823ef66a29031b883", + "public": "0374369d1129cb7e0ee36c245f1de5cdce492addf44a3121fadc088aeea218b41c" }, { - "address": "2mHCiVmVtrEmooHPX12n7NUPGd8zi1d2PGu", - "secret": "70b4923570988cf421355cafd89be975a494ee7cb4ecb48616f5ecc6a5736b04", - "public": "033568f6c0b0ddba018548d721b92bc9509a1535066d0db6b06b4b11fac79d02d0" + "address": "LumhVq7XrSSzaV6EcGFcNJa2PRhUw4EvRS", + "secret": "b8e85174ad383c1b31cf412e36a8dfc5c7a70be075bb6dbb3f1265c8d45a1716", + "public": "033e763b16e8be84bf728c03a8a842de3e9b668db298e1d7a9a42fcbac397a87b9" }, { - "address": "eFi5dc5zx9nUgk4LN5rU8GGVFMH6nD7WcK", - "secret": "8d9e921acc1a06a7f25ec4477a09a021f118036ce04f2ec08c92a063dbe4ad12", - "public": "02891fc1278806932056b3b3394b4049ca6035bcc395864f210246551e0cd6ad63" + "address": "928Epy9MYb3aXiSX3jViUK2quJUHddzm24", + "secret": "3b6bf331929bba2a60117ede5aa6e82be42dcb59fec6dfc8b7d56da04229ac15", + "public": "0247c4215f2b6d5b7e9741b229653aebcb9fd407023ce710dfa8a0dcbd6f2061b8" }, { - "address": "sfSv2sAh8Pi9KDdFWNhSxwaYdtzwthRw2G", - "secret": "c700f46e594e61ccb87ba2a3626b5ac1568c91ef6c29edfc93847b1689ced34a", - "public": "02d8ec91fb6b516c507ff7e062beeb16660151327f34c6517f0949ecde88e2c2dc" + "address": "x6fedkRZ2f3uAFWYuAhMHbwvezuW4YakrZ", + "secret": "be633fc2e4797327d173ff4129d17b7f00164cdf4e6bcda36575ed50e733f6be", + "public": "03b73a0b399d47ce4790adee1f5b7cab3beaf7d127ce8137d93fd8dd0589e69fb3" }, { - "address": "2hsGE9jfP3gVTHmZzJKfoCr9bM1vQknAS4a", - "secret": "f6c929f1777b90a879f723699923a3a1ab0bee5a150e400351cb5972088da2fb", - "public": "0288086272dbbf447e7dabb9473f7f7963fcee8da73f3d901a6f02cbb57bd208f0" + "address": "jzij8bbtnsQMJox9mVxE9Wbt2cZji1av1Q", + "secret": "6c5f2687c2a14db0bdd44e293294da17b6c48cf1a245dec3a724a503ac7d2d20", + "public": "03ea4ff6cc2f3bc601adfad608e0558418bf0982b803bd6c61fab1d5f7082504bb" }, { - "address": "2eP4TZAJivV1v5NvzC6AGmi6FieWsustsAn", - "secret": "e1b837bb7a4912d7b8453fdac9a7bbfb5a1d165469fb51e1642885732111298f", - "public": "03715f1733aabe3de17eb56d25ae1e57ba45a597fe22bdc4c24cb22152a27465d3" + "address": "24JypXuBsutTE9Au31byi6cgYUVfXDa76Yx", + "secret": "caa801e43715a4080604ab1962a74b6985481a4c42377f5c210b969bae817522", + "public": "02fd5562bea861fec333eddd21a49611e9efaab8e593b7f8898614982e414fa537" }, { - "address": "AdNHtQqfsZrqqkUuxzE3d7dYeLaknCPUHX", - "secret": "b9483b6796beb1c59461c742981a79753f948f3757b0a18d434e08fedc8e87a3", - "public": "03ba6e3da914962874f1ec3711b7438c77f531e1a5843cfb5502e30b6705febc8a" + "address": "sq1oxMdWKu9y1GqYDQzydUsLsnCaSsgFdV", + "secret": "115a9ee9d3a969c4c6777347e3047af13158f6b2feb2f96a207fc2bbbe6b989c", + "public": "0357723a1e36cfc4ca932d05aef4ff571a74dd01d72bb21df6a1df2b6dd6634c06" }, { - "address": "2gfu4Dxc6923muYdJgkkhrjVcAsVTJBHzT3", - "secret": "7416605b4d123789739080e8a6ddbe3e6c14d6e1e2846230e433f028bcb053f1", - "public": "027141240feedd318511e9cc30eb9fd15076059410d9c13ef2e87ed7ec1d7fd9c9" + "address": "XF3MJCJf34rbZ71QSmTWzsc2K1EW5zp11L", + "secret": "a15da09058bb45eee32fd2ea2421f1cd9910e1f822355aada7abaf98ac09820d", + "public": "0296785ce0760c05db6e9f81d1650d5dd71a70fe9881039592e91f3ae1f905cf37" }, { - "address": "2HJnKau33Kw2ebTkgXqMmPMB4zNz7wjrtGb", - "secret": "376bc56356e2e2ba56cbef0a626151bddcbaa36328d68a95c5b589abfd8716f2", - "public": "021e1b6169a0e59e3fa295c76d0e3afcc28cbbdd1b2df9fc7de372c2f08fa870d5" + "address": "2MuLPu4CtC8rCaGvVXdaFsvZCGEBSFquKyT", + "secret": "c2d06a485140ef111c0df041d019cf7f5f6f2a57a88f98b4818bcd3471fefbf8", + "public": "02d037fa293b9c13d7332fb57873a5c9ef6fd3faec48e2192073e4cecafa383c7f" }, { - "address": "2i8fvMSiFBysndqqh1JJ3BdeAUdHQZx2Ukd", - "secret": "f925a8f4ca2f83bbe5f595758abfbbd5ec6234139b4c41b214c44a1b65cc50ce", - "public": "02202a505d34c1c0be644037c23dcc642633bbe069f7d99036c5ca5f518625c7fb" + "address": "2AjTTLFwqFBTv9B4TqEttxgGxd6qdb6Rc95", + "secret": "00755ec32e300f700b65e584e00d642a7f94b68bac09fa56d9dd52f68367d06c", + "public": "021767b3cb8da064c221e18e5da4aba858c0783253b807cb0e7d3034e2a6971a40" }, { - "address": "23LTDD5CxB5tw2cnG7MrusftCwwGXUWJXwG", - "secret": "b3d1720fae42e943f7e4e965f3afb3f7c7e9c27a2cf42164d653fbb0ba921e4f", - "public": "029c8265f5512e099c272b0e5ad1bec38dcbb6537248c1cce55c4a9f4b6043e969" + "address": "YVao3N44KWz1gWwFA99SzE4eEWuiNDQa6", + "secret": "5d419baf49e43360a2db92ff445473ae5369a3854274088447f3b8aaa730e4a1", + "public": "02671cc9348c2b37412f7be7f44cfaf887878faa61ba2977d76a341121ec8543f5" }, { - "address": "2EU37xLZsZaJ65YHRTcfB7PXmisHbx1WdEj", - "secret": "db5825e00f5dd3633e29def21acfb4cd068e9a4388a32c1297860c235e379063", - "public": "021e3b1546211b37148df7e0eca0eaaf59e5de46db228953c36b1bca22baf2aeba" + "address": "2B6CQHAyf7hXBdujhdth8m3iXeGKoj1cUy5", + "secret": "5ce953dbca541c64186c6cd9be8ea528b4b2e46ca018da86c568eff924bc2950", + "public": "0346f13ae7df82aeacc3f1a0264b7e1d710f09e8464acd68989bd4009d8df44912" }, { - "address": "2SUeDrR2DTD6dyjGatVviu52My2PRM4T4GF", - "secret": "7d6f1f63994cef6b1b419045ff3adb3283d39efd07a440a9f180a14e598b981c", - "public": "022e71f773b58dc4cf34e4a5df618c0d5c0f5590a429b810002c3c4100d44cb03e" + "address": "9qNtyuayg8LsLBxwByHFrSo6dMK5okoFVj", + "secret": "22c33cd73e3c93597e7a30e0e2f7263100dff55d1fbb1cbc28862a4adc01e393", + "public": "039f4e4dcdc790708675a86f89ff79ece90e2d2db6963453bb05639cea1277e0e6" }, { - "address": "28tDeLWCqf7vDnjZqmRxhUgxu9vi2DLpz7x", - "secret": "3ede1094b88d0b5dac7a3602b6fbf6103480c92c7ef59a79243d9a7a7d6cfbd7", - "public": "035e83b9d218f9508ddb1662737d39b6b3a0862acda1ea6d3f48fc742b9a4f266a" + "address": "KEaVf8Zwk9erYrwqYg5vLuTWGDZfFZvzH6", + "secret": "52b2e3d1fe43daef1de9ecc03f26d769d2a585e75caf027dcdd8e9a001de559e", + "public": "02e4ef2ea0fe31a8cacff87eb21d60c54bae50e6e69c725c06dae4851853c1f821" }, { - "address": "2cJGM1xuLQ1TgTGz87HbpXsEF1HCUqyNqUB", - "secret": "bfad5fc3a31a4bf7657e8a8232eab3c859bd95fa571a4ea5bea4bf675083daaa", - "public": "029cd947dac339d81f0c890d0ecaa36d80b9f3cd9be4369e8e211684d9ca080435" + "address": "273HzqvvGsbfqN4DzmLXSHwxoQGvr6h2JDa", + "secret": "76ad5b4e12a5ab1a7b8b229bda86214d00a8c96a48d36ea2b10c7407ce385477", + "public": "0251e9738384fe9bd8c9bcdb49db45b37cb817032ad5e972bbc4e62fe221f6537e" }, { - "address": "Y5KxkHdJEWnE4gf7KzcyU62kR6cniJfUuG", - "secret": "90f3e8c523ac5d3c90aabe404725e37f126debfc76a9595c52048e77a7c5bd7d", - "public": "024d816adc4e2d1c9fdb7d0950b37fc2b544aeb747c7170f433f4576c096a83fd6" + "address": "tCmpCM4QEmcW4KmfyGJHCUGtdpwKM95M36", + "secret": "430d620b2194fa6ae143bf501ce4c6afa86cf59deff48e94d4a61aa0eac3af84", + "public": "0336454abd9fcfc96d5b9089939265878f0c192beaab0266792496b3547b999624" }, { - "address": "2PMQtBiU3rk8uU3pSh4H5mREHraNeKNhget", - "secret": "df84507944d29febc2afd0d26f15bd8b32bfd1a95504363206c1c76207ece040", - "public": "0299508ce2809b3ec87d9529a377868226f50bdce4490b15ec29882bc253b9d2cd" + "address": "2Nr54S79UTeMQai98FHMbytUvoYpVhhTXSA", + "secret": "302e30106eb4510299016075449887cfe695e7b5bcc64acadd2b9257caaf8307", + "public": "026f54ddb61336452eb33fc82ce2eaa1cb2a1fc463d5061a6437e6a379763d6725" }, { - "address": "oeDMVkwJ8HSLhTmoL5eWBMK6h9bjwcN6XP", - "secret": "32936f7b1f1d99fc19a09edd0493add3129ba17d315e6dfe8ddc426e873cb9a0", - "public": "031da2d7c522052ca3e112a7275cddc3ecca9dee77f0ae9662ddc7c20cea40b27a" + "address": "VETgdwGFKAc417h7jG8AcpDWvVaSvJja3A", + "secret": "ee896d44fd6a6d9a3c5d54843e1d5e2acdfd8f8b94a89e971af11250b7001ab6", + "public": "0321a92b89701a16780e524564a01b8a8c487927f6be5e5d1e8e503c1db8b6656f" }, { - "address": "25kJ5ok4FTRXomSD5QJnEC9oY48Csq1Xt5o", - "secret": "0988e9290224ad72634aff4b274383728b51fa556a1e43bc854127e960ce2c0c", - "public": "024f58bad8d5d2a86dce577db1a1fa3c95509dd59c6f7ccd27ff7b2784647761ec" + "address": "aDooZkbTToo2zhsthv4DLzy4b2sB1hL72y", + "secret": "5036311405ab856a08752b575c77f9689d034804fd88013cd61ab1ef8ecfdc88", + "public": "0332eabe8dd5ad5bf2df2eed4c194a194688f55d559873362e19879486395404fe" }, { - "address": "XUqwnk1YwQH4oURCg5HrGmzGdHgKan4qd3", - "secret": "580c3eb4895c9bcc853889e17789a5d671274c67a2246d24a3ed310fd2746c83", - "public": "031ae7f39ecf4dc99ef33ac779306d49248851f0c7da048eb0453cffd06034fd8e" + "address": "2TeicjTeiN788NHkpLCYXabcViRYRzyHnS4", + "secret": "0d5615b3585c8039e8111839037d5f278761e3e2516ee747b92a8bdfa8a3042d", + "public": "02e46c9b263f06841bb8df6d05edb7f965272cfd7a84c79a7cc34eca522f3d5aa7" }, { - "address": "iyadCABEArKCNZ1rmUpDQv6thK45G5vUPH", - "secret": "6a00a51bb7776ae15412f860e4ef564237f646c9ff4c11b67cb8bb282b153324", - "public": "0289f6d207b3faf085727ee7003771d035aa7a7c151322517c5131d8996bfeeacc" + "address": "9gAGvw6ALttV6qsCv9yoHn2duKkvawUMT5", + "secret": "4461a0e36f4e178dd98d073e524f6c175c4af13d69e5895ca7d113155b7058b6", + "public": "036d44c748a5f4a0da05e9f08412ac59370fcc1456657c8da02696042b6e549319" }, { - "address": "9vxUyxapFWsUzQCidEYEdyoLWArPpKwoPL", - "secret": "684055b3ad25d2ef4331c527da552e82ecb5242dde2a99962def2dc07ed12401", - "public": "0279350adf65b49fded0a6c102ece9c6ea01e75634c7b1d65d1745c438535e9a28" + "address": "2RymuWexhMxWGqZMK8H7gjcpKHYzJ7KTW3K", + "secret": "fef98b243643886cd6eaeb4b03718b2583e98a5cd335f7aa145888df0e3e62ac", + "public": "0363f7994223cc65f5c344a5418bedd4fc7ec3f153651fe9babff0e387c07cfdb1" }, { - "address": "o4pEvgB3o7AsjBYJ6GVXejS7RF5PC7nojY", - "secret": "ad2448f69ea3b2a47f81b6764c9780121fd3096de235809abfa31705f08b94a5", - "public": "02aa0209e405635eabfcf2eea9617ff33ce03e6ab6e3139d1d47002ba1f8270bfe" + "address": "tRzJDgcGujKjFLvhiP29DwCFcSENXwD8NQ", + "secret": "c550510324920ebc38c2b3d8f7207b45c72f53146bbe75297f65fda29adefe70", + "public": "03f1c9b77f74670325f9ed5c9144405e227a4ebc19fa2f71f263197cac542f1090" }, { - "address": "2K6aNn59qjWJSYhgotJSRBynAM64HAn6HGT", - "secret": "547ed9d5af269a2df91b116e15539095db1ad5b1c71686c4b49683711599bbd3", - "public": "032b553d97db94356be3c72d4e56963ee2e1f244e2ef1c37754ef24c1ece7420d2" + "address": "4fnAyeKwaaFqhL7KpWVk3dXGjTUKkZMWAE", + "secret": "adefed215155b9c86cf6b529cdaedeecf54813be2a92b7e25cf3607b635def63", + "public": "02b9ee73048d5e1547f6064c8ef19a40e334c239a0d50e2e7742881abccf4834db" }, { - "address": "YuyoX71SKjH3cMGrnRrwQGh7fNWxbNvB5S", - "secret": "f7ec06136efcd6d38ec8b5db8a2e6fe89545ea9d32ecbdf3a73ccdd0eeeec1e0", - "public": "03c58405d243f6d948530ff6bbff53c0cc2ba78be8b9ec73ac292808d82ca0c397" + "address": "cUg6C5xPeULFUYAi7k5z825UCFktGr8QHg", + "secret": "6ece6dd12c75bbc6147091af4ee1eb6b9ca83daa4c8c74fb857dde9a559ff354", + "public": "03ea642b0f6dfe84807c2be013b697e811b056f38854185c0624e509fb115696b9" }, { - "address": "2ZXer8m4qTp6i6CTcuA3aGKfLoMh1FWPSVE", - "secret": "76ce76a8cf31351dd1b5c69ae8b3d1131ab231b39e2fcf2c52c3e1bd3c014be7", - "public": "03cc748b680d616388866913301900dfe25ad1386fadaf31909bb10135941aa11c" + "address": "vJVpVYYvDY4mA8kdrtuo8W1A1TeyRqou8y", + "secret": "a1536d32a2a0b53847cfc69a2ac15934c8f4b5d5d3601a7ce683f454c958a9bb", + "public": "031edeb3a15926ab996d39934138f4776c8903cdd2b3373b93464a19352fc0119e" }, { - "address": "6ryuhBCySJLxLz2yQ1c1c2mxZS8weRpH8L", - "secret": "b257324dd281edf243499bb8df87e78136aa6c8103449822a8616df0a34aa0a8", - "public": "030fec91f273ac46b35d5d629cc2ff43fddc768e1913e391a8890f1b26068826c0" + "address": "y8hhvxPjZpinCChM9K2PLDBW4g1av1ZcHE", + "secret": "e29e15da9d8b981d7e511eee9ce4b3320b72eb476a7ea405431b15ebb04e8a9c", + "public": "0220c85610ff73b1eec67c09305d94cf094acdde37396da909de697e6c2a91f9ec" }, { - "address": "22MZjpJpHTao9ibVxBwsSEFp4hkXrhJm5Mw", - "secret": "5a23637151f9b1a609cc83b4b137f23f7eda6e4191194e526ea53aff93099fef", - "public": "03afbbdbc63b21f7c44eae38afa91df3c8245bcead3a80bc3d6fee35997f6bd14e" + "address": "2mMfN6DGbDSjaUVVkigCvBUvrW2Te1jkWCt", + "secret": "8409735d24e573dd2c8b49f9eed1a4b43a92a0b0538fdb1a3453b012b7862c41", + "public": "0203e0317f62b21015090c038e8402cf9f68e90b4f309f848479290fff989ea77c" }, { - "address": "7RQUEeTCWW5uwQGtGnWNwQDSS1hymP6i41", - "secret": "0871b7a8e6844b91e2632cbbc9b0f9f0430c0eaa57aaea93915915d71c692a05", - "public": "029e16626cbf04736738b3caa8dca3ed7cbf4e11b3615c85624dfe2d1b07e8baf8" + "address": "2fZZnSM65DF5XKtnNttaVkNBAEky9GNdoEG", + "secret": "ccc43a9f9b194263c547e8bc7c386513d0aeed9d16747e86ff0be5e70994515b", + "public": "0358b3ce59c1362d05214c30b581fc4571053672e84c4a7bc2a94293f4b3f47c89" }, { - "address": "dTBNaMbtZPDz7HA7bYYHHidizu6YQ77oLL", - "secret": "56bc9dee43d11e6975efca5f737c2320519d7512be8b92a5779df776f335ca3c", - "public": "025aa824e03d85d350914cfbf2f594432523e2a4aa1a80d72d54ae6a0fd53f1319" + "address": "8yh8LN8kFCg3pXqEtzyTKNMwyjNAVDsNVU", + "secret": "38d2135b506023ea860c37fd7b7744daa81e25f170a746cbcd7dc0ecf54e2415", + "public": "02112e98e0e9c524440a36f77cab80a971369f4e21d9e19492481318ccdc081090" }, { - "address": "ohNgvz4J8qRydPC8WZ6SA7XPzVLEsSj5vs", - "secret": "dff6e962a8d8fc5c7d32d7742a257a36c4f1fe354e6734571984b61a88ab9d39", - "public": "0300d299fa93707f993e2fb1eaf9773ad6f4b83550c8d7a06982f7b2e3bdd5d3a4" + "address": "jkFvb3j5YzTCg1LnEKrUGnjbAQmJqFhHuc", + "secret": "be596616d27c8e0396ebefdcb1897829bb39a7710b92f17548ae6812cb367b2e", + "public": "02959ca4a318184bc71c8e7df8636fc4d6cb3704386453967972fcece861df57df" }, { - "address": "193XrzNpz3559ehg97WsDLY5maGyksLXD4", - "secret": "24844b4c1c22a80ed539fee46c6555cc7cb5431a098d12ac0b50cf9bf8ecb41c", - "public": "028b9516af5f87859cb88c69df55b5ff64e50e687aaa6b57b22951598287fadfbf" + "address": "m7QnzaABKgNqx4ekdVLf5SdWGUxVSFgPHP", + "secret": "d1c9d0827322a843c37fe58d3169d145d5e8477f9714e44ac6575de9f20c5bce", + "public": "022169ceb4f864b4766f7f1c085564f1334a63c6c7611787ea7f80828d9e41671d" }, { - "address": "qSrhFu9hsVbzoNrRNDtERJm6juZVkmqBRK", - "secret": "415e70478e0ca07ab8d7a6ede8c63f76696064fb204ca4bd09d1d419c3c6a71d", - "public": "021d664943ce890659422bbaa25881e79b7ec88b02316cdd5af6ea9e80c6e57f87" + "address": "2Db6fRqRY7fkYpdFMp7ik9eSicRHUPcXXuY", + "secret": "1ca5d69c367a4dd6f7ad4b702825e17fe66a2c0a6e219b03f00f4648598b056d", + "public": "0215e7d934e04d7b12385ffbe6e55b4dd539d4bb45b138396c18c5aa9854562896" }, { - "address": "sYYaoZyo8TFz5i7a1B9fQWGJms6tRtSjwR", - "secret": "942c2e4e527d65167836f7ed1f1247bbe68ca8c54bf51e97614e89a3cf0e759f", - "public": "0356cee130c01603bf6ecc1187e56a6c467debf7afc7f615eba0c2529bede60282" + "address": "6MiD95xbpTiX85WaezBFMx31qHU2Cy8mGb", + "secret": "cc3e2454363c09febf2940941b07477d226af5ab09d598f57818423586ddc3a7", + "public": "025ed910484ad0d8d837475339882248638efa73f1d96b29ee681b8dd1f3e710bf" }, { - "address": "2SR1Yko574K6UQ74mhnJ1DQ2fQb6VLg4wa7", - "secret": "73e4ff005ac47bac8d7ff312f4f7e9bc895dbbc7347425033c7a255c99653a7b", - "public": "02c0c3f258354a8ebba1ea3f6399d497154f6257e41460af185f64b5078eb420b3" + "address": "2j3PE1Gnw7dimka8tbe2DWM7nadFtKZDRCi", + "secret": "b33249380ad2c5ca60577db005bbf15e24cd260e5dbe06c8da9e877373d79bea", + "public": "02e90a239e782a8dbfbee2aac3d2d729bc45059a80f67ee3d52ce4e24b24a7aeae" }, { - "address": "2K4uSkw3PsvWC9eyvgiRmz7LUACv44arV99", - "secret": "63f91b3c3fce1ace969a0ee05117c44449710901e8543ab15383522d1cf766be", - "public": "02a487adbf17dae40a2a4f8217f0df3e8cc764a01a61453d12cc511fb70ebad88f" + "address": "oUmQZvH1kKqfKEhj9EkjPH7mJsDd9PekUH", + "secret": "ed2166711c446df7efe1615619a99ae9f9192cd548f28c2d76e0ef224003ea01", + "public": "03f2707b4ce0ab1664b4ec6ca958e9a6ad53de97687b933b11f36309c3ae9463ec" }, { - "address": "f6sFPWU1xkgt56eijR8dRSqKE8SgcZKFPP", - "secret": "cf4dac23f92710dc08acb6cd74d8b127c91ca1f32b955b41e3884c4f8b8f3f97", - "public": "02c62a7b6ef28cf1380e586eb4ff2796785497e044fed5c8a0fe5cd825e51ef116" + "address": "P381ZTCxZB7XJgTBnv8Je6YdQj5oRCnWrV", + "secret": "20412f51c1283546151fae13238c8173f71517e839df2399f59d6975d867ba00", + "public": "022fdf6aab50d1c7ba9f07dca660507294c2347e9f0455e9d906a8b76d46232be5" }, { - "address": "vVfyyApuUf1wivt86uE6kqpKEJ4h76g5FA", - "secret": "1c64b99ecbe95e51b050619fc6d1511568f9378dedd3ccd199804b51e042609c", - "public": "03a1a09716a5156385e3115764bfa1e3bb9db45759a546791f5611cec559eebea5" + "address": "bvjjm4USaFY153twBg4k11mKKW1SZri7Kr", + "secret": "9ebc684f04adf27593e3d3862042c867d9e7b93a15486d1b910cd3df01d6f5e1", + "public": "03a26dd8d7c5536fa1ba0b8ea88974a1449796bd7a03613c7a8d0386f634d83605" }, { - "address": "2Nf4oFSFCvpNsRdwDcShetnZYxE7A7QXsg3", - "secret": "89c633923478f9e49d2ada20371e2778a96a3d9872dd1e86c4d2b6905f122b58", - "public": "035b8f6754bbc42d4042891c23a190b4f16797db3fc72391b6df66d3f7b6d37d72" + "address": "SjAB5JX8MngBBmZqHAQv6b4xBf8EU6TUdH", + "secret": "ef9391016d560ed1bb76e27712b3eafba14a97d765e3a2c95e4a33c91e3daba7", + "public": "03e7e8262b1b397ef1f5d956b9b4ef46a87670c6e74bb84dd63d649074d6a90d95" }, { - "address": "qwAG39oPt8TViWgtnT4XPWkwoakABRkqkq", - "secret": "24a27a267e2de2b3acdf4c930e062c88245c2fd46af995fa3d6eeb9e84093679", - "public": "03ee93b18ebb5b946290fa05ff1e6a371dd0e18d9e2a067754fec8decb24e0e2fe" + "address": "AaowUNsWWGCTSQt8Ubg9t7t66WXgNm8qj6", + "secret": "ce21b58c3a7f7eb5d7c5231a906215a39d13771d903ee07b1bd6ed2175180f68", + "public": "03c5b1e76ad124d9558599a670af3f196aa8380ba2068a3f8fd86b78959553af50" }, { - "address": "2biVNtHhuWqkFhVdgaCVmSmu6FFEdpiYHcC", - "secret": "4307f97bb04c1638e3f60929b63aced6724479b28173da9279f9d85aaed5f8a7", - "public": "031f29d439ff00d6e4555f3f5add7a14ada2902e09c9fbd675626275319599bd94" + "address": "7M5c2bpc6vChU5LjgSenmEiRxKvFrjdJRm", + "secret": "a9b800fd9e55855e3938b2d81b7ef5f38c3ca48f4ff6f16e2a846bc8924daf9e", + "public": "02db984277e99de74db246766d96923d0da2025588bce93b3002f67020bef74a60" }, { - "address": "SXjbYpggC3LZHUEG8gavndSgRDM8AUAm1g", - "secret": "0bc3b2a34827b92388d9d8826b08c97ca94d9a1c7aec24a44ca4559f3b82051a", - "public": "02e3da28e0f4af0ee38ea6e428848c36d880b286e1fe8de4c75d2fd5f8213d03c8" + "address": "2A5Bu1Ho179P2EyoNcY6iuuweMpnTo6Dszj", + "secret": "916a59a3fb9e8cf7ca8b57e12c479a3bececb4e2cc045b138c30d24193b2907d", + "public": "03f05db64aacd7f1872deade0890c84144ce00e38a5dc07e2880079f8e480a2eab" }, { - "address": "S8V9LqRMdJ1rf3knusQBLCbJBZ6DrCQoxE", - "secret": "e11633001d6a4def21c613b64e79b3a515f085c5d93baf3f6646a82e6ff84955", - "public": "0360cc43acfcd90616b588df003b40b75adf9fd09799f0ceae292f7afc88790a83" + "address": "25dcnottoLnueHerPbKAhZRmUoXjKHpUTi1", + "secret": "787132dcc79020e6037ad2b33708a2ccf0221154be3a53779bb13ac7fff938ab", + "public": "03b740ebcd062875de83f984c37d71f1dbe56b054bb39ac1d1294d52e8cb702d58" }, { - "address": "2CDFYDuiirnTsoVofwMYerwzZniepPCvYjr", - "secret": "8112a230f7040c72d4fbb7979e6176ce7bd2987a0ee57550d65bfd0d80343c28", - "public": "0324d33bbe4b5e8d3d214333099a7b309a62a5e63a7b06480e62cd2990d7a0971d" + "address": "Yez45aeDFBzSDLpLRT4j1ZW6Wu4dH487QH", + "secret": "b55fe82dbcab00982ae20bdc5d6d2205132161e91eb4bc80646e5d3e56e26deb", + "public": "024b71d54e31d943a04299bee61abaa0410b665724fddbc02062544521826b66c8" }, { - "address": "2LCsxzMv7fhASAAxGMQLCMgxzH61aCF4tPS", - "secret": "167e59bc1afba7767259584add0e07a017fbacb98b1f14e9f8cf02af3a9b4358", - "public": "024cdb98f9b1e395b3a9e29da37c7b5f6bc1d9a392ed0500869010b9f712b53d8f" + "address": "4wzjraRSLhkmQBfdzPYu9DcLoJCLtg4PjN", + "secret": "a0297d49a0ac7db02f303fca9e342fde7d3fa9588322a50be65711f3b33125ce", + "public": "0363eb9e525f712ce3549366d42944d9bb11f4489d38f61d30bf319f242f0bfcf6" }, { - "address": "CHT7YRWCW6hLaufRj76q7BDfA2XfzFC6dq", - "secret": "ac34e7cf18333a4bcfcd750def2a2a8965134b76e56c518b54b1c4175f71de00", - "public": "0367634ffc4fdb2395757c8fc1b99e0ea8cd5aa5275cfee212b50cdee0b62b6d6f" + "address": "PCgs68kierVHr2ZqQKkACJe5uFCaqn4Twa", + "secret": "362097a58bdd050e595df2f2e49ad7be2202eacb5a7bd86c50a9b44c9d10ad73", + "public": "023f74ca7041a7d9f3ac4c524f8686018d8a24a735fbf942b271ceb2eaa840c875" }, { - "address": "2Wrw5ugpcqqboyvckpoGMTmzphWsAZnyrMo", - "secret": "e6f796752fd240fe4fa14f565499970a9aa6ce95b022e447f3da5748eca51ec2", - "public": "02fc1e9940fc1656b6094480ac9ef5374f62aae855ccaa7653908c194f97f161d0" + "address": "pJ1EMgaUEpeTSXu1X469gtXhjd6RvCjNq1", + "secret": "556e1fab62c57725765b5250062b6b9e3d2af8bbdb522255d1304f12047d283e", + "public": "020a6a5ab65ffb60e706fc1febcdbabdee7f8f3f916a2100dcab925cc8ed0b34c0" }, { - "address": "drNEzLZPMekwxBMn4JkoUdFbey6hhFhQVq", - "secret": "47369e8da17d5196d75f21f6a55f9203311e788fab5d45d8bc230c1944b7b601", - "public": "028b541f1ea4413d880ab0028f30e204e45cbd510240eeecf4f695fb111cfb36f8" + "address": "PY91kddKVU4mVe2pcM4ZmEvsdP25rFze7J", + "secret": "23bfe9afcd904fd9aff9838dfd1edd67b897cc9b2aef6fa5eeff116103887a6a", + "public": "038824148c1b8ecf7848dd3d1acb359423334c5822fc46dba4016da02810d30f74" }, { - "address": "2eW7DFoHpWcoiCUJsvRWn8cQW8izNmtNs6D", - "secret": "d51fb5bb4d46713eeb1ccb5df1284044f01e3adc976a7d8663147c72f6ddff73", - "public": "0225ba0da8cbc844b12846b4bc01895a9693f64738d9cdb9a3fd346a39eca7d0dd" + "address": "2NRQSCu82A61Q3Crm6fMJLUuwEnwMraT2FF", + "secret": "c352efce59357fb758de15e09f00e2638b504123212003157a3917e8f41a2e96", + "public": "0202ccfdf6248cab6f045e620789fc7c9eb2a561ff80c2a89f0cd478b15d1576b0" }, { - "address": "2R1Sjq72WGsjXn1e26jijcoHBff6DaPG4a6", - "secret": "c3a7ba353f95eb70e32195b984f80400c70774fd3872c58f451bd8482fcb0711", - "public": "03620a4298ee6f53ee18d8854719df3b3a3259c029988f94765febfc531d254525" + "address": "3RRzhD77qJoXvM6v5D9qxdHfoKjUhnEYhX", + "secret": "63c1cb5a1c165c78c847548390a01b8bff6682a1b247373ed6887aed21dc4bb3", + "public": "02d608b2d0df929b6ab7b261f5670d53f406e27b2bcfb00e024dd256c85623b77a" }, { - "address": "E8gxGEsrGz5R3hgAfh7HnTL5NZA2zwrxuh", - "secret": "775242dae67810ab7d885415e2dd660156e986a6833e8f02b23242a3822867a1", - "public": "02261563767d209c13f020a44d32f5471d4db0dfa68deaf6f70e1ff33440e42727" + "address": "2d1BVVuCTEhTxdKfKJnRYB1QZvAZQnzKqKb", + "secret": "c888dc692ac017a6e7937fe04612473ee816f3f35c0a5a099d13adb9af7f7571", + "public": "0219c3f2baf3665dc97ddbeabbfbda43c37f9a797c66623c2d2f991e8b39a99858" }, { - "address": "CD5SS7ZMFL9txFgm21sGgvVAmzr6iFuS84", - "secret": "d02fb3edfb11ea9801f230eaf0f85fc83fa954d2c6dc6fe38d4a16153804d074", - "public": "02d680c60e8fbc09537abcd65ef9423adb47e532d968d5a9fb8f46a8600592dbcf" + "address": "HqZLYWBYACeiSgC3ZugJuq9hwgmDTrDgRN", + "secret": "fd1780ef43c24ede009e36107e15903a29fc150a1581a7844370e440cc922e56", + "public": "021ebef79e0e5afce2d4d4eafb2199cd558507ca1a0ab33556c464b41b020aa5e8" }, { - "address": "QTDP2UFTL9ycms9AQHg8tuZVrekPkHuDZG", - "secret": "bcd1c13753152298b9bda854b29d5a938e0fea74c9a8610304ba4b9099c2f1a4", - "public": "0293ade953ad414719f94433ec322a6e2ee79f1f2547f86591276a6f821849f558" + "address": "2cXxCXNXbFx6vF7AyK4Jq4Tn8gvL1tGxjJZ", + "secret": "fb90dd91878c0a09f823b8142f71f702bbe2cec4319403b37967e17cef6aee0c", + "public": "022491a0e903acf81c62f8e13c2e342905374acc4afe48b8cf8650f269899e5bee" }, { - "address": "ZgwhNiSseurj55bbpdkpZJNte19Aym8gTN", - "secret": "51910208943828aabfd02f7d3c863c852cbaca0a34e24689b9039756145d9aae", - "public": "02e142df7a9512021df81db7ebea054e16b57d4bbeda2a0d1beaa0a04413359d78" + "address": "u1qW96EaRAuxaKWTJT4Uu7v1EEiiDkDbpT", + "secret": "5a3211ed2aff62a77006ae14b4af4cbece71e3932fe835cab03e7778b42684dc", + "public": "02676a8a39902a79d7057b177552fa7c99ccfeacd8d1ed5f4cef52d20909bdf067" }, { - "address": "drkqhquv8xdDEkRiYcQoE7BNopTYHyf5Uy", - "secret": "c76091c45d44e8262eb493cc4237946208be650c84f498c876079854d7d654ee", - "public": "02192189c4dda83129639b3b8d13a9f41258e3783f4b4e227e765878dad3952ed3" + "address": "K5PVBVZjJkg84f83p6A4Bu66NJPJBoVHYp", + "secret": "1214af921adc1234c210a62675b5c4b962be4708638a67b2c840b950a7da2bc3", + "public": "02ac6ece3449fcaa163302eed3e3dd9293a46457533e4b5f28c137bed59da53e4b" }, { - "address": "m1wbKL7aNVwe3FGdfiLYesufejYw1ZvY2j", - "secret": "7de3414c466ecd530ff4b37a38bf48593cfb48ab63bf298e5c83fc6f0d9deb8c", - "public": "02ba8a7c55618f20f696f0ef8071c7ec90f9603eaadb8b78892b9e882a5505f464" + "address": "2Gg92Ak9qtPMmijPb5W6kB8M3S5J41qwJHT", + "secret": "7a9d1e7742bca2aeb4a5b1a2bdbb304293477bb14345676a27a2052e5d4ca1f8", + "public": "03eea804e1a66b4b00ab6957a03e07750b9bf716be5deec43642e20549f54af1e6" }, { - "address": "2ZCHqFhaAayset6HENBESfdZZchEShutbQ6", - "secret": "97086333aefb860c849a91d692c810aa17588d2562054ebad93c6498e46ae5a1", - "public": "0322253731866d531c686269389fa172f11d26731535e01facd035dd3f87bce4b9" + "address": "CmFiKdFeKorB7hsKCmjhKCw8UScJCfXx5d", + "secret": "7be562525ad05357770a38a48380a23ee8d1b9b6118ff0d36f1205d3b265727a", + "public": "0316c776b70f4ae4c158e68c3393a68b3f9bc76864c805386e93057fccde70953b" }, { - "address": "5oqPKWZG32w26yccoH4kD88HeDh4AJSo7F", - "secret": "46d5053f14860b772648ace44643ee6ab58982384c08f3973fab6b4a3917dfe8", - "public": "03d3bcfcc0115d03eb2c8b2a01677f2f7cb4068fab663aa49112e3b9c6e6b625a5" + "address": "29tcDz14WSM58YkXMhaPJfiwUtTJDAXt2zn", + "secret": "c0bb01bbb159b0bedf44cb7ba6f8d688ba94370daa08bdaaa5b8644b57045758", + "public": "029f5edc881fd9c965626bd57608b3d39cbc03bc12891684bd3545e02e77932c98" }, { - "address": "2Go8o89gVRmr5LU9ppcrMRvpXCPpDzkH9D7", - "secret": "1a206745160d03541340ffe3361747cd765c8f525a0caf942cffeecd44fcf6a9", - "public": "0390794eaf66bfc3d0fbb25bcb9ae284bb5feeb51dccd7e83947f70bc0557510c2" + "address": "23QXSzuMwpeTpdfag88sM7teo2BC2dEiqUm", + "secret": "34ba38674aef49b33ce5deee37b685e6ebec56f3e1f249c4d9ef6bb5169c775b", + "public": "0242e775c22b176ec52c313fdb2c070c34a1de75b9f5b0aaeb5c4f37858c7541e5" }, { - "address": "d4zF1oMvx8ecP8PPFCExwoybibbdCA9ejM", - "secret": "85c5a5c6ac69ac7add65191fa04d75f23c42071b645a587f3c14d884355217dd", - "public": "02308dfd9c3bae2f467c3088b9f99f450b58c7ceb2695e200f33951e2c0928057f" + "address": "j2twcqftn4NGiaEKTG8C8EE8ThV5E854NL", + "secret": "646c729eb1df22aef8c1ae4ae5fbc493241b2beffbed8cf80fe29b59c61b5946", + "public": "03ceae5231f5e67bbc1958e45cd8e13861373bd273f8a014c031af845384c26642" }, { - "address": "vocHBqV9NCEh8g2vLZCXUaQwhWjHYQRGnS", - "secret": "56c0e7703b180b29937b1096dc311048ac0506df9674df26513348e8fce1e9a7", - "public": "0359f0e7c2166e6b4442aa97740bea6ecd8836c2f1706fde0f98fa3a1ca5b8aa38" + "address": "XPNkBF8xkXbFZnwvJs2mGKVtzqbYT1sxMu", + "secret": "69e76a9701546342dc4a67b4b96d88387113cd0ed03334e76ecfb7f760539b90", + "public": "029dc62e8c891bf8996292dd7b9dbd4f35de762e82ca1e34075aa7772f3bde6340" }, { - "address": "NwwbzuaC914T1pgnuFrQsWBDJnA2onVdB8", - "secret": "528c609487bb40378ed684852f7a5cef71ceab684b0bc99245f2c74383a51bb5", - "public": "0271b760cacbe5410140315cec2c62f2c582e6c90e5800fc40540db57ec9faa510" + "address": "2GWkZ9KZZ3tqL5b3WU7bWQBBAPTnoffrRch", + "secret": "e8b1495cd299d98bc817123bc3925aa58b43d80fc2e54f2572bce0ebcf890167", + "public": "02763f7a152c2190cabe16a1f29035c6c70b80a3636e5568fa4fdfcfe35094bfae" }, { - "address": "jmpBDMkbH4SoVHypMD7RALohvfoNfrHJKp", - "secret": "cff994b90a27345d0ddeb184cf04460e8742080c05b9321dbb2ce3ca9bbca058", - "public": "034b179ffac4fda857f3f82368ecc2b9622a25e8f0cf20dfc8d6222988811b6d0d" + "address": "DmJHLWMHp5JNCFcpwt3JmxbywjNrne5jEi", + "secret": "8c2f4d83eafc53c13a85ff8035403c61d9e4c17f1453cf87b6be7b0dc6ef9e9b", + "public": "0371288fe9beaa9fc75a63444803969ad821550141e74712e9dbee02b21725875d" }, { - "address": "272V4JHpFdb5UgnZQKi35Skz9pA5VKcxArG", - "secret": "e33afcf8e91a8d302a518467f8b861108321c25b2237744d74c0d576b8b00221", - "public": "022b0c5becf659d8bec9254f9e471d25adbab65de72580c368717acde44f974da9" + "address": "26jmnqf7s3FPRu2wLBqQc5KfbBKrkgtLerT", + "secret": "026406771a4e3b8baf98de0521150c91eb068422d37af2974bfc6ae0d4fdcd50", + "public": "03e47579aced7c10ad1c479e46e13e930b535ac90b628d29d89f6d02a75ce6bf80" }, { - "address": "qBZyLc2qxRU1HsUJB9VehHDP9rmjpnh1r9", - "secret": "a21fdae6826ba4382c391e997f1eea705aed4ed4402dc62b3a7d52ab5e31330d", - "public": "0242edc742be60829903802ffe0b58e6add3b71f6884210b2c6727551e5771d78b" + "address": "2UUvsfNWQNycy6smEG8c2bMNyCh9qQ9P5EY", + "secret": "1814c9a6e012f1b4dabac7e7040adbe519e3e8071c15089b5620d091e3c26cc5", + "public": "020429f24353d0ebf7a17c9acb952df72b6364a010c69d5d98c61ccb462a65b2b5" }, { - "address": "22P7fUktGhqe7UHRPgRZsikJDJT5CpqHUsf", - "secret": "e46fa5694a0fa7bc2c09145e077a9e609c074254da2ece0dfaf1986a3a577af9", - "public": "03cfe55e6a7c785766262c5f95c1e9d38073fd464bcb9501db789c5210bc2427e0" + "address": "haWRgQvuH4MdCSyjAUxzzunVLwNi3vgoj4", + "secret": "5ae9f61a0c40f15c178775033192c68581f7dc014a5c7f23b1f8342e853a919d", + "public": "022139698f089264428fe2e194d7ff0138e633f3b21cb39768b9c6f65dfa689eb5" }, { - "address": "qfzAyKETwAzMs17Y2iVXsB6P876UTB3ZZT", - "secret": "908bbc808e4fb42fea415b4fbb6af9a8341124796dbce788378d6b0b8c745110", - "public": "02554827d37181529213c99599f74e96db147a917a4c51189af9bea335f3dfa4fe" + "address": "28wV2r2XHDMdAgriHeYL9Mq1W7TmJufBwp9", + "secret": "bc37955215e69841e42c9881e284fe53eb090598f3f511fed533e3e82478e83a", + "public": "03c2c2c3a698da61e8a3d95744326e1015c1842aa84a091565cd3b235b1d55a16d" }, { - "address": "cicXtZrhuCrbyPEf6NGsEyc8m2CLwr1rj9", - "secret": "8706ece6bf135781c19f6d86532b69f0c5856fe7362f69a78d9cfb11bad31c10", - "public": "038aa4c7647ac77439bb2b91faab8968003b2be0a6a0f563c3304c7ccedd5cd8d4" + "address": "28WhxGF5tSuvWF4D9tSJqp4Tz3dAynY4rkx", + "secret": "c7666cc0687a4cf835972c65c58f5a395beca834eeb8c7e0db1e87de1ee5ea43", + "public": "03c2ed06a2d7c5ab80d35d0c792ef4b3c9630a50ebb6c23aa886d4981437c79389" }, { - "address": "2QvHQbvcRoEre3LfnAnfe9FoRN8Ubxbedxm", - "secret": "22e80b0840b8ca4315bca162eb39d73a4c91f0f63ed70f03f2a20bcadf800e90", - "public": "03f0ee3e93034a2de37afa34aa9ed8921912105f0e94a5e195d53bf69e36292ce4" + "address": "etcmKzzd4K8NT6n8aTiMtUkNxFc8sz8vyx", + "secret": "a3fd517ccfa8ab4623d02331e818c4d713e26f7cc7d18b2a7e1125ce3e405335", + "public": "02e1438126acabe6a4c2eaff465a5b0899b4cf66fe762f92434d6ad91b44a3ae3a" }, { - "address": "SVyV56esHtnArfQAwaacP1gU21kkeHr6PK", - "secret": "5aa360a81136d751848912e195532bbf6f96f851b3347865fe3039ee687eb42d", - "public": "03f0a5863895461e27ed2305ba5464e551eb6ad960e112e2080cb8621f848d3157" + "address": "F4YnpYwedDV3DSuTVgAqN2F7mikJkRhcTP", + "secret": "efa78a590bd91f5b51964d3a4537abd76f03c41d93e2f68923df89662f52d32f", + "public": "03b05cc039402bd180818546c50dce27f21cc34f85d0f0a108fdadf8a6aa670d82" }, { - "address": "4rmAg1RHBq5mRm1z4W5KyHaCTWTgjeYBku", - "secret": "f2472d4b80985d884f2733497376819dcac7f377b3a3c941aade3180bbfd3f3c", - "public": "0350442dbd85e05dc0b01e6a9e8479d19121e421808b2567c2d9a66bfea13e3f9f" + "address": "2c6N2MabsomEg3JKDkch4Jpz29bsNU2chWp", + "secret": "f0873cd7a110412e885761425372f29c72555e50fbba2af0cbdc2745f60717b6", + "public": "030da68239a9b2f59b09726846321a3ab9268912b01802743098721229b4e36c90" }, { - "address": "dA1UueuYYxvGoYH3fszvvbqbpmCBPtFgYD", - "secret": "7b840b8e18d70e59f7e1f01f5c6300d5b52403ef53d07f6e04b029eb95d1bbef", - "public": "03134d5b1b519aed9adeca15e3bf2742f34c339257549990a9c8f43be695a1e63f" + "address": "23LApPWq6hQYCe6G4cgaPnYVS8pAX84FBaR", + "secret": "52aa35161bc67fbeb4db60e92872d737679da25a4fb65331f8ff49cebe9ec56f", + "public": "03038fde27b7f8ef7554632abf454ddb8e0dc428785851afb742599a4a69371822" }, { - "address": "mk4F2hkySK4UKjxQQuZTZkCMVjyLFP7Z5W", - "secret": "67b69d151b9444540b2af66e1b297b39daa5b1c2e2944f7f54fb370d122ba566", - "public": "03b37f91a82b016d614ac94643c3a21acdd877e478e79aac2b5b170d44d7d603b3" + "address": "xFw9ZDCbQFG7DpRiQPTzb2WNRHqrkj7RGQ", + "secret": "eca2b0b5b6b1d84723b01384112f25786c5c8f3445c941070a71cc76aa95ba88", + "public": "039b957325b2c35cd8734b8d1cf83facc02e497ad886940350a68e2f480768b0e5" }, { - "address": "4gD5aKw8aMnzC3ivoqvvx4SwKJGoqXXJma", - "secret": "c152f426923ddff393bc859b54aadd41c00ad852aecdd316f1ce9be7d344bd72", - "public": "0258efdfc0668d28598b2ffc5fd4a58ecb8222c01b557273414d0b7c49464775c3" + "address": "268GpgoU9Hv289M8Hse1akwZde5ag9uj53x", + "secret": "2b5b22635f3aacc25b8e49aeef42bd6d64a02417a80e9ec724a68cb219a7c0a2", + "public": "02d8e1b7b6ceee82a2ed233139abca00cf638c8f2398d477f0dd06b4660e294f45" }, { - "address": "sHJyGQNqYAQbpc7JPinjt774x44G9EPbdC", - "secret": "3e753c0fe53269b02a0e2d94a29d7cca0cf5a88950d8cb017f01ac74ffa87662", - "public": "03b3a046e7938bac9e0f1c2207dd3ad3cf64cfc102f17857eb51ec2c98a31f47ac" + "address": "2FCo3HNQxWgh5K56mfG2RwLAvzagB6d1jah", + "secret": "4d9df01b27be68b30693b07335823009231b9da913c91b8e5d8b8d4bf0f52f5b", + "public": "0313287d7d4684f66fe587df1543766dd415c9086e8c95b8daba9242d0853b164a" }, { - "address": "2f7VfH8JsDZLajLi4yNFQyDW5PLXPk9tsYa", - "secret": "afb50e52c219d3e5b213a27a1e4e46ef4924e26a4e7b0608072b3785d70a276d", - "public": "02cb01e8bffe5654f67142ea78ddab24445d49b6b9d9a590a05234aa470354c2b3" + "address": "2MpDqMjjZ5yULWt4CVDCxdPQGJVuGhaajfw", + "secret": "f54df30c69b3319ed9b23ab5a6b8f304bde489876d94a321929551d0a8308519", + "public": "02b67fe14d0c9341f3ac2aee4469517c8afe0a7e4377bd17a23016a08489f4a9a5" }, { - "address": "2e2zqgw8sQ9Fi74iH7c2HjXBWshG2JqWzFa", - "secret": "a4dbc2b7879136242a0490623f6d6a84b8e8b81d9c33fd68d103d6c0a11ca420", - "public": "031b74380a017183367150cfe7fd24e525384e94ef572a9b22b2c96b1b0902ebb2" + "address": "2Xz7wn9Bxb2tszHxPDNgewe4FkxQk4SccBT", + "secret": "2c1a5fd49bb16649b9a928dcdb0d3c1ecd6846a53cc59d1456883b7669dc89fb", + "public": "03c627ab67dfafd83933b644c17154cb3952fefd97cc88d80b4710c0e90f4175fd" }, { - "address": "26pfp43HAZnZMkTHtFJHYLkTTYdY7toAFRk", - "secret": "b8f1fe1abb8ddf31482f6e7c898eee05d389652d0ea22a639ed77204d6c24144", - "public": "0318f9e52b8b8e33e82a708334298dd8aab3bbf86f72c3a570bf5b957dce586168" + "address": "sGEef8vBoVE4EroM3Zt1f1isXbpyEkQDMb", + "secret": "8a630f2682bd44c03490b6387bae44e5842af0b6b08b2b1c0a4549e73342fb53", + "public": "029d3349abd73409c2ab4ca0d69159dd09f3648abd85128f559a422a61499cf46d" }, { - "address": "RyaWW3EU5DA2couELjYyoyxX7YqeZFiyp8", - "secret": "a3ce7297879e749500bbb0d860fe7dc4cfaee162087c74f49012198ddb0db0cf", - "public": "02a1f8ca224afcfc4e56909c534a31254057707280afba5b8a29ab3770f8a12c84" + "address": "HxKmR2d1tRHRXeAQ4tL7ekbi3MRfyHVWow", + "secret": "3d7de091a784479b3af9ca73d8dcb8646b055b33faf8ee18b88a188a6048bd40", + "public": "03fa8f11fc56eab51d0f1658b8476afda73eae0e5d4adb3af4e721fcbd732ca25f" }, { - "address": "1DfdGVPMPSPrwKTk5253Nb8wZodLZyE5ix", - "secret": "47863cc4fdcb9ee84d3ef3ac52e58043c7d787f47395557256baae2d267e409b", - "public": "02be0e52457a507a70dc7f6739078ad8759e83ef0ba4e81f02751bef322f522512" + "address": "2eD58A32HBAUhHVfCgF9udzJRdswTuuG5mi", + "secret": "6d6790b0807b0dc719eddfe623b1ea711075609d3be17609731f5d9ed05d6365", + "public": "021a69827e26d0c81e1fd1a690f84d94fc183bfc066e8aea1f0485ce1fffb4faa6" }, { - "address": "26MRi14GJZTKKvFBVN8Y7jFTpDFjyaFsTmE", - "secret": "8a2432ea3caff06da2ca4ef32d1ee4a7b9d8b2d8fce7c629ee29f371e1587b10", - "public": "03c1309d1a433507bb36bf9718025a531d95639ab9a633e236b3e9a03aef484f85" + "address": "2e2Mr8MjvUHmMSf4DayyoVqgSerZyFsK79W", + "secret": "f09b7f763a7cbbcf01a63a81dd0a60fa014e0a96ff609dc544b3d003d0f82b70", + "public": "02746c6784634fb65f5d0b6a73a023464c47a4232831b548a57b5d4039a177388d" }, { - "address": "eUQMGj6UGsnsFFHaCNsaDVeLUa7GDqr9sM", - "secret": "7057c07f2b3d11d898fe64c8692121225e3292f72e3eae59a7f959292fba57c2", - "public": "0377a42fd2a96e2cc044e3f4b8cd7b850d2bc95101e1fb7bff4774579c371c9a7b" + "address": "27JVEagjW413PVigf6ALjqNCgm99xS5jj25", + "secret": "e4d69a0e022f119941ece60c0b0fe8f36d93f7f7115fba75ba6c3c646bc0b804", + "public": "039ad4b9726873f1ddd35ee87cd49aafd1734cea699ed9feb3c5fcc6f5a20ab237" }, { - "address": "2SadyfG1TL5Tu8sHZ8MCzJKMqezh2oxknG7", - "secret": "66f53d3602765139b7767220b047227095f67f043ae86cefe0cc458e661787fd", - "public": "024a9bf3d0b1b224c5aa181f4c343933b4257c654abc52881782c49259c9e5d2f5" + "address": "d2LgfFBTFTwxP7PyzHwpqhHKc4BLPbA5cv", + "secret": "fc46fbbfa893010b6b3b7a82aeb52290d58f6d14d25a68232f0143b99eb95966", + "public": "0248ef5a23acdf96f41e3a3f1b796baa6e4bcd303f223f92b34025f11f3875117e" }, { - "address": "myYeHpBRP2gB9qTJ5xUMafnzftCstxfU5o", - "secret": "58ac03b9566606cbd2e166f784c600d25345703465593b7d911be36761add4a0", - "public": "026719be6991b6b29f45f04e4eca682894445659fee2f398f845f5c0eaf2f5898d" + "address": "DYnuqgGZsGk49sU7c8SFqCezEzeZMnYT6h", + "secret": "dc7b04fe3530713ecb0bc55ad66236040f3df7962d0f7764184059a5300de5ae", + "public": "023240e626ea68612bf3a722df5cf567052e807a555b63eafd3c3fdabab1aa60fc" }, { - "address": "XYTU6vjKbdAVqKLQdDpWzUXmg4uJBBpo6Z", - "secret": "543dc28612587f4a6e3dfb33a4d28fc1bbb8d0a336918e7b2073118212c1ba71", - "public": "02de86edf458eeba52a78350ffc670cced18d6a0c37e036e743871f5fa5771e466" + "address": "2XpYsb37q5XDQHvtK19wZbsTrNzkH7BVc21", + "secret": "b2d00fb19032ca52ab73f6308248e3fbdaa6e747a5f00af9cdb4fa914d76e19e", + "public": "021a7d5d53479b596f9510b9fa23e682dc02930e715550cf70ef9844c62a9f7944" }, { - "address": "2GEnw8ofYUNtjVMQcU21ScppspBHzF1so5", - "secret": "a7467a7f30287244f31da4670ff79bae66b9a60f04cac33c27ada5667484648f", - "public": "028fed9a8a48a846be9763e05177a0cddd6400f23aecfb7fbf24c0b96265db8c28" + "address": "ucW7K9gf3qU3RN2b4i6bGxFYrL3woqAGgb", + "secret": "9ad70994a257aee7ada71f7f93ce52973febe7cbeeeaac7ebdbdf1e6c481dfec", + "public": "02ea5e47e063bdf92c93e0bcfa3ce25fba9f4df0c28ff008c6b17737bd0e994292" }, { - "address": "6PTapWXb2sLQUkyNz5S7shH5jJ8WiSUjhW", - "secret": "4bf73b0719100756d78144e5d0dfdb103b5950cb2d7d1bb6037401040f83aa01", - "public": "03625906750e6e9106abf9e00c7173a2101b3b026958257a0583e1c1341467c349" + "address": "25fbmTF3vThUywruNQqVXE45sViGFJREY18", + "secret": "f62247d6d0644814ab52dd187d34a409d7e4fd92cf84525adb6703a1d85aad7f", + "public": "021f05d696dedef4f9739c6a7a258e49d62cef2d53c23a37a0a3589f95e6cf7b02" }, { - "address": "GcE5gzCj7EVjkZgEoiDMKyDkq2Eou5QhHM", - "secret": "af902ab7d6299d5af8273c0b1e6c68c650b223ac844ffcd5630aa5a464b21cad", - "public": "03e4aa9641daab6c36959c8ece66506ac0eed16a85037528c1b8966a14983f649b" + "address": "xYMp4hezFHZQDDyRZeAdv12fwaCiJ2vMdY", + "secret": "6b4ab66f5d8913678ba852718f6ea0e663a6433f7f3d748966b4063c3a6177d9", + "public": "0302f82272e3d4ab41c5f2d90af3d457f1317ec703cb28e10f657f34c4b702142d" }, { - "address": "kyD6vA8A3UKrB5n5FvWZSz8xKhQ99TVR1V", - "secret": "968b4ef4811ae4f755da8d9ff5acd974c73023850b217c42e3cf7a785b8a6701", - "public": "02a1dd9b1d3606dcd8e0ee84b580675e2d023e836ab8cb08b34004a4dedfcfd38d" + "address": "2QtyuU4brhrHAfUTKba4nRTMzGk1tEXruVM", + "secret": "6e9aa8ecbedcefbbae841c8b9abf7c72d047ee02d02ab3de3235e02d24d9bcd9", + "public": "03eb4850fb800b164540382b34d7d92c07f054383c4c5e8cd6da2b2d721fb27c42" }, { - "address": "G5G1iPNLTmEKGwUane66EhSUD19hat1oqh", - "secret": "f4132011f71fc1e3c9c61f888a44bf01814f4413ec173460c79b790f5a8a6dfa", - "public": "02737457572eb8467de391858ac8d6eb3767b1f6c6fc328691fee36631fabbc723" + "address": "2kvThk3SQYaNSNN5HrjPTbTFM74vXj3T65T", + "secret": "bdf9c95a73abeb67f87cb4cd628ffe1c8f11efb6538feca26b50bd8697b6df2e", + "public": "02d4cec5d6667aee1afb4c077f34031b05879ab4246decd0eed08218a8bfca1778" }, { - "address": "29EKJ2Ds1y8QxxGzgSCidHu2So1qAgK2kzp", - "secret": "a456afa690ee4b8716e2f4c2342a6ee1c6e0c7e1097b60c909539a15809e4f76", - "public": "02d67db840f75b0547830a661922e6dcc5c10fcc99c832c34185efdf220ec68209" + "address": "gEnn3tL7KwqmVuXQgndgbdxKesw8XLwMJ4", + "secret": "e98a343f67ba8e50dcdd8d23a32bb4fca328fc6c3ed3dfb21646a48e396c0c08", + "public": "03a69b41e972c2735d740f1c1e96b7bfcc9c20d157c3fd6981170f5171fdb0a5de" }, { - "address": "28dHKaLtZRQR9hgG6rKf3ZN9UnKHn7V4Z8d", - "secret": "e1d492c670f2b33ddd67b6fd8d20310145efc3acc88320f58fc6bd8079dcf537", - "public": "03446eb3ccd107945f96ab9ec2c53a4713c87270b5999527a1465c8b6e06e9152d" + "address": "QhJj9DnTETkK6BKN5hX8CNxoiDrpRvp9p8", + "secret": "e4e661663ed2750e8abdb0c6a66dd61bf3883155212c83e0d6e2ebfaf47c4138", + "public": "02e8d9982798c5f006a0adcbef9ec806a894bc88de7adce0b7839a197a437fc417" }, { - "address": "JSAT1oewxwgeM5me9Y2MkYheRJrQ4y1fe4", - "secret": "84ddc1c3bd760e1fbd02b9ba0ce48bf20dc3600bc0d0437e2375b8ae96e20d36", - "public": "023e26c4527933c419ad9daa63a99e6d40591025ef91ad82f43a84b883da1bbf32" + "address": "occqAdzZCGaz6ZHLmyW1FCSrRcL5Am49Pv", + "secret": "20b851a7b0615ceade0f4777e0d58b0f6f8531d1e367a4523f8f182d534bfe55", + "public": "03bea4e1361b538fe990a04555d9dd02fbf7f7b6a7e04fffa80914a5b1f5b9d74d" }, { - "address": "2C114quWs5YKxXjNQCJjeBnxywCZRuj9QKu", - "secret": "eff13814b68bdfc5adfad39357b6feb95ad1bdb5a0516ef10999673ade26e356", - "public": "03914ef651c2de2406a99578f6795811daca975b64c1e17acb8530efefb1e38824" + "address": "22YUVaU84KrbVogn9sjpATTEVH4KsVWdmsh", + "secret": "d75b07572d7bbd6aed033392cef11e46ea53b07a309e10a88cb13b7dc7b895fd", + "public": "0235ac4849583dde931ab62f283ca3b6788acfbcdc9118f95e8e70b9235b0f20f6" }, { - "address": "oicBnv7QQU1r1ZExd2EWxAfvi1Wz6483Gw", - "secret": "ef85e4e34857ef2a264a42941168749efbffe1344b02c832fdc419d50422f7a1", - "public": "029549cb1a62e76184cb1d936f548e325301e3357ee6e21d22b49bae92182667d9" + "address": "67Bvi6FjvJrmtVs8knw5jrhbB9CHbydGmb", + "secret": "f1ab28b4d9a4e7154200f9e97021b505680f2b6aff67b84556d3595f24b3526b", + "public": "03658ae2dfaf17d476e66d3fc37c60589a358dc2cee8a0da100745672266c6f174" }, { - "address": "bSoYfpvjQzJ9adX1H5oJsuMQzgHR8QrokH", - "secret": "9d8ed33ff336afa6f938e2b45c23cbfae493d751ae968bd60afb131f4b2fbd05", - "public": "03644ce71261ef9a2972f3e02045020050463f972e21d777190cf3e75797e51189" + "address": "234EUS3L1CSktQjv7Gew3XyuiWfuyYsW7zk", + "secret": "34d2973733c9907551bd889bf373e43a2e8c5b725c047f30fd280c11fc5022a0", + "public": "03f26a30354f239883057cb42ef7c332ab02509d0cf65abf0a4a62023a8d649ecc" }, { - "address": "2L1HadYmQL8wyR1H1JpbLxbowZA2qMStb4H", - "secret": "f1491c0b0d1a60bc0e14ad82d29df91f23ab66f9db662e4d6dcec1589f5745a9", - "public": "035edeff004c969b407d1df523003350a03de52fbbb15639b5eeac01554064e738" + "address": "rh4HV53HPjP5EVzovH1N3MpS56xEFHBWR9", + "secret": "1ea8940d0b18999efd6f6cf7d59f40372732e10abd9f08d2bdf366fe3daddbd4", + "public": "03eaf9fc065239fba9e5fc042b250988c52aa6ac9e5775d4719004b20b431297cb" }, { - "address": "iifvBeD8NZrCFtasqiGGnkctL4DZuH1Xkk", - "secret": "5e04f032a7f28affde2ffb7ea1a12360d7e5c5eb4ebec83f40a43e3a49363a73", - "public": "034593fb3060dd749ebc0f2998d0363ba8413d88512a1dd29527e2506c72a912a3" + "address": "2YzJk1MuPpnAvKXYMTyRM1VsgwrvsdxfjT", + "secret": "bfc39b678b8ab0c31baf501d510548b7e88f1a2c4c0d61a56d99ac334eb4420a", + "public": "02e73b0cb3d96c20b4611e74cdb81501f5dc8aec50784e021cee7e3a3599eb8de4" }, { - "address": "xtw94mT2qScK1QzxuQJTymW5z9afz9bgwx", - "secret": "9492b2dcc5b1c07b8989d654cc899ca067a8e1293f3c806e75873d5d7f66c0d5", - "public": "02b4872666e73ab3ea89b7a3841c9eca712a43d3f882c89bdb07c814cbe84ad571" + "address": "2EkVeCkNTSD7QEaz88g6tL72174si87xSVL", + "secret": "4412a0ad23f28be3735698d4a086e9c285a5f6ae1651a95b526f3bed320b3de1", + "public": "02fbf462883546a2e516aa22f1f5f06c89a6a3b7cde80b59e7ef39bfcb94a78e50" }, { - "address": "gtDGM6Wig8sBTSeu7drkc7r1rHBjNYrS7T", - "secret": "18b8f742aac4693ca835797d5d577b631648aa77daf26524263b9a87f2c37b72", - "public": "02b3a30f656416f2fb08e04404d4b22bd3956020a3c878787f43e3cf360bdea9c1" + "address": "2L8NW3x6F9fnMVgosWWdEcXmdkt5Sfhkyip", + "secret": "da5743dd6f09bd139c9c6e2105843b19de9a3393a7549c79edf91532387bd6ad", + "public": "03fd90e6f33e338fa4e9f6111396585c124b83d6b390b39f92d072bdd862831d7e" }, { - "address": "DVm5qnRoZ36GEJHLWME8H7wiibsYsosg4R", - "secret": "44ecebb4bddc307897e4cdb925779c96a8b4810be5c1379240450f5ca9384a81", - "public": "024a128cc69a708f320b1e2b5ecd9a3b110b01db6efa3784e71da5a4ce38008894" + "address": "22ZB5dM2NVyz13YiuwvW9X7uKABoEbHSwYN", + "secret": "910176e477b73d66007ae2f5d44a7bc71fc21891ad1bbfd988d8badcfb1fdcab", + "public": "036d9ba5504a7fa6f55577ee34b5e8f2e989aab504dca6ba265d26e6518f5fc5a6" }, { - "address": "29ez2dVgABpsu875F64kuT8ibP5FuQR9YXX", - "secret": "715daab9b54a91b212ad236d18f603954a02f5e2513c186c30283c47a405cdf2", - "public": "022c203cc2f2b31eb6a81b5edd16341240eba45c8b0aa5a0a156e0c9c9a8b981e9" + "address": "2RcNdAmomK5hPkrzEagpBPbJKPG1YhfqBZX", + "secret": "8b656b8a83350a408db0258f81c1fff913c6caf10fcb53049be6cdf5f6850ccd", + "public": "03e0e7fd4a33c7e2af83e476ad5d78f5fa91cd8f16c5f3a3904875444f76b038de" }, { - "address": "dPk9z6SR6gitFp8X9jKsiJ8hn14S3SpMkV", - "secret": "eb1b197633f2ba1fae388bbc33aa6bd461a0082908a1a7b51fd79a4ab8741a06", - "public": "03a88e4f8ea0ff30c6b423df6818eb9899959b0a8ecc5730a679d2fd6964550de6" + "address": "mECP2omm6nNKCRbUUEA3ngU83gBtbG2p53", + "secret": "3306fa898776691df724ca8b72dd5ebebe9a166a9f107a281b7e83e0bcf34d8c", + "public": "034a9096445d1401a979fc821bdefa15f44df8dc02ae88e051c6a7b45a577dfc64" }, { - "address": "2KeuehYNgVzQHZpRxjb3vH2VXRtsKeu5c1P", - "secret": "6b057d7a1597e21e942be5bcda430b59db18491824d97ed3e48e60346125945b", - "public": "02db3ffd0b4adccd7c7d9672c6836a917b0f67c2dd1e09ff3c2a4c85fdf4aec091" + "address": "22nsdEVSxa5aDvpFPeyTz9qpcc2h8PLzRt4", + "secret": "e6fe5bdf75d6e4f7aaea16388cf2450fc1839b088c415bd3f7b9a65958c08f18", + "public": "03349d2964d9d6dada8ae6934b76145cc4d92bc43a41edb55d548a7da36530ed2a" }, { - "address": "2MuQsRMaSLTmggyrwoNiwZ8318ksKNgsHUr", - "secret": "7ec6812906756d69baecea4a65c4ef3a8f11c53a82abe1ed7607be0756f1a265", - "public": "034479cad62de92ec439b83bc63719dd269b455bf39da374351ad09eba5c69f78a" + "address": "2gadfsU9qYJSKcjYSbYGjrRXffK9grr74T6", + "secret": "56d995f35b80a3046af165ad9dc0a507ecdafa9a947403ceb63c79a3084be6ba", + "public": "034010692d87e47df712c37a3490f096d4323b0148d71eb06756d1153e47de9558" }, { - "address": "SUrBaXq16LCbCSdy6wpMr4aFTZpXrHTNdT", - "secret": "439424ccb73c4c4fb9a4cbf899220b2f20dc45f9cb9ddc4ca1516f95f2fb7c83", - "public": "03b39c4bd9201aeeb4b600c45e2b644be2a88bdf7faaf697937303c70ba3a1c60e" + "address": "24krePYfSFjn21YTDA2e5FAWZefu8qE8Z3R", + "secret": "493102a3bbcfb4178ec7c1072631ce03f7f3e1d07d5876f07c3902cddea3e5fc", + "public": "03253e2a852b5aa4f8fe11d5d32cb8364dcd5460665935b47138ab945a1b7550a7" }, { - "address": "2gEEX12T7YHL4dbRSTPG5Audo3Cwm6ot4r1", - "secret": "0575f402cacbdf051af527e24ad78da7c7456b14861ff9ba03e8436c77ccd7e9", - "public": "028cba720b34ebff8b67e2222c2d36781c83441e4e379a7e65468f444bfbee352e" + "address": "rcqLsBcsWXHodbDaCLHcjQJKSJ8kD1q4Ff", + "secret": "cc8d395693f126bdbdabb3622933d1c0bc148a2d929bc30e66e22f07421f1592", + "public": "027558c499a52a96043a001f8999a6cd38a3fd2527fccf28d12edbc90fb7641aee" }, { - "address": "22vVtic9ttZba4f4UDv75F6o84YSwVtvyxV", - "secret": "ee8a036f12d963ff9a72b21dc8370e3df7163f4db3ee647efd35b63d0e9d4a18", - "public": "02080c14741cb9112e1a80255b75fef47745c4f40259548a8b42410b653cfacc8f" + "address": "wvFzxVWV9xGs2ppokV3wmpy2C9BcUe3DZy", + "secret": "e8e09e51b8add90be81a392196c76930e876c97cb8b1df408eec8df13c215b19", + "public": "028e99b6990ae84d590aa30acffe4b9a1fe5033cbbdbcd9971022c6e249b43d98a" }, { - "address": "2GvgsLWmUyZ4uw4rcLG5g7P5K7xjCTSoAHV", - "secret": "8f661edc4ed34e5ac7c9334d0081c79833ac2bdcf86c16b118748e2cd6567d7a", - "public": "030724c750dcc46673317b57a8a7dd64b31896aa61cd15989b839244cf8178b51a" + "address": "21124BfJReTshKP7zKthRyLAkjSnvbo3JL2", + "secret": "f452d999bbfbe7da6cf10d8e602a09543ed716167649dbc6b260f218d08d0a33", + "public": "0323535070dbdc40d0e3e5ce3f1f75af79922dafed3f8a3d102fbc891b9be3efaf" }, { - "address": "D7NeFEybBKvBVcQe7fkMPyF2eDVoQKCPHn", - "secret": "a3f454d867ba791a24d47d36a32182dfeecc13031ffd85ea0dfd73cb3a47279c", - "public": "02ef3b36df98b686fd6a39472d47192cbf61d4a7d014f4934b8b7efa364a342926" + "address": "KKqLNqWvbsMZ5sYKAZpXLZm39jZ8zUamy4", + "secret": "0fd7f48cc79b6252dcbd7a24d5f3e4099acfd16368f8f2e7c7db356ad1488284", + "public": "02cc8fbdac02a1050df58a28793247184b810bceeda25b7e2879ccc4b695cdfd20" }, { - "address": "2MmtQiFC95gtswQvHAQwpVmFSWhLUKVhZjo", - "secret": "4c2e72eb40db25a39d58fd68a81bbccacc4f44faf0f2d7a65c23d0325bc15c1e", - "public": "035d3f918c22c4d706f8d14646b22146ce0f0ee9d6b3c09bfe4e9bcf49044f4f44" + "address": "2afkMQHbNM5EGuVPt69yjjzxfPsih4hzfAt", + "secret": "7ef7f98aa685734f83c7faeae4cb687b246c21998d29961d5899757814a1c28b", + "public": "0321f6a774876011ce97bb51f15a35ef2aedee2bf9aa9e5a2be3193d7bdd4020df" }, { - "address": "2DHrx7R2bA9UXEn9tq8ovmWeeTGzoeN6fEv", - "secret": "d08790ddfb4203a0c29c7bfa33d7826061af7835810a9718a2342cbb34a540af", - "public": "03e88414be41fe8e1cf01b612a428f3e18005644ae0ab4bbb3dc729c234ad60ef8" + "address": "QqrvnPdiJm4qg2PZuhAEYWCHo4s9VRzQ1d", + "secret": "3ccaf169d3c906c5475f0d2ed148a6a0bedb23b88df3a16f485fb7a27c61f465", + "public": "031d90572ce93b645673c299b4d3540fcb11cac5137356ebff65f29e47e75bf921" }, { - "address": "2fjrh1bYcbRZXXrdetAG8secwxxPZG5MjZH", - "secret": "1237ce4a852df878e4540d680805516a1b9eec451487354bbd6d57a1df5d3897", - "public": "036c1c0eca8d07f7356b2f615921d0d7d8649dee7959084964e00eec82399155f7" + "address": "26oEbwGTv2tGemBwWvbANw5z9oW1odHLKU", + "secret": "cbdfa24088c30d9c07bf634e84a739773b79bfadea68db57e7e690cdce00395d", + "public": "0320275a12cbc4888b9b0390de849c2bf6811a128212e43c2359fcecd2e5bc3fd0" }, { - "address": "2NGKNpNiHrL29CWj2GXKQY3tNJSqs855unu", - "secret": "5e8f03f02868ac6d0d58241102c02dace8e51fb04bf9f953875122c89e52320c", - "public": "03abcb18565914561f7669de7e55af575d18df3faafbed391e34164fcf804927f2" + "address": "2bNwEBFte5ezxWk4hVB2gSDzh3YTacKYxKo", + "secret": "a216d679e012a931b34ddf4716f4d5184073afd962f3ffd293cdd1974eb5e919", + "public": "03fca51ddac76f423fc3863eeb7681a564f75c16026da6bafa50096c6748bf4dce" }, { - "address": "2hX5HfkHjxg6xAFUu8fqT7A4oxXoCwSgGco", - "secret": "2b7458de55b7bba1e796f77c5fed8ed45afd7e4dc312d66532cad6db66f85dee", - "public": "03a60f090b956265b744a339421c42da8b90f903abfcf0fe73ce9a35d649b06a50" + "address": "2M9Ms8uouj4wVZSd9sJXNFMYMDCBrLQPwNj", + "secret": "2e3757e0b1c32e5c930c27f9ef8a60f8eaf934b063cdfb788370f0f4a0b12100", + "public": "03022caa31c325e86fe4f9f28b7a3f4474587722821c7e0384a7e05b7aa6a8e72e" }, { - "address": "2iUrKDetv55RjsQw1jhVutR6wk9mKAQr7j5", - "secret": "55d76bf69ba1e1c824c70634b1241099b61678196fb2d75db44e35ec07d1ce1c", - "public": "038ddcb464b2c6dfb0ea15e422d39e90eb90a01e996d21925a44cbeff6c37525e6" + "address": "ZVD9KiPi2BjuXvqa2uVSUz9UVvyt6bCin7", + "secret": "16d14664cb9c65122d76a74d8fcdf542f5a4badc4e63da12f9a2e21a49364142", + "public": "027044e66f79defc67e06bcd5aab6921a985c1a78e5f9c965b2b8b576aec5be7a4" }, { - "address": "2Ezbykzfwga815N99bTsd5H4go9iDuVxM8u", - "secret": "f63b88c0b3e7a1f0042ded585e7912932d46a14e682d2f4095f2c610c3024ac8", - "public": "031f6fb1747e8ca10a0f259ff011d6d1e3156d65ecfc92fcd3052c3d813d73c459" + "address": "EWFzgYgdjU6CVtPXyP4WrwMondHoPX9VSi", + "secret": "bf6f0cf4e0786300a07294f18d9c0619ee77e224274ddb0b4c74ef9b5ae12bec", + "public": "02c402d13f5bda635669b0b384e2a7f937ea3668d14c6667472fbe974027f338fd" }, { - "address": "LYe8WDKVvxGTihbBtXAYQyciKzhVArYSji", - "secret": "6e7625d5d89c7c4e84ea93984e420e3be9de8ab66baf129aff9f2e9b60e01263", - "public": "03fff7ae25e8faa23bfaca10fd5dd01d3df92ea948bdfd49dd026cb9279de6cd68" + "address": "frgeQ5LGCQiJdqbBPmzJrvHf7osA95iCN", + "secret": "1b533323661fc93337c9a09546613f13f10c0dedb756a935791336b1c847a012", + "public": "022dc106b9222bd5779688fbc75010ee6f24d9491a7db1dea0bfad969d27080483" }, { - "address": "2GbsurQ6iZ8mXBrPLWWpbzRySAqHxX1ZEjE", - "secret": "cae72282204b46577cd2da677f65eb1987bd465e58e81ca640b189f0ad8642d2", - "public": "03a741c89435c4e0d60ce54b82900fe2d51333628f9a0bc721f1da3b9004734cba" + "address": "2Ygc9Y4SWt6pErg3smALUqb4nxe8y3Aa5SV", + "secret": "5aff64e7ee0c57c08b80c66d91c5db5d0892a7a182eaaf9fb775eb77d128e731", + "public": "0349af83b3db967df7319957aad339eeb85550e57835f4acc07293e2eb353de8de" }, { - "address": "2AxBjGuXTqicNp1bvEbaB9wnkeSRcTx68h3", - "secret": "b091aa2a175009c78d96e21f4d3ce26a21e6d04d1065f984f55bf0ed8da928b3", - "public": "02a7e6fe0e688921e508ccaf5cb56f856635374cd3c36d49ff9958c07d584ffa1b" + "address": "VZSQ6ji6oeLZgxd5Nzzt67JPUFzm9oXa7D", + "secret": "bdcf7de5460ecaca02d4e485892a4858ad4c4a7a17d57fdfa8f311a0a3b386c2", + "public": "0335f1138f086f04fba73c261ddbc263f9187454b9dcaaac91d2f628ff64e2d7fb" }, { - "address": "22jMDQUEcG3jxdHhpSdtD7ts2g4HbWttFgG", - "secret": "90b65441c572769f94c5812cd0356a441c796b46714dbf3b6c6ed8a0139d9cd1", - "public": "0285f2d967b782e9dd3d1fd926448ce87567aaebea5ddb0cb9628b4d2276ea5e04" + "address": "2UtPuf7UmE1RMaKaRnQnsUmHsHmTyv2GCqd", + "secret": "33f62c9b2d5984aaa7df578a2d8109a010f400b522d95294dad79d0579b69790", + "public": "032c2ca487f68198688cff80a29f59ff68dcd659082b8b28e850343a810702b6d0" }, { - "address": "dh7dRRbLjQQssswmFxjCPF75PYY6nBykpu", - "secret": "922cfd120c3bef19fd18891a44e572e595eb2f9e290efda197cec9c30993452f", - "public": "02abbd8ac6eaf5ced8b5f15d4dab519525a3cf8a6c01f796a1f4b4c446dee9dc27" + "address": "CQNjG6VeT7XLoFd2DHxj7Bdu1ofdkvf9Hz", + "secret": "0d323574b86731c76d23912641b4272aad76c610641794f6008de85245d90501", + "public": "03cdb086cb3d513a001501591289093bff66c0e4694390b120c9997af573789fee" }, { - "address": "cDVZqrshu2tNjrAoRxPG6Fx5CmW1pYmNuL", - "secret": "99a51bc539133c72286184560cc8fa1557943e5ce5e8653582e7630978db8e1d", - "public": "021edb72fa0a5f563d04c0fe0c807f1af12e975e8b0ed2cd8d972c2c75aa1a01a7" + "address": "cFhdRpgfDXFD1d9tzSGTDxVkyexiHHbscT", + "secret": "04b1bc8cc808c62c32ff387b2cfae435b3fa48e6775a98cf564e5c77d58c4d80", + "public": "03214b11698b52fa5efea3549a08c69afad4d14d2e1949a267f29a7486f40d1662" }, { - "address": "yc9wGsqVYaBJamBYLZ6HW1LZeE4xphdNCY", - "secret": "ce50808050c736e3d80b973463535d33f05c3af51db6699c1f3581baa698acc0", - "public": "027df9fb9c4c90816b925981697a7b101fba6577a52c1b4e19b56a193cfc8b4b83" + "address": "EPqkNxDnvQorZaKoEtjGcGKURNcywr3dny", + "secret": "de6c09ad0b43723096aa1b5ad133a194954793f2005066d2f3f7f629bbd14429", + "public": "0285584deec2240b44f3ba9fa9380b39aed1582896e38fe0c8254bdb1e14bd7f0a" }, { - "address": "zE74psA5e4xHSRp9qKFEMKhuYHx6Qdm1oD", - "secret": "0ae280699091c78903b95ea7f94103c308214db5b2eb400daa601243c872a227", - "public": "035cd0f81d0138b76d3d633ea2fb2cebc8d3b5570c7d8229e63c173724495ee29b" + "address": "UhCE6NpRtm1Bd44MkPgVKToavRRLqoJbDr", + "secret": "3fb29d455a7d5917a88f001aec8bb44ea20d17d7a68019b4e29320cb1bcd4561", + "public": "025c453cb7b8c4470678976e1e08baf10852d9b28a5a21b55376766f302af15d32" }, { - "address": "2EpQZsuMxzowYwvUYFL6tafVwbbXZ7gVdHu", - "secret": "3d851ee68e121e154e03bfc8339832241fe8ff0626d591654ec55f218b3dc185", - "public": "03ed61fe9ea6ae34fe267a56d46f12db865b7f840b461af7e1ab6564cba444d212" + "address": "j6rcr86aiDCMtHj57zQt3f4MkG9zoscywy", + "secret": "1e05688f0796d4bc347a92bac8748bca26fc4cf749836672d240fcae8b8ac467", + "public": "038b8875d803161483165346766f9a1bdea5b123b38d7705538d6a1d8d5cdf54c8" }, { - "address": "AGwJerajMx3knHnE6LT1hKH4bJBRzVwG3C", - "secret": "9911bb3715543f2577d8b8812a57047f588aea83dc8b53b99a9cc84a4048bd09", - "public": "03606f89b2bccc73b3aee7f4a3d1fc42c7606486275dd17be38b6ccd5f4a553846" + "address": "G8unj5XY9mKMjPZ66KNrADKojueP3FxpFV", + "secret": "4eb017d642be8864dd5c54d0e81d4804fd588361fa14f31b099cb5211a0b14e4", + "public": "03c0b736889e8cfa84b9fbbe9053f508a5cfe44c6148e0b575cf0d136204adc9c0" }, { - "address": "cQeW3GTLiw2nYj6S6oAoLwrBnpuzUeLQQd", - "secret": "58287050a231d8ddc0e38aefdfbb43888105122f5949ca8ba7c2c36f1283f009", - "public": "036dbc2ed6f2521465511c458a1ec6275d92f17eef1840c505d89118d7c479d144" + "address": "iEY1wongyqqfMMCwwKa6yKnrBPzWRv6Cjd", + "secret": "205d5d8cac7ef46d7049a8e360b5db56690c939178ca1cd46db8a686d9f2ca81", + "public": "026953569b00b6d1545899246f12bbace2fd78f568a004d0d08ac61525c0eb8e10" }, { - "address": "2be4hXbGArUZ9tqCRwxCmtXVtXnWjsG4frR", - "secret": "f99e859961dbc65607cd59b95b140e992756d2a19a389cc360a355aff7f4e6c9", - "public": "02647857ab188c051c4e4c20adc1586ccbe20c5be5d1dba94debb339d18af0c0bf" + "address": "8MofVFHLEyfDbybjEuj8Av3tvtAHm7aB6i", + "secret": "b88a93973a8a62453a83c10e00817112922471d2270d1cb0c8490fffa98ff4a5", + "public": "034abbe2d59395e30fa5e769961bc54beaa08598370b3e85193a9e200d8b18213c" }, { - "address": "2eZiyr3VyR9WNr4e1eU4UaSxHh6bGYBs7dS", - "secret": "04f20c48d8e2da2aed7e4691c8fc91799534e6537194a31825092c6b45114250", - "public": "039bd91946d91b6416289625cdc5a8320711a484c12fc59d4fbb78efcab6981f5f" + "address": "LokNHE2zyrZgjpXXWrWY5L5BNsXR6qJR6D", + "secret": "fab1c44ee39d0839860710e49df3f47b35d48465573c0251bd844fd90a6366f2", + "public": "0251740aa6f68cb3290cb0d72db8d9c03447bc747da7f272847417cc8e40330e9c" }, { - "address": "2VctbjWqRS98PS2ACwfvwYrNtm8Xh3ycmRy", - "secret": "b0941862e4919ee74b4f0af4b4ce8b405effe2a9ed887d397931c5c69da19a3b", - "public": "029df85b142580e9aa75f7b7e07367e7062519c796ee55e1c35159b627845eaa69" + "address": "NXV5XL7rggQ8GAPDjJ62jpXkYGJ8VAXSba", + "secret": "631b5a1fd96e7a99ebe33d4788a8d6e45a6d4b116b11bac53aadd116f39c4c11", + "public": "03670833bc074d7009dfcd1a61cf5b63a08ea0bd58f0f295121b8d5825d897dba8" }, { - "address": "24KuYpRLxwTy5YuaoEvp1rBbB5bAo9YAzFA", - "secret": "cce50d93c1d7f02078c8c057e08ab64c5d19fa788b1bc084ec3c21202a420d0f", - "public": "02fe4e44978e65d05047c1ea283bbc77b2e398202b156ff987b70fe04f97aa7080" + "address": "frEtjtXJoKyuyq49akz1Zx3yLMpni5gYh2", + "secret": "8d50af61f21107f572606d21c35e453f997ec17e941f2b7afbc051acb36283f2", + "public": "038daf6200f2ca021673a6915e57b4c424ab2ac1c1b749db8dc059607d2092b1e3" }, { - "address": "e9Trge4emLSbjHtYLbSJ4MKNJZVgBMqgyo", - "secret": "8a4783addf04077424f2c11e2870a6dae637ac65de3eb45dc72a022a074ced19", - "public": "02e6f84c8ed7d531582afd139c2b43db4d7b9c1b5ce1ec8fab5f3d4c46a3bd8ef1" + "address": "2Fp1fioauYwyMikcL9VphTrG72ZBwP21WF8", + "secret": "af01bdd50bf4187bc8fd855962fc0a68ba55b3950d9abb192ec7b5179638e045", + "public": "02619d27f77c97b36ce895a9ad47339ef69a9f02a6953379d077d078ba7bc6535b" }, { - "address": "2QqEi4r4pES7sK6acTrWJT4YerMLfJMG3wZ", - "secret": "57e7e381e2a174b73b81d397a3c8ae77ebe64d2ddc124daf3e51f7644189536d", - "public": "02e8ddf911bd3c9ed5151bc7c5739cdda583e04cc1a124289c7776df7dd67e9113" + "address": "PeoTufGJDpATgy7y5fKUkM9xoL8tzk4LUA", + "secret": "f8c45f4c7034fff54f2c8f2f2b8f9ea356b299c73a66a9979832ab7e162ecf59", + "public": "03f4f3d208cea7bb257b6e6e84def31a26b22a2375c9ed50e0e02041ece9b09f50" }, { - "address": "2Re68nir9gn1mQah8sALwwgQgpLv92fPMxA", - "secret": "19184cbea175a83833a64bc9391d31b4f817994e08982040430ac8c89dde4276", - "public": "02d50d10790734afeab67124c8357cd5cda8da43714f73d7d04d35655797618139" + "address": "2avexrXAe1yFcmEaFSMpp4E6bkHDyonTg8i", + "secret": "4f62ec6881c21bc8ec63676b124ce103a59d2acfac567827d29d9f3bd8015562", + "public": "03e17e14a0c2691b025b2a07d63ac21fb28451db69d8e18904ff8161ca6bd93f68" }, { - "address": "YeH9bejYCm9VPajWEEQzNvLW6mAYLuKUhm", - "secret": "72ba5907e953d210c4c4164a8dff7ae3048d4230cd9ebffeb92a5a09b9298de4", - "public": "029b283f57e16327b839d7441127bef3fc1a078160c7c8e466d3849c925654d557" + "address": "pwNab8Wa7Sag9Cg2FmEDF56izp8mD7kzQw", + "secret": "fcdf5e499b22ec63290dc2c680f87745aea192abf5aaef858c007e946ac3002b", + "public": "02ad66e1ecc629d989a0c80f81997906f5465ab1d4ff908f02f23e8a96cfe00f50" }, { - "address": "mz8rJDFGeuULpBphAEiX9w2z4PtKuQu9pm", - "secret": "ee8bd6d699aa4219f0dad54b1b4b9157b7a2f33109f2674f09b5554fea5490a6", - "public": "02bb114d0ce0f41270bb80167b99b673ac0b8044c93f412e281b0f17d2a15e929e" + "address": "scN5GgoA6epthFqoXEKc2Y5QZz8jyT9FNf", + "secret": "24decfe6e2e505c5fb7a9a7a6608587883554ed81bfdc581921525a5a23f6305", + "public": "0344f0bedc327fa09c9686235ea3b2139c07259497264c2b4461cedda3f55399fb" }, { - "address": "Hxhg1VT4rVNokP9aWp4a4ftFFDqXWzy3uz", - "secret": "0221b98f0b29be7a2cc09fbfcece5a9b7cc2c90279f96a301c3d80d111431fca", - "public": "032ae8a4bdc614a822edc5eb774dda002f1e93d743e23e41ad11067fa1fdfce2de" + "address": "SEAR4hqpuvGLPVoGLpd5U61aoYHUc6jNqG", + "secret": "b5093a711d22263967e5ce2b2aad751e6742cb34ab51c8d517a328cb406cf801", + "public": "02b5fd3eb5a00f7bb172fab386af63c965e72c1874520fcf2121bb3bb96988f68b" }, { - "address": "2m3E9itHzcVfnm4caxttVZLficvgpgBfcUE", - "secret": "2e3eb3b2de8edbbfdbc5a0fb5b34573ba83a0364eb153168bfb12b572e93aa82", - "public": "037a2d0b5237a791a345fde1f67b74a9a7fed1edef6922054dbc44c32adfaf74db" + "address": "2agxCQqyVw2Ne1n4CtBboaWQ3YjmhXaocdh", + "secret": "ae897238f5b80a8312437b2335442d83c695feb68b44482f5bc2684079ca40a1", + "public": "0294e9cf3b98d6c5386dee498da50e2a0fd28244d9edc82aa0aa3212c4c0ef06a7" }, { - "address": "2arqNej9AVQebXHgaufZE6SiMSVphZusjmV", - "secret": "b3d3cb9be241e0d75539fb3000797f0e7ce1e47d254f048e1c348f0199c20761", - "public": "020be04dccc687c773c239985c8b2f214c6332d47ee2315ee035278f8bf4122fdc" + "address": "XoHShPLTkcUeFqiwSEfRgvJnHHKhNYAHc6", + "secret": "bcc65eae057e0fcf3e423255a0f5ae2ce146919bb707dfd4bd3fb762fd69d78e", + "public": "03c740e434cf3614b53c2788274f7a356905a8a1a27725d6ae9e67cb1a006027cf" }, { - "address": "RayQdDyiJkvKzQUJp54sWQTDu8PW6HLvC2", - "secret": "3a9776ecca48f90949caeffcf16cbce71ec70afc66fbfa9f2551f03731fed4ec", - "public": "03473d067788b5b7419c90ba4217eada707bc39b4046c6f4d925c51160754be568" + "address": "2hGNn3KRW1Amg5xWEW8HXDW9pNhdyvp3Bxa", + "secret": "7b39b68fc581a9bd7d759a74dbc1d7beab35e0a64660372ea1d598ced36d9ee8", + "public": "02a8f5bdc94366497ffbdf88fdc423b51718947a0a523ec63547f88b1c10c0382e" }, { - "address": "BQbLFtQfnXjxQoHwD4BndgVbdr2Mx8XSnM", - "secret": "2c91c225a4bada25f07c7d42e0d20ae8fab62ac22b2425d9ce7b76bf5dc973c8", - "public": "0337df5c2b4094b2c27b05738efb1137ead150dcac45e29f2e773bbcb7a401e1ef" + "address": "26T57mqYiFif4KBVW3N9w16RGfSg8VP9FfW", + "secret": "c71f7cabea5b39352997f647f1481710c13ae1a29a06f01480af3cab1e6b2f8b", + "public": "032f0a83a1826005975aad6e23c87088000bef7fafd11a52e1dadfae590e859a0e" }, { - "address": "2Nn4KuBKV5zReezd3PUoZzkWkgGLu2dFNX7", - "secret": "4d846cee3ec8e390050d8f582792bb799494387d29ce37d5e60e96baff162033", - "public": "03859297dd300955a823bd2ec174d8eec1bfd950e20d1c3c82781abe39474335b1" + "address": "2eCjgi3o6eTNtj5fiTs9Lu7CW5WMXWZhfXN", + "secret": "8d6142ee69ff6eba19bcd25fb16f1c781a93d404385dd9b90e85a4881187797e", + "public": "0339f788c880d61c3f6fcc23e0e90a1c18f79460533f392389650151314d59058b" }, { - "address": "dgd5oLVZd7LwAbVjVXpbzeRTxAp6WvpasH", - "secret": "8ab137470d0c57926d51408633ca7a86136149cca9773ac6fcdb0085519b3245", - "public": "02c1fcb962a929e06819e12bc395abadda97ff3bb4250db3d18359814485db4b00" + "address": "22a6YptFqi4MjqsDjFp2L3d5ZGV9NDuczfh", + "secret": "865f1a3d7d1a95b54627dcf64e3677cca758a7cf35aab7389cb2eba2ec6607d9", + "public": "0266e102621ee4087707692aca8cb858cb51ecbcb5579b99cb2725749674394766" }, { - "address": "3pHd7FqDD2GdpnHbcpNtJ7RXXDw2DdJpDV", - "secret": "c5e05935261ab43f12a709f83e36349ae34c3062b0356010af720ae3a93fe2a0", - "public": "026fb0d400b0d1f905f71167a35a5a1229a69a66c0afb829aa643b1a1217dde57b" + "address": "2Tzi3mCkXk2h3GshRuw89zcku2WbvZiYXmf", + "secret": "1a4167d782b49faacbb3c89994bad131ce61850641f79e52e4246bb1a05bbce2", + "public": "02632b4a6bb063f28ddf1034ede2e900194dc1d4d709c33672fd33070291f53d3c" }, { - "address": "2ETpRgrRsbfvjVGjqEWUA3wHGZeBvnAHe7c", - "secret": "29fea709bee3587fce0b933b41ed6c38499685e581f0c31804d79aa55244842b", - "public": "02be2d3aff0f6b8dcf1082b157a1d87a3423b451dcd55155c0758a6269c1dd95db" + "address": "9YRxCxLexL89oe8RV2SFCZy4AQaBYXAsLf", + "secret": "253249e9c22d9c28a110be2d8be3acbdc6a3d04bd001a07aa6759a3be2a4c591", + "public": "02548f69543f4622659ee0ef77db503e734112813f70d3bfe6b4223b395a74364e" }, { - "address": "bocdtKyHpvsCHsvV46akAK1vuLjw6CA2Fk", - "secret": "0633223f6afe8a9c5cddb37b4546e77190cb94723966383a426a20071bef1287", - "public": "02eda914692bd9c21a0ee538297da0dbc6bc4b2ed0414e0a9b96443c7dabccb1bf" + "address": "EXAHo74kkrdfFnFTEU6zKSMubBYyY6ZmWL", + "secret": "1a5f08c53c600ab5a52e948bbbe77cce9ad52e90aa14d16d78938fbacebc2c4b", + "public": "02cfb2fcf1ff02fe24d210df86d12cbbdc81429eea6613824c031a8da77db2065e" }, { - "address": "RikEcbhsC9KwX3oMtu8np42junsJFUutyG", - "secret": "1ecc39159c7ddfb28c4403a1fba3b11f6f8099c820e47cef9e96220c6d8ece2e", - "public": "03f2583cb72e229858931c9de9c1f504c735de9969c082bbb854b135ec662300cb" + "address": "2RRBNvJSxReWxHRTqxHoUs8gMuhkBAvQaVM", + "secret": "4ad2c6899bdad0d7a8b36ae0ba0fa22cf6713fe48a454327ebafd2a2cee2bf57", + "public": "02835fe7180f085ed98bbb305c84470d585a391a9b53cccb344f26ab0591efe186" }, { - "address": "24mUdqq2SDoYMpk2w6D8KhLaLUH2fx1rRjq", - "secret": "f904d747705f79788d99be56a23f8a710a76b816f6ce1c2562c793838ddf6d0d", - "public": "0240cdeb516de6233ad29d729e8901913ff622018a755d9f6d19e2b4e5bc855194" + "address": "DLLAzoNAdSqmjoeHY1Zs4C8cF5TsVrhxMw", + "secret": "436f14e457a94af30f1064a3ebe4b925feb0bb08728b9b37ce6e3fb2f048e6d3", + "public": "03e6c236453466b1c7e7ec6edb05d8ce526f9b34ed696526e39cfa0e7974289043" }, { - "address": "2kwkfFojC5kSj71yawE846V9iKTnT7uqoHp", - "secret": "53368cfbbb62ffdbf19767f9dfbf89ebd110f117be2cd197fdf0844e65ae5aba", - "public": "02d3ca90f207cbe8f11e8a3503a0b722ac16b6976388cb6333925c07524943c690" + "address": "2g7WeX2ieVcucWtFhqVouh2U34VT7jBTKvY", + "secret": "6c147b748cde69b07054d13132180dff1e2968ec311727c3d5b430074abcc53d", + "public": "02515f6a52401a03498092aa16c0fe94725030545b987e2572c5700e91c7dbb7a1" }, { - "address": "UJjAc48L3o7jn4SU4gNoVq76axSvDk9pSZ", - "secret": "94945e21611a26bd10315d961bb629ea0369a61e2a24161ad9b15ca2015e899f", - "public": "027514a37a1d37e4002fb565b25fd24a5e388e6efbcadd6d9cdfc9d31f0b53a059" + "address": "27rnygUUorp69QkwCHqzy5WJMc1hnxoxN6n", + "secret": "2f0606e012fa536aff11702f3fc192550abbea7ca580f65ff44013f6e6d2ee62", + "public": "02ddafc8f9963dab80b74c602d49a42f9ae8fbee1ebe9c10d72ef00284c563527f" }, { - "address": "27eeu4ZHMF5YxEE2fPgnPbQpDA1vf56ACdA", - "secret": "355ff4314d1f73e97c092d9baade32f3ad5bcafba1a8a90d2a33bc423fd158f3", - "public": "028795e0b82735f195ee1fbd83bed035b1bdab2de384b60e71c1f59a0dcd3cc3c1" + "address": "2RcdcDLnqB9pvNPy15MaqcSNjFjZ3ToYQt5", + "secret": "0fd61a8d1265e0479293983b5b6628867fd99f965179e5d51901c602ef2c8671", + "public": "03b9420f1acadb53799c7bcc7693d1024e45b66998821c957abf57def534c82d3e" }, { - "address": "ULwkCzCxtzz2cSv1mFuumb14cU7fJGHVe4", - "secret": "da6b6c65c775057cd9c758c4a972658cd8f84bcb50525983d328d807be187fa3", - "public": "036a2ed3a2ec5c7991f46a005c10f554e5260ddcc941c8dfb90ada4377034469cb" + "address": "2L4E53nxkgMtdEJMVEetmEqN8VsH8bvN3qL", + "secret": "5bcf2fd07fa946483b0bff30d0008398e584ff001093e588c99d4fb4303a6654", + "public": "02cc1fd871d6ad834a8c7997c38b1101b7bb781ca886add7ff39032d7e11774031" }, { - "address": "cvgSfTxA3DzD2nNDLknrt34ZXj2HjyxtQT", - "secret": "6fdefef9a4fd3101e187b2c823516db0ceafc54dc379fd6e65032b723fac319f", - "public": "02d27c8f2ae50cb2407f28d7012e21f8bfe37bc5674427df47666b8d3898571ae5" + "address": "nasKi6MWvCCyupab4SoScbhxJDYyzS6NzC", + "secret": "9c3dce71afa6edd50d843534d0d5bc755c36e0609ebb4d42c14f144d67b57867", + "public": "033b9a12e3ac267d17c0ad1fcbd0e6204d57f021cdc3e7d63a186fb6b46c9a9344" }, { - "address": "27pmJnDciemqrPYydxYLSXbkqs9Sm1Z8nSj", - "secret": "486e829ee12dcc6897e7496b3308e1da6328424ed73e7d5eaef37e24c7fa4529", - "public": "0324750a5ad402a14d6687a6e47c3570c77035c66ef60d36d9e54901fc0fd285df" + "address": "JtrbAukxBVGesZgcuU46nqwYnMJxSvS69w", + "secret": "f6f2398e745d764547fae8d939cc137b21f0788f4bcc2b18aaa98ce9b5bfe3e6", + "public": "028a5936ce42aae51a92e89ed3d000b81e186892e3ab72da8ea02f36e1a09656d9" }, { - "address": "hJUMwSvfem36G3PU2pXGYokZoFimCT6Ewk", - "secret": "390daf4559833b2c6577a9b99f13cdc8f998e5866a46a6b1d9236b521165db26", - "public": "02da4f52ee8d4dc589570dfc78df53305deed647ecfa3f867fbac203d9c5abfa15" + "address": "CmJZiinFtNVFsFGCo4ad5Trup7DBmehmB1", + "secret": "deb89ee1539b6cb4ed4a3ac1153f6893565b4279d9aec526651e712a02bd29e4", + "public": "03b3ff7fb687b17b45178138fbce9bba96f1def5781564adb5964bb5c1d292f2da" }, { - "address": "VCFskyE28mBBqDYNGh2DUZjeBVGsHqkyDi", - "secret": "a97fc559f493f5a0f7783f3b7756cc2dea40f6dda263fc32db1f840c62c603c4", - "public": "0317e8e73b9a5ab3b02ec4294f07f16d6d9540e4a5e8c291d734aa32fb45899710" + "address": "28t9se5L397uuatoiv2y4q65ZB73C2dxRRw", + "secret": "ac33995bc96e8ff83a12a49b22673484f8c3f742e2a9be2ccb74739d603e023e", + "public": "02863968a7c079c5ec060dea520c87396a60b840d7373cb6ea1a1c250f8e273031" }, { - "address": "27ZqG5TfneveU9hxzjifgC2AogfbHrUSJvJ", - "secret": "3d1f32623dc0092ef97c679bd927beb786bf946ddc98a5059b98e89b1f972b45", - "public": "02eb02b0bda767ab89fd1b8e0174670c2b29511343cb3dcdf0be2adc2c47cce14c" + "address": "2bjyscrwVN6nSWxM8L1yhavTY5326GUgdMU", + "secret": "54faa9a7a42f6159ddd56d8edf97acf1004129786d6e7beb88e0c7471ca32c67", + "public": "023f441a065b9026c6574ab08869d322d1dee79cae99f7bc1b71b98db92fab567d" }, { - "address": "2GNZpUYAUoH452Suo6kcYxdiLgRphkCvF7w", - "secret": "814a80b1ede845283a919eae6557d10ee981da7dcaf8c6d85f80a2a547cbd5fd", - "public": "039f8daa8c157e609ce8a635a983458572c7f8141c0f6acb68b6f5c5d66bea1e38" + "address": "2fmezc3WLhTCwfTz5AG9C9s7YtmGaisLSLz", + "secret": "c2c7d6d6cda61f543af9793d80508bc62b19896216039ef946d8ba68fcf84798", + "public": "0290d8e460b751e0cafe38855a130effeb6f090a0213374b537d6759c617ff4c68" }, { - "address": "2U51u6pyC7bSLjqzKzTQEeiCK3ja7s4qEsR", - "secret": "cc43db5950a3b2f65004cd653c8c43a4797f42b4c9a97e40e105380f107ea137", - "public": "0282066c26454ca8954cd2ca8017f838c83f3d911262d6bfd9cdc45e4bddebb4c1" + "address": "2PwxALhCSc4XrgRCMknLxFWMoRwc8WYF2cr", + "secret": "c7c3b8f070204163dac5aa2b4318181540662a63bd4f0ba14906e44a6337fbd8", + "public": "028af1aceed2ebe9cf27ff522fecf8136c066d6c6c3af1e4030c8f9e124ef71602" }, { - "address": "HoHf9ABsBXNmsNdt1X9MjyhhD6h443c4S4", - "secret": "8ae9f806c1c7fec5a09dfa97c4e1d8c53d88116017af8d970bb18b4e6a35d3f8", - "public": "035880e900bc5f7c4c6d362ff0adf6f1789be1c2dbbf874b8f76efc6c51ed004e9" + "address": "BQFdx54A54kcGLx15CGi6Ffnaz8iCTksfX", + "secret": "f7ec3ed86093aebef546cb068c0aff22079f84f388d16399ae7410d171b8a095", + "public": "020310b0d4934d5f28db1e6db364392d3e71cd6e31b95a94d4bd5cc23b7d9e8c41" }, { - "address": "ZPaKGuUuRrUeq7oEePvWEytWpZDyG2zX2z", - "secret": "99db768146a476455d3ec274e927dc8edeb14d394106b3ea18bec960cd8ceaaf", - "public": "0263641654766ef476b19af3541de7463939beb4778ab6c121d167e00b0aab78da" + "address": "UNEV8oNtzoUHHTRuYSZs4uMCEYZFk8Bob5", + "secret": "8e0c7f3926a867b0bfdd1d1b62ed3462f9e564040f013039ee4e94c8b7519512", + "public": "02450766db9e74917020297e0e3d509a584390be68fed4ee488362734f075f38d1" }, { - "address": "vE3rrkE1ftTxB7R8BK8SyfNbTx4wp6XiYp", - "secret": "8c03256c98098a420ba1abe1478245754c5845506ddd4e45531b9bc91b243737", - "public": "03ffd1aca15bf76477ccb234904601b725dabf30375e91548255e5fdafd79f7337" + "address": "2ZMV9ShQLokk1HTUVhqzR8J9tABBxnzASnA", + "secret": "ab2059ce17a55d13e96137be6838b108105d561e6a888116550d0fbfbe8d1e31", + "public": "02d21a40b09a09dbf8947f67317f2262d2c72fbf0a96c8f143c65a09355a3b96d1" }, { - "address": "2GQp1BK5Xuqc1AeVMwsAQnuEgHbanSDEeMu", - "secret": "0604adfcce117038260842ae3cbdbc39c8f6e24d588d917b63c1258af74edbb3", - "public": "02bed6b35ee4f851641167d48311b4efc87647980d28bd949d4fd75cafc492bda4" + "address": "KeykKcYHZy4WKXXsEor6o9PuUJFTUVXbz4", + "secret": "d7a282eeb2a7b1182977013d3583fa13e80d955be8ce2cdd2125635812a79a73", + "public": "022d38ed4c43431b5ac35352b2aa5291c3754075a232b694a6e06740be7f2353c7" }, { - "address": "aFKEm5sPYgZHPnYc64zCVvPYU3zxDw8Btd", - "secret": "645c1de813fb9800d60e41f30a0aeaead3fa8e8106bb48f3f3f488cb9ede7064", - "public": "0271818921010852628dc91a04f9ac70d599c333c99968187c95f990c68e61fccf" + "address": "irKDBpNkRF59SEC4aeJ3uBnGfsX6T991dx", + "secret": "be96ac4a73e5aedd538eb1c38bdd31ecd4600b1f4987bf64128bede52820f02a", + "public": "0233d41add351854a597a7fd80ba47c5124ae8d926c3c24b531600c2e4f9688275" }, { - "address": "2LtUy9uBa2xPPiCn8WsRgsXAwmjesHtwkYt", - "secret": "86798e04b122f8fd18ecb28a415e821dbac3d9c111dfbaa5cc07a5be32feb221", - "public": "02937b76b18252a863c31b7fbc3b4223838cdae75dd9529ff6ba76d60c0e0b2c3a" + "address": "2LWEVDkftAQjJBgaW8MPPTrijdXyH4wGjEn", + "secret": "f6639cb6b9a3ae2cabfe37404110cb17a0787fd92a109258a6fa19b183003764", + "public": "0381f5570ce75b62b655e9aecbb02bf5376adba0e91f21e893ea92e21c8a50bc2a" }, { - "address": "2PNE4inDPgMseGcNrALvSkDP6U5pR7fKjXW", - "secret": "9f63f66f385f0ef7878f5a3f8bdeb859906f633344d486f81aaf88b90c199e25", - "public": "0316fe5f63b976fad39b4108f252ae4a2ac41f6a2c7a97f98cf323b71a9aa5f24e" + "address": "u7uJsj6EsCd7Z57jQnGQNFAis2YiyoeuuM", + "secret": "034d44196c5ee1eded33599fb1bc8cf205b544f86e8947afbf49a868d081206b", + "public": "0245a408560b1f747c86b47033b083729f5785ef6b00cb37fba401ddc4545384da" }, { - "address": "29znUse18ZYGysmJpfsBwMf5vcBDGaS7dcx", - "secret": "586583a623b782a838e2470038e71ee081487d3083234baa994ef521636c36eb", - "public": "02c92ef458d279462c3bf4ed4914adfc1b7f30ea25c822a1d1a8c3082f853fc0f4" + "address": "EuuHKQUFGgHN68T6VkssAwNxP4e1htMEAU", + "secret": "cda4c7df62d18d8ce0141c62fb52f05c7a987706ccbc26fdc8a900836711772f", + "public": "02894d1a4b8e222e1ae067c20567475322f925dfeca1405e2e30b845e3ef047756" }, { - "address": "xju2pK7vVRogonGb7rsMJEUt44D4MLyLqf", - "secret": "db618a70f1c7de671dc665464919c316e4644dd4ffdd4d37098adc7464bdcf28", - "public": "02c09eb77e065f0cebed6adc5dd9864331953ad4a81db242705df0e6089d23bd92" + "address": "TFVXLJKgoGENxDPfiNn9h1eXWLbER71Dgn", + "secret": "0e7d7e87f806b6d5e1063318268fc1df380d1e0aa13499d2b7e6034b89e94943", + "public": "033e8aba7f8c579c7164aa2369c62a3cbcb24bd0b49bf5339841d3c42048405a38" }, { - "address": "CiCcW1j4jEzbEKo8wLWPvPN1kxRAg5sPwH", - "secret": "305a5928918dc1956ed817b4ecea7cacc210a6a673a00fe0422e8f51f24cbc4f", - "public": "022479e3c61e08d0290da0a756490e630952aad1d763a2751254e2ec718e5882ae" + "address": "2bFS9uBumCkSkFhbaV8q3dYnNxx7725JVDV", + "secret": "28672a34711c4d818c8feb835dd2198e0dda20d4dffeaf78dcdffef05c991370", + "public": "03c88bdfb32a4c8932ef3b06d066495700cc5161886f6350f7dd46469b56ac3ca2" }, { - "address": "wBuza9TBmKRdT3gUMQyHAbwSiqq9NKgEGB", - "secret": "0c9269987fe8f16393b4c9e6292145e5c070b1a2732a33871931bf921decf42c", - "public": "02b81a5acf31c4e56fba5ee66dc0a57a87e34d7ff005bfe5f2c668025eb0f67763" + "address": "a3QUbyUgZaXcZtZPFm9ChWNt5DjYgo2wKH", + "secret": "dc644efb58c344e4f999080d7d8847ff159710c85d0726b80036c47e336a0ec0", + "public": "03494aee0e1406ba2ebf85de3d3fa5cd19877e81720be24140d9d703eadd14d881" }, { - "address": "CWjAcNJWxWWktnh4smEJWsNjdetbaVXjbd", - "secret": "83191d9a479596487ae91cb64663156ab18f45f6ac2c73e02ea2460e6416c813", - "public": "023b891d2f74211afeb2d747aa2de960c7ae1d3858e73663390466e1489b377f33" + "address": "2NZGkbUWx7CHzJ6LHTf7KpcDJNbMmM7PG6z", + "secret": "5d4fa6c7fdf51ef26a9095245dfe6ad181f5284d338cb5b008e38a6e07399b68", + "public": "035492a39daa2b6abd7530b5846e06fce0ff45f69f62ac722f0e315a092d377923" }, { - "address": "2Qa2Z1kgES6ExgwNc1zsFMVPgNBRh13EJrT", - "secret": "748740fa2c3a8167956fb4cfac2e52faa986509a1e9c26d4da21255d2a293a94", - "public": "0227a6e3340042e60ff6094dbd691db8127980d4bc7e26c63f9bdfe853d8a9749d" + "address": "2daa3YQCFEXFqwZ7HwrfhSQXgmDucjkKC2R", + "secret": "a9d6dc77d7e4633075d0581eb43cb6266bedba600c62a98fd2a6349b04b98ef2", + "public": "03d83767f81104accce7893437d33f613567d85ddede6b88c0973ee8ec672fa7f0" }, { - "address": "2ce2YWx1Cyoyvc3eEJ599i3bR8poP7uRRjf", - "secret": "220abb15fbec36713c85e1864941b7cbb5686477516090d9703501b9126100fd", - "public": "03c31e2ad54f2ad4128e5378076b9831a5e54cb57329ea007f4bc654bb3dac4c73" + "address": "2HrVw78xZrjDMz8YahiRXVgghRJNYxvoMv7", + "secret": "65a75bf3ea1df83c1d56297990620ef347b6671e4530991a15a4a0abc4b91c53", + "public": "0306ca67b3fd9b45f14865afe7405dd8810d81ef0fb27e11d4a98862565ea54eda" }, { - "address": "mP1UzVXxmyMVSNSGstjAQiM5jgZ5dwXfrg", - "secret": "7fa6a12066d8985ce55cd9da8eccce2d4acc0977056f3e867ddcde497ba270dd", - "public": "0201a0a39a64cc81b56645a9a4f3a680b0da71862be36b02d6a6c090a9aacf44ac" + "address": "isQzfULaF8qsZwEjVqttXC5p3CwWdVrsEm", + "secret": "f421529f43cf5de54382f390fb7d4118f7151bf2b114eec6205d9fe557d07024", + "public": "02727f6d688ffc1afb11202b85b37e35478b5619afde09081620018f485970cae9" }, { - "address": "HqXas9iYuV1cXGnCwsewzQfVjqmYtGi7gG", - "secret": "8d05f136116e61747b7f75de12b13cabd7dfec0eb7487c4b4a5b919f442f2acf", - "public": "03d3ae34040fd6e572b0943f0e3d563ddc7f14b13b01d9350482b49048518ac8a2" + "address": "bBHE5LpRBZEaY7upVZrk9THomitAmUQ7pw", + "secret": "22f23e4560ace182ebb9e4c809236e3c37e636d02cbe41dc7f57f1b0d53c3034", + "public": "03457a68ca3c395a1615bd7b41db4338b1648c076fe008973377252f23d538637e" }, { - "address": "25A2dstn6uSWujAQTSXLBgh5pb9ZuX1rGZb", - "secret": "c465b4314417028bf230700ebb2bef4715e43633d2e058a02bb27e0311617afa", - "public": "026980991c504b1ba7914ed2ef6c8e2918fa5f821fb7b62b5be03b81907f648f98" + "address": "R2Tmy6uLAyyBVkV9c5EzLvx7dn7QWkgRCp", + "secret": "5f6cd6f06cc6c5658f2212002bb31984e98edce455cae435b0abd2dd68549c95", + "public": "03a51c801274b5774032661bbfb691d832da2ecf19d77a6be035a4e0080b618d8e" }, { - "address": "2FnGaEJBVNAoSXZYUxt7cbxYn1tKBc2sGSh", - "secret": "9f7064824f759e823c37160abd5a5f43f22a4ab60d403940045b778f3d0fcb80", - "public": "038d927e95faf8232ec7f92bf85afc782ead4af88959d55d9512c757ab6ebd99c7" + "address": "2FbLk1kx2pqoKJifFNVKYYdhxKQEJLqBa4p", + "secret": "bd3591b1afd596cdceb604d4c8755faf9effaa8e6a42637066db28b22bfbfd7e", + "public": "03717c0ad9214a4e590fc0379be9696c4168443458e75a3552cb1cce9f40e5bae4" }, { - "address": "7jnxTHBiUwa4Au4eNSoq2BPmNfBZ44fRuS", - "secret": "fd9d0b144d7a39e381b23957972c6292769e272e11b565e56a7cad5aff8c738a", - "public": "039f3c8187c64d82be6376705a8a8b70c0328a00c3f32a7bdb95c766fb43c820f8" + "address": "D4F4Vo5xPLu4YX1sTaKzQfUGnmGk3yCUb3", + "secret": "03e60b222f3d7571669e7f943e85d08a65693c8d2054da755149802a69307411", + "public": "03078a2be8905c0c4bd5bb15bc52388f90c996f7e59c8a0351dcba8876e0102c55" }, { - "address": "2iMKh5kHHjyQLiZ3Bb7J3rAbyg6N5rUL1tk", - "secret": "2be4dc36029add3d2f602812475ae40d4f4c89b7ca318621556de6e86fc6a73d", - "public": "0337ffe7d818fa7f0caf294cc362d4a90a41395574f58bd16a39dfab55ead2c54a" + "address": "uZKWALKm9AYC3GQxxC1T5i4SZTtDaQ3ov4", + "secret": "be694dcc0b7c37ca2251b509dec610b1501ea16cf2dc7e48fb44953eb881373b", + "public": "028fb5be4d87deb707259c4fd9fba441f3f89f171c9b5b39cc7cdb3aa694694bec" }, { - "address": "2i24J2RPHPPW7bkKmCbv9enLKzBP8T2Uj7N", - "secret": "7d1abdb1484f5e122dde175d3ebf16c01d013c7066b4b23ee0ba8f1726d4e592", - "public": "02742784626d0f477fecba34defb5f15c8b9bf917c6e79b1d5ef7c0e4856eaa657" + "address": "2Bg7DduvSuHQQodT8rDm3zgubnLApfwe1qF", + "secret": "6a10bfa1c59f6d4cd1be7e707320efa6160853bdfbcc7969f9b30fbf0a9626b9", + "public": "03bdc46bff88f5854dd6aacf5a69e8b344a45633c6b2fe46b902188f70d7f4af46" }, { - "address": "3zcDGct4KexDkSARkKuvG1kdGMUr7gPxmT", - "secret": "37cb44f48397463683d51701231b1f74227cb2573514425b0a97d8fb9d1f6f4b", - "public": "03e607e26c51aa13877a3230bffe5a79cdfc7c43e49c0ff51c60b249ce75811b4b" + "address": "XLkHshahJQ4QM3XdFqeuTEfzq2B2Sut1gB", + "secret": "48d4aed38ddaf9131b75c34976cd6983d4c35009eda7461217f9f24dcf51c854", + "public": "02ea0380924ec74c9a1e61ad665c283c6dd8e69d5a403318ea0c9f6dfe6bb71c47" }, { - "address": "ShDyw58scZBMghZ1E6y5fRCQndk31RgLAn", - "secret": "fa2025655c46f6b7bd754503be5e65d775a2e8a2c0fa216b6f3e0b5f8df38e3a", - "public": "03e63f5a71e03f6ae55691b8561143f369b673870e11a8ac926c7c3f835b8d40ae" + "address": "2BPMq8EUBGRyrz8NDSaUSGT9NrFrcDjq1pN", + "secret": "96819304e4803e15daa655205cee676dc04417c368b9851280c2c54fe509956c", + "public": "02382b4e6a8feb6d13de1394bcd4fd9dab6e6bdf4de96c9f0efd917d5997b94f21" }, { - "address": "8z9QgnrHFcmDmUNj4thrnqUXGtsARkbxN2", - "secret": "c0feff803e98f69bd5e25ef862e9f69d102e9b22e85f89f607f79d5ec1bdabbc", - "public": "03eacbaa94c2b1c756dcd3bfc22f661c6d6cc18e9d77c11a9518241dfb28ab5ca7" + "address": "2GGWkSEStqCKs2kGUa4pDbg4RxHJVhh3DyQ", + "secret": "e81e01c500a5f159cd5451b054568ee1ffb2700ddf61fd38371d0e128934007a", + "public": "0270cfe30a0fb41dfe30b9d897580ea16a401c4c41babfb41a78b1f20c12caf0d1" }, { - "address": "78iWKcpYLtHH7gMAWwShCAByG141XpFXyc", - "secret": "856c0d40c3d78feee51c4de68c7362b26e5eb4e9ed7fcae22c58f89ea8fc60d0", - "public": "0366daf56f7df98f59a05519720ada095f1fc65bbeef049c3cb176966a722aa666" + "address": "2JAihz1jHZxDVSJ478Yx2cdkseqm6ZfNnr9", + "secret": "c40ae6bb5a1c19764797563de1eb978ba85c686a379247adcf36426918f8f25c", + "public": "03d8a1fd67726ce2aba192f8358ce9143b8eec0066d80e93333f27931c8c96af56" }, { - "address": "RHXVXX6XVmXw3upgm7Qquj7UZ1iQmUzezR", - "secret": "dd4e9fc6fa2ba22d9bd5d3ac996fb97d993183db5c9f18b12568dab5f8b35a1d", - "public": "02b0b916084d45509d305ada3c42b819754239999bfda5c9c93a677f1ab2e71ce5" + "address": "2e3SyTQALdRjunDL4VpUkQqZ7kL45twGSvy", + "secret": "443200ff2becf64f313a047c0afe64470a1b79ea56802a2a782d8a4c3b0e8bd7", + "public": "03245acebda4649d21578bd2ac5466470125d9785668e0d0e6d6969ef23d99dfc5" }, { - "address": "kXdPLeZc6ToadyGRNb2dw8M2KRsSd2pfy5", - "secret": "0385e8a9b75620cd4659da1500913c1403c0f81c8672f192a2f440f5cb5d68b6", - "public": "032a6ec193063428dbf407e4a5cafa551e607ea4e8d7aa4e769e2536b28e0b44cd" + "address": "iXws2tgmeN1i68GAoneEcEzASNosHZCrR4", + "secret": "a525b3c37481552bebf2b7f6849d5cbf8d891f804427ceb01b4d0fcffc3e6a6b", + "public": "03631cb9c53d25e67cede82f50e5fb1c905a166569894b2f1a75109253ea455ce4" }, { - "address": "SL9nnMvcmY11h3tD9BuhZ9Coy4eSdyeQ92", - "secret": "2b8b3d4bbbeea7582d6c27440ae6bd6b53b75c08b0e22bf39e026ce0ad57ae67", - "public": "03a64ac1cc4ab2b678ec7b13e388b05e5a1eaa5807ab4ec1e9224a256aea0e9ce6" + "address": "RULqwD1WjY678XddBPK3qRJC1KC1MLg5zi", + "secret": "9d465bdd07bbde238dc7dfe872cb05a3a8461893af61ea37f85a8805edce44d4", + "public": "0379f5996ed66ac9a17a990cba9b619cfabf87336fb41043145d240bf88c1c4087" }, { - "address": "SJLTVLpoShjjK1E9s8Cj3sVqoBR4dSoMZV", - "secret": "11049e8a320a5f08b675741ca2fb002bbde3dbc145366308cee697d01b801cbf", - "public": "0389fa934fdba691a635977277e1b2f3e7c2cf3d08008c14c18df6cc037ea7cb43" + "address": "2e4ekDcVtjG6PHuaeVBd6y7JSiLKphizGo9", + "secret": "601832e7a373217b5c84c5d77cfb1581069f970c0ec3f96f59f2907a69bb9c6a", + "public": "026302c344271cc040efd6536cdf77fb09f2a8b7cf49a2159a595770e25a741873" }, { - "address": "Kh71enDYqXAFRAZfHJiyF2H2kuzs8bW3nH", - "secret": "53a81dbb1cb33e6e555aa4e739e8dbba74b35499433ca84ae7bab18a562899ae", - "public": "036e0ac74d33610699ce88c29cbe74d9ef893419edee8d30df22d963c30f45bd97" + "address": "2iLYSsW9o3GGnEWRgcuPiXrmZ3xpKR5SbH3", + "secret": "130179676d01bc4f06e818b9746ebefbb2ae3d7aeeb287e85db1dbcfd1f12ede", + "public": "02057b44f1b07039ff175a24e133240ee378d036fa07b82b6f897ae352b8e9c66b" }, { - "address": "9DeCty8XTmyU6Tebx5T2dBxDoV3MWf1q12", - "secret": "15837d3b924a1ca1b49c7946309d8ef9b6f9903cd16e8dbdd63d84fe72f93539", - "public": "03d7fade84c49efc9b6ceef7ee8d69f5d6c1d0646a81d0eff7d3a78d6d2623f4df" + "address": "5Xx14ZZYBtd32jH8vRaQVydBo37PKDPXSn", + "secret": "bd8f3c1423a321e75bb1358e9e48befad2730aa0eb351f35b89264686482833e", + "public": "024cac9550b8b534595cc4b648335256ce22e25911cfe85e6b50a59484ef0a6331" }, { - "address": "vZtyawVMMvugBBkFwUYwhHCxS2WVBZxWY5", - "secret": "ec495672eb39f29b3d23155eb0d1d81d260af7944430df92277e55258644b7ce", - "public": "03394e4973089aa5df071e3a7be8359d7292cb2b9ed0021725f35dd60a96f1bf0a" + "address": "28m9mZA2vpkYVRotYxaWU2cAJ5rNA4fU8qo", + "secret": "43e19b1dde61837e9237afd145664c21d57ef0878c298b22db20d9f1383c5a0d", + "public": "02c2d5b3e587facaa13bc9b480be8995b06cdbb83edecc7b9a751342a1dc47d3e0" }, { - "address": "ARgj9NPyCVDtYoGDt7SqKHzqSH9fPPk3hP", - "secret": "970d196807ef15d19bf8cdb7668a80cf0983a3955412388b0e7670efec759393", - "public": "0255f30670a161c6d73f0996c8685a407a26505bef7fe9877ac0784fe404f4bf7a" + "address": "k5zSTYgM1JJygeyj1HiH29quDhz7kp7CdE", + "secret": "037824cdfa5b27ea0918ffaa34a700a32a8d216f04aef0335d775adc5dd47ef9", + "public": "0257aaf74b90dce0b3bcc41b0d28ccbcb6f4bd6c06fb24c283a740bfae74cdc136" }, { - "address": "2GGp9nW8JtSxqFfxAcnYQ9YVXa9945GNgUU", - "secret": "a63af98cc978158498b62e799809a6a35edc17484d67117eb69279bdfb2a2f92", - "public": "036b781784b4e2210dfc5db3de37fd7be00cb73bf7a1e11741b608b2e8cc9b5e2f" + "address": "2Q8onKZCoJE6YLfSqENhPyvkHtxvduBy2t5", + "secret": "53e6dde235adc370674fa60b7718b8b8e66e37ddadad2c4a75acf50f8d1975a5", + "public": "0244e3aefc7b751b97ca4a0302d31f361a93fcbb1d89ac1b1b8bf6039975c6088e" }, { - "address": "QgkTEUc8VBxcicuoZqbWTgTK3TFqpKh1Xu", - "secret": "924c3c053cfb0a1af8ddb71c67af3ca36fba711372ece8b512d88c1aa8c93348", - "public": "020f6edbb4e25baaa2d4bcc1551fab21d4594b954824cf80e8d13083a6a3b813e9" + "address": "2K9tDb6pEaLXzndCDnSEotEiYBQazoDEmMd", + "secret": "127cf350a9dd07e2622d53b5c3ddbf73030882d55538746896b135004e9668e8", + "public": "0299325e94d7e822b53055d1400a91d914993b96b78b2273d52e9032710a2d7404" }, { - "address": "29EEYxTsrKByPzn2WefLQLfsne1eVW2XisH", - "secret": "3da175e3514dcc6c096be64b51067707d13a6a9e3bb72c819ea2dadeb395ecfb", - "public": "025390457cf7bf4064453d34fd5c5bd50d2dfc16b9b62cd03c5a3cc9dd62f97a48" + "address": "2Po1yzP4RSDm8p1w1tF2nbwcUcCKaEEoQJq", + "secret": "74ed922d8ee20fa41c5cbbec171d1248da080b3a974d0784737709749c6d9374", + "public": "0316f6d02dc551aef7eb45cd6d271a333ffea11c2a3b6c95ba84f44b1a7e366da9" }, { - "address": "2hLKkNBakRdHgBeTMboikeKeH5rWY6ELtzu", - "secret": "17d10e9a946a64dfbc8697e1d2c27c6da0a623f2211dc291e657e31385ba58b9", - "public": "023e12a0cc5486f1a3d528731478d856a549acb2b9651f4bb51b829a3cdf034793" + "address": "ztvFFxYHYLzGDmW83chkUToB8Htkz8119D", + "secret": "1696d5006de140218790c9620873ce0b1b605711686a0b9fced1c0b10677b5be", + "public": "025d0053049ba7034a6d227041ee2800b3d4b575506c85b62a0a2e22791f88c093" }, { - "address": "28ysuGBnTUHMBGA2PpL1g3f2SPG1PmHtNbK", - "secret": "f6567b7e368acccbdfe6342c538d655cddb8f20641ae915489ffc0e8d26d0cdd", - "public": "03d451c468b74cac08e4a04e567286c5db4bc4ab1d6c123782ebb5f48651427261" + "address": "22QmSnYryfxUNRpgM6j9uA57Dn7Jhn3JxFG", + "secret": "05042fa3951fcc1c3e392349d8589cefdc6a1eb6d986f497fce500bcc454b4c4", + "public": "023ec539cc83b92a8121c0e45a3d21ac79c364455efd3df406a87845ecb7f120be" }, { - "address": "ECTkKmcngkGxo4wLnVENuWuDkyEpBy1Pu5", - "secret": "60324ac810c922ee47f1e03664371018773c89999fa3358c9c1e567f0089a9fa", - "public": "024a48020daf9f6ba5332675fc59a284d6c33e795b067c871bd6edf78e1ae5a39f" + "address": "1EXdxZfNk4VW9ZdXd8VHUah3nBmARtfD4r", + "secret": "291a3c544d77662dd4266425368f39e05b91ca916a8b0b4bcc773567b0bc461a", + "public": "03612f2c6450b0e95960d8b5d6b56dbb12652193f843b30cc9770e46761cdfd24c" }, { - "address": "gHccxh5A5p4xy9kCe855wBXsPCW7EVfvfq", - "secret": "2e8bb2b99660d1e75da7b0bf32ebf027f4b5558a33b5f2bfdf26ac6a988355ab", - "public": "02a8e7f166e7ef47a04b4be804268dcba3aa76a28a501a8eb8b9f0e1db102a391f" + "address": "AH5WE6cxeqJ7g8ThBWCt6351dpmqZxEtvR", + "secret": "387d9f7de29bbcac267ce51dd1cd09cce463cf4daa2e208f5a5caf79129cb03e", + "public": "02144e16ad2e88d743de602393d93b9154c30579789546f39b1538c787934d23e9" }, { - "address": "2iLm3JG8YjS1ftbVcjvPLBNVLUeXRmDXrKY", - "secret": "3ebc979c899057cd845a971fc7449f5347e770ba89cea9035eaf70927a4a7452", - "public": "02a68be1239198b690a72d66dfc4f51f713cc7034e10c2a343356c8531391dde0b" + "address": "2bUvBzrA2rySkTsTz8ubjxUiLG2X2UXk132", + "secret": "730001c2c9564606fe0148a9b25a22150b386edbc657b81bcf63fe4f5e77e9ae", + "public": "03ae3acf63026f08d3369d57ea42f277c6b5dcf5c2c36f1dbe1d1d8b54b493cc82" }, { - "address": "zBJY3jpLtRmMPwbDpNuSu6vSN5KUqHbXao", - "secret": "fc1844e7ad34bd0626f66cbc4f8ca44ba2124e04700066b7c526b344c5a0ef5e", - "public": "0274ec900bf3bd1305db18c7ed668d35a5ce6d26000ebdb09eaf20eba7c6419221" + "address": "K8jHVZcygoN3e7Uh57nUfQJzmews7rWi79", + "secret": "02b6931812541d3cb7de3dcc88c877918d477ca0cf6f25ee7d728059bf11ba97", + "public": "0225b37ef3f5014dd5b6eeefcc480e1b136c28e9147f98e14ffcbaa6ee2283ff11" }, { - "address": "x47k8u89vBgCiGaDpabndbqBfVdBWqrjDC", - "secret": "3321340b10497143bc3d7b68d147c5b809c559cc39b05047de4dbb67d24160a8", - "public": "0291a47ae318ec5904b52c2d7eefb0bc1c9e02eff96b4e8f8af05409b25d407299" + "address": "Cr2ErUjL1UqhiVMVuPu5o73NDQhRFp43up", + "secret": "e55e26e1fa9decc1e8030bcabfe2c996e08a2a009984128e7301cb815d96bd61", + "public": "037599174736e30d76f9ecc5dd1107ba032353641ed7eb6acce126b0018c7ce71e" }, { - "address": "25UL9Nfcjw98Npo7Hwa1Rp9rk2rxxpD6b17", - "secret": "d60cf124a3a7e1e2fab5b16fe9b0da89aec6a4599760cc3fe9c5596b289ca1fd", - "public": "0238e1fc40bf25ce477ceaa08b482c7b7e54bc6ae33a42436ea07156b9d0b7b06d" + "address": "2UrDkbr8qkLaUJHMYkXN3k9xvmh4D19Ucei", + "secret": "4a8f360f40ee58ff53e957782eb3aadb861a6e0ec252339c83b5579c1990a37e", + "public": "03b9c9c0631811a24edf9e79901114d1d03b762561183d2651443ccd65e16568d7" }, { - "address": "WsH8vYmsfhWpatF7rLFpPpERfDRz8cjC9w", - "secret": "22049f4cf3ecc8b4f434db61328dc4b7f17bc67ba12d1344475f7e18410abb74", - "public": "0394fde0a7bc20bb4e07d8a43b030d072d3b635ab7d817ce964836975a0bc7cbce" + "address": "2SnMjTtr3WRJ6q8GU68CnT3vMPtrXcRLiHK", + "secret": "9ca92d31e7fa4b7827126bab0ab02d2bcb608af1e9efbf4ee0edbca3c387fa36", + "public": "03856adf3f6a7079e6d42275a21fa0ce851eda69b1cbfbd96d25f2d72228498b1b" }, { - "address": "2jQuQnfxbAXfd3FkJFEFtEAkg9eWm1nsiWa", - "secret": "fc858427926256d865d49f6200079ee04e7640d205eabf2fc9d2126c0d9fb614", - "public": "02a43d25f846b386bc06aec2ecc97e9227ff141c56e098da819a5e615024289264" + "address": "2dXPVZij2rRzCERmaXs5fjnB2epMy6ftAsj", + "secret": "28ca80b3f0db34c13e73b7ad5ff8605a6ce9099f06494a1a7b6727c51c64110d", + "public": "03545172070d03df86e8ad6580ae6fcebb6a775f2a0612d373395279debd7269e6" }, { - "address": "2c5yybQEhuw7aSzH2CUFArq2VNtSEqi1eSv", - "secret": "599b69c187fb437aa5af19a051b5e3f6859ae78a2e5a5827380af9db8968090b", - "public": "03c090856249275742d67fffccca4ef4b03e53d6bcce102e8df1591b87fe976331" + "address": "aMdRuCA5s1Ak8QqcEn7gmX9xFUJXebbntH", + "secret": "d24f4bb16b89077ab63a2faa921162f4f9ff33558c6ac33ac72f76af45cd6fb6", + "public": "02866b765a68f1befb293cce71775697e8cd03cf3102a9888f337e5b1703e751d1" }, { - "address": "2D3RxB7DiQE7SZvQ51wpdBeRZFfsUJU1FXp", - "secret": "f914867c4fb26b147f110ff579ccaf4ddac52016f353a0ab973638fbba556ca3", - "public": "03376abb0e3f4cb89112a7098f682f4bda2e114fff9ce83eb6d13da842aa54f1cc" + "address": "HJd5e87cu7zu2GEWweaf4SVYX1PCxHnHmE", + "secret": "be3aa9e7df5bf981a75ed0b655c7490d2611c23b973a902d8dc5295c4b41b555", + "public": "02833598127e11f7935000892baf351e5a0de50a008d5864f9a951fd5449859e66" }, { - "address": "5NHQg64wJ8uYtuNWQmrp6MdA8qM3L7Pd57", - "secret": "626e14717bc9d7c7077a44dcc71f7d5646a005d40c70a8fec297601492cb9363", - "public": "034268d3d19bf2970955ebf5454d42ff520af2979ae7242b0cb7aa8c83610f6b81" + "address": "RjvjFhLR8UWA8UUBwmyPFV4V99snhSujJU", + "secret": "9f17ea1077558a3c898f0d080eccb1bb2385beabf092b3f84e027a9a84fa2e1b", + "public": "02f6ae99ad5a0e79e75f681b8c365e33ed31041d6038139c8f0c46a9cc467b0efe" }, { - "address": "znpM5gH4aLyr6C2Q9rcvi1nNxeyZvoMhaN", - "secret": "a95d294f1f73c36b2fa64b4a0960e53c29ffc53de57c53adb4920bd68533057a", - "public": "02881a18c000cfc9a2cfa41f355913ff6bfcd2ee65e53ecd189d8588e4b88825a5" + "address": "smnUYq9hco8u5Q19wWRNtMieS91EA76vCY", + "secret": "b813a912be979cabdbca7b9b7d432b6b969c8b7d9b9b0c69f7e697945989aa98", + "public": "03ac5574e7787a94d7e79733f7c1f428805bd502608888a670e41c548cd3d466d9" }, { - "address": "MkDkJyHBjgaxmXubFJHfXNRzJZNVf1Vh2k", - "secret": "8eb845c2dae6f2e92496c0276dbf3704cfef98d22f4127a8ad40d1e94fb76e41", - "public": "02bc5dd749a1b332893e3fec78e7a08793c06574eb944f0c92a12107d82e78dd9e" + "address": "2KKp3DbztvFi1Dq7fCbqJW3jyMLxRcVgoXf", + "secret": "8bbb021e60073065cd2250b0784e47fb0cca7974853166e3e942c070ad192a95", + "public": "02fd39b777e33098fa4c953b2f98660005a27fbfbea9c8ec8bb96fda649a139edf" }, { - "address": "tSwovMtC3Yn2YkRX2a5SaqSEJieewX7sjp", - "secret": "7d4342e26a8ec874fd4b09f8cb9029ddb6fabda621d096bd94f64d12a95ba2d2", - "public": "032dfc0f4db4577d69b6e8df3ba54ac1cf4d2483c5662a02a9421c5336a60ed087" + "address": "oPWJvhk5tDy222LCYAzJUJZce13cVoZTba", + "secret": "0ac8ae1963c9b62b27d6a0dc32a21daab5197c4e81ce81bd5f06253a36b0eece", + "public": "03c29d315728a212c153f094f68a93693bb09aa3868f5c0ce9dc349e2792f0bbb9" }, { - "address": "ht7TTJqnTFdehpf8FriP6dadmkCBwqV4wF", - "secret": "193c8264480ae568bf95cafffc0205efbe448d6d51b05fdfabd076cb8d266fc7", - "public": "02cc6a9b197bdd22c5ec5b567610750b2761c20d2fd2af41e1da806a2f37d97c0d" + "address": "V2KpF1Yoht3iGMEpJ6VKLpm65uYxEmk6L8", + "secret": "c1786113036db1edbd2e7e85322ba5b0f49a71b49d975cc503ec0bbeef70c8ff", + "public": "02a7359427fc56d44639ad1823805fe2790034811320361c0884e8dc3f9253bea1" }, { - "address": "2b4JMm1jFZbpZzrYgKCkf1GNGCTkFLjtMtP", - "secret": "fe82ec798824fcbf817068c69fd2206910f41455b39de53b58f31386bfb4ed37", - "public": "035dc00c9cdee15a0e28551e8c2ce3b3edd744294be2369fd041ce50587b48178b" + "address": "ghZL4ds3pEAQ86zaZ2VqXaHajC7AWPvazN", + "secret": "7ecedb39e58d7dad0d035c947e350d7266a836533294dd0b645288f31fb6ce3e", + "public": "03ff6b7ae9a48247ae440fe8277a748995d1294ad40175eb63810864bb05624984" }, { - "address": "269PHRTou8QopwoNw5bSKcABnSrLMmWWRZK", - "secret": "725d1e442a7ba69cca28cff2099371101419a24241cb380afcce9f051670695e", - "public": "03f50ee34ac65ce8d8f6eadca3104674d5a552998dab02689bd90990c4357ed0a9" + "address": "jRzDnixfu9hJoTGA19diDvUZmx4wFMFzYz", + "secret": "184e8fdc7e1cd4d666c578601f9230f93611f465bce0e429b2e7406f41a249f2", + "public": "030e121a88721a5e312c6508e3d76cae63d27cfcd5fa0d5109a620174bfecc7355" }, { - "address": "EoJJMCLsGvWUYrXe5jbNzeNvMt9uP6HnTb", - "secret": "2af19afb4c547c72eed8fea26b14a1dc3a87657085da0257d60b397f2c68e626", - "public": "02530e5d930813ba564001d378f0286b3e16d595ba7afeb745fe8094ef1e5b78e6" + "address": "24ZgZVdovTJGACYDmzTr2UmCiXvLS2BDisr", + "secret": "6201e4a74d799d9322a373d5577466f0b958ebc66e36b0c943837be70c4856c1", + "public": "03cfde6af9a8673a45c7394073a7bef3d5c734ed5fbd9e5d6bff0905521508f036" }, { - "address": "ZRhbX2xruB1nND92rtkWpSfd3qeqtzhpUZ", - "secret": "393610869d1239723ad8f2513c8333659436d588541ab6ce4e2e8c9ec1e0ff24", - "public": "03101128d034b2f476141ac8df4a3ea224f320259a410fc3f6e2f845eb8cfd8203" + "address": "9QLaTBBFzbNT7FqtLyr4mC3SjUF81wscKu", + "secret": "e14ed2a6506c03fb7235637ec696508d9a4f224130db2112448284d97319f729", + "public": "0257544ad0489b631d7f839ba50ba8d817fce3b68849b014535c7c579b053af479" }, { - "address": "UPUyoesdWeG6WHgbTxzMbNwzTUdxuGjqry", - "secret": "bdcead444813f9157aa947108820adc92f3c9fec95e85c2996323f23fc56808f", - "public": "03a6fcbaef59df4d8aa44598125ce10859f41045d6f03dcb979d0b1409db568d60" + "address": "2mrdnsDH8GkDxzTfKLGM5Qic6twVNnUzUCp", + "secret": "4272244bad296247de956a03b15027018dc3eaa997c7eddb62e11eb4b62a5fce", + "public": "025079ec188d81448851558da00f1375167a99f5a47ba55178c23bd5fd83e8fdf8" }, { - "address": "BAuvkCb61Kr82t8cbfCiyrVyvDPz9iGWFe", - "secret": "035b6f5d2fc34fa754024b22bd9f3902e5f046dba86ae30267e641d138fcb62f", - "public": "0334e44710bfbd48ca0275de46401c128a1fc4108db11ef22194c219a35296955c" + "address": "5r1ppyYuyjxLRchj8iR88z2v2YmSjA4uRH", + "secret": "41399be04144c30fba7767d2a8b320b051efd72727a73b0eede7503a150b82c0", + "public": "0348852f17e6e423f99a927ae6711f0ca386950dadfd23e87d986e13c049249636" }, { - "address": "uhV5FjqC91hP5aU1Li4tYnWxEmji27p9VT", - "secret": "c283e6c8a8910c6ef1630119ed7f0224622bc543fb337de3fcde669c22bff797", - "public": "036bde55ad61f88c43fc47d96728ec3058ef3713610abd41f43553b5f9ad0b6255" + "address": "d6Kr1rcKXZFsbiA9XnAvYraR7K9b14mtJN", + "secret": "6dde963a31bd1c4ea9dac7c262a503f73f7f00a30b6bd684d39c7b774fbff32b", + "public": "039e9dfa055b56922799d5abeb4d9ac9afd653563b5827c1c0a3382cb33d32b937" }, { - "address": "2Cg1YGscmq8pAtnRC6jg8qYnffbGgvbgVKu", - "secret": "29160307738c2a5a104ffddf5651a99ce4cd69c20b0575c10955d37b8756c467", - "public": "03dff398577f2048c4c214d57725d0a15c22ff36389a904609e5837afaf0b1c5bd" + "address": "23w3Mpx7B6T7YzS61KzGRTdFaqqVhfhSPVh", + "secret": "3e1e627486422c1e38525ffd5f3a20b84698337fd376a6298914b9f7ad215cc5", + "public": "03fc41d428a7984ab2e8a86de2c72fc843e3cd0822694a58b33f1d30295384b091" }, { - "address": "sY9e6B47jdYsFSHzJwGrnKGS26nbmGzoyG", - "secret": "6bc9515ff654afac3173bc4ea0701a2c2c62928b6c094d98cfb629177bf1975e", - "public": "02e1b146dbea421b9d34bfd2e7b6386e6c23ae7ab0d631d5f51905c1463be1ae91" + "address": "2UE1RjgYByFJTaZWm7CASrJ1zLpD6A2ibpN", + "secret": "1658c7ea9d9c887b47df2bf778a2a9f02acc7342c7ee98e16250e51193f70e20", + "public": "020d1c92e2a29a11e5b77449d817edaebb620f4bcf089108fd5892d5e293760855" }, { - "address": "bZmbt9thuhhjZRDUFzdTzhiNhuqCTg28v8", - "secret": "90cb679649b6d2320842e815ad2e025cc03d6a2fdf8a1e2b0fa8eaa68d223b97", - "public": "03aa4ee81f0f3810c9411c6f40ef68bfe4d4f02ae026aaabd17032d1ff7357b424" + "address": "2gUQycnLvW5PNbjx8zbX6qqKSMx8AZcbHJN", + "secret": "29990b7a22aeaea7dc196cd588c0855ae29b9cc501ef5f36a0e48493994c8121", + "public": "039a9f1c0426e4acc12d754e38373d7db58eb5fb5eab6adfd920ab57ee786d7b5c" }, { - "address": "2L4qHYTP7yaVo2EEFuxD9q4qqtQ7e2ToT8K", - "secret": "8bc8635be08e9f55eb6e11021640bc9dce778bfad4827d45454c8ad0dbe29b43", - "public": "031029930552745b49d074c575d0fb49086959ba9443a416dc57a46bb00c6dcbc0" + "address": "LJJtdHQ8YwTXyv9ZiNTrCGgh8N6iud2jH8", + "secret": "0f7a45ac7fa48214e22ae57d598357c6502b0120a53f0846a89d24b278869625", + "public": "03f96bd4d570ad5e3a424ca6b5e1fcbe2baa3990e9f930d8d096ae6e72f41908da" }, { - "address": "2FttFFHu1UW3WLBNFM4h2geHeyZH8cRoqWz", - "secret": "a336e6d768a37bef87d35985a0593012b4d96086f9660ac6cbcc76991a5c9e90", - "public": "02304d0f7d748f5f78c2b642a7c5e78c3e81a924b3a4e651397cfadfe71f5790ef" + "address": "2erBQmqWbCn42XHgv5mX4FGdYmWwGWNwJtF", + "secret": "fc8ca55c4e86af2ab9d79035618bfbeea89c4582c39f6a53cf254fa0334eadd6", + "public": "02950e3d4516dc08c46228b6a77b0f28d73eeea47fd4d31ad9fb9246ff0c02fb13" }, { - "address": "Cz34ANd2qx5MEjGe9L2x5Y9J53tSR9BVJG", - "secret": "34893ca4b9f6b08497084a05451a45b464d7fd0c3521e2fe252b7278a8a911c7", - "public": "03c6a5fbaaecd7d2746c7c7e048f620480157c53dba2557d43905f58cd4600f3c6" + "address": "pvvZnFhT5braNsvEF1LEDABDLXJPPy9n3D", + "secret": "f9d86da49c0584a6640aa990599f0d9986f58650eefad763a7eaaa90b747666e", + "public": "0268c65be7256ea4d769e8a723698db683faccc1e21b1fd38a31a591825d07202b" }, { - "address": "2S5bJH4jw8VHiaCJRso9bfaqoaX2SB6Hxd1", - "secret": "21a428f244f4ec4f08e5b27596028bbd5b45524539c33e377e9f08bc19f12884", - "public": "02633f2dd9274be51c0bef01fb77e64525dfff09683b59cf78ff47ea6b2ec22d9c" + "address": "6SnfZwj1UeVtzg25n9wnkj1dun4ZWHMUwa", + "secret": "6d3afb2bab90de214060fed091f8dfde04fa19c540d896b5c81495d98e5256af", + "public": "03484096e0e52f26f11fd5bdb501666d4c74cd15c291d038aa9b3f9680f097d6f1" }, { - "address": "HgfQ6GZW8tCHiXH3tqUbBXhDLuujP5NVWa", - "secret": "4526435830c298ca9c5a030171e9c4d79d2c1e78dc059925c014c2ffdb19a860", - "public": "027d63b76b50a10a1dff3d84a88a924332976d9084f62d6493cf5f6bf7b9989702" + "address": "22Y6d1jn78SCSrea9dipxWZsHMmGYVVzrEa", + "secret": "0669359fcf951af5c51ae9731c5064bd7c937015ff88842ea15971fd8a01cf8c", + "public": "03004bda791425eb21c1143628c200df0cbe2e26349a175fdcb2a6dd54e135e03c" }, { - "address": "2Q4mEnx4E2gdFTmKAq3NVNp2bAjevXaqxWY", - "secret": "5dbff6bdc8dfea2efa205d44c38b111febd6f8d1470d634815693ee08bd62300", - "public": "02bca4ee04c7609fac2ef62b8f38bf6b6db3a2f9d59976790eec3d5351754f150b" + "address": "c6sPKAa4oJ6pnVdLSpcsfBtvseHFCN66p3", + "secret": "983bb4b8c8390b8a00024074b43227e2afeb1b30080e91bdb241f2434cba3c9a", + "public": "037b6f7922f08910e0b282e08206517659565254795299cf212724bc10063a76dd" }, { - "address": "v1Lx87r5K8nhP4mYtrNchHkzPtfitNLMhG", - "secret": "020ad9864228e1cd3f0d91545a96f094d8bca9f5c900676256c4f01840912919", - "public": "03a132ab195153d944b00f9993b0d1018165ce6433048d1447d9047e57ae2317b2" + "address": "HgoqRHGQCqjBaib5JnGxzzqJerYpSQDoDo", + "secret": "c43caa26364198a11e898020edb42eb38b48715a7047b4a970b6bd80038c7c6e", + "public": "03b6ece9d98596d9ac7b3e2297c0b321a897bdb539f38c7850a9981ab940a464e7" }, { - "address": "2LpNHKtsJiGjQWWCqphpvAcEkisp1u8yPKk", - "secret": "2f6577e365230a466a1d523608679a0136ea8cbfb3edcaddf30c23fa36a0ab4d", - "public": "0317fee08d1f0cc9fbecd2cf456b72da339866344b8247bcf4f068ea20fc1a8dee" + "address": "vujxJAz6RJrNhwGpRKEHTnwFvTQ4mQwfrs", + "secret": "031b4b8e634853c180f13d3f8aebf5a44dc3d85eef6f5e86ae3091abf8e49a06", + "public": "03bdd90e83de029d7d1e9950d4ea800542b47fb1bb2e5666ab1b5ba4f5d12c1d05" }, { - "address": "258zX98X25irkax57dxg854kEr7U1PSwsac", - "secret": "c3520ae5170af8ed20b70b7d6873488cc1fa14f49e573f60460b0991e59d45df", - "public": "03663ef01283613d857db7e87359fef6c7645eef3cd8993029a02835561047d723" + "address": "HXdBWU4ned4Q19MUJvr1T8BkC2Y7gYJHhq", + "secret": "06962e39a38fbe298731924221cfa42ed0ae9abb105843cbac487019252879a1", + "public": "02363ee0442a993d4dad2666ebdc7465e2ad30b38f74ebc2ce5be39cc5731283ab" }, { - "address": "d7AoJ2ymWLd3KLnmmPSWUjcCW7epnyR6wV", - "secret": "8c5ad3d861d561c54a67b8c4dba776bd4842f24d14dbb085d40cf75cbe9b7503", - "public": "0333900079e924e7500615b547b1c0dd2c6daf14e7463af456abfb7adfb103e010" + "address": "2mJtA9XppXTh9o2267QFqmgUc4vQtMxH4Pf", + "secret": "a3c41a8aa49ac7c989744f59037ab6e7ba02305e3ddb09948664698fb3c7b546", + "public": "025677fc7e26cbff2de1d162979d011fb49c2f94a51ae0049a96354798f8df9493" }, { - "address": "2gLAas5QL8Hn39H9154szS1j6Tezp9uxxyq", - "secret": "9fde1c9e4c537e4c8d4b612f802322b2c6796839c67881389ed93270ccbc5cf4", - "public": "0360b6c3c85996aeb77a652109b6b6d1c11301b84c70bb8f56ec98a547aadfbca1" + "address": "2WuGtr54gfEM6E4hzARgeDMiVke4mZGjyK8", + "secret": "e701ca2b190297d5b5d17fc8e85400e555a1cd4ce59d9ec9039615560d5a77e1", + "public": "03e4a81a81a0b38d3804c998ea6d3e40eca24b301d9200d7a40f47a7bef8b1bfaf" }, { - "address": "2iafC4c1vhA6YriGCvFC1PqxR9biQR9FijV", - "secret": "599383ba553b252334a82d766ceb30ed4452ac2e42e171d426a03cd7ce96f374", - "public": "022e78642a5b025dccab99bcac30075aa2d1fcde0cbd46fca471a308237f2e71e7" + "address": "21SkhMpvCAxvVnVRa3QnKEocXrPbEfpQXer", + "secret": "06f71a679c3dba236d942839f9cecd105c93df008dbda4e88502a70c67aa66b9", + "public": "02e0b7a344d4a571cdaf8b0f46feb2007a80c24027f71848745568685a33ce9a84" }, { - "address": "PtJTsad3T5EbBnKYagjeERkswJipYwbxGS", - "secret": "9243362a17c3feb0842ffabc2846bad4018f10cfa891fc5e62eb9c59bd86ef04", - "public": "02b8832caeee6c94a2d29438c977724dd64397e0c095028287c821da36afef238d" + "address": "2Hch5H6WNpXjExggAWUVUozAZaBRWEWvpsE", + "secret": "ffbd71a2fe82aeb6afeba8f7dc4247820bf479ac5beb7a95ee12e1d511736cf9", + "public": "028b22c80b41a8a2fdf64d78ceefc639745b87b6909dc4130c7bfa8828d5aad1f5" }, { - "address": "Vka2nDJuu9JNQTYic2YgzJZvHuLZ8f7Jnp", - "secret": "c1db8420d36eebaf538cbfbec5d3d27a765696b0311c1d64f73927fe9c186f43", - "public": "026aaa515577a1d00d05f64cf1b3c408e6628eb0127e4f94d159195c0ce9871c95" + "address": "2FRNJ4e3FDtY9c8RALijiiXqsqZNbkHHGsB", + "secret": "ea2a4ac1c298304f065d00f113125596155c2c99641988240be833c09673bf05", + "public": "030f33fa43b5854f000799468b1802e61baf183baac079e66f124c2a133e3997ab" }, { - "address": "k1XnGiBb81fZ4T5gE4XvQKaw2gaTojQ6NG", - "secret": "6287d8c3f778df6e2da20e7ceab2cac35a20542aded2d6809dd9afbe756add71", - "public": "03a4897cdbcadfd9b8f72179d0a230d042c49f6cea834a564955049835dd5b1f16" + "address": "iszc3eZpwcUu1GQQSz3CMnN4veQ44yMYRs", + "secret": "ea333ff90f76fb162dae8290d0984043e39cf6339e608e1265fb5b747b49d9a1", + "public": "038f2cbe9174da40beffc058f1a89467b1c37dce1777ab9352992f90a38763f02c" }, { - "address": "SkarHWmBWt56LaNChs7X1eaVSeTJkuD8CZ", - "secret": "c2397adf0d22e2d5c211f7c99959fb56644fc1c1fd124629bc81c148cab8da1b", - "public": "03e5901ec2506cfe0e6e4a70dbfc84f88c825e084801a12bd703a30edfd75727a6" + "address": "2iaaVJguAHYeytjfLcDVLLJLVSgPtAxBHHb", + "secret": "0c4a939514204b5f8a7327b36c491281652900993a1d78d356cad26f4370ea23", + "public": "023611dea864deef27decd48b58def13dab411eb9cdb8c32662f457af30cbece7b" }, { - "address": "2gP7Eqk1JgnW542ewo5tJvLCX1NFCXKC5UZ", - "secret": "0f01a8c481530c008ddc1988bf3bdd1e5f52acdafc1b46c526717e960a567279", - "public": "02a1b83f4a235804591857da508845435837d52eded2a55346a2e75cc8839d897a" + "address": "2W3ep1m7sk4opyxoX3k4CTsmgHeqfSGuZ7y", + "secret": "3b21495ebefdbe33ecd33bbd9bef707648252d3306256b3852f2c1e32cf19301", + "public": "030e7e2017177e74a272c6f231dc429d47d842b86032f9e825e26dcd33808d7052" }, { - "address": "28qSZcpZEegskCg9L7VvFMjVHFjFKphncB8", - "secret": "1247c9156a95a1b76800d347d01a02dff2212caa01a4e7b26eef6b3563aeceed", - "public": "024d893a1588a39cb2886b49c6116c2812b720483ce9c2c24849cc5ece5dea7e7e" + "address": "27qTt9ETdo1L8WjA38ui2mVctqu1akWnPn2", + "secret": "bd2722b3935a9f91cb7d158a36a53c33a27f32a07d02f4ea160596d96d9d2682", + "public": "02932a6c3dbb4efebec33236009ed9f625560df67703ce162d8579af9c2c28817e" }, { - "address": "2fNyRepLrHt81wTSuRTN4MkpjqjrYyuJySo", - "secret": "32ba4645b26a57d2db85f22270947f274a011a9577686be83d98498a7dd05176", - "public": "0353ed651cec6f85e4a3f1f16137ac35024b33432aad89bc4de87fe4bb0d4b0249" + "address": "dBFXCh3oZmfLEadzRpZuLvp7b6ty6MUH8B", + "secret": "080caa4dbf128bbb328ec33fc87ccca81171ce16f30697b4198e247bdd49295f", + "public": "0260863678aacc4fd7ab87668e54d7be15a7a762a276070efd6cf3f93a285ee4a9" }, { - "address": "2iM5zcmvKENjcD8C8Dujg8kPQZosz1PHDMm", - "secret": "def338f733c37fb8410f90ab79e34af239e8d41a36a4571f62e8914098f26374", - "public": "03f123a72b6dee5cc100c7c6587564cfb5eace29e3112ea8fb2b55efbc574d050f" + "address": "Vm38DRDiryXCdiUUy7L3ewfsADF8x3xrvG", + "secret": "9f8df7712861e96c82d2af651ebd06ddfe79b31635aca4539a018e6ee3533ecf", + "public": "02d40797f08f3d9ac42c73367db84b4243fc87dedcefe91f1ad44e288e58177389" }, { - "address": "MVZGQXe8vsKMLz9vrxE3TAG4CURTWFA1dd", - "secret": "706472c57fb701f22e0b69e017fb0d14e6188eb7fd0cdc18dd3d7870b564391f", - "public": "03a80d790fff2266f00d047bb7630198fb5f2647983a0442da8aae03e7d34531f0" + "address": "x4FCuwHK2B8uxy6TcW7v9V4rMTe2inrjCp", + "secret": "ccc879b0ea61fc4960ad3933d592c407618af109c4cc87221fe9235adba4c499", + "public": "02ab01ad4cad7b1bcc9d20219415fb92fd9bc819f6cac43cf36867e8284d41d50b" }, { - "address": "vnnLt7hEC5coKd7aP77Nz77TbdnPemDezR", - "secret": "f2cc8ce2a946f589f51f03ff73bcab1eb9c06ba33c43f474ccebc84a469d545b", - "public": "0372c1e256bfc7d0fa015f86b08d2e0d99300a6f45e24ca0b986b09defb8b1cf45" + "address": "2moHfKQdFLvdpdioxUiewyQz81yBKA2T22m", + "secret": "cb2e589bc0fc5c3fc5f9dfbaf454f5c5d6eb2fc7be47a547c4ffceeafe074cfa", + "public": "020233f795f9380e7d04c9c8d4639c7d8ec598e4e4c8de59a4c73a76c3bfd4f161" }, { - "address": "27k4tEkoxRwh4SSZPg9ns6SZ9B99NNJmCqj", - "secret": "42c86db309e7c5fe6a5c5a953c4ad048fafd4b4035c14000406b4912a73db054", - "public": "02192ccfd5b68598f49e9df66fda5438896bc1ad72aa028c955dc8f497c9cdba9e" + "address": "eNpWwxqZeY1PYuj8M4M5TwoF3jPFsoKifj", + "secret": "73ba8fe059ce1c08c5c716300d2bc92097b9dd92fbb0581f624d7b064ba0fb29", + "public": "037382d2900cea5956f8cdedd21e8cd81a63ea0227090deec7f5a7685279c711f4" }, { - "address": "ijnk3U8Vg98ghr4zhQPdsexVUaa4viv3Hb", - "secret": "e82c711d55d6ebce78d5df3358a6f99f4843496b196250f8413519b6a919c21f", - "public": "030b05c635877fd64cf8dd69ba345311bb4def8af18bbaf8fc4d5daf4db7a975d7" + "address": "2g51QorpyKSr6rrCxf4dD4CeZEYAMURc3dw", + "secret": "f3861c2d1e69b93b666aacdf0cc2cdffea36c7e7b83dc1718829ce79e7513c68", + "public": "02381d60f8d1803ec10ac693e9d3060b9b796946f503ee7eb01f967c8bd5e5d89d" }, { - "address": "pEefiK6EdGXXxnwr9yAMhRQMjn1euqWEu3", - "secret": "d8729a797d271fbb6d1c28d727c75038cab5cd74eafee75ef4621ba88185361e", - "public": "02931d00f5efc9f4268383732cdf3a50a3dfd04619843f02ef1293d930bd5f0bc7" + "address": "2DKTyBvzGiaPU2kL51AVubLGQFq2mjTr4HE", + "secret": "c3b3d02cea87e4f6c335784d4cfbdaaec7bcd7e45836567c60230f49ec8b304c", + "public": "02274e27234d8e7a0a15155fda616f7e75188cc1b96e463ae399d77cd17ac56db8" }, { - "address": "cskNCHetVvnoia6HQUXF9c6jxNHwqozupH", - "secret": "5e4b5de367cc0d7c5ad0d64cef1ec1f3b50eefb63681fa0e583b00c0848bcf55", - "public": "034bb5e93141aef75735d49509e3ba8b90e042404c32d4828afd79a0ddc3869a1d" + "address": "2CFcXpDqV5vNd4UzoHTsjPDTWuryZcQExsR", + "secret": "a239a35c1279ceeaa4f6f23837e92c464e71dcc86a2217587b1c1d0fdf9d4657", + "public": "02c8dfb3b231c7ba9cc67d84b9c6fdae1945f5c61ea5ff9b443abf866e373e2050" }, { - "address": "2WzbezFT9PhbQfKd1wEh3bueb5X4nbtLJy8", - "secret": "97eea6f7aa64ace240a9a64c18236183b3ee725d25f6ca5254c53ca4012946f1", - "public": "0258f33e2ea3883f288175010128bc1bcb7f1eff74b6e34941c14b2110dadc0b9d" + "address": "2gDrnTUUeZ1xrC3hCJyXhkrkm79yABLpdxP", + "secret": "6c3652adfe9e2cd2704fa0b1181b90ffd7dc4f8a4153a633103057e08b5ff881", + "public": "024b3b047a60af29f997d46cfe157a57bc77bd53a894dc6c8557d038e6d817d763" }, { - "address": "2MTtzHv53qSXrgFSEKiGuFweNfg7hGMsBPy", - "secret": "3079e35cef998a6ceda2268e08ff4ad88595a31b967574212e9436ca1ffee900", - "public": "0301ec26f65826bf2ffa9d8db86a55727b16ec8aa2785a441858834e6d5a4c2da7" + "address": "5fHL9AfwcqgYEMvjqyX5RVeksU5x4hEG75", + "secret": "f3451f3fc143fbb7dc7b1302841dbfb29c795dfd86402e2dd625c9870382b801", + "public": "02a858158514e7355b25ade1ff88d7381c3a0bc2b3d0af7dc7a15fc085e3e9ef36" }, { - "address": "4H2N9hy5ZCzUFSPvjUSNzH8a39Lv1DqAny", - "secret": "f9e4e397c16e4027b92e55d51cf8c36280f28bbdf08c738efb67d22d35b0d340", - "public": "02a75ef80c3cc9d399691febe6a83856cbe7ff4d71539ef46094fdecd7a51ae3fc" + "address": "2BbgUyWCqJ66xaznA5o84Fu64DzBrCTwvyK", + "secret": "17bb9b6b89948673b6faf3bba8c0680ca1b77ee23b16e0b2b23d4d31693de961", + "public": "02fd5e3ac72dbec55b340529bf913c62075ccf8cb399d008c8716048468cb1931a" }, { - "address": "sHneHzFTthzVTHwaZHp2kVSJfsKZh4ato3", - "secret": "4b0f88e63800921c20b6533e68b52914bf6563c1f9fde23b610936c615212da8", - "public": "0265bc2c521eed203cd1745f79778c12bddf509f62be86ed4780268a0f55efab53" + "address": "2G8GaA8JYfVqj3ooDtkzWN2fNideKU8b9xK", + "secret": "770fa4cc2d8f1a8a686281e8aab3ff589a852ae450983bc3accca5080495829b", + "public": "02d69f91cb1e70caeaa8839c1635643b0360f0cafc9d890ef8c1bb7c91ca40ea35" }, { - "address": "iWyGbbU7SzA1Z9iKf65Mg17fc2irA84Ke2", - "secret": "71a16ecaed8f267b7c05618b77ce819c3aff8b37e8748497ae05dfde5991a8ed", - "public": "03e68bce7dcb8aac3d413c082adbe30359195e32463b584a36a7b94f574a9bf31d" + "address": "2BwjUtSuGKCph4EfkthDa2CdyaGzHy4WDjD", + "secret": "b6dccd72e79f39bb939f2efdf1a90868a09dadf400629465e1ab97e2236ee7cb", + "public": "039cc9b2602ab2ffa175f87ad776a1e040555d4dd3485fc09a03dbdbe39c8740f7" }, { - "address": "24YeHY7UbJxZNnQdVCKefdMPzMDZa9BKtba", - "secret": "dfcda9ce1b0b6461fc6fbc315697d7322fa62ffdbb0b40d31660074f65c08d93", - "public": "03397f62fc05fd9c528e7d46b31528ce37a9a333bd6030c0553783a7133020e992" + "address": "wa5sR5oYKKY5PyqG5rnBCzafjhFmU5Mk2o", + "secret": "3879cdb11ae8bd760a2378c178b29fd694d3c7447e03d161f8fd19dcfad6512d", + "public": "02d6fb32ef1862b79b935dff7bb5aa868b040749ff08a9dbe8f6054e953dd3504a" }, { - "address": "2LLjRULNV5gPYHRmPvJvqvMQtF5gw2e2VVF", - "secret": "0dd1d81aaf690a54e12a6b5355af4b122a1db7d1c05a79bc8a0d106882a92735", - "public": "03974edacbec5630040aa1594dcfff271a90390b5e4c4f3d803e632f8a5ff49834" + "address": "2APKsjpuiYDw7DgC1rK4NEtGCu61V4zAc4o", + "secret": "91b23e1ef44587743475ca071a4ebdc3be0e87ffe46657be9299e17b3f0fbdc0", + "public": "0314cb0648861cb94994bc2631a4c782bcf0bdabec37bf3de1a170fd0503b9d258" }, { - "address": "wXZLe2vobtbyxnkXcaTMHrJ4wL6EQ2eBcZ", - "secret": "d0ad8378412d4eb3abe1bb4401ccce3f999d0f8f1e16ae1048642477ad9d37d6", - "public": "0242f901e69015d6c4beceba2846993ea097a7e7581a170195e4f83729e31a8bfa" + "address": "2FwB1ZYgAB44ENWpudrpmYujkFZBT1ARF2q", + "secret": "16f82f75f6ea09ab92cb4110e1a397dd71fbec81ad7faa9c7a54c90875757a3c", + "public": "03017078b4d051aee4050e7dacd1b886cf27432d4e90286e47fd9501922476617d" }, { - "address": "2bVVbsrTFYEFNszgdo7ksutseUkyWpcW5gU", - "secret": "0a087da6df1523270d736d1a57e2ab1b1f55ea65b0cf55eddb5c36258ba18763", - "public": "028fc7d34c937e5e77101f0695c840ecb54c9d295a08072f4fe25c47f21930a3b6" + "address": "WFNNgbZzsTztN2HvLroNXNDjP4y2qz2Wgw", + "secret": "b245f9311b8a69ade2b61164e18585ec636b0b4b9a5356b7561950c9b5beedb6", + "public": "029b5a844da9c824f7338a5d759402f7dc871ca4e331f38bf363f7e91cf7057ee3" }, { - "address": "21WExogvTtSgCJELefGgQxX6E2f2QJFehgt", - "secret": "9dc51d0e70981c177d7c89b6a5bc5df6e8eed080496f8cd5bc807330f736a87d", - "public": "024cb2473b4a116f437e4184e8f5a112b3197511c6f176bf885ee7ebb2bcffa141" + "address": "JrF81tT3NehqrGLEWJPqTntBecMkZHbTLa", + "secret": "a7fc0662dfd8fd39f8589903c95abc60b22cdf45ad67fb2a5a65dc7e2c3ef9ab", + "public": "03c67fef9d6aec9e842b7915d78a060ae2271b01cb8945d1e14fb8c16ae2b8a3c5" }, { - "address": "2ShHcSvccLbJ27sgB68PKHt7qzEKtiZksrp", - "secret": "0a246ef3286dd2d9e35c15fbdc071540d0f73546a79e1b8d74f845f4ce328ad9", - "public": "03ed9853146ca0679049412d05c6e2bd8d9542151fd912becebbb81780ba7703dc" + "address": "h3vEzWCwWSGxyEXHhmVbGurjYNfJbnxgpX", + "secret": "287cdfea83b55bf184e81c0ea6889832db112c8a8762f2331d78caa7cf9baca7", + "public": "02b1104780c99c9e6f9d94ae9a564517362f374c536271f18fdad6334f219f45c4" }, { - "address": "2TeXAB4wibtFjdtJsTXXnfjff3szzDuPm51", - "secret": "b8bd93dd8af44435698a242e9c6f666e1b1337f1d8cac48c487fe85bbfd20661", - "public": "028e5dfba491f83d0d525e434ec080eebd6b2f3ca3721616ec78afe8339b230e39" + "address": "2UnSqnvfPVgWXEuNuEdmBKoyJ3xBvPnY2fo", + "secret": "df35877a008cf9e514c9f64b245b5a3e0ad134bbc2e95ce9557551c79e46fd52", + "public": "03284b8af8e7cf913f02734f74a00a1df9102e8f6e93e826176a830a7aa5324fdc" }, { - "address": "QJHk5x92a8EprHxWCiPUfutDBMUAxayjeE", - "secret": "ad069d8b236c7e4853b9be77987871303a55a3aebd5946a00c4022f384ae8f3d", - "public": "03cc54cce0928b29f6500ff097598f1695a4ef520f962bcfa597d5f47b80aa2ecb" + "address": "VZptjy7VaWQjY5crMtFbDWq3mu4t5Lypso", + "secret": "f91ba72711696fa175a549dbed4efdff703664fbd7dc98dc7c64619ba32e6390", + "public": "02b1bc13a83d263633164df5fb9eb71e913105bf2e6589ac9b5607223f7170b481" }, { - "address": "2AxezKaXkaP1T7VwSefJCDqR6bgqCQM1cHF", - "secret": "a411215a3ae66e8309e74d1211eb3e2f288cb9b426ec6b3ed5dfa5838070e49c", - "public": "02b20bffc581172cf14ad1039273da25382c61e6aa5af3c5cc655961d259396db0" + "address": "K6Zvz4DHtdih5k8JBcPdcXZRRDhTBWMtD3", + "secret": "fd515d026596d95fd283ea3ff94a3220e58c1e283711f79b0720d8bae7df5801", + "public": "03bb2baf3490d40fab6171d4d2e4387d72f43d40f516e8ea219530ebab2fc19a47" }, { - "address": "JcKf7LqoYakFTno6nd63jUXaVgem5q7pef", - "secret": "c11de6d9e8ce4a1aaf3d040c961a32bda08d3b25cc29ecfdfe1acdf92cb67593", - "public": "039d6605091adaeaa675990ba7d02f38f24d2c0d73a41794710bc657a8bf503dc5" + "address": "23WQc4TFLtfZQADK42fTfqLvqd5fVc3eCFb", + "secret": "9f49138a3f36e5fe5b2b020e7595ea39cedb7db6c55da6864d15966b118ab3d7", + "public": "02a25227209e5620211e2b5c61f20f7376c83015fdd338f6ab30a5221d71a5fcb7" }, { - "address": "2PmtvJRe2sqJxBmrDEyr21zXMnTJfvL2q6C", - "secret": "32b8785daa0cfe990f77de3f3128d6cc1ed1283432a222d02270cc5aea3f4967", - "public": "024605e6885c640d2d614cfc5f30e616e000d1d4c234ad1d9bff4d0d4911a22706" + "address": "GLSoByoK4BEQWfiZ3rbLqLxmSyhfijHrbj", + "secret": "027bf03c34f696cee5042061902d4b15e7f9c5163e2abef6d2bbb24989e3660b", + "public": "038d3c9c0734574ab07c02d905a7c045571803fc0ee93cee1626b3a15b4c993f49" }, { - "address": "23XqpUS3R4mmv6KDW8fZaxkg2THG6F7tFN3", - "secret": "20490cc0c75913f05c468b08ca40b246a869dd1113e42bb115fb9998a38c9117", - "public": "02012f485fbedad5e25e66622a8dbfa65b3a91ceb2770b9374a7c3689710e39cc4" + "address": "tNdNWcH2F96PAUtB7pC4n5M5TBSTpxKVse", + "secret": "e9415a0e3e395800cc7551be12b54bd04dc3c4bd29995a031dbf11ea3121998f", + "public": "02db97fd454c0d93e60841a153d22471ba7e82b6aa2e3f49d19fb4bc52a8c1f5ba" }, { - "address": "gJ8Fv9xz5fZgv285S4NCaJxbj23vVRgnLm", - "secret": "e357f2e8ff3c86b6a49fd7356b6e3f426def78a1935957e69122c01e34387a44", - "public": "02598626ce38627e8877fa6068986ccfc0efa9ffeec6cc43417c992dbdcb9947cc" + "address": "2VNyTcriS4FrYVotvAJaqmQuYwYSBAYEKjk", + "secret": "347e2aa0653c13973c2694e3bf368f9e84deada71edc0cd4d6f8b587b81d767d", + "public": "02b4a1fa85c4a9d2a6868efde449a41249bb4f8c1b3081fa9dd0085ed414286497" }, { - "address": "2Qiio5Wyt6bWVKb7fn6UAxTSFu2qUsaGXxy", - "secret": "75fbe6c0795fadb4942fe5ba897db33da5ca9905c9df9b755b9e3370a34d1ac5", - "public": "03eae43afb65d3784a2a69d0ac69551f8977b044d42b3dda85b18207071073c657" + "address": "2eu6HH8nryPEjbg9TMvxNi5miWwiFHdXEbf", + "secret": "e1086f1538f9f99ac01dda8b722c6973ac2b890fbd8c0836115a1ecf8196c84b", + "public": "03e52237f3adc43fb7f086c089c452f85fd9fedf8b50bd1c69965124e7828c31eb" }, { - "address": "9gs38WKRG1BwC6x97FppAmE9Bt91LdcqDV", - "secret": "53c0cd5c0799cfae7842fd49cf0839e7a4524433eeb935b25fa9d261c0df91cf", - "public": "03b42db3f9d58da4e9343847c74b6504d9eb140288a15499b4ba1d800d93eb7f73" + "address": "UG8Dvm24teXpSs4MWY4BpBENnT7BnFbDNK", + "secret": "3bddb147f42c46c265fa2cee35c90c182604618d822e22760dedfd5bc2c41199", + "public": "039087ce76a965f0b3dbbcb3b3532544b94c96d73ee4d41804f358d19648642bce" }, { - "address": "dWUxr4h58cNv7DG2jmc8TUwR3Me3D88ati", - "secret": "c9c7e07c900a8e66f722f25f0892c073f6b8cfbc37a3fdf6625cc726a5c0c2fd", - "public": "0209f20e7db634c004adc42310d8e91f6d945754dc8f8a869113f0a57bf707b06e" + "address": "dzdJh62tUkWbFkHcEJYNeDrNYF6osZew1S", + "secret": "e5b4fd658c62ede1ec0a9b073ab9a70cf63fd0cb55a00d173657893c935d4909", + "public": "037a2e8f9a1600a8550a27792d7a543bfeaf4e6183f2ff280bef6c1f8ed85d9d07" }, { - "address": "QL17RSFH3re8WpQF7DMoyYqtJ63f5gQL6z", - "secret": "d749e275f6aecd9006e1f9b85f9559945d648f17758c93e70e518c7fd2b4e06e", - "public": "027e58cb741cca7c41b749b5994a1d9349e6fa5dc4c6eb38a076e3f9d618fdd20b" + "address": "a6zxRQZdY7ZurpcUXEo3GBpX5Kf95F7JhX", + "secret": "d3968dada23fbe55a954aa2d6b34c7570d5846a84b806c052c3a3adcab120b79", + "public": "03db3c65748908d1b55ad7b8c96eb8973df440e1971f05066636f4c39b53262361" }, { - "address": "pNSBXYm7e5EmJ1PYAoNiXt15E9jzKHqvYj", - "secret": "3e33715e763dbb7e06f19a8dd7a5bff8ee6727cf7d5d8037f730c5482ffde7a0", - "public": "03f8868d1abe7f971694dac87ad4649f9310e64082fbc4b0309d180a0bf92e511d" + "address": "2GGTTctwYB3iHjYBDE9WFxGXJLFBUn7UzXn", + "secret": "48435832c57f48ee7f19f6a09c752e5c2e0f230ce6ff1904445b39c3e9203e0b", + "public": "02c686311de0b0f37073bef4e2743c2f42052e0258e1dc6541cff2571268d1c852" }, { - "address": "2kiPTZzHLEzCirjYtZcR5h41DzceYgXDMst", - "secret": "cb255e106d726fd44db495235ad472f55664ff86447c7563c8a4bc1aad85e67e", - "public": "02106efacabc86d8d09ead6c4f59e2b18789c628aefea661b8943e29b35a1f2e1a" + "address": "2aVNmkkrKkCRSxe5JnX9QnvMhNXwwczk6nN", + "secret": "0eeef28c43478e967e0434dcd1231af081abd3ba31d80a8b021cf0fdc8847307", + "public": "03881a9cc92cf911a5d1c7e7c7ed6e1f38f85cdf42415dbc27a5bee88c17c52836" }, { - "address": "GA2AStbJ4USteGdVPQZtqqCm2PuJaCUWhw", - "secret": "ba4fdba0c64d6355b84539766c651ec2621ba00d5b7fb3720b4096b4c0e7cfe6", - "public": "030b08be2c9ea29860816afb58ba083ddba1f7c6e3449cabf64499c90e1bf74e27" + "address": "21py334hX7LKskHjLZhUPeEtJ7TYKVqfaFY", + "secret": "eb9e056f34028cf4546c287c7f4dc37c92d58c26b6546dfc17911359c93ae7aa", + "public": "02e3c5bbe2ccd4edee09601caa941e19847df1e8b40117557fbcf95354b817abda" }, { - "address": "gTBRiruKHsamJaoPfmNWHo9qFkttjzeUdV", - "secret": "ea3de2d01f69d134b13f82c05e28ea67c19c56e31252a131ce2695f9a6042ed9", - "public": "0343df7b21045773e3505b6eed30115b627ec66e99156424083d0c6128dec51d48" + "address": "2TKYS9gbr3CnSmAiLewX7RppUzC7r8NX6Hd", + "secret": "f792b0c3e445775b4ba17400525848f3e27199bebd29380474ffcacc1a8a6ac7", + "public": "033ed56d7ba7138d71a213adcf823d9728547e849afcdf02aa0c40f6536537109d" }, { - "address": "iSc5HevVadZwhsATnLRZgzLhb1vgSLDY3v", - "secret": "2e53afa8001ceb42c493692e98b06f82031ab209e6ad3364636e31d23aa5bbc2", - "public": "0302275d84c08a2b509cf7d77fae9663e6cbaec03e69d260b457364cb4c7e284de" + "address": "27T6vpidojqAZgPhFA1gV32hbAGEvxYhrhk", + "secret": "f5b982ac586e994fa405c8b57225d4cb9f79e6823439e930ca6c3675856bf87a", + "public": "033f52847eda3a395ba83baa7aff6c40b6c27cab7e31bbff2e59aad5fcd2c39f7a" }, { - "address": "2TRmkD64RagghEe3J7uC38DEcbTaxXAeUh5", - "secret": "277849e87348e0e9e88635796b5fcf807fbde5b5e2712916d53b4437e78b682f", - "public": "03e11b73c26af5fa48160a3cbc51f3a78dbf560d7060a63e08233e2dcff589937f" + "address": "fKRmxuEydH3xr84jJbM2RmXLTrUQY754CM", + "secret": "26d4a55a93849fdbe9df353a8a94f36fdc29850c26a80af1efd9052d77f7f97e", + "public": "035ef6fdf9d281e09fe89737a9d5aa1ba7a2f353471ccf753035a4d59b084a36c4" }, { - "address": "Z8JTBrMxVYMdThGYgMLjCEEc8eSvv3pqRw", - "secret": "a1de6c692fff821715aef1d1966358f2ec7f9acdd8a511b77b01db335782a9d1", - "public": "0385bc529dd1777a99d491a00c12c05b9220fa5c30abbf6f22ab052f56d2aff89d" + "address": "oxCKHFyceqKrQz5ufoNkiNou9vx6yiCxrf", + "secret": "7d88523fb836a1e68249bd8b30052e2dd0105f925b0bee6192f318df099e8104", + "public": "03be2cbff63238343dfa80072c431a7fdc09efddf529b0fd403722ae3976ef6981" }, { - "address": "jeavKb4C3P4F3T1EdiCMcZwXTjYUr2FTQJ", - "secret": "7108e5431ddfe07f6bcc25f1dcba3b48c8d8a4550efe111cf4c98b92c0483f98", - "public": "0251a210b8920438a7bca5da394495da8646bfc19a3692621f0ecb37df1015e661" + "address": "3RJy9j7ztK14sJgA5NyoLMLAUNxAFg11Lt", + "secret": "7476b76ac6ad3254575f2cebf43333b02ca6b263ad06938286c00e217f39864f", + "public": "03755eb7bbd9500055a58a6c05144b2479888bc59d4284b3d66bbc7e9b8d78c903" }, { - "address": "23Hmfuja9BJwsHc5VUxNgKAbaeLg2injojE", - "secret": "608371ba19910c5b9abe47ea238978ffa005d859850523f60bc2c5cd4455bd21", - "public": "02975ea673f399f16ca544879b441a0757e7214973e06633d54d75891e8246405d" + "address": "99Rq9gQBzT6o7hHVh9mwBi2KWpDrVueokr", + "secret": "efc2a3b8cb9d78f38c3432040e2e2ecc6588125338224a90ba96a72e6df63150", + "public": "03bd8601f987579cebe725c52db9f343744165c023c8cc011b643df1cd0f9c4187" }, { - "address": "2ivTDQ6o6ibPJR1LtRwbjPXKA2WpqgqJtWC", - "secret": "9fd199f019016890e0eec08f05df7c436c60258ecc4234e876e7f156b2d82d35", - "public": "02282ea1bc3cb9ae1472399a1cba57aec119174b599829cce79fb50fce6947f917" + "address": "229uFKbAxjKb3S3dWxGLRUhU7nN2rm7AjJ", + "secret": "9fb9f20b2e6a51603689d48f53f7c65f3fbe37019f6e4dd86f37602599a8c4fc", + "public": "03735784436e95bd5de80a203aebf28f4ff01d51c15bc724cafca7b7681abbc5f8" }, { - "address": "29AcYwMLcYCYPfqzp6Tnt1V7YRs4njez9L5", - "secret": "714347bdd303dcd3c316107d63992e250ef5ce882570642fdfc68005c389c60a", - "public": "03b757fd7dec7624b495cde1c03c91167b8ee3c987bcb149771adbf5c5ba308e44" + "address": "R1EMZ6BCUN2euBPftE5P9xMcR2wH6wFyuV", + "secret": "29b9c973254a1fde206af582fb3bb1dd6fe5719180640d5f15a52c963bfa17d5", + "public": "0371f270f8f053116ab75c995f06ad975417c10a3bd6134d6032fffad8e8d08114" }, { - "address": "fvSRw8CVjFg5NxSDkVZ4Aa9WXSxUSmSFgR", - "secret": "b311b899af8385e393e2b9387342201201a85a24ab53bf23c2767e4f5dd9e7d6", - "public": "03fcec6524e37f428e14dc24bc626062f1ad1053bc351ab3b01e8e2015e85ae4f2" + "address": "KbDQwkTKbeG5WSWJo1Vvp4RoRktGyDuUTx", + "secret": "55bf5909518a71986710f11bb911c42c9a2af2714041c2cd5cb85f3232035fec", + "public": "02d133fc33f2ecef76aff19b8e0730a1fb3b63287b1a68023ab5403cfc56d02f27" }, { - "address": "2Rca4EL68PAYnSXjomt1kfaBJXpNCx9oYcL", - "secret": "9a883ae17e9f05ce73c5b5219867881c7eb9bd9d402aefa4ee35bb14a0bef2a0", - "public": "033f9dd95c3797807bde13fa990bc02b82f68208530b6666da8df20787f587f0b6" + "address": "xVa8iZKV9oFwgCDooUJRpSmj6GV7HGywBp", + "secret": "8590b46cec2d565adf8e9463a5a28b3f8e3c6f6ac7ca54e7446f5f8aa61ee7c3", + "public": "033d2efefd95dc97173cec2327ef9ad8f643ef40811cee511e63370ed052904e71" }, { - "address": "2PUKYV9v3hy54dzcA9VAi2hPCeSHAv22FkP", - "secret": "d09e6d9f82e5437f5f079af7f6c4fcbdb22c59d844956459093f4750e140329c", - "public": "02c3c8b5bb35630d1c6de894f608bcb4c6927f161c6f142902b258fe49d251c078" + "address": "mhkWnCSekNPca91xzoGijAzk7pK5xe7YVa", + "secret": "81bef4b4678092a023b72b425ba9518d577e86f5a8b9337f77ce3cacfea56f6a", + "public": "027616c1c5cf8efdd7a148fa20c037c2a3910ad6cb6518844aa56f4b8cc0cbdae9" }, { - "address": "Ph2XLtdpTV4o5HSehnhZgjeQGh3L1iCxLP", - "secret": "792149b44244bf0676bea6e767dc1eb8348e2a3c74b60e8e45603694e04c4a97", - "public": "025d57fefccfb33a8da6e47730ef39027f817feb29af0bf9de253521e71dd4eb6b" + "address": "2H5W2Jw38hV6eoLWNUPqExSJ8AuQC96Qfav", + "secret": "c3680727fbdd7b7d8b79d7f736886df08470801cb2a868e010b27e4d8414e1d9", + "public": "02811390fbacb53a0b30d76f70acc9da9e06aa5acf0166b8206dbc73c3836b5ebf" }, { - "address": "AouwEKMTYXMHn2EKJB37bwADP313nVKHnh", - "secret": "d2ce802526339a8cee69f4f1bd8156c1c70ecbca7a1ef4f1c1602598229050c3", - "public": "035a32dc5b5beeba07823495d335d1d2add0b6e0f8148dc82c2b5de0133743d5bc" + "address": "gBqUqD4wvWmsEMk73iZ77fL9QwKXMX2C4c", + "secret": "c44b381379048198f1d676149bc496aee52a78ae356cc8ada3f6ceded0b8f9bc", + "public": "02603067281ccef6bef438e77296ef76679128c0eaf4a43c215df5dcb08a1d15fc" }, { - "address": "HmC7EaBj3Hf5o5GbKbcNLhCM7qxyTor4A7", - "secret": "b7b788a58da4824849c2ea49d869324028bedea9f3b834c0e68710360808094e", - "public": "023d444c91fa5c8acb2cfad27552484968f6c39182dd7309fa3ac3d2cee242380c" + "address": "2aBtN3zU8f5nHW4z9HgRyaviqQAx4kNoUBt", + "secret": "2584c7512d2ec4a9e2836db33adfd709676768b823266260d8ef86abcfaf3cb0", + "public": "03c64e69cd4d2c448425dacbd34b68104820d14dcda260a9e088e1aa6bb13f9832" }, { - "address": "2kwK5hrnxzohBzDNc37V1bNDrvBpL4gtMoo", - "secret": "f589485935746789ff04b0f04ae2e680e403d6493a74565c1bcf1064c6a80269", - "public": "0309d4e4fdfa53bbabbb339274d43719080244abfe371b9094da6c9bff31acca68" + "address": "MpJfVPxdSwDePFQqzqreFqFHyFPnFvPmxZ", + "secret": "8bf59fcce66654480b1ab5f0d792532b11829ec84b93ee325f4fcd7b7da99fa0", + "public": "02dc2a97e5e0b5986db4d7682928b3d18aad18a4375b2ca4f5d5b611592d629170" }, { - "address": "2m7A2VLXNHr7gDFVzUYH9NwrwbPj1TgB5Rv", - "secret": "7c4aa389d7ed9dec49e9de83c2a5d10725ab0094581368149195d3669f9f7797", - "public": "02b1769ef9956c592babf5555cbcc527d09129e8b795dd057f9c234252b532f19f" + "address": "fMXu7ACfhpAddDQUcYMhFVtBjfeXTxPZSg", + "secret": "ad848094a7299cf5e485debc38ae745312f1de43297c214eca1712a8ed56aeda", + "public": "022e13429bd73cf57a0b81b2d14e99a6f215ca643f567275b9a4ea48aa98d2bc36" }, { - "address": "2gywCwCAtEt3BYN6VumefNApfwdE4nuSh3J", - "secret": "714699c03ad40052cba64af127ec9d3393a7eb309834cec489cea38484996418", - "public": "0378252a58bcbb4615fde68613ed0f586e7dee34c0b6f1e78567acfc64ecde9c99" + "address": "2HzJgfGUhaszpeqvvBkxTunGQWvMo4oi4De", + "secret": "817eafc5caff271c2a4caa381c4340d70594110ac5a5564b322b2bd9b7317fd2", + "public": "03f2f8dd9b867e863d7afc5e222d49788cc80f937b3a69d27775866f28ee557f00" }, { - "address": "dQitB9A8chZQTijoLacyZ3T4eX9ELT2VGp", - "secret": "7a922a4cbd1c916fa7c87948e5fcfde2e3e1ff456df0d4058910bf8984f7def2", - "public": "03b7b19412bdcaedad84d5fc1e125379cebe9afe2242e532afde8dde91d6d3064d" + "address": "TEfAFxc3b7BTnq2nBQNbwNDdNQVGLEDzZi", + "secret": "040e3177db9566e5902b2c8313d31e29aa17015580de4b66b0dcc3a6760fe697", + "public": "02a8cdd0040d877f7553f35021f8ff7bc13cb6f6f7b16d4bf71f1eeab8b417ae48" }, { - "address": "2g8tXxZYNvGjJ8vmEHyiPcwcMFWVdVeeZXE", - "secret": "f68d62567d56ca00bf818a77b52dd408de8473c7fd443cf4e9721e68165fa0ec", - "public": "03f5f558cb27d9db3daa6ee00994b0e9b64289499614346617d616f6f6debf6573" + "address": "MQ9xeCGvPPcQsrjeu1tQ6h4W1Kf2q9BoG2", + "secret": "9aad6041f7eede6e858e0379c0afd24f60a9c73346be12ce9fa23bc58607f0e3", + "public": "032afabdf323ebf7b961340fd32b8cd5dceaca5b58f81f3f28bf547fc978fb34c8" }, { - "address": "24jmuyX8UNR6khJzoagqvcMSxgq3SjiN52V", - "secret": "af86b3322b767a0b31e30127eaef5d9b5d6f4b186b552546e83b2d59dbd89718", - "public": "0356a73a3956e12d380728ef4d2e91589f812e6da95a39983f0d72706931751c1b" + "address": "23cxi2zraJZqyHLG1ModJpLBSohWDn7T9ZP", + "secret": "cb9886037a6d33329a05f8eb2668f9c68721682ac4f68767bbed2dd087938b5e", + "public": "03923baf3cc7f3e53edf3cdc60c7d64f83649ec9b8ad611a190bfc93f77cf165ca" }, { - "address": "uPBfe1fp37jto2Gr4rV8Yu53pEcWbtwLQr", - "secret": "d074380d57f7348d59a81e25bfda5fd1167d6fce0bd482672408228ed240df03", - "public": "0378e516a072b43e48859e6027b6c09e5c2ab8c3570ab155e78aa601dd22e1d30f" + "address": "2ARxqoM21PhW9zLqreZvoyhG2xuVQBnWVsB", + "secret": "b8d18a20d90c3be8509e1a1c14ea2a084c546dce3800fcfd64427e8e11cb842a", + "public": "03c6a58df05a703a561a9bda49ac053ee063f4684e2d689e64a57eb415a799bde1" }, { - "address": "V9gSUXRnoqfcCHtAAguiai4TPeLBjnrmYR", - "secret": "98d206c76952f6ca859fb7ff4f10f25bd81a68554549edcf41439ddbd2734813", - "public": "030705ae1a4ca2fa487a57cd804c78af3f7bb5d1cf26fe1115df6c14c0e8f453ff" + "address": "2hFDnFqkKbfBgrShepvK2DazTQv4Lvcb2fS", + "secret": "300d26fcf88f23e874f714b16e5c9539064e74d3e5fd379e0bcd407811885ca9", + "public": "02c8b777679aa8fff406b3065f92815e1e7dd4e06acfb2cc2cf73d834640efba6f" }, { - "address": "G6jFUDGumobA8LUeALyrph1kUNfpY9xyzW", - "secret": "673248bbb3150108cb81e2c5e13913191f2bcd25329cc713e444094caf408ac9", - "public": "023c1686c350e70b109a5d333df9deacf395dfd63f25b6aa605ead1729c19c6bf3" + "address": "2EMb44AyrsLU9tcMaGZH5qKMAWURWjXtj1C", + "secret": "2c7d8fbc9e91d0754a184b52363b2c5ce304031b30d7488a15ec53404ca1f81b", + "public": "03aeb51a80bd56711beef6bbbfc26cfeb2356e932fbc3c6c6b8c6d7442b1d2556d" }, { - "address": "MyJkDegzZd2eL5CYy6ViViDWx2Gb9YR39J", - "secret": "31acbb2c28da981bda87230aa3a01dad635ade10a5215b2a61673a5edbf1ca1d", - "public": "029d6511cc7f79fb985a8fadf0bdda2305212ab0c751a28d2c91efda7a0f6723b4" + "address": "RsWcgENNPyhM7KHFTo9VCLw5b4uU4CLmpU", + "secret": "ac9a2f724bba9198c756b026e5df829b8e72df7837182cff61a961a84ded209b", + "public": "0364313c902a7e6197e95aaa85218532b2626b10836d2dcc8078dd18022d3a28ad" }, { - "address": "xfVjLBTRguXbjcig9eDY4M2dEY3CCuj2y1", - "secret": "c3ba96d86a02d904d3ffdffe728d240135e8d03750d41a6a47e9359e924c235b", - "public": "03a292d3a7b7eda49dc121e323d7c033d563aed2bf5619509ca3b185a92c0c7602" + "address": "2SvGwVovNFjwS91HNF1vrMjEfT7STTG9r4N", + "secret": "ffb644d19360dd7eebf66abfa70e492ed3a276aefe38c172a11b0284aa169541", + "public": "03f3a1532a61087e9bc8f6a6ba81102d429de7414ae0085ba9f51594e68e3d1a97" }, { - "address": "QyFZEd4cQ1YDa7GK74qamVxLZy7hN5C9eJ", - "secret": "a8fcbd60fb7fe20b348dc5791d7eba6105ad58b92ad5b99121bad420c5173600", - "public": "02822ff981017a33f30f84227807e3af0cef8bdf5260839199e852b3cb84d023ed" + "address": "rZMkh43Pod6kpNBGNaBXNoqXotme9NHBC8", + "secret": "5558f95e18cf37496521c244e37fc0f842e936d20cb203c3a0e6bc8f6d2e8a9e", + "public": "03f571e0a9a233ce8cd348606b097c728649f7c5c1dcbe0f5ca2874dad3de77919" }, { - "address": "2R3ydQLgDCqWyy5p8VAMz9ot5VCGffk4W3M", - "secret": "fc78501ddda35fc1db0b563c63e532f6ab6b5fd5a99c7d2c7635cc6278e495c4", - "public": "0383e5e12ec23e1e71798ec789c47191a34a1316ea693a331010e1bdcf36f16aba" + "address": "2RxvaL652F4Wyoq3PLjr4tFEaSbbeeJZBqe", + "secret": "f5b3d206cc14c4b57df04a2fabbbaf91cd6a7e9d07c1d09bde4c0ebaa43b3ee1", + "public": "03bf9105249ae909f87dab44e18a8a052940a17180b4da0f5222f8cb5f2562da76" }, { - "address": "25R8XWoWJGwcZ1Pmo8HQovEXQr2KSMC8Zb3", - "secret": "5bca8061bb4f6a79a84f738de91b6e6776d408668ede88e98357518171559166", - "public": "03e5fbcb0f86886ff1e88eb4127c225db1202d046b2206d19d209f6af7f1e35e65" + "address": "2Mt4eBP7iXYxYJD59UET1DpFJSG6HoTavJg", + "secret": "7ffc75211c93ae6363522dd6b1750ff54204c0f1204edce6e368ca3b771ba821", + "public": "0221463c98407c8e24b21cfa4ec10960747daca19569ea4b3f11c71e98d27da0f6" }, { - "address": "wr2kAXAk7o2FT6RmVTHAktXEXKKHyQaSSa", - "secret": "6cddee0ec04d94db9515acfc2dc7f263314ec15a374207fa932c425fd64abc57", - "public": "0232171e10dea03833a99074a0b2b7c982c68a262dc053ea687cecf1ea4868e6d4" + "address": "qDQMt3d5dYCohkMT5B6izsGHkPRUeVZcLK", + "secret": "b683a64ccb4319188831f8ba86c7bcb596da63d10ce89d0ca64c8dd1915cf669", + "public": "02b6a6fa5b9c8ff7836fc761be9ab4da0d2e27c53ebde0d8869a7d128cc72801a8" }, { - "address": "YJznzra1zZPCA4xSq3mx9RWakretbNyP8J", - "secret": "76bbf8b0fcae0634c04aca3152f1085be29d212d06da4224246efc046a61244e", - "public": "034a8161e2a6c01ed8a70cb6b4f1e9a75d63dd04fde553aa7f73900dcf324bfdeb" + "address": "2S5Nk6LmUD1cPeVk1gBkVT9ca47EPxrmZqi", + "secret": "d3874feee7af97339d66a43890b16e1fa4e490ad6d8bca3eb69ce2b20fd8ad55", + "public": "036918969f7908670b5dffd58efd16003757f43e647c7698496ef534bb7332703e" }, { - "address": "b3HttwjhCBHahkEFHBddmciwhBxhZx3zSp", - "secret": "2ce9a518c6f12211f8dfbb0bc9f5d5003d184f9a6ef7a27c4a72f262bb49df74", - "public": "02ddd0cd4facf179fcb173ac8c7e9690010c550690a229ae128080a5aba545e93d" + "address": "2j8fTL6mXwNG1aHz4xfGLcNxomnNtsDeyXY", + "secret": "0f3bdc50d6664a7b9b1b537aa8c34bdfa648c9a3cbe5f45afa88cdeb15feec44", + "public": "0242704747967357dda0fe5f6f2868e2e558dc7fe8bbd653164cf87b94bf309cdb" }, { - "address": "2XbzTXTG9amUveM1hjXvb3Ztr7PVXDddnk9", - "secret": "aae89dbba9b87454811d1d09210dabe3bc1d3b57e7cea607be4e955aef1faba2", - "public": "02b9d74b103fc3b467c08fd9d27ccd27da9308b60a53219eee0c78a1ac33ddfaa0" + "address": "2kEpigdrfgbuN2sczody557JbVjLVd6CtZb", + "secret": "a34e6bf7b8d3b20500f51695d36b667d9b88ba9f442cf4290260baf8e15bedbe", + "public": "03300db6dc465d523c01152f1e91ff50537804890a0b4457607e5bed41ce268993" }, { - "address": "Z7MLvJevTRVyGTBUPeugA5UxNMhDQbPraq", - "secret": "3f8e17adab503e0dec26026356504dddb486998d2915afc1e5cf1d0273f7805e", - "public": "038839dfcba1062cd77c04a34468ac57e1358f1d07c42ce8baf56b72541b10677b" + "address": "2KGErAn9X6KUykj175VQ6GWkcHTQ9xg4yvK", + "secret": "c6f96ec8d7b9bbd628852c417ec221fd8cbe301af5800914bd48886099a99a31", + "public": "027b6393a34246599475d26a5c35169431d79ce0b062d3bb25ce4a00b5f469b63a" }, { - "address": "22CMQ7myf6qhs1n2q7Xa93LhwaWRAvXtgLr", - "secret": "3ee1a72abecbdf8a17a52405dbd421b2a426b1ecff122fac0cf3c82603b4f2d1", - "public": "033028fc717831d49e86a9d98636474379e31ce5203bc2eba8eb7482086d71d10f" + "address": "Md27STrLZhDXCzeyiWV4dnYha4LLwoWbjo", + "secret": "2a0b423abe24b1554fbdf5a0cb23b8c537ae9763e94b27a4492ec5f73fe37c10", + "public": "0249ab7ea2652438992c2cda1f23b01678f9de1b037d2db8c1171c7e3a67fdddc1" }, { - "address": "NRVRGZVnWsHVtjeY4rUJme9FjfjUV9Xb2a", - "secret": "1c600f61503f82d286d1635a5c7c3cfe0fb4efaba362ae0dc93c655be2312a68", - "public": "02caacf3ec5c8de004ec3becfaa205768b6ca7a29cb9dee5f97b75d2e666157439" + "address": "23YsH6ZZcyVsVmoKhJ1GgFL3HudWQwUgrm9", + "secret": "db525456d04f0fec18a228065fe5c977e818854337937d491a4eeb9401236550", + "public": "022bbdf07624dc2bb2ae619781cf217cee4121fa53267a7e99c275ec9b692f8f76" }, { - "address": "E29ntjBox28AgRubpxr3y7Gmpef9GZcFNA", - "secret": "7f7723baa3e8b3f9a53bf5df6606ec642068d55f9eedc3a2b03d68cd5e13d685", - "public": "03c366f075a4d4fb42bf87f8b93e7468f3332437564bd05f9bda438a7fec7e2acb" + "address": "SCWSUcZYva8MDEKRY7YmdYRoNj5sFe1XQJ", + "secret": "e0912a7bb851cedca4500657294f1bdd3fb6549f2187d458edd7c8cd468566ed", + "public": "032e20e706fd2f9745569d6f714c6fd0941f6c4b2806c00ecf15409a8d9256db72" }, { - "address": "2k82F7dagfRCGELFjQtr59LcnGz33s7aU3s", - "secret": "2e2c314acb631e02bf415ce649facde2576bdfabb84d41a1f2ed4dba0bc409ab", - "public": "020ec02c1119177459ae65f8e3b75f9d90a8e1ce5dcba40948a48afa9623c5e53d" + "address": "2JgFxPbynhqiMvRREQ45cKiDdsiibSjK2et", + "secret": "09d3054ad1d287561b31569e18c1d46a3a45ff74ea86515c1d0aa119a993b717", + "public": "031e2aa54504dd6cfb2d6911033df39de005a31bc110916dd046bf15f82fc9347c" }, { - "address": "EiJzxDxn5WeBvyGdqMTszPzESkLJmopaEu", - "secret": "70f5c10e70215beafccb78378675cd826c4678518f8bcaac72aaa6fca72339f9", - "public": "02e026822f2e472ae7ea7c40f12a01f66157c627b190c750e1e408e39213d8afaf" + "address": "2k9byFja2RVJa4rFc9reVuNdn3Qq3cZFoRY", + "secret": "943b62a940a348d81993958200d8bdfc00c13b1b376478635e07b68f080a6178", + "public": "02421da715e7043dbab22e0016018e4c94e8bee58f4c9335fa115f0c83244dce18" }, { - "address": "2SBfXpfbCzipxojkMA3o3YUGbN1qP8qr7Zh", - "secret": "5ad4dc1b0c883bec8cb927694d5fac6178a445492956b583f28018c052622304", - "public": "02ce89721ccd8527b733112b92aab983f9468db8aa84fedeef3c7cb0da4cbc7a4f" + "address": "2MoEjzeLCtzMPv8ZGbkAkQeC5479wH9ha4w", + "secret": "c65414ed2eb2d83ac87c77ac6646ada456573761400108b8e0d05de9a5ce5fff", + "public": "03741c4051901ea5bff8e8d59676f0fd6ed7763d295e92fd1d800c6363da1609ff" }, { - "address": "2XvoVdaJjygvhhwnP9mhkNTsEQ7sBVkaBEx", - "secret": "9c0454e67a841703e8550da7f676adb7dcf1e7e9c86ea105ddf1a3e21b04f5b8", - "public": "02178aa823a35b2b6c263e40bb956335437c18fe694398bb1b884e063d87c4101c" + "address": "zTtMPPtk2wiUac2uB7Qc1k7JC6ssPnTeRy", + "secret": "79a8da2939915b0da33fe11abce0fe80c7a68e0fc6d372b500fbe06f3269d165", + "public": "02489ef908c3f224d8b8e68d7e9399dfa66ff53dbda4a452d55a01ca2ff7278d7a" }, { - "address": "2pzEhkVNyjp6KSLKThhmEqCgKgo49n4gPH", - "secret": "72ae4e6bd82aa7f0a4483ebd25e6ff24b4e55d021408d1e32a0d3187edfc6201", - "public": "03b1a7da4c9bce5cadfa56b09ac9341ca9c1b28c1bb7e5b91f03f565b47d4c0e06" + "address": "21jfiioBpG4oYW8KjYpSs9cV14aub75ZQha", + "secret": "9aa3371acdc4444d281a770e7579c42d2b81f24b5e8c7434fd3754212b577bd1", + "public": "03d4e9be8f6b7378f7448435a1043636bf9a77602b6a2446c417c8f0d289cf04b8" }, { - "address": "TXHH7kvFd6Sekt9ZuepkpU5pEH9irVhhbp", - "secret": "86ede09e2594647707e92058bba5bf30c844740115385742ad310af5a2bc6001", - "public": "0380e220533452286686c0d652f48085d7e450abb5a7ba98ab48c40e364c140afe" + "address": "2jhGXgUkXV7L6o2ooBSJTRiZp8voCXsws8L", + "secret": "312c20808b5c6ccb4305db4cc49831322ed841aa354c5e6f6f78ad58ea770381", + "public": "038aec6a7a2ff76b2ef68347d8cae7b6fbad292a07466ec69ba0643bf21ac3b2cf" }, { - "address": "PSZt5nsqqArwRNcCFRrFRzMVDMVkVTEAkJ", - "secret": "f136e5ec66860e630a2eaf3860279b5bb726242ef5347954925237e635e3c856", - "public": "02b625226d733269985d44df1d06a9e674df610dbda2027d27b60b4625417b81da" + "address": "hkQ28aDsUPiqtGAvVdhq9HS2JYGZPvSy7c", + "secret": "fa115d4a9929c01d41d7c1c23a197f377fb06166d0207f859bf469e75675c6dc", + "public": "02896b7c2842f4b641a3f723adc9445620f6ef1f6c354846958569349e19f15a9b" }, { - "address": "NKbrpD8k7F7KujgE4kZZP958DVa5ZvRdzV", - "secret": "8bafd7c9923114af3b421947a10ff4fbece88ddc105540f4a7f029b6cbc31a7e", - "public": "0203f1ea4c23283d7c108ef3e0cf2598d02ce20bf04c3d2107ade2fab6229197ec" + "address": "2HXGxGiyTiiA5JViSuYDva96pacPkKEg2DU", + "secret": "1091f0c9a82613f7879461d623e5420981116629d8163a6486ee564c95407f9f", + "public": "0277d34e24239b4be68dee716c04c4f29961bfdc89c0f1a90250d8a4a1b0ec508b" }, { - "address": "vCkFzKMVoMKkJSRgTNMCs9LZkLDr8u6tQN", - "secret": "898041e934f68d89e4aa299e14a19d0b6e646a17d2dd37d62d8a54d5a33aed72", - "public": "0226223b499d8a40c392b1f3d2869e95dedaf3331bffdb9d0e588532545cbd29ad" + "address": "ETt8tPLv7KdEn3isJ8ovCk6Arpt38R8Xi9", + "secret": "2d5964c37e55bdb7daba25b8f73cd30e7658263f679a9771c6eaa76d73a469da", + "public": "021098ab98d1dd4beabaab7108e2dc267d96085defb391db4797119bdeb7b6c10d" }, { - "address": "JbnJYQpCgHvD3zPPaWuxsuY2AKgi1ZHcc3", - "secret": "83e2c2b84de2e5cdba1194e4cfd0fcda0f3ee435341fe9696d8b5733617da73f", - "public": "0273088f4638a59ebd0d09c5a61053f057c4196cd6195f9bb401834ba71406ada0" + "address": "2aL2T8aem5nGM2dzzkQUZyhoYziUZ2q6fWG", + "secret": "ce625aaeeb7aa8d0967c20a572040b71622d225abcde8c7166f0e355163be56b", + "public": "027ab9006f88a03876f9ffa2bdd87fb687f3c9edfcec37bcb4023f7fbed35832df" }, { - "address": "2fa1jQ64VJRRPpxUxM7UMLDfBr8z99UqrAk", - "secret": "608981186ce6f9e2cd97c655cde23c4e285f00f773f78701edc38de9359b01d2", - "public": "03f66221d2d5fc9669baecff2b518bad86824bb2f2a2ee9a380233bea3633a7e61" + "address": "MKutfh1PF7dQ2yyLLyVyUyKLrCcKFcrXi8", + "secret": "c52636ac3ebdadae875e9a74b264d1b2ce4c82034415ebefb5827e1bb6fd1e4b", + "public": "029ecbd866ab779ed2cd90dbfb34b7283da00d3f9b71ed805ca92c6944ee30955f" }, { - "address": "23DyYQifETDkMkPdAggv2ZR3Q9McAw9E5gk", - "secret": "2288060adeda33e8b02561e1757beebaabaf46fba345c26104bc3a4c78f6ab1f", - "public": "031829058ff921cf273eeac5ee8837a3f2bdc9793e5d6f8bc09fc38617ea86d14c" + "address": "BcpL5eUt2jXBMCUEYJMKbDzsNHqFbapSUf", + "secret": "0ec1616139c61bdcd4f93d86c1115077e769080410b5d077718d43715eb49323", + "public": "03550226d015d7cd3298e48acd54bc0a5698905a87c5ada8467d4d0a0565362f7a" }, { - "address": "2jBDxnTXGqDXFF2XPQsCvgCqd5M9KMYn77e", - "secret": "6d15407c83424538eca77219a17f787d6bf75c6a6e2da76964f1df51892eb3bc", - "public": "0297b7021349b6799620d287a8b7fc11f384a6f5485665a9556c440c491c27ab5b" + "address": "C6wHriSkyTXN1MxkX3c4tDFUw8qAS6gZt6", + "secret": "7e74eceae672c54786531c9c37840da266cdccdd334271a4034fe87805fa22dc", + "public": "036af0726c32dbda8b224d655b1f572bcf625bc8701ecc1f53fa0e5ca45b2a5809" }, { - "address": "c843vzMNocnFZhzrZyZesHWSdCzgAdinot", - "secret": "d15540d76d6cbefb7d2fac0535913bcad25d3392eb21c28b1132ba301c9ec610", - "public": "033a6480c08132823dde106a4f30bcdf2adc61371a55575fbb830033d4def24da7" + "address": "21QWTX5QyFovW5ezTQ2as3ndPtmk5ScYiFS", + "secret": "65da770ee49d0b6f62cd85db5153a6961d4345f02cd1e460209b9abac795624a", + "public": "03cb526f36a2bc9dce0adaa33c27cb10302927c9ad50de88ea541e81789b246298" }, { - "address": "212uoia2H8cPtM9GE3pypddrFUD8Wp8LRm1", - "secret": "d1b5cf973cad6a7fa9047bbe31d5df3ade9d311a10572941ead6b35e5f292d53", - "public": "036bb0240836d9c6ed766489cc96666cb7cfffed65916bd2c44cb4852375d4c779" + "address": "LA9fKvqm5A9k1agtszrWfnPKKjgtu8VxFR", + "secret": "4e02f9b57a3ad01a77e30951c2ca97ca0955f39a54346ce47311cadcedfc2f08", + "public": "027ca7b0b8a83845c3d1318b3e54ba94fccd14f259865dd770b80443b5631fa10d" }, { - "address": "NdhTtud8GREabzdkvBnbzB2aa3tPftgdtF", - "secret": "5c1a361899726e029e1a36ad6dedbb9300d7b9d8656a9220229ed4721f8b2a30", - "public": "02ba203b7bfe9cb1f060b0f77b4eccc1adf8a229956937a3803e26aeb174d702e6" + "address": "2TxMvLAFWwm145FndHzESjU6HZLU6r4vQAq", + "secret": "c0c11b487b7d307d0cce023520f94c9d2e5d1e656ea3eb2ca3adc1361998ad04", + "public": "03ac77cd63f2176fef590a3a30e619e4127fe6c1b45368682b468375bc908dbcf3" }, { - "address": "24PYPPhfiQPTXxzVVnxq164cxBLGSbuhag6", - "secret": "54957f87e486df818275c246dc16423498eaa04815431df18616993f3bdcb918", - "public": "03b69a60e93cafc61c348146629f7d0159a546ff62a68a163b95815bd206cc2496" + "address": "xd9dBK1mKxiXDBHgd9Eg35Cz9sLbkgcLws", + "secret": "ff38df8c6834713082048d42afd3218bab991ca44044c971774ff2fa7a0dc918", + "public": "029b1c4622f0248a0975cfcd8502fa6d528d6a2a6d397601af0628fd09b6c4dcbb" }, { - "address": "2hjGCntwh23r3JYXQ4Y7CVuzgTmZkPkN1vv", - "secret": "d658695436f8b7a4943e4dd9fb5b290df9ddcf15ca73e2aa6ce6c3db1e540f72", - "public": "03befdc686a349465f142914a17894aea55b573be2deb8c231170d5d32e101e324" + "address": "NwGDy3Qoj6k8nqRqaTQk7r2jUfzLs5AEny", + "secret": "b79e882093fd2adb54b4fa6e408cea0273f8252acd4179540d7fdda6ad367dcf", + "public": "03dbed449745129f24b6b18b68272ff5d9fe3008ad4670adee385b669674f34d4f" }, { - "address": "2BZwstFH6gm5mcx53XMwU1qTNZ6cTuqqqpW", - "secret": "5bd2f9af5fc045257c991e0048a3bbcc912233cd457325fa3d0d1e5451fdaa47", - "public": "03811122cebab1570d1d6205d1c06b614f59dd52fb0da848c0ab58c3ab60151d04" + "address": "d4H2t1an8nB89LEK4Jt5mWdFokoW1cWieK", + "secret": "4d9d83192e7fed98e7db7ce06a84c0c0b7d909fecdfbe5d0c357f69ac9838869", + "public": "0259d4c22e3388e6720f75481de2c0ae3b45d08c0e1c8ba6876d2cda2c65d2d225" }, { - "address": "2ESMmzyT83SxiarrP75anhperUsZn5ULHSv", - "secret": "2e094d4e1a3b9a18059a4c89863a7a8d4b903033ee7e6fcffaca7d8467a00c35", - "public": "03376e24a480d728f1834206507779f2b98be91598ad7493a47bed0a88b464221d" + "address": "2jTF7ftopY2Hj6xqNeLGcWv9PtPZoo2JYav", + "secret": "5342506eefc9b01f50e4844179ec6d2c180e35b28b05f56b8f6af2de40f6edd1", + "public": "03d628a9bb74f35bc9318b7b28ba90421fbabd774cc0c004bb26b567c3beaefb94" }, { - "address": "rtoTVteL12F2mbpNUXjFq9K6ubeFrAhiDs", - "secret": "6bbf66f76d4d7c71f0daba8514b8c861fab01f6dd0940348dd3e73a7f0387c97", - "public": "03a509f78999f4dccbc83f2202664ee31a81d3165447f58c3f3fa144df1f87bf03" + "address": "2Zbxb2VLkptcheURB1GvfgCor8c7QMtiWbr", + "secret": "7c4cf9f367c4e6b48edd68b8c8cd9e8871f7e221374f2b5d8cd3d08203b076f7", + "public": "02aef811f1013bbb834716e05e798f73e5a6921f58dfea6c8c3398b9f3019fdc6a" }, { - "address": "CYkUT1mmVSsN43NttBx16ihUQ1147cSpqH", - "secret": "0b0b474f1aea9d0abd618645b6d15d2fdaa8acd0418e5f5268b0c63867a048ed", - "public": "03f864d22154eeaa58afe53650c62624443efaca96d32e9ea35ff66dd52d0292f9" + "address": "2m8BVtBjvPHX5gki7X1BnyiTmK66t35mQDD", + "secret": "b057ced7e5492e9ded80586b5eb2f76114a6c251ed5e39b24c3ec21251fea1be", + "public": "034b17a6fd6bfd049ef97e8784cbf60e107c8221b78d5500cba83aa9e59cf738ec" }, { - "address": "LH2SAGbDbtzQLFcMvAfrp5hPvGEU3eFJHi", - "secret": "c4ff0d7e7f1809bf884d048af534b1e9f8adde62ed06d2c31e1051b25e06045a", - "public": "02618042f8ad6f64ddd95ecfc8eb602576c8b7e14b6992b1ad4c225d5c32cfc980" + "address": "2FaK8WZ1F1BKHSjbdhyfSsJsEK3QoHcJSKi", + "secret": "c79f87f1bf048398a6472d874391d4cd3b5c7a39a6ff61e086f175640d7447bf", + "public": "033db0c425c4155a970fd67804944b021d40ff2d3551950ed9da5c610a43425d55" }, { - "address": "y1cuJdHHQcckS24EsWXCeK33RoWaYp6H6r", - "secret": "bde01d3b18f55dfaf8f129a6aca5b719c423325969b1345f16c1ea1de3d80d48", - "public": "032b4e80d378c0d69405bc36006c4dbe7a944e12ef2c55d55d9f36ed356d0a1785" + "address": "2CRGhkAxp5buiGacrgrfubi7Uhn4X8KHJdG", + "secret": "26865442a8640529bbe092aa2f91668866ab75c8bf0749f4be250f873f62881a", + "public": "03cc4acb6abce20eadd4ac2733842dc94d8b8af31cc6ba1199190c48bfcd07e7ff" }, { - "address": "HWweUNicnA2qG5qceeQbfCP3hbMcP9LsGK", - "secret": "5ad0291ddc5adeb911cfc2ae2d5d4d42aec7ff9518f0fc8d91b5b7ba11d1d90a", - "public": "022221b522d4cbca6d4b4e6b9a12754836be31bcc68a93c52fb4a476fc3adbce3b" + "address": "VNy1SQuLkrD7DFtUGCv2ZRovVoRYTgQxBB", + "secret": "246e7490fb721da5d00e3ef037a0cf91e83b9448db618d4e7f1529a5db2f3dbd", + "public": "02c5697d970be8cae8b2f74e5b8482b872f130fd396d317494865d761303c969ae" }, { - "address": "2VCF4e2sHpGSx1KdQm8UhSUFsnq9cKc8XV3", - "secret": "b231d69074774c6d3a5295339b83faf8f630d307e27a13b8c4d52fe2efe5d98c", - "public": "03b631ebe214e128fd92e3dc3eb304c8f8c49700c6d651476aa4353fce033fdea9" + "address": "gRiFHzstLZD8DYbVGUwy5wnX9zA6yVaUs", + "secret": "d1e407b654de28a5edc1e76efe740d22c57e12dffb6651851272e1b50543822f", + "public": "03acd87ee0ba18abf1f86526d38e7e0e38869cc08f612439ee3a30fb3c35406167" }, { - "address": "2mvTwLcRGyEFqYutNvsNkLnyCJoHW7osX1q", - "secret": "743ac133ef315ab6e6a18de5c4fa7e2e8fbd925d3e818572d5e762395fc085bd", - "public": "03b2d7de1f8e20156dca02b64fab36e300551d5672083fc63d5009961642a76de7" + "address": "2XAGsYg7bbb6wcFb6TJzSsutWpGQb95LQLS", + "secret": "e6a4e56812750dd194a556f6e0777f09fea03b4bb22e2529344f7ab664e64321", + "public": "031039ebe4e1d925358ce5640fa9b740238ce14f568d26835927449c5274e8a992" }, { - "address": "2CF7kjxbyihhAjF6ELTZGyuegBp8dvVnxLt", - "secret": "d8536eec96f2a160fc099232574ed6a90ff968c2328e826682775acb17a74605", - "public": "03eea6a578e54dc158d945832cdcf6ae3a0cdccb5291331d6e4a7befc4120cefaf" + "address": "pYg6r2ysRY1v84tzCunvg9G3VZkF6cD2LN", + "secret": "7c553337f10619cd16eb1659a3edd2e897e7687960f27c6fc4b56805b048c3e6", + "public": "02a21ce35dc6e62279f2276e5a3eb684c6f15164218be90b39caf52fb2b5cc092c" }, { - "address": "aYGhEkwzZp2Ue2QyRExc2bcen8uera9PJu", - "secret": "838ec0e412ee1b48adca9911b7d8b9cb7d530f8ba82993267508a8d0820f3b93", - "public": "029204d0cb82adb9b8cb518ed13f558180180ea80b3ce963d8638479f57cb8feeb" + "address": "wRT6Q3pkwHcgqWQBMh5QJQgzGQ9p2rDo64", + "secret": "b0736043e34e014da806c851fd4ba9b5884871f1a8bf907255d0d75087295424", + "public": "0231bdbf26e1d2bf65a713ed36008a6b471db068266de238ec15d02f46b1a349ee" }, { - "address": "2CULa4RhiSzV9iv7fW9yU9vKLr6joKoAK2V", - "secret": "0345e192e72fd039fdb55e8672b53897eafe59d86f67585fa7973340715a5219", - "public": "022b1218dc39835c7bac774461063b50da826839e5e6eb12b9112f9908b89630b9" + "address": "Zu6t4hJBBUJU4ovfceA2HL7VSPybkzxPk2", + "secret": "1994b927514fdee4f75f6421a03536eae2fb2af384e9fdd8d070cd1b8bb1d310", + "public": "0220bd88e29aec79bdd0b5ff0117273722f4e27e37e2fda6211489bbe3df06c1a8" }, { - "address": "27jMhd9bXCjQn9Vekqqu7abH9PtMWZajQWD", - "secret": "55633bc32369dba2e54aa105bbfa5084db771ba6f69da854683ab9b3f466e242", - "public": "03a0451ae1a09c0d87e0dd1b3b366dc6618b5537939ad44889a6a8fa580fabfca7" + "address": "rj8c2gwEmCqPPQ8aeCrDTkJdmxDoScddVA", + "secret": "3bff5ba7558f7b7dbb57f9bac31ed15f5c8593497e847124808990dba099137c", + "public": "02f4de29bd53fe8376aee85bbdca748fb83bf80b1161efeaa3e23cc939035de782" }, { - "address": "ZpDLCUsGbH3qeDsTpSDKa92aW2v2msAcp9", - "secret": "e71f7a02040e47cc30c96415d34eda0ebc11efd3eee45e6d14dd7b3159c67092", - "public": "026c838c4b7960d6c44fe08bb98531386d7afa6394b644c46d472ff7818b60a3b8" + "address": "EhEDFabctpkEQaJQ733WLfWUn6MpqZU42v", + "secret": "29da61ba08814ac6cfc1c06e931142afe3785bcc8640ad712d817de2fbb0eb23", + "public": "02c890ef71edf9fe2b1d3b8a8a7cd8e0925e9a55b093fe0e34a1ed5c336b0051c9" }, { - "address": "vve9U5zyoZ2Ecj6Ajy4r8bB4ahiR9dPjtN", - "secret": "fd4506870905b878d7fd2a29dc8e0fd017596873980b12f79c378ff04b5c7c6a", - "public": "02f993b579fbb1b69b237e9c16d1d3536a445e7d91a4296dffc8af24014286aa8d" + "address": "gpAimarggdCr22gAJ4kxiF3aQecXaxQR2V", + "secret": "83b195bedb8c8ab123ac337aa943fb8366e87a0b78a46f11a6e99811b754cc28", + "public": "0233a097a9f450f42884d32110ba6b9b384339044ad7abbdca8a9dbd10644c7c04" }, { - "address": "2JWqoChA3UWsRRFpRupmFdhbcw7gntvqXYu", - "secret": "f6ff4458c6a065bfaa0e81c38468e076f0c5fa4385d7dde2a5d0bf13427fedfe", - "public": "033d82dad6c599112504232f9ec47c59ab2c9fb13c6fb168a40fc0b1ac9099636a" + "address": "277i1qEXLAMWB4EWpimpnHSrVu6zB765nfM", + "secret": "d4e2ab32dfac3fd6db1aa5e48f93369f71fb22519512aa08e27780e900bcab8e", + "public": "02734ce3a6116b3701a67d169c0cae42422bf81f2e16ee10626ae8b2534fffc8cf" }, { - "address": "xgDXkvgRyBhywNHcHWNfJJmGDB9iL39cPa", - "secret": "173ca299d130847cfc3a2b361641d73e18f13e9e8023989c420bdea4c4f9acc8", - "public": "03bb31ca3dc87852644550d7a4549abcbfc3702080541a9495caf724cebfe29982" + "address": "vKSL2GSF1kf1GQ7dLqqLsvJBXbaijecZwm", + "secret": "1e9ba0985d8e225e6b5df2a15e38503886df0fc2173b3e3d9ac7660a72f3ab5b", + "public": "0321019f74d1f922b8bb10eb6a5445c7fd7cf4e4dd4f0867bf64f43c0be0c0c800" }, { - "address": "2ieakbEoVaivsRK7fgKiYL4eJ5wnhCWHdK9", - "secret": "9e9eca03073f7ae529fc0eab90740df284c9a2bef814aa059e995f09564412ce", - "public": "033baa51212e9de554cd79ce6f0386b61f9164991b903a3cc1c196d0e004eee68e" + "address": "2E83iNBy7MQyBCuHy42D69ib4fY3PmpJGzK", + "secret": "ac1edd6226835a859e5fe8c5cb1a0fdf94f68ed17219da5743083aaf93f3eeac", + "public": "03c4b5da359619972014f1f55197d9493e392aedc96d9e814ca71128747cfc20b4" }, { - "address": "2YYSsKLUGUVoyHFpwxKN7rENdyzKbUvi84N", - "secret": "74ce83f0b95c76922c91796caa4942a709f45c08085d79b361df1c5ad826e893", - "public": "0272d9ffd807948f6418b9c53b1f815d945dcead26e8acf9aa3d085edf384af158" + "address": "CpZCFZEjSxMnMqeWWXuo3QgNw8zMUS35fb", + "secret": "db3c84f4b276bf9985c9a645f92a477fea63e5d5eff9a51c35d323a87f9b4c42", + "public": "03dc61b6619fb09fd7d69559f5c6775651b92c5c988290f481cbb7e7a2fb8365e7" }, { - "address": "nRXnfikdMrJCSht3mn9pmMdjx82pW8p1wm", - "secret": "495c59bb24666c8d57e4d7c4e01c47947e9b47d71513d2dfa17046b6bc80116e", - "public": "026a14a1e43cacfd8c635b36806c83804f09ff7ce04b1cefdac5bd5cccf512c56e" + "address": "14fcNNPALfDmtfjt3iqnUx5ECKozQwpNuY", + "secret": "00d33565e34e583a79468d6401a4789e7d623fb3e69d8d20b9f4d5751f7d0551", + "public": "0244b282442667183a585263c8a631c7abf0245228829b59d7314da2792066f92d" }, { - "address": "av3NUdyi6wRRWTaPbzvpwQnBe6zSsicCXf", - "secret": "a22a47599127e7cb29a12d15589b782ee3b15d26760b999a81553009d06b8a2c", - "public": "025b1c8fbb2d5eee12d56df446dd6f4372017f5dc3955383922f79eedb830f5df3" + "address": "yqK6WFVBpuDN4kfcqVqMi5YDVkwE2iuozQ", + "secret": "e155a8a39e9e4ba79e16ec0ba2f7c60bf2bbb9b70011219400999a920706345f", + "public": "02b55a56bc0b74fd16fd17aba5211421f040950e9484483af788ea07dd3d7183e5" }, { - "address": "2MqLDJinc2URZNgZ74cJzAQqL3pZs1XaUwc", - "secret": "057503f5d21359cdce7ab0ad0c98bd62011caa315477b7ea74a63d18ea4c5877", - "public": "033979434ddade5dc967897bd74cfd734e76cc34ecabecb82eb2a6e363f0a5d27f" + "address": "W51H6pd82ZWMw69h51yqufMkFKKTLJ6cUD", + "secret": "ee32e6b847c7061bf1a351c1b37ab31d7c2f7d530a59757c6c69929c9a50277c", + "public": "03186946c764572808287eff9ec29cb1db45511785f3ab3372d77ba90fb27c8f1c" }, { - "address": "2WoEHEVinmNn7xvKo4tpbu4xm52W8ZQDbza", - "secret": "816b338344dc89f5f0b8d3a6cb874b4b4d5b25253249c93035e8a1688532145b", - "public": "03ec4861c751281c23af052e28d5c07afe95306bfa6796d86ec0e3606f12a932cb" + "address": "WeBMYEagMqSvmHsFA3KuPAaarBwZyXGSG", + "secret": "1b3c9c5dd6b081a20bc2d24262b8007dbc2c541b71d18cf38c21f41451f90205", + "public": "031f28f96a5ea3640814207a223679603599e47b4f5f97f84788263760051d72be" }, { - "address": "vFi4qHQCk5r8HtwM8buLoCRT9BJ1HW2Ndi", - "secret": "c88b02cefca4afb362d8834a28cc2e50dc4b666257c82a1d686388dd8703411d", - "public": "0322052fb90d8c393a63f9839e04d42321b970793e94500876895bb086bb8bc067" + "address": "xDmCFbvJ54uUFsWs9JdMVRc4pLgGSfMJg7", + "secret": "8ab8de8bcd5b3ca578efc354834fd5808e732785424f14041b5bd88e52d74058", + "public": "03afbbefa4aab3a996d06d66db94d6a2bfe3c73e2ab06866b267322eedc4e8ad74" }, { - "address": "2gZVQW4CUQU7upjWDWVzmoEKSXeUXu56cyc", - "secret": "00f01aa1768e1a53f3970d6bc4df237f78646d0ab9074d96e967b5c9d6bb7ba9", - "public": "031c817136c4abef1708e4aa8314ef9117f1d4ab9cfa98c97de5332c1f5f2c6b70" + "address": "X6yjHdHhJjoZd22mBKzPbtmoAdn1c1GEFd", + "secret": "960bf9bbad1970f6e29a9dc94e7257fd97c2921336b71345575b701853b1b03b", + "public": "029a88fc03edbea796c19081151942fadad9def61bacbe4acbb2d8e5cc32b3791d" }, { - "address": "5unt9w1zdXadpT3jJJ6YGYMsLCrQeMzewp", - "secret": "dbab63d111aecebd57db299b52f3782e9c71b9ad18f79758400e74b5d16d4f1d", - "public": "0269d81b95ffc9d98910c1d81eb463149c0e47ea93748893ae0dda1d242b089930" + "address": "2NtkQYTkB1Gtv5vEuxnJ2rnw7vBx2MaFZ3f", + "secret": "244dff8ab639cd4d1ae38e838fcb970d0e409440214aade40ccac2b0c93748c0", + "public": "02f15c4404d16679aecaf06a4c0a84599287f9a672ef81311c85b25f6d11fe2bac" }, { - "address": "Uk3nditXHsRyfaiQ9qVnqwBoLt7JdNX5qY", - "secret": "8e2bef1e6810295b909888692596085718ca4fcb9eeb8481af7fb481786dbeee", - "public": "023eda6dcc7552b1a80ffcb0d8fa43ec60b7d5910c1b641e5c14d6f5b998301ae9" + "address": "qdUuCBtnWFPkqoLS4T4QeJhv1MTFd65ir9", + "secret": "328e730c6ed08d616ca8740bc05de4144f1f39a89b2840636d13dd9eeb69a1fc", + "public": "033cae48014b7dd9aaf8ac182b9d11acaf2119c4e8b136ea2eb8ef42a75e7b45c0" }, { - "address": "23QPjyswa2Tj4JXYU8Xp6SGFsGx9frmFPAW", - "secret": "3a7bdb5edb15c930b39073fcb86a7189647be18af2dfc6d670e2c1d656599370", - "public": "03b8b8f3f8fe050ce3fddb099b92e7a355beaaf0e2a839fe5e04c9d2773acb1cae" + "address": "Ce24goELgjozPagSMjUJrKdYCwfzi7guUF", + "secret": "f37bba7af44d3338c12bd91f95d0879aed78bd8763925dc657faf33f0335b089", + "public": "038ec03df3b4b5c5a51abc135de0d2641a892382732fd2471133b70b9da2a99944" }, { - "address": "zukaqy3AtcCc8vncKMP2sikbqprTFNzrUN", - "secret": "235ad1607d62fe227719c08f8c7018b2a8ce8c5f9641c6a8e9f3603b117bbaa8", - "public": "02949eab34519f1a0f162d3e4349557157972a2ad5e144f10ee24e6cdfc9bdb862" + "address": "C5x5R9HUaTp5nr44tX7KgguMp7FW3874Ri", + "secret": "fa0d9ece0ac17368976ec01348503cc026a19510218f660ae0abbe6965233e2e", + "public": "029e6d69030cb4730b95648443820e3f974e70b9d7d5ce2a2559163e0463668153" }, { - "address": "vCwidxzoLZiw8xxMAD7cYiqDTQtsVdp1CE", - "secret": "4a1791312dc8b2045bfa853905d43f73ebaa7f0227175c3604316c6ea45ffb56", - "public": "02f3cf9f3b6c426bdce115b01573f8e86c3a592afa73ab9734707c76406dac4344" + "address": "2b8k8jUXfHnDpEDk9APRWowqVHMs1C6u2xd", + "secret": "fbe064b4fcd145c2155d717bb1916b1c7d73c1d624691b36bf7df1332de410b2", + "public": "0292d4e8e577b274d72e74b3fb54e56443cc2f4ea586748e86a8311a474457e2b4" }, { - "address": "R3WPmwXEi9LQYhqmu61BgdzbMeDXfjPpu7", - "secret": "4f57224db1669384b256e6ff7a61c53d7ea77c96b7e364873715159facf1bd65", - "public": "02303e6b8dec467dc8871b2069126cd8742413a06069d52fffc1a0bdd55df26d6c" + "address": "MPZ54f9653bA1V9sDRTgPFgnYWdqdU7ye6", + "secret": "2fdf6ae40789196480461853f075b6bf34fda7f118949c4401b5d4c05dca43c8", + "public": "03e3178668134726e267877354a3e34383823bdffee27b3f7edde6b882fa4b2183" }, { - "address": "MpS36bd4kVqV79Qka7gtqoEai2imKLsNkp", - "secret": "c0a775f4eb0ca632a14399c1bea56791891ff9dc47f27048e982d73c5b137083", - "public": "030753f6402a1018c1f9b0f5a17167c1fc7159e3f3395cbef31362558b9ee3fe8d" + "address": "CicfeSE7jKdooXwA6pb2SFVmTKnBd2b2RB", + "secret": "a1f4b57b2de3389fd1b45bdb838b789a7699c5ca1d0bf458d84faa4a9e68512a", + "public": "0343a7cfd8b57d9359de6062547c3fda453cccbc4ba7524656e9ca58bd5e4f1ec1" }, { - "address": "2WYcyosK2VTdjvQsCicz6gBnCg4Bh88im8E", - "secret": "2912362be06a64d3127dc269afb9588a35bd69e96ceb816e71dfab82f575b5f0", - "public": "02eadbedeb9586a4ef338019f8c8fba98597a7933280758d03b93558b82636a4c4" + "address": "2itVDbUu9t6Y1sJB5hqGUECp3r2mA1KEg3D", + "secret": "2b5a9358c31be11e49985c2f6e11c9039e105ca9175980609c7052cd5ad10b73", + "public": "03c06daebbf6d2c25955b3461fcc8fe73c93f1fb35ec46f0129cd03560137cab17" }, { - "address": "cBDcu3mgBq26mH8kJMbK5R4Hczd39pynRf", - "secret": "ec728933180cce86756b73ec29e196088a0d4b3d5f0d088e8efd76e63a86696d", - "public": "0254552766c98a952e24ebc440fc577232d4e8ca1324619f248b589f37c3356f7e" + "address": "hmMGDgFx1gEVCA7FsB9Xo2AmiGXnYaZAck", + "secret": "a53404405b2c79359d04eaea710d283371a92e18caabe8e0cd169bb77cada7ac", + "public": "0332aed6d0d7cb573817142a69be2f34257bd95b95e04a7f29750ef284fe248ffd" }, { - "address": "23C9dGGQ2a2DdXAeprTBbjPCvm4PQSS4MKm", - "secret": "dc438f3cbc813ae0b9cd5d3b6a74ea18400117278b8e651ab1d0ba9983fc3109", - "public": "036d87b489e5036a4d0e8ccd1bb8d92ae03e3c9115163d288e0bb094c0ef169467" + "address": "2Hz4RbBvSeNbTwhFer6vV1Y7uUfqbN7FiFX", + "secret": "f5643dcfc17be04b092340b11fdad373d4bc5cab710761bdcfb94d76c005383e", + "public": "033fe130623f83bba6cbfeed537952d030f0ee3f99a4b9bcc18ebf6471274e1851" }, { - "address": "2jnnR9ccxtdqMYSmDPpFfGyX2zfftGNciiQ", - "secret": "b9a02bdefe74f52511b810170a65ddb481523150f6f062a53049a9e559bfc1ad", - "public": "031020eecbf5826e37d290f639ac4aa9447394e2a3acb209f6d478b43f36a37eeb" + "address": "9Q5qJ39aeRmY8ippsZCiodMyon2wzfhDYk", + "secret": "37e970e52d13e3b95c4db1e5e5b8b13b87a03fcc433e81d49912726033ba5b12", + "public": "02d02350a1b27a087cf0301583551ad488d336b5cd2dec48006b6dcf2a08ab0509" }, { - "address": "2bmQMX1Zzo8qQFTM9893TsVVCzXDweLypsv", - "secret": "2452046539545a08b750f03ed1c8f36e14a84347074a652c30732ce47e8278ec", - "public": "02a950b4f3581404e649506c0976d9d22abfaa5480a935dc605983de15eff5cf6b" + "address": "pXys5mPkk4jwQW3xYRyqEyQJLKz4WEypsv", + "secret": "381dd50ffc4dcc059beeada39ce30da070c0fa67fbeff5f4b183c2c3e427e7c6", + "public": "021a36d9ab658c57ff3f5734eafed081feed61ae1d6e15f0fd56bef992ab9a326d" }, { - "address": "k6ueovSXnsWHb1bCvtsGsYk79YQTJjZW7Z", - "secret": "0144cc9c95348e5316303f5f6cdc0b14d1e595d932f768f395a938881a1b007b", - "public": "03b437cb4d65aea6144b0fa8aeaeb139592fb33283b868267abf228adf3efad2c0" + "address": "aVp2GMSoJaXJp98jfksbyGxUVmkyYCTyHK", + "secret": "9598203aeae46c16a3f57551ba6541dc83052eb62bfffa65c67beb66e2468c16", + "public": "037985090f64098cbe218815361bf49a1143de4260e85519b9bbe64a18d7a009a0" }, { - "address": "2VVEvqMGrruqRWPBAoHU3YuqebuY58wUXwz", - "secret": "ab02a39032e8d248552801b3fb127e6783227f33ffccf9fe5fcea6ef79aa867a", - "public": "02f52d19b1235f2fed14b4aa405fe5824bd41bf18f64bf1dc1e1fe6a3e480d73dd" + "address": "2d6weK4E7LmeQ6viCECBKteexwQfmXJefeV", + "secret": "55c82c51607d2612d2c558c87c0ccd2b1c1b02a16616d632f09eded8ca9eeb5d", + "public": "0378bb0f40994c3bd0d789b5cc48aea01872136c0e25eb27e0593c4f8fdae2b63c" }, { - "address": "76nXXArej1iDNM86R5h6KmKiJH9uX3vU8u", - "secret": "4bf0cbc805ef6385a25f600c0fb91986fc8a0f27b1dd6894ca48dbe4e596ffe9", - "public": "030a39992718d86f89fb7a03acacb18fd3015aca2a85c64ad68a5b03ee37be7c7c" + "address": "17eYicrsFCUDmQ9Ay6k2enNG6kDRpH27Um", + "secret": "1d5a0997833672800fbf7f55b9dbd5eef6bc53c033c0659db8a474faba7428bb", + "public": "039fa99bbce21aaf219d1eadd3c9851280b447a21f5e42c3083e01243093f5d237" }, { - "address": "xYvB74JAEW18G2E8Jy3jQdi4qA7sdZBeZN", - "secret": "dfe8101d8e7afcfbae680fa14c2a5a5a27f3a9089bb7232f55c84f3981869021", - "public": "022c17d40843fb25ede8dfcd1acfd15e0f7ad495eab736465b6dce97ede6357744" + "address": "2SSfBC3MeLVgb3XyBGGXsKYzckjCbYKUgsP", + "secret": "c948107863c1f274f82c8e7759521f575b616fc0b593bb7a3f16cb84337ead51", + "public": "03fb19b4b9769665a86d3554ee26b7e44585f6d9a90109a915cfde83271d7bc5c3" }, { - "address": "2LEjdwYmawN2ZdkihaU7PaDbLtKoPzkN8bz", - "secret": "17ae59bafc69a73b80bff0f31c3afee000c45351e0790881f50f2801e121d574", - "public": "026cb0d8d55f2353881a54c884950bb19f7a6959d0e354c3fe84c9a431c25891f9" + "address": "2n18ViQiVXuUqwjEszaSWvi1kANDYKeQH5y", + "secret": "497d87deccaf1e7c30cf18833c580ac4263ae6e010273805b1940a0e652ffc3f", + "public": "02e5ee7a913f43f7f6adeb6a6f52f0eed025267b930426747909af342b5123e106" }, { - "address": "26Ch3DTr4LXmXsvhpBaTPGfeHFoBjYTVHQq", - "secret": "344ab874c500dfb74e3488260426d59d8313f7768537f61fcf073fd6a542ecca", - "public": "028b350fd44d1654723731d52ceea8fa200179528ab9d216dab0a64659f3b8c37c" + "address": "2UmBGe17SSXBpYpp1t68zCU9ojfjk66dYNH", + "secret": "d42ac161ded15f405c83b5bd2645ffb3f9c8f28095dbe2277de723395550a453", + "public": "02118d8b12f20485921989d7156e9cd06a9233abe03286992fd94116fa57b8df4d" }, { - "address": "LrBgs27GVtJFZtXWocuJ9nHAa1eWnBvsjk", - "secret": "f1d9f09ea4f3057c013c8fc0da7eeacd0e281c9d8f94213b38543665c542aff1", - "public": "038348a8eb20a7a95f621c8948fa2120c3bf23a222f1ed80c65e14452770462de8" + "address": "U8YL4g25u9NnpALPn5aBGbosJXidvCooCr", + "secret": "b6b75cfa9529e12e39394a5852a077061b172da0cd6090a4271f4f942b82e7d6", + "public": "02c5094141d4e994dd81e81e4e91a6b81051370b96ebf41a624f3499f9b4525119" }, { - "address": "2Aq48zDDkn2gmu11YuDfapr2tf5kYS6Tpbi", - "secret": "434c347fbb4b925d1abb4cef5d3b3138e33c6892b772247a1fc83689b733933b", - "public": "032037f55277d5ac38b6c0603119d243652d0861b5f1651d565e6497fba2a6598b" + "address": "2U2k86ibWdUoe5BNBj54d96sw3rFYXnSySH", + "secret": "e715f598acf607c8552679d0d1833e4ca10aef44e4d662aca8ea84adb71840e9", + "public": "024041c3512656d1736bf7ee532a726ff43a4b4b93a89cf437640ca3f6f17f8eee" }, { - "address": "7a8G2sASPMcyFc6fbH37Dogr1oVUZ5eY5D", - "secret": "94fbe57a57ef189d0d20dbcda1b4f1957704c7c4374b47a9b02386fb7e7fb31c", - "public": "038335c203f2d1d02518d71b3d296de309a93de5de95513dd9276751fc3be212d4" + "address": "FaibKxHFYdqaorDr3KYXq1pnAYE8581MuH", + "secret": "cf2ebf9d3f6d34189b32c7e7730de432e6ccf9858becc80be734523c5876ce2e", + "public": "02b6b3963a2517bc2010d3042e5e8e595c6074538b22db7fdbcc0c2d6cf5931922" }, { - "address": "2EyyHNy8EwNjLNVQDbAax57f24iDinHziPU", - "secret": "b9db84336b66600fbb56504c6e2d5484f46bbb50a46cb7b3a40cb65b7b5cdffc", - "public": "027b07388f7e7d2d66d01454b3612cf1a9fba6589155df1817d12aed97f38a346c" + "address": "pB9Q5eXorXGxNZtxfr2Mzuk7xFBYNpMnEo", + "secret": "8f92555b725ed6e25a5e5805f53c5624b58a9706cb144d5a07d60509713fbdc7", + "public": "03c97d38b690b41240cd7e1bbf23529d178742736d6f1ff9f5a8a688747eda0e71" }, { - "address": "LMRZtvHa8b7STJFNuvr9Sio8Hue7sKTXuR", - "secret": "97ff5cfac5735bbf39abee0e5daf52f850f65529ccff7b1b90a30d1ca175e0d1", - "public": "0385a3c5ca70dcba39d93360792f369c1426c5be37d40047e460ff36ad6a0c7c41" + "address": "2Rbxzsa7C3B6cYTdk3Fun32woki93ewxvNu", + "secret": "bb6d4b2d400e6c1b631eed7d4f572fabb51081327bb6645c425d9663e0ef8a12", + "public": "0363d28fb085932c0cfcc17f1174fd70973798ce480af85ff4430bf0bcd4715199" }, { - "address": "2NvVm2jhXG2AoSjDSrxqfpj1sfm9kgL7dZo", - "secret": "491efc34b937c59853cbfcddb10e84709b80ca2c93a07024b7ad062801667773", - "public": "031c6a9d0fb81d33ebd6729ce9d6f37cd12d878764b423d7e6ba871f20b119665c" + "address": "Diq3gG7K6evBUEE8osDTPq4QKtXzbxUtDi", + "secret": "81b5d2598b5dbb522a57b67073bbb6a130f0711923448dff127c02861b03a946", + "public": "03b0bb0ab5ca2984c0f0fcada6907ca8250d22a001ee69380b083df443265e3a98" }, { - "address": "EWzpaxdBPuTQBkAWkfViaWvPVcfPaGwJWa", - "secret": "8cac7e984686d7e7afdc2679fe34a98f48926ea1cafa6873df68dc201ac1c698", - "public": "03230f27428e5e77593458d5abfa90b2a5ca583699b8a3ce74a55e927dd03b9d50" + "address": "2epzEVetCYHwuGNZefGrZmzYtpeaHoDAQEY", + "secret": "8dacd77988acda3ff11b62ea1d8ae24b45d398b43f91147cac23451c5b68afb8", + "public": "035afc03e6b69359125261b3c78994c6b04525f09b0ae1c5111357be772ca88aa1" }, { - "address": "RSPjwFqb3toc27cxLfQ62GBQUv4nvD7gs", - "secret": "63a6891e9710131bf04363cc749ce5b48b49168a5e679a88a35fe72b59abd70e", - "public": "038b9278dae25a0e7220a2280fd5d1f7a89eff9b60d3ddbc774f3217e269d2ffc2" + "address": "2Qkx7LFzEfxJzqWRPxTGjE4h8sFwnnfZSsw", + "secret": "d828a1ea868827488473c9cd4347c10408c00b4b42c649a975f9385560128607", + "public": "0381df65e2ae07acc12d48e09253698fa510bcc9c9f8ec34a136c9fe248c432103" }, { - "address": "2G1fV1N3RD7YWZQZUDNcUMQQmTQAJs7onQb", - "secret": "7555a3ba9bfb93ac716d6ed8e9a412c8a7daf30ef1e3599e857f8af57f1ef921", - "public": "03662b6929508392cf61750e9a56b81c839dd3c5985faed415c29a2b6181a1805b" + "address": "gj6RTW7z32ScNorWP5WzHCgPPrh3KT8kmU", + "secret": "6d10041a9ef43512dffb1a94c82171ae2afecdb62a729c48072a877967d2264e", + "public": "036bc174c86d63f4470e151ada6b664dfd7c29bce402543ed249aa7ba67568df00" }, { - "address": "2ZJjWSgGmPfu4FAoZkGB2brrH2DsNCLYVAx", - "secret": "fbd4e1620c337d87b08d55f90a494d8223b759eda9151bcb43d1049db6af6977", - "public": "03ba76db3041187d02bee69290722da5ec900ce9967cf92ab30b088fae6fcaf372" + "address": "zAS1wCFHtdeUgwRWFY2N4cMCPnSTLd5R6A", + "secret": "0c072c2ec7c3a4feb9b946856082b9ee4f35295bf9b278349a254d3d12260c80", + "public": "02439f39e43b0a399cf84982f1e7085b5a2c0fcc248aa6ff6a7a80e1260c8293c2" }, { - "address": "2HFNBbWL661ZdZq8Bo7xwUpdRj2hW5hyUQY", - "secret": "5a6140f49d2b826310ae1a15d79c9ce7048df5d93381ded3acfb744b995fa40c", - "public": "02a847ead6d08d643b23576ac0f56c268de0be1c0e31405ca9bf63f4911ac42130" + "address": "6Fs7FRMk3GN8Z1wxksyJQTbmwjgZPcT3Qj", + "secret": "11fa5cc4f1da12b142b18f031b8de70588492f3f7c136b8227236da184bbd17b", + "public": "02773f6b07f15b38a96b3f3395206513372e92376098c2421bc8778424ef19a199" }, { - "address": "4sfrFMU22jb7B6YPCraDbWRNuTqvzgHvGD", - "secret": "eedde99eaecf0de38f01d7d2156d4abcded88fed4f9206f521360e6f03978355", - "public": "03490210d19b8b830a17204dc3d7ee852a0559c6bb1bca51a75ed733d5415df93f" + "address": "WpjbGPfvrPARdjnfARbsPhA64BU36oaKms", + "secret": "a3ca77abbd98c442c15ec3a9d755f708474576986d00a082b4999939786b8bd8", + "public": "03a4b79952218f7d035de076d464eb61ef837bf58db060a4765462c95b4342a8a6" }, { - "address": "21VT2fAki2F3NgfDgt5PLgNTmXbSsPf9b5T", - "secret": "6f99410712903cbaebcab90ffc1d2774eaf76375521be29a8a490eb6473ad3a6", - "public": "02855977aaa860760da681f77985a87bd4e4e5aa30408eb51bc222f925985a5a75" + "address": "26XKvqVnXe91pE1a6nnfZyjHRmNcHNQX14Q", + "secret": "816345565c3d408ec600f7f012185e5e35fb201a2517f56235e96730021a032d", + "public": "02d5ee48f9e78e6ccfcf20716ad8991624df0e2f08f9585071852d7cdab2505306" }, { - "address": "EcyVBmXkjttB6LT1Hxfw4cSVEpDraNJAxt", - "secret": "91533246976c286d785e03bb0090bfd59cd542e596e12a0b24e532359fb45cc0", - "public": "0260c2befc5f0bba653ba0b6e583a6755c718b0bb7e9313e24390417acf76c5f14" + "address": "6ymppMLFLv9hDKngn3vUGXuKa82n8fVNRX", + "secret": "04341a22e621f8e46dace5b8f4e6b4a7160b864474c04c3d96874e02d1ef1277", + "public": "038c519a633e90ad55987f55ee03acac4bf269323dd3e5367597e56dab4f0a16dd" }, { - "address": "85WSHsp9AoeCtuCAbP7yZv9vnduyoQvM4V", - "secret": "fc565add3acd6a3c1ec2e9a2fc3a30ef307f84074ab440c61a3eb78034667fa0", - "public": "030df3778953e4d9a08064fce19340ed80a54acb1c3be575cc1265941edc26e160" + "address": "3BfpvXz5km93FKb1L9q3e4gZ5tiLoNN6ES", + "secret": "388a333fde8f497babb32008b17f4172849320f16bdd6688fd6582a52d61be2f", + "public": "03ed04ed7f880f3cd8290b53ea0f41f44f227e842abcc43d73a9640e5ce216a79a" }, { - "address": "eogH5JFiwv1woViQzrqdYyLQrzEmqywehb", - "secret": "9f116dcc0828b2bd89d2aae1a85bfabc5bdad81d50fc274ec911aa6e5a7d3b1d", - "public": "02e4a534fa7d96a371e92a4dd257bca79961952e4fce6f682f3570bcadbe5f8e72" + "address": "EaBntaU8c9V3EnfSo6uALdB7NVNVm7BSfU", + "secret": "2f0cea8d8d0be0bb2b826b813cd24da9bc6a059f785dfca5f372d1fa3ed66020", + "public": "03893d78ebea3f3835ec5b88aa5b0fa616a165af23384328a1689c684af46f74e0" }, { - "address": "217idSxb6BQctVj2nnNtvDsmxnSt4MmbovJ", - "secret": "ed8131cc1e686e838b8552176bb2101a0e240f1c095cbba4dd70d0fc039d509b", - "public": "0305c35408624454ba4469ce04eefe11b5a851a93a7e7812277c58df11a713ba05" + "address": "85ewkkmYE23QsaJ8QGHDQ6c788CUTDEh2m", + "secret": "8156a464cd249208b3456c7c1be5d8ecad3d42212278cb5db58d036503316501", + "public": "02cf694432823e75825bf1a9034c2b7ad054210bad5d58250b0dd8e8107a808abb" }, { - "address": "TfjAAtftnGFWe3s6UCHZTfQzuFEQJ2JM7y", - "secret": "ca03d3ad47356d52f56304283f8967fa2da907ddfde4158ee08d29ad27e4eec4", - "public": "027ec9a54da8036f707b98b52c4c468b51f33b6396736bba0e12db1bd7b201129f" + "address": "2fkBZZHm9KzJCj9uTwyU2EKeGVGaq2T6Tsh", + "secret": "1ba157b63be9213eac9504fe35bb9b8b8441256bf486e1184d1ec95de2360b62", + "public": "03026989d4b9ba7c82055586525a3081b52ef0bdec1c60dd72c5cd2a317d7b7b9a" }, { - "address": "2TUiFHaSPmaDoRphRJLGpvp7DjZGB5DcLoW", - "secret": "7d47743a988676c8a13384e2da651dd46395ace4f89a53b8f377c249ec21b629", - "public": "022cc57e38284d5bb96857c872cfb7d90acd23801a1da40f09a9a5b257c52d97bb" + "address": "shgRMgZie6idoREA27V8zzB4YKHp6g3D53", + "secret": "0b530bc844170e8c96e2fa0270bc25b18158b1cd0a0dc335a2082ad78ab952ce", + "public": "02b9be84fbe4377cb38084efb37101296fa74871438153bc7c10b50e648a467f59" }, { - "address": "QgqAnv4axVcniJp6ziDR9Bnza2AP7Q3et6", - "secret": "fc146d6588858622ae43cd61049334226e8e85650dae2847e7e308df0b026ca6", - "public": "0320dfb8c51b6985574ae8ebcd11cc2ed077dae0225f980312af6822964cf76bff" + "address": "2WXMUMWm9BxPgg1nu8Pjo9VAA3kv6z1wctC", + "secret": "677e5a6bd11d2d7950ed67cdf19b2321a7ef6735793540615d7dee25f4a89099", + "public": "036d544ff08e196318752c2d0694cfdd2df265fd37f8f701309b206169c894464a" }, { - "address": "2Z5B6BPxZDDUGpsmEKfgB8nXg79aRMG8Hgz", - "secret": "496eae79f0da0314a7c7f890638385ef274e56ee3aef5160e4a9ad3452f0556e", - "public": "03a4d8945a7c7692a5e2f1be37640d49c8c64c96780412aae17540b85ac103fac0" + "address": "9h7vgZXrxvpSNkh9v4di38NfsAAoCKxdTV", + "secret": "64687125d8d1d0301bcb7c7f8254148ba674f2fd7976fbfd478e388e2fbdaf34", + "public": "03dda10d0169d9492fe86e73dcb4bee444f8655a3ec54630599e1873b49d62361c" }, { - "address": "2ETM53aVX1q32Ws16MAYr42EyCCuyqd1e5V", - "secret": "cdcb8a9a91797bae593a381b64505fde8dd81aa609aa4ffb8edc3298826e512e", - "public": "0298be12ca733cd8a79173041ee3da02a414289345a735af36ee4c623c5ff0c10c" + "address": "2A8uy8LLb5VxUt9z2V2tqvFJZujEQKBvHk", + "secret": "4418550903f77fb6afc475aa45f6d46385505aaa261d3333782739aac63775c7", + "public": "022ed942f2c7f4ae006a56d40d2f2973a9f6489539712b09755611e519861a915d" }, { - "address": "23oEJ7CX83nMGkpfkJEZHTLHJEFMNra7uC7", - "secret": "fd21893a3e10ac5200c409fc80542f59565fa8006d9483602277abbd0881d108", - "public": "028b9be7abbcd349a6d3abaaef312139a96f3279a9a3d0f189ae8cbfd9ca7f386b" + "address": "QcURHwLk8cNaycfrcB2Rw4eLojXTXFafrG", + "secret": "22ca073353e4e79b3568d7f273bdd4d7798f32211856394caa568c06e45eb379", + "public": "02a633a0584586a40799160dc620f5198cbf9288ca1e067cce1f9983e7cd536616" }, { - "address": "QbNSQC1Ehpy5suc4cQm7c8DmVdbWrakhjG", - "secret": "0bba4b4fda5f498efe616a58a58f40af00387b48ec0a91d3adc4946fc9e4d1d9", - "public": "039ee1eb3c5720c19d01ecb3fcd489e71216ec4ab9064be87ec93c185a5eda4c2f" + "address": "251iuEvBheMsacZDSmnQeekfPtwjQpf33hH", + "secret": "63751fb3da5decacd945ca81560f083dff8eb89807b8e9111e306e547578ad5b", + "public": "02ed51caff4445482542a0b6ff7156da9bdf7cfa8d722c7b181c1c402e5b33beea" }, { - "address": "2dYoW9dvPzerxbGP9gnBERgjVDk7qGhWk2F", - "secret": "7ece73fc6869a22d2ec19ad79f72cc1a5e4e99afa9b727996cf52f370cc1ec7f", - "public": "032fab9d5295e05f9a75a9ea0c86dcdbd06ea8fc08d376e58585dab7ccf89d68c7" + "address": "CJPiAxCd5B6SEg8gwPDGFi8wfQ7MmmCY5U", + "secret": "1ac56d8474ba1909a44e93fd62516514219c3df4b1d83a0caa3cfc8a9926ae98", + "public": "021c30a39512cd8ae0a1dac9bbe80031548c2efea00046312e84bb90265c674315" }, { - "address": "rLHei5RZ4CgyCBcRBf3wthcEyRJf3VDBSF", - "secret": "5999930368e831c03f73e2c3dbf28957c5b9913688257b283234e61e2e9076f2", - "public": "031d39e6f9776d8c4be0fc4d0f9c33958b643413d38bd4c4243fa3ccda3306852d" + "address": "2WngTwv8JkpeBGnz78k9WuzUYhspAcjV4zF", + "secret": "e077f3e181e3870cb6c3f3ee95b61c3cb61a05c40661073729a71e228940486c", + "public": "03da594d2e0fa86a0e77bc47b832fd1f270189b8e509dcc14e801103a202388467" }, { - "address": "2QPaAYJNKvn5SCJq9PH3RZTwASkS71a42uL", - "secret": "f8e8385ca5b8c951836e7c385ae6f7eb332c948e0e665f00a3ba972bee719811", - "public": "034bc8096c03f6268a796a752063df35cf987046fc347bd8ea6fee2cccdee61adf" + "address": "282LaqNpQNhgBAGQW3uVJgTTFFbjX1qvAEp", + "secret": "26e1bf94fa2c8a12ea407e10bea604142e7b81c879cadd378a8c151503a1dbcb", + "public": "03609ceab8230f56a60c6d85f9a4ee0b5f3275ae6ee204c297cf3906404a0e607d" }, { - "address": "MajSsKoLpnSBjauCjCRbhWvhrkTZLg7T3L", - "secret": "06f7fe2f7a027d982e6518392e8b68abab71bb033a627139b8eea91cfb3a4c32", - "public": "02126882fb8598482bb79d96a5382668ff3c40b92c5effbb70e7de7775d3ef9461" + "address": "2M2nyEzS8KcEgBHTFpTpQu5WuCHMqpwyaZQ", + "secret": "485604374652f35a5812dd9b75019d7082209c02cf775e837500fd0233436a03", + "public": "03a7cdab6917f1f5d458774a1a6a37216da8476822bc1f9e89c66bdc7cd0650997" }, { - "address": "2EQGYqYhQKyZAHjDxhkXGVvNc5q36d7kSmo", - "secret": "385084482b4fbf07f225f8fee15c95a9b142c48cb3c977225426041e85492acc", - "public": "020d0c8ecb346a6ee65a7a39d4626d84a0e55cc6138b248ed4e5d6d6c87f1ba3a6" + "address": "P9xPYDRBaZxSczCGXnkepWtZfvjKWcjAJr", + "secret": "9abd8aca5eb851431dde8a2aba245fa3dca2f196596c75bee0b4b1f5c54a8bae", + "public": "02baac3167bc9450f0595027f30bdd5fa52e8e7e2c3db98528b4bec3b116ba03ad" }, { - "address": "2GpG78LGMg4WfN98CVefzrCYSLPpP2fxKdn", - "secret": "289b82e1c93aaf54782e51db05094bdfecf9be7ed75dbb83cefb028cc526f549", - "public": "0214613b75e418e95d87f9f90e2983bdf98b8bb9070318e24f3d642c031ac4944a" + "address": "23avPf1yDCPwYDooFJ2uA3ygMshBq24oa3b", + "secret": "425570cb9fd473ffafa9c3b10aa9658301e94171cf6625b8a0c8f1a1f284575e", + "public": "02b3c25bc926088840fe0325c4c277d1e5e135ecc47d77ee30135824767a682af3" }, { - "address": "XANqnZv3nFPU9Q5vZnoUqPr39rzfwi2DYf", - "secret": "c1e262e82db6fe7a5bcd3b0108125dd8ab8f7c5087c1c49cdcc8ced73a27525b", - "public": "0397a3708062c06037d731691e7bb0d783719b7380d4dda1a3521df72630aa06be" + "address": "MFY41NGXYtAxyWsrSPFGojAVuLRUS24tZ6", + "secret": "aed7361510bb9fad15a1efb6599d7759ae3e4c154145f386e415d2d86af09b3b", + "public": "027658dc03f023433ebae5b19fc13110b8bc81786355a62cb0395fc4f3e44f200f" }, { - "address": "WS1WedPDRvx3MCJ91oHHm3A7DSxs3bzY44", - "secret": "3ff0c0e517695f67091f492788390c2345309c3c66b7dd3dbd3f8c6e4ee5393b", - "public": "03ebb24b1c2da827df6a00eae8977d3c637b66e557aee0deafd19cad33e82ba6db" + "address": "2mJhg63fvEcfvHkjABt1sqhsV9U1R9fi67g", + "secret": "c0739f6996b0fece57a490c12a6b037739526f709e56e8ec93db7ec58b27a341", + "public": "0383d00c097840d92b66c828d555f038dd23f160e1408394ab9708ad9602811803" }, { - "address": "276Th6CbA2hNvisQ1rACStjRZK6hxSjbRiY", - "secret": "cd55713c599ddcd4324df12c505295b7129bc81ea40d3110eb9b39e2313f8711", - "public": "026d1b0c510d3fb31d752d0dc0aeeb32e22cffbcc731d69bfab9e4bbb9a7b01fe7" + "address": "B7uERaApqSwMahW6VeqZ2HekW6EHSRLuhu", + "secret": "e68379b76208250614afae494bbfe5da612e9c0de863ad2c916aae46f5a92887", + "public": "0256404e09850fdbd455763e45b75b79aec15b5eb005cb89b906fa5c6099f84ec3" }, { - "address": "2XeWykjPWgtP21Fw3LqtV5aNSutv4QAhmmo", - "secret": "8fdecd647481825bdab7e57a7ed3f8bccca3d2fed3925ef1ca562f967d8de18d", - "public": "0396da1b82debb3afbc76e724ac6e41c98f1fa9e403d02b26333a1ae6d69c4c34e" + "address": "68qcyx2YJY1C1sFvBkSPpmqpN2G88e2CvA", + "secret": "f9adaa10140355edb590e61818712040662491a6eb59765fd3d8364badcb27bc", + "public": "0321c06486d367c4c40313672c3b6998c7291e3cbe0519e13827a7c4049d5c16a3" }, { - "address": "2KNzvh95YWLdtUbvqCzVPhKELeB5wntGFCi", - "secret": "6a9bb20a1b12c7842019e5fd61de775d961a32b4567d7c1eed8461ca731c2e34", - "public": "026e9c9dd0afc0b53a98a916bbc7a5b37a5782d1a4910644e97df998e35b8a6f0d" + "address": "2FaMkeRPxhdiuDhUhXqLPv15pnmsS1oSkqo", + "secret": "f0ad71ef9b7bbd682988ee3b7ec68ead4c9e7dae2e0fc41813ccf719b6ce2857", + "public": "02647a9839758ed0830bdeb1c1ce2769acbe4e8deeee42ee745d3d7f18e8f261d2" }, { - "address": "2Yc3yJVnMf51xCgFYQ4obcVWBsWizrFopEo", - "secret": "f8d38b090245ade8e2242f8ffee55492243c2f9a7ebc9684e838f87644cf0f5d", - "public": "0251b01792fb3f38a7c45bea097cf6297f708b4d3b5f0c33640bece794048717ee" + "address": "CFdDHPNwmVk6WhC39WCvWyrzs6SRo2bLXz", + "secret": "ffa8b3da58c93aba377e1292afc33849cd796d826d185aa04964473f0e978343", + "public": "0288f6df8b041860d17fd8d991c87a164ab51905f79c85bf93930042ce196c1df9" }, { - "address": "2GDrbZ8wteTWgeUfBUfAQWMJMT5GnNauZPe", - "secret": "84a8abe04425efbec3e32faf6dad972a7fda87e9d4195c80771ee295e86ac6bf", - "public": "031a47a13d0c0fbf2b704c4870e5242bfb1cba52bb9dd7ed13df0751136d4a5c93" + "address": "FKmFe5i5z2krYxQkg8NTq8PgPXRdP6xjLs", + "secret": "06e70a542984378260026ba1a0cb09fec849a6e3de827129be09234c45959046", + "public": "022df795fa62b6497c171898520b4012b89ef28e66dfb2ec4c01dbd83d6a633d08" }, { - "address": "2DKoNXqbPiYvGvjiJHAMFNWE5K2CaogoJsq", - "secret": "a1dfd452208bf4eaf7554207e6a2e45a77cf2a39da1d9bc31130a2827bec353a", - "public": "026bb8c4b4094f0aa1bee5f7ece27076b26e40786f757f522508c7ac33c000e77b" + "address": "NxKCPRWfvHmpavAZw5MjP5d9JcXieC34Kp", + "secret": "9ccb0d6970a675903491fe280f6b07dcb018d3d7e470f3c1a6ec2984aaee7bcc", + "public": "0220b8d468f5f1f65ef33948aca4606fd21bc8b908a28f14b0de18dd18ccebb838" }, { - "address": "21txBjPuyi9pnNsDjcqawUE9ZisjG4Pbkhj", - "secret": "5fb6b9793c77b6db9ef5ccd9ebf2bba92313cfe3798e42ae21f5151814cf41ac", - "public": "029e1f22c60686320a9e48bddef1a7454fe17248381ec11b63753a01743170018b" + "address": "RJgPnJMTKBo7KuEDPd7GQQB4DeEtyczUT5", + "secret": "3a765a74fd919c407a95ce6d2ad9491641589a60878b785d9e18639e3ed185da", + "public": "03fbfd66876c8200c688488876f227df16a665e50f455ad01b3264658797c54f73" }, { - "address": "2Yy5PXo8FWEd4umB45EfjVrX3qdNWzmQVZG", - "secret": "a6bfe4edcfe5d5f8e2b8d949db88f246ab2be50bba4779af244866981b97aad7", - "public": "02317bacc202e9ef37249fbf4cff9767421bd19affc03833e38832d7e9261c157c" + "address": "2ZK6KxmX9T9qk5UnFb9SfNM8LvrJejux5kt", + "secret": "0990c94bb8b0d8f7cd3e7e097efc6e85525720992a9b8af9bf1f2e5127f11277", + "public": "0393941b893f7b4efa9d0ecc06df1b55d46ade9fe9b385bed458fc172094b9cbf8" }, { - "address": "2Lac7SMNPnhmxeZJGGcbbiZcCiueB3dRQg5", - "secret": "cb4fe67d3f700c296b50e99016deecb2c53bba868255dda241253826f08d6d09", - "public": "030b2e82fb5de3aaafc7e2e8e0acb9974c2ea60a23d6722c279b4c42507d1fcab6" + "address": "2N3RdM5K4r3eYmHCFDH58CnUGx1gFMmx9o7", + "secret": "8cb43acb4b196c151e45227fbde9488d9e15bbf8da3a1b45b8997dada8700cde", + "public": "03f6c1da3c8f27ab64794a00599887c97f32cc9e42a822451ecf26d508eca9ad82" }, { - "address": "2RxrMGssAe1dJomS2Bf2ZkXZwu1NwdaFWG8", - "secret": "49c8fe0afd4c6770715524b6a0e5d977c91eef1cc01480c82a827fc0ea0ad0eb", - "public": "039f293328f93d56bbd92b7048378fb125366bdef144d3d2583249b1fce46e0d83" + "address": "2H1VNSr9z5w1szqtva9bRUCLXsyvLNSXWrq", + "secret": "b695dcc4a615914926331365f1e894c6efb33078e44d87542bee580574f075b5", + "public": "035020067ebc6f0b5ada96bf2ee82177cbe2fab157cc6733cb52a05047e122e0fe" }, { - "address": "2cq4oeQ39hrNaBQryQ2isWGs5KNMdb3sgqc", - "secret": "59e02ed9fae25a9ec12c41ed01dcacb1f0fe3eced1601bcfc80e2676548dccde", - "public": "03a34cb69fb320cf5e191a26d29a93ef487e634233369cf3d211a0a3e63352498e" + "address": "msNB3k7p23RwHgHhttqpuvw4psfysq1Rkh", + "secret": "75b36b96993b83d56a21376aefb2638fcadc03b3e1a1d67332aa4d5e05842167", + "public": "02cb48b18b854d05d3fe595c9036a3e0f486761c43e7dea7858a5378b97040f5f0" }, { - "address": "wu4ApVuJbZSXXqXoyf7jh6kxcLhmh5RZCk", - "secret": "63cdf40973b4e03fed7fb5dc6f745c5d4515a27a3774e4d5d32a6310e6d14fe8", - "public": "03ac2d534a56ef6edfe4f7c052e1b6f39a5526bb68a17a7bd8a9734b454d832a97" + "address": "2f7axMoMyTFgCbkbsXvi7zRYgQFdhPZXh6P", + "secret": "04fbee77d3726559ed06eb2f63c11dcc231547910d70869a0e061cc858efd0fd", + "public": "02594db5ca23a3c18801205e3aa94b1e70e1eb632ff0e5fe092d1b8f109932a9e1" }, { - "address": "2F53rUvV2d6UqhPApxZBaJ1eEzTa8BTBPVB", - "secret": "50a04d2281c4d03e218d7d978c7bb3bf3406e899a7b0c0f52eee192befd4e8c4", - "public": "02ae89d945927efcd5e0868fe8fb419afbebb92f73b3bfe3a5d3e0449c84da5338" + "address": "4nJxCkfZkzFC3Gcng9yB4jTYbc9jYoeWui", + "secret": "7b4eaa2f5be99c3ff630558e26ec8df249d2f3faa2f6d5e150ada68946e56024", + "public": "02d6e473a3f1d0ab1d10f3e49b22a0f10a0c7aaf6a91ea20a4c0cc402e7be557aa" }, { - "address": "29V8qLsXzpeHB1L5ePsVKkT8YyU4VYkyJPR", - "secret": "11e3e179ee26eda9b751e784439709b70afa1893ef457cea434a0ebba5410a4d", - "public": "031d8531dfdea143288cb9db45441c41d1de505f25cff9a3b3d9d408d13819b49f" + "address": "yuGQw5TzntwHHSFZ3Fj1yNfU6DuVtrK2Bx", + "secret": "d716d9193356f96d634913768b0a9fd5c76378d87e472a20afb086566b17ba7a", + "public": "03442b91d87ed6772e0fb557ba5ad2b481c78cca2730b4ffbc0cb637c14472f054" }, { - "address": "cRqy6FMDVhf7S9WRreiSMEoiB75xRZdbe8", - "secret": "bb0fc36931ed39c78a321e51fecfc33def7a7f3b927542f6c7776aa07c6f3c1c", - "public": "031e53e32f7438d8567f3a80ad0588aabbef5204bb788e322f2b5d46dc655b646d" + "address": "1L33Kg34Gj7yccMoJKXj2ivzQyxihoybaY", + "secret": "4583af591c90d5df33029f874c76ada794ba7ba2800fbd91778131ab8fcccfa2", + "public": "03723d1d42bfc722cfdebee030af95936030f602ce3c464593eac6bb048df5989a" }, { - "address": "RU7Hqg5QatkdZ47DPwQZNeukiHpLDhkEBk", - "secret": "800ec58cd0db06c65ad3e806f628ca93d2f19f8fe27c3d260d5124a492eaa095", - "public": "02cf7156f175871bf814de4164130a00c6d1f5b883b17079794ed80e26fc3205b7" + "address": "2NwiemjJATwoJ9r25Jfmi6biyYtBUJqZ7vD", + "secret": "c96a2a6ecc7c964766e15cb3e6e976500153b5d6192d8dd4520a8ac9077bac4f", + "public": "03054413578006144e776be5d65c171667fd0466f41c865fffa8d8ca4f58d3b46d" }, { - "address": "p2nhFHRcX1k3u9JXkcC2aMDXGoDtDkNNoL", - "secret": "44e3260ba5a4bad23b423c2028b2a93e038a081cd0e9871cc756687f7de350ff", - "public": "03230e22f09ed4b35290397f17535bdffcb5ed5a0c87d48941b1149ec0d837a7c4" + "address": "wh6cxtvGracfHfKPga1Gw5aAYL7YjiaoLV", + "secret": "8c2e6470f1505d55fb80d4112807f7dfafcbebb3e33ed5e5bdf844fcd8415e09", + "public": "02a8e00fd4e4a06e017c17f3d93edac7060a8f97ec4c2226552b6881d94e102449" }, { - "address": "yBt7u6bgu3QxbhB8DvJLFoy3x12My3tzXi", - "secret": "79ef1978d02226aceb7b4bf106401a9fcd15bcd5ae90561181ae7f07aecf74e5", - "public": "026456eb6f00de7b28cb68ef644b82ae79082f61e19ec7de1f50bf76464a94e0d2" + "address": "2jTGRGAkWVojYeNrJ1PtE1ppcq2mt2dCQP2", + "secret": "f41b9f940cc71f9fc889bf8e1c42df2c8cdcfe051f6e9c0bca2f3567f991d9de", + "public": "03de30a46efc8ae7e14926487fd940bfbf9752fc48f8260d17362e59fcd98c3326" }, { - "address": "avZAtjrTbcCT1cUtjveTBWjDWofjU6rZwq", - "secret": "7a74a0481e821cb96dbeb3c248927d6d68ec625dd3e256211eeece807ecc6b1a", - "public": "03944e5495bf38792c552f02cc38130d3ba44721c26f4aacfc5ff8bae242f15ed7" + "address": "2gunAdaL2kStrQEcaiN3wYXpyuTZVdCQgJu", + "secret": "ad8a98fea822a9f6e3dde77720ac33b645f1ee653653b5002daf0b51b36054cf", + "public": "03e71f0b9923dea45f5b36f03cb39ec95091be101f50b515dc4e7305786265f12a" }, { - "address": "Jbaq8FXD7x5dBLrJyDS15XGdTxjW9k6B3t", - "secret": "a0de8c920c1a3d86c3b0601d6bcfcb51533aa424157b5f9edf922c9098055a64", - "public": "03ff6afa47934ab42d432c7ec9e157e650582ebd40f0d9123ecf8a5837fb892e9f" + "address": "2aqkXB7Ktc9UqD3cpD85LXWM6K15sExbmjd", + "secret": "ed8a62664b20244f817ba415b88748ece10c6c017b47c1eadb6aefa81a1339e4", + "public": "032340ae72ed38c789d18e9c79337dc7ed3b758bf79ca46bc96d859842522579e2" }, { - "address": "JszcJgu3Xe5o5jVRZfoXpAfDbE6pUXKQst", - "secret": "b22abe22d4e27a1306219717655595cbba8b8ee5b50999f45be5bfb59af484de", - "public": "03cd4880a79da5260b77b5c9308ec6eebbfe79756daee0b86e83d4b6fdd93243fc" + "address": "wAzQNGrVRX4YUpa1cVAHHAfhDUNedenZq5", + "secret": "3142f3da96ee43338c96f9adfa031a4c8f9fd6c2ecb1a3445dcbb1120c25e9e1", + "public": "023795f20aace810257af3d7b3657f91871dd420dbf71b8325bf5d4c7483f64566" }, { - "address": "2VFpwFrxGpqcFSaLQE2MihAxfYM9qEfEd41", - "secret": "6210680ccd1ad8acbf479652614f6ba898ea59c061d4518f45d0ac74470a7074", - "public": "02dc5578398e98ae2476f4698c90fcebfea13bb0f98c58e61d6455606dfb33d2dc" + "address": "EPMifzsxYan5zGa4vQucqTqRhoD3FVppLJ", + "secret": "c4822448039a8158ce1df9226658200617b9567731d40eeb194932420d3fa3b2", + "public": "02d9cf102f49f1f4a179bc1c3f1b1f98d9b048521a4030adefec219c578b084a40" }, { - "address": "YrzicrGJCfPf4KXwHVhaQa7DpQmDZGKnQD", - "secret": "18cedda5cb13cc490107f6c9e100e0b8d84f78d09898ad70324faf6478b3761e", - "public": "028312a435c211379e4a618dd65bef5e92bacebd072b554a42dcf0069b21eed5a4" + "address": "S2A5TZc9KreFuyALfSrAEqtfAnDpNZc94m", + "secret": "447e435d5b33194e4d9e4fc2843f0565a7d0d4b70f5aa9e5013b41f248cf91cd", + "public": "03c1fb28de9f691912d2a70babbc75bbb98f631600e271abfabf61d91cc8cc4daa" }, { - "address": "GTrVraThPGf7tRXAwx1i7Tb1LhGbQ53xaJ", - "secret": "583134eb2fede7f396f1cee8d4082c8dfb6ed68a7b0bcb7ec57c9cbf924a7f88", - "public": "02b276d6a10c44edc0f9f330dc9b7e9f1d0bc0a56ea7217a9d064617114d2ca13d" + "address": "iAYSpkDoyaLaR84EfrtQvN717B9u6fj4qh", + "secret": "e7f0edcc22d803e6cb9d267e081749371654f455ca285fe89933c036dcb371bc", + "public": "033557467e9d623824a3fedd7291f0305b8ee6ae2425031a9950bff58174971671" }, { - "address": "2bSoeaPXA7dSNBVwf8er29t6dg1RnRDAz5n", - "secret": "3a39bb9b3e8bbc0f5dabbf088311774b559953a8f921cfe767e80624114e9579", - "public": "03aa5276effcb37827660ea46be7ec6aa8c10019efb985dc079ab8fd211afb641f" + "address": "2K1nzfXsFnvSVZwMJL6WEvhW8qxobLtaQR7", + "secret": "e7698cbafa77734600bafc754f0d9a24ef84b94c16d69ef4594c375bc0c849f2", + "public": "026525ef0253337c276ccbd8d7c0182ab7ab48583d5ec743ab408514d6af2ecb0f" }, { - "address": "Mvs5eQRZJNL4gCxyoR6GpgwnM4NFiHzYcQ", - "secret": "275821673309a1019f05a0941ba18bd723aebd29e9257d0f4a2adc1fc7da0a8c", - "public": "02f02e242b90381d2881cb3c82b38ab2518d4edaf1ee90284e70c905eed4d6053c" + "address": "2NLypD5yFCBvqNQ46f8y2AjTzrQtmdR8Amg", + "secret": "63356b3d581b1416150cfe17c698db997c734b2303b7e7364b91b42139597a14", + "public": "02174eda85628cdf4a38a6059ff96b58435c1f841d70ebde77838f14ce029de210" }, { - "address": "gJWCp3XfKPRgUvuczjgMyWorCJ5gkeTbKG", - "secret": "007d371b273fb4b14ce096a3d9d43d321c8f50fc89cedeba4a68391673f55508", - "public": "030dc51a9ebd50df143ebf6f7f1293743a72f09e59109abb314704ad12822d8d9a" + "address": "ycaUcxZ297suGDQHX8rAE2o66uBbaHSa9K", + "secret": "22f75ca0d85ba3ab8ab6133c4f8222cca188418422d6c8f30535f0db6399a747", + "public": "0287d014af5975037275978bd20691124f4d906be9c09ac5901d6388abc6fb2806" }, { - "address": "21jTFrqiPRfouTQNV7edgP21pxgPmRdePe6", - "secret": "a1743d7dfe4d3017fbdc0bbc6612d1eb61d0364d12dfa31db1a87191400a9d0b", - "public": "03627576935ea7909eacf34c3bb497517c23974e160ac577a723eb6a5e9fd03dec" + "address": "cvDxKoZWNEhuG73dxxjwBHJwHqHoj82qQJ", + "secret": "3cbc7c5436572ea5ff736489d84420158600d5c39e8175d3d1f752bc1ced2b90", + "public": "03279f03cfaa48f1eb80c66138e4e32b22b943c0b46c387c4a26dbd1cca5ac4147" }, { - "address": "2Srf2kK3pM1JQ1DbjzrQV4Ght5FmDB2zdDa", - "secret": "09592b7039f2b282abf20547d1148ab9f3bae2ae25157fd7591fae4e845aca9b", - "public": "039bfb610cc7ef2852771721d30aa31b432bc3f8cc1af9063c43cd88cdb0599710" + "address": "2V6bLf431P4U8odSUTozXtNVyVhhfD1x8ks", + "secret": "4a9234206aefb76345294863efc3e344ac8294542d6c78eaa8f0f94a396eca29", + "public": "02a096ec8754944a523602aa7141c17e76de62c2d910edc107d9e5d2e2ddfafac9" }, { - "address": "26Y71T8eQdZqa4Wy7Z9AJcW7zkQs4zEb2Z9", - "secret": "49804766e2f956d6adcd09e601da6eb9998403f89d85a1bbbdcca69e03cda9e8", - "public": "03a926504c328c04e139d4d0e625d6bb95b62d44776d861a5e9335e10bef2598a8" + "address": "78CiJEYytgY1GY3e7YkEEtc3iKUh17BsRB", + "secret": "e9fe953daa778f1a4e2ebac0f2d5efd9a10835d3301f51f6c23b3c03c1d6bd2f", + "public": "0311cf95a60d6e04ac1b08b3354efa2d364fc1f26d552b1f6f864379a264d49dcb" }, { - "address": "TvUMoE7x3cFEiGPwDT1VgSm45kHAJedjXQ", - "secret": "0ad225a2da9339138a8feae3616c3c1002a8414761101910fa806e4f7949a1c9", - "public": "02b7d60a96a680eef517adf035e9c02e7d90358590ff8786860d2e96d46d366e27" + "address": "KxXp9kXfiUwqYApRBpSieRjG2gUz8MCAeA", + "secret": "f9b6f18626230dc0221df145949885138b66add73f216febbe8da03216852fa5", + "public": "0200780f30aeb162071b8e8f863d81ca0a9aff46fbf8475da8faa702ac66f7a705" }, { - "address": "H8Xqifon2xwYaX4s1bafkX758pLQ6awaXz", - "secret": "090eba3bd5b528cb8bd8e58a9d16b21e27ff1009a684a5d14eef94c6e958c23e", - "public": "02206aa067edae12ccffcc3b7b3fdcf89baed67a83f6e2f82bfd321fb2ef2b3bf5" + "address": "TRXyHSr7oGbVbJurhkJGgSA3Q1NvPQadqs", + "secret": "189694b3d311db623cb393808e89cfcdff228f1675a8392f3a85882d116a442c", + "public": "0280a7a939f549d5d8c8fe377ebdde1413223b36708ea770a9fc37fc5bb4cfc742" }, { - "address": "2fko1MavmRx4cHFgVDcEWhSVPRRzUkiZeZR", - "secret": "1267f03de40ab7f46ff79a042a4237ecea99307bd04ea5a6beda9de98c9636c7", - "public": "02bd59e1db66e9de812bd61c7329d59b9e05c5c8306a8642f8c70d7d69b229a029" + "address": "2dzxhFNvfELuA7cPFsHR6z8NnoCZbBrwq8b", + "secret": "626fa9e02b3cb633ec3f5bd75aa7f39cb9c0c494ee9ffa1c059032086542ba54", + "public": "03aa1d51380d5ad3fe1e6c3bda6fc013d02dcd620784d5c1e37dbee85ad2296cb7" }, { - "address": "2GuJEy44Z8zekvhGKM3hC8wint6JPg11fGn", - "secret": "16b7f134f56de8a7e7ef70558effd3f1b75758c155e2b9ca833cc16dbc12f28c", - "public": "0251229e824321a9595ba506e8c9b5d2b2b6955327a7bc4fb62be7387fea5700d0" + "address": "2NWM7ZKdpa1KAKbJGoh2kjKQWnF4PSRuTWd", + "secret": "77a01079dad73056ca87d84251811bd0e4925e59e64ea2a957fcab3368f56d5c", + "public": "02ab48fa9293ae86ce7eb083a2c90d8f63301e115052cebe7e1dbb281f424ddb8a" }, { - "address": "NuMUpGJrYQByqdKp6sfziy3SKcriNFsEWb", - "secret": "65e42330adc20f32979ab7e786fbd662047d98c8b45f050c385f99dfa6e6c76b", - "public": "036e65de878585e239f6a90354038e5087ca3bcd489099f1c9efa157fc3acba0f8" + "address": "23X2NT6wQJicBDvZMUDysSV3wMgXVSoxMr3", + "secret": "aa7aff9bedd949cd11efdb243fea9e09e8a36700cf97d611122d9eeee9d597b4", + "public": "02bd0d5009b71f203acec6294881215d7db08595e9ed86dc92e634d5b0d2f23f0a" }, { - "address": "kxB2uCb7pqq1J5DcbEkkexk4oo4pXkVgu2", - "secret": "9dfddf6a9c15ed24852c75ae6a135e227f1292fcda0a80119c38b82fc58ded70", - "public": "03b155a899c59b01f245cc1d6b0f29f31ed42017398ddf770b463ffcadfbcd45dc" + "address": "LH1YBP5AjvYaen4k7DYgFyAzqi9pKXBkgW", + "secret": "464afa06ba6e8c59a1f16315cdaba68549cd1616644a7a25b343390ca5d86bd3", + "public": "039bde448da1bd733e8582cd0a99f6288fa227e0f36f1e945603b2d83e5bb1edd1" }, { - "address": "Npoe3Ktf5LUgzJGuyoXr7DQYwsnRo5Km3E", - "secret": "763455c34098fc2fb7d3a11252d7d27e7b83b9d7ce475655ec94055b8ffada96", - "public": "03972a99fcd5815485feb3148b8c584394c94634e6e2ee7413327f7bdfc5a4d53e" + "address": "LPedwEmoxZPp1Hfh2gM19aadcfjznvdcvA", + "secret": "ea2e750dbbaba5eb4f25597e27f0ecdad267de8404adbcbdffdf9ece9cb0e168", + "public": "021d0f2e38c66ea712101b9c522e9ae53c827e8c3124608ef64fc3cb316b4f099f" }, { - "address": "V8PN3cVcyjME9U5fsurju5ehDxsiFYZAeY", - "secret": "a3efd65c275c186ba6b4844aac02c99a62a71485a02b2582295546b678b433b5", - "public": "03e42a43d66ddcd37610142c0598def04549ac6b67e630347568a24ca35339a777" + "address": "iuEGDZe6HGaVkR8Z2UgdDopPQaJZ9GahVc", + "secret": "88f6191752848ad861182bc02853fa7a62b2ef1e6a037a81738eee0ee0d5d495", + "public": "0224a18069cbaa5ce86031530cc6c53f5be72cce4affe5aa9e2fad32e93b231c58" }, { - "address": "KZQWy6Fh3NkVUEnwqd6ERLEimYi5Cqbsiu", - "secret": "c5f86b26b54f2cc28fdd39e1439231c35eb3c4159db4e007907ea1229558dec5", - "public": "03777b403bc8124ebdaf965726af510404eeb09759674143527b2e45fe8c5702f2" + "address": "2fFT7hVto1ijQx5S7mNtiRA14nkxKHmd8X2", + "secret": "a2a4095a7ee80b306c02c0dfa672f6de067ba62f6dd23e48cbf925e7cffeb376", + "public": "03b12f22cfdccd4999c0f8623e1b482f11679591198d76d7c448de1209c2b75a6e" }, { - "address": "eZi3ReXCCXaSC9KbJavkm47vsjDjsNiNqQ", - "secret": "cc96ff541d394fbc4838b75dd575d141fec4f149a3beb3c17c4caa12df62f650", - "public": "026dbfac88a0a8291618b8a1965de4e14bcc380b18e1ed3f046cfef14fdc11cf43" + "address": "2epcFgre2Cfgzr1nkLgB5LHmQNPxdebFHVW", + "secret": "3b9ab3594ba9909e49e46438c637f9247c3b343027196533047369af3f86d761", + "public": "034075500701002c771f867a354c5b63dfd7a27b230d6604e2b8063b945e1c83d4" }, { - "address": "QfHy5vn5JKGBpkeVe3J9Cnh9NFUcNs3AMX", - "secret": "bf2c1d850d46c23e4d9aba71f01f093116b52cb09a5ad65772efa0a6c60c528f", - "public": "0219d04c8ef004638418c1ecf8bf8d0e16525a8e0d907edda988c30eed0551a7ab" + "address": "Vwgtss72ku5Ud7UDZL836MQJohdcSuwGub", + "secret": "76690e5179208d5b72b57b19e492cd8201ee8867d5ebe40bdc8667af33b62da3", + "public": "03b88ae823021df56ada42cfc8c1fd88c7143eadea1ef884f1f0ee2e2943b8cdef" }, { - "address": "7NVDfJ5bPS7AZzmhGADJ5VP6J3wK3f19TH", - "secret": "5ed1762902a3ab9d8c9d5c56774fadbafff878fbacd20d3441b21c8b5ded6ffb", - "public": "0283e458a3f10f2a13ce85850fa8cb8f23eda3045fd2156f2a4d36d619e0324a3a" + "address": "cXJ5ihXqFezFnWMygwsfifaskFT7xV4ghw", + "secret": "dc352ef72b282321a30ec9b0d959d4d9b77063a45f32d8c905448d0873460b69", + "public": "0320b8d9fb36ac1b22177930e31430d5b84c89aeb89ecdcd554872362c85afdc2e" }, { - "address": "2RykcM1xL9VtyYsuyX1GFf3NdHn1ihK9gwi", - "secret": "3cb9a8566e0f9c2d971958fa430ea99d6003a8529d0a607127fb74b7478482f3", - "public": "025923e560450ee7fd5d0c1413d7dfbe3d632d76f0bf57209617b724116fe3c9b4" + "address": "2B5gSmoLbRppmBiHx8wxWwnX9Wt5XhV8c4m", + "secret": "aa687c90db3b0c2f87bad5455fd030bc8775dd0ff8a65948bddb2476f573aa46", + "public": "03bc34b2d5cfb361477821c4d7707f239b95c87d26e6928d4f3f4acc2d6718149a" }, { - "address": "Frzj8dxBSN4TuWhVr9HfnZ4oK2BWeyKAtU", - "secret": "2f7ca64ff30ee2a14c0eb7740481e2925b761a5dae4414263061d9d6d058b430", - "public": "0339003fab45f135b3d73f1174bcd6b95fbe84a1249f445820a7b6e53c5085cc1a" + "address": "CrMPQ1PjwKWnDdPVAQaSfozkHPuKzDe4JK", + "secret": "688c5018bec02673824ff63699d3002f80382aa6ecc7d2767f8f3c74ffb0590d", + "public": "0341fb80c77b69a986a39d1797a0c5b8cf1b9ebbcbf4c108a122b153e2d8ac3063" }, { - "address": "WDbcr4xW5JLkEfmXZVmA2Z4vg2UP9pDohd", - "secret": "ce64203fd0f79559452b35a8f2563a5ad852822fdf9be4a3c6ae922350078a17", - "public": "02b5f3ee59d39630614e00e941877dd041078de3dc31d37751ecbaae0124c28361" + "address": "UxFfwBKAquEJYus4FZRJXu3Hqcrb6XgVXA", + "secret": "1be47e095bab584745b8474c9b8e3c1bd03cd14ab6d4cdad4278a33d804e6018", + "public": "022b2ca9b29ffab11f2ce848851c326eb8f016e7d402477c80fadea819b4c7dc2c" }, { - "address": "2Z1GVc19FUcNyouGYPdSExFMyFte8dgytyN", - "secret": "93983a10f28354972359ee883c7cb5a3804459875d2441d6980829f369d980f6", - "public": "028008a745d0bbcacee287a8344cee07b698f31cb5070e09e07ab92168f2c9beb5" + "address": "2bKghkQxAUpLRL2CH5UXi5obZR3e7bMXjev", + "secret": "4c8f815282e42bf87fd63533bd11c27bf2f684886419927ab539165869dabb47", + "public": "0327ff01fc52d974f53769efad15458ddfafc7526628faff0834b1688429abdb3a" }, { - "address": "2Th22bsAPfEzcXcFmNNFsWmse5FJFuAxYkB", - "secret": "acf93c2db94341d0f6b37fe4e36d321529a9613d05d89fb8d68c3149d750dd4a", - "public": "038abfec24484a8d57fe288361966119dddd2e74a6fa0510297fdc1862feaf42ec" + "address": "yNQkWKwwyYaSWQRqxkuCPWLBDUny2VwRW5", + "secret": "e0a08d6aaa1efe1fd000901732256ef93946d68c038735b3ea99b54d0aeee8c2", + "public": "02c8c10b617f36160a432cf69551aaf10e5d92a3ef55b7960bfdea86b85c6a2aac" }, { - "address": "mH5ztXYGghEDPyHrEnXA9doJxboKZJsVpR", - "secret": "f15475e10ab141475ea7e7a5b760e8ff8cce15402f005f51b1d47be2caa653a3", - "public": "03cddff9c7d8b5c6fa2634743f4f19a63980d56b91386a2c07b2f76037e2633df1" + "address": "Ehy18wxh4BaU4H4ddKzhTe8upRdHdKgM3C", + "secret": "cf82029c3429bf9e3a2918fbb059dfdf667f56ebab79c62bb3379c4bcad9fccd", + "public": "0341b4c77a846dfb985f5e25c21dded44577d51b8cbd2c6728f1ccfea6f80ba547" }, { - "address": "DAG2TsknxG1pSsWx9YTH9TZvmTenMnJMJQ", - "secret": "960383078ac7a2e7836168a6cbd2bdbe8797a7c4def9b30e0f544af94a19912f", - "public": "036f447e982cee6d0e840cd651de6347744850482c462d12dd9973003f7eaa3897" + "address": "87CxDUGMUEG4TbmKuJrnE81tnDfdbji3iD", + "secret": "7d9656cb64662392ed93c60d66c7c2e5c6d917bf955729c4672841b63e6967ff", + "public": "038a4b918b57f7b303ceb32f8b3e4a0a3f93907edca2c028b1eb1730890ff9de1c" }, { - "address": "9mEjNbwUsjbMr99v5HU8hazNcLy1ppnS6f", - "secret": "fc1efea22bb6ff26ed2efa51f1f16910d4889e9302d172eea852ced5a6dd440c", - "public": "02a4213090c12a8f586aa3831ac1cb6a2e2468e704e15bad5cea6bcee791ef47f6" + "address": "M5Hd2UfGCYHHHAMRhhRNuMiH1L4PFTdBu7", + "secret": "7f96a3f77ee706de79268dc5b161305f0d60b32b5e39f827fb7c59c9d2c6f594", + "public": "03355b8c6ee5d09e41c5cfd0aefa230b3de94484bf65fe04b2b4ddad68a452cefe" }, { - "address": "2GqoowmoFmm9fDMbmueMLPUukfzu5DpNKfv", - "secret": "02811d3361be4e532e40e9136718dcbcc2ee912e7cf2b76c068cb375a5f9f7ff", - "public": "0325ebb52add1e12e024b630ab4c300b350308003e471c7d3615d98d3f10c3a629" + "address": "7dCt8NcfvF2eqSDU31BSX6sdfbuYg6D7s3", + "secret": "c6d2f40294eeb8d5e9b05f79ff0011dcd641c318981f2a6fa118c1fee8301787", + "public": "026a28127485642665a7d791b8a94b7a19ec42ebaa30a6cae318ded26fc2e120eb" }, { - "address": "PYoAGRbU5r1iecTzdqYuyqNRZwQ7RT4pNV", - "secret": "c3dc96f8f64e7ee15d9e5a407ea1c867937c19dae845c85f04b889b15e7662ee", - "public": "022adee6b45935bbc93271894fa7631e39798ba155554d112feb71c716ebb1472c" + "address": "EfjaJj1zqUT7c44FtWTpTtZd9SctAsgYgN", + "secret": "5fa1c6aefa6b2c3265181f94362798bd97ac1157e2825a555c3a73ab298c9085", + "public": "03c51dbc5d349755cb608535d9678b67690a83ce6f4b4abd2b4b1bfa3d8deda428" }, { - "address": "vgToWvkthQLGTYYoNgbSdy5FWwJKuXpJyn", - "secret": "d20e0d82529b0791ca93a908b765b5bd0b702a55f5a682be15763cca4c162dd1", - "public": "02999fa7bcf8dc7d89f151d41d59a1582718d97aad56c33d60ec8018e779cd2a73" + "address": "G4t7VPjovTXpPkB4WFR5NsQs6UCKsZMrTV", + "secret": "a92f1ab3e1c387727a160af2236d5b1140b69016d8e328d0600e3ba933eae344", + "public": "02f5ef7788d11f164cb17facc1c3d755954373ad43c350ee22de71b1b4d3f6a921" }, { - "address": "k4gzd36YaEUH4gCWaNgrXAhpdio9iVefGb", - "secret": "2a7732a4531d622963ec4ffbf49bfc747bbbe7edd335dad00753089bd4316059", - "public": "034cccb7a8a5597f4ef19e1239d04fc320f7dfbfffaeffe474651fcf239aa25eef" + "address": "EqnAHqETs7ZqSEwmVGcUBWENuXfF3AwX7u", + "secret": "8ed59413c05a8fb4258a38bc8e2ae33c549c31e953737433edccc00f6e281375", + "public": "03e99890fcf8468447dda686a52fcc4d2ebcb4a2a9598645cf17bd35e1b2036e4a" }, { - "address": "UhV5yHqrGMiANR5ygciF4BxgBEtpyuNxVN", - "secret": "ad401fca81bffcc736b1944b38d61f0cc2379f9ee3abbf87f6e55dd94ab2773e", - "public": "020d8d58b81bd82fb2287f6638d483f7553dd79b2ac08870cadde2d08b88079cbe" + "address": "9JY67nL2TLrh4rf8W5KezEjakLffjJ7ZJv", + "secret": "819c8cc72b0c266c144c6c77f359d0c5f476fefc7d5e48b0cc32e694e00a1be9", + "public": "024eb7dd60ec2195640e68ae70cafbf9d3f32ed84491e9ef9917d50a15da31156a" }, { - "address": "BEyoS7pARaJbRoEgcSXgtkgTrp8i2XnkT6", - "secret": "0f9607808115dfea8b986b9e89396c25cd4d181630b8fca138de21d1965df337", - "public": "03e625231d2843ce6e540fde641265626866212b7ba744bbfd6e17aedf15f32045" + "address": "eJhighy1FQDgytHobEPkFUrc8MRRDUrERX", + "secret": "d8ec3cefb2571360c9a63e100c133e1a28f5298479f6b71f24fd2e35a2ff391b", + "public": "02ae12cd82ddf09f2d41f2eeb4c89d7bcfcf7ea6d045825d5e7ff480006c873cac" }, { - "address": "278GudQiE9GtNqBuhAN5TWcDZK8Lfm6eSAA", - "secret": "b8808cb894e6038737f02602d1ba69a44cbf31a9d3ed3636c7cbf492151f7388", - "public": "02a6af124e30ba652c485f81c331d855aa5b3af2bcf5707d2d07f6f58cb0ab428d" + "address": "sXKjeTQx1Kxg7JiUsY1s9JzxmaZAxJGz71", + "secret": "6d2213281136b28c2311ba20c7f06dfa2631023cb9c41600a343b12eab7a1fae", + "public": "03efe76de2c6f2bb427d311f819421fd737d9796ec4b5e884724bc83313bc7df25" }, { - "address": "2S4N4zuYRMNE2dpirSvRtrHernE1BaYok8v", - "secret": "d1ef744503dd1a763754bf66f202157ac07131a6fcac034a3d96f1e225c980fc", - "public": "028daeba354d31ebb15520a39a4f3d4dde60d9ad7870012cbda7b4c69b8331a79a" + "address": "2P4vNsCQX5e2TEFsA3phiEzzLNcsa55z5ZN", + "secret": "7e34200c29f235e7d41165de73e3e24345b333f2d62b1332d1645c79a131fe41", + "public": "02431861ed3afa26be09c750021b2f0e91b115216ad177403e45135346d037c421" }, { - "address": "iGVd8qyqwJgQPFXvehnib36cZwu382yfoQ", - "secret": "b724c0798e5badf3a9644392de517747d380149bcf585f5f715419bbf115dd7f", - "public": "0324063d19ab276ebaa819b1a84350232a7c0b79ec92421dfbe87125e3df199d65" + "address": "2hK3XCyTcLDihcW1EpBqvRhUEfQTySJvtZj", + "secret": "26e1cbc5e0d46ed4ce85ffec8e2673ceb4703796b88a3dc47207f2e08dcff8dd", + "public": "03c07daec002df3915d53e49dd3bf592056f9ec01c4c9f71463bebf622d8db9651" }, { - "address": "MQeL4MRKwTo4TZqcmCPAfPXyPMUwowNV5P", - "secret": "92b319d6fa91da6ddce2b956d658f6ae7136d6ecb7c7887ccb8ccf139f6d1e77", - "public": "0275fdbb0611249c340dc7b3227703f32a96f80979c1e5878f6cf6be65ba3b7aeb" + "address": "CMyzndV7XRPcWyvLQtUckf4AqXh2BzeDaZ", + "secret": "016be155c064286b20c31e3eb78570aee436b4a1bcb51553a98a3b88db3f1a0e", + "public": "02dffd952d6087b6839ff2fb5406f8df0a588b47fa37f6b6501adef82237cc91e5" }, { - "address": "gT4ZQeAguEVTzXjm1mbr7CpZaGGYzfZoW4", - "secret": "4b8fc8e4347f90e0014810b1073d0fcf5fcd2fba385327f8912bb537f99dc5df", - "public": "0225a503c692879b405aaa9dd97f5c17aa87e5327495222b2b2db1c3530aaeea4c" + "address": "2Sx6BgyjTNa4SRGzrtQ3XczPtwKykMDNYUU", + "secret": "fd0f956556804aa600fbe8d179a5cd5293fa543f4b301496df71d44ca18f9f44", + "public": "021306263d266c508be82703eca67e924138e8373fad6db63fb082b173e3790a83" }, { - "address": "TJz1xGNcrvED7fJc6eqG43Tf57rYMPgY4w", - "secret": "68fe9d57af1441a6b0cba65531c08993e34d6b7354be691d4c83734499607ed0", - "public": "03296c90d0082d33a4be096d5426fcb0c666805e0f0a86bee5fcdc693b76bac3a5" + "address": "X54kZpzfh2QgJKptToev26n3DKtREcoPu3", + "secret": "5ebdaf145155d2c3b8f3c2058878121d4da049de70569287afcabdcedf9e548f", + "public": "0318d7c0dee3c80ed280adeddc136dfb8addc4a96a0fe1686ae40ad48c4538485a" }, { - "address": "nv5vvpM2NDQuR6uVRdw9CN3hf39TWKR5gB", - "secret": "b9dc320bd7c0c3735a27ad8b7209a45c358797a6f0f0c40df995dc89cfe749aa", - "public": "0215afd277c5f7f45f38e4fce7a9a58c9e952419bdf8557301fd6cd8a8d3238ce9" + "address": "2dy28oXtQ5xjMmk5WZoxestCyYrdDKp4k9a", + "secret": "9fef49579fb653c9a1cb089f286318cd125db8da7a02e1603a516ce0e90b9519", + "public": "0367c6fa57634d2dd0ed737eeaf9a968ee566f0f9ff8c080fb5d3a20955f1b9cd1" }, { - "address": "2aK8Vv6HeUND4snxCUfwr2ZbL98QEWmgVK8", - "secret": "efff6d18e1aaeef89fa6a647d58479f938a4291912f931af1bc48cd51b46f5d6", - "public": "02896deb07fa9dfe9a60c543608e61f2b668daf74dc40b16c1efb9dcf0e17e80bc" + "address": "2YsSC6ULU9ud1HFPx61iK1EmbtFPwuPvLmX", + "secret": "93ca92327524ca10a615c97c803c31e181ec25e1221a66f6cf4ed45549832f05", + "public": "0272595118ad56acb6fd1a7e733d580fef7bd7177c8f5150e834daa4ade1f69d2c" }, { - "address": "nTxh8qZR4dxXqLY6T9b95K9yxm1mgE4MHW", - "secret": "5bcccf6ae8931d1ac6a43d87033e44d9f7d1d17b6f308e26b2dbe862935d6261", - "public": "0299294ef7f29d169a52869afc6b68f770ce38db1976c845fda2bd3428bf0db62f" + "address": "c9yNnwGMSciNxtfCfDpZYQBqkKhcruoCBR", + "secret": "1837ba45ee86dbaa69529292dfbcc93c1424326ebdf8a77608f1a0f7f4e46679", + "public": "03a7a4a53f0e573ea39f83bb9bacd91ed402937678c7909a2630c852f6a677659c" }, { - "address": "2Edkcex9eU35t7M79wbBeaq84ez9w3iwAuw", - "secret": "a1e42e7e2855a186ccfb8ebdb23d67389e0da8385c370273cf693dc77610efe2", - "public": "03b58b37dfa47f11a9b6ad44489458db34773e2af9be646d1e28aa000fdac2e197" + "address": "2cPy9RXG1kqppk6hvBWJdYPusTM9oaNpaGY", + "secret": "5838f6f51f7ecda21c6bb33bb6878c0a9d25a86015dba6d79b0cdc472577dc4a", + "public": "02fb56f26293d4ac62f3e49e3b87e81c78661b8af91ccff7ee4f452cace307d842" }, { - "address": "ErRSALd4jasxvHmoepBSJPKEPNcjQwTfnd", - "secret": "fd1aab93951ca04f4eac3dfcc91e9a5543a6efdca64d7670f6dc2598d5dd3d24", - "public": "0226b62e13735945d4961da8acf8bdbfd8e4a9cfbfd664cf4e1097c49b693c72ea" + "address": "2RrSuZnng4zVoTt4Ytq2tGqg9yYSXB4pwCn", + "secret": "97b347bb13110f84c58bb17e8ed424714a897f72893ed476f285db2e4fd8c80f", + "public": "0302adfd41a08a7f23338dcc45dd6fbd0bf3f4352f8abf814c10729a63c99863e9" }, { - "address": "7hcHDamLskFkjEfu4yDsJu3rCNcGWrekaB", - "secret": "7eb50d2747fe9b41d980c1c8993fd22faf9f9668e37f682ee84b6a44a5fdb4e6", - "public": "02f12ae7c1123b3e6bf450b6e726a716197313a9ef13746ca0197e0de677e10433" + "address": "3ThUUSbyeiP8sYcKUJfjTh68rZSBh2K1Qe", + "secret": "b5396837ab1890a661f493011d5d3198849ddf54f3620ddc89c7127cdc6e1031", + "public": "02a9b07fce49c94f70ad821eed6691d35435124528e4dfa060b218098794288782" }, { - "address": "2viyNAdL8zbYeDEAnp8KaXsXeDchXX8WSM", - "secret": "00ad6173d4c4e7b546d796384fde7d0e0cabc5755d6b08560a9a81266f5c68cd", - "public": "026cd81fd643de7ce0b0994a46ef6a459e247f22bb06cfe5ee64bb88bd9447ee99" + "address": "2P7eu8oaRGRqfZMkm7XQCA4bkAMVuW7XarV", + "secret": "aa11b35c65657a62aa20b44fa2d79d7e39f0d50af94c83758db244e63cf3deb7", + "public": "0301a3fe3b088d93bc40f197f476017d02a3f269bf7e402bc30e8028f95eeb323d" }, { - "address": "Wdt1XFunXKMPtmkRnZNv5JKMA4w6nQN7Qs", - "secret": "2fa31ed2f789dc4b400fdde1ed995104fc046a551c848ddb46739583a996876e", - "public": "029ae828c88680026b4542d4ab87c11bfdc5c7daafd4ebf8ccd684e96c66f3525d" + "address": "wDgABtGkzH1fFoPRFRdXXPC8Eh4fbXA44X", + "secret": "e7e5b7774a59efaa663bb190f4141a443811fd915a0542ae6d5b80350ab4d566", + "public": "0398a4a1db8426a805b7c78a101605173073a26395b9e870894bcc19edad3ca1bf" }, { - "address": "tfJ1SUnvLourj4nWPJDtXZndSoLoTntt6q", - "secret": "ffee10c2441fe27525344d4a3b171e42406bb2aceda84e889b6aa5fc1e678366", - "public": "03963765c24c895317849a1eb7e91d1ba82daccbb577dd8e5d01ffb55f5f418df7" + "address": "2bxejRENs8r4JTvfcjzzPrYqAFHCZWZpUgT", + "secret": "fd684a261ce599c7e60b4ae3dd8c25ce6f379cd0917145e784b2d65bee3dbd40", + "public": "035ecac650a6ad90a0c7ce37c4a8f60470f720bc323665342b4c8a0891223e24fe" }, { - "address": "2dEnRCWzEN1QAvTYbsMVsBKdWMErnjMe3o1", - "secret": "a1e55f9b7c9918e1fb203bfc3edfd3858d35d516bd7723e055bdfa9e6698d1a9", - "public": "02a24f6363bae5d289768b3c3c23c826097b5ca8032a27d25d388d8179d188ae1a" + "address": "2KGpywnakyuFh8JwrQzkZVYZCNTUjNUP4QH", + "secret": "1f6f6a383bde7f74e62906fdd0e732777bdbe083d8cbc3f937911ea97527fb09", + "public": "02710b1c5b760022a5defcd04a471cb156304bc97b0f2888ec0319677de684d1b3" }, { - "address": "2CAjjckPr7JqrkAceirvpZvprSogexB5S4J", - "secret": "a13ef117a9d0578a13bf80fa6370fa89b01c3d667d215288d4c45eadabd04ddc", - "public": "03b7dc53251faa4a39bc5e22fe7cb442aacb24d4b1d96d32760e140e63a3c4f560" + "address": "RtK2DJPZQKcDtFQUEvmjDrVWGzZ7yBL5SY", + "secret": "398bcee8a98af1760b796cf0ffb3b97915a5f7395976af48e56a88ff1723abc4", + "public": "0395443d2c26ad2e5b14c62d83d742c212741ea90a9f862270e9b6fa65f7f93eec" }, { - "address": "YcFogQZ5b2XhGogWRRBFEkMb8eZCbCBpWs", - "secret": "c241b37362ac74f70887c6b5b37d92765d875c3a6b469215ec2eff07fb90bce4", - "public": "0224c5f12e294d0cf27b8436d348d3d1d9366c6a3ecdc36fa76ac16ea6557cdedb" + "address": "gSHFa7incxNmjnTRVeu9adx3H491Q6Z7gL", + "secret": "6f75672a799f02d99f8be68c3f5ec9cdaa4e225d6b63fb28413210592852339d", + "public": "0296ca726068a5902489957ec48c85cc9d77e868b159ba9ccd50e6a5a7208515b4" }, { - "address": "kaF2KLLgg8MZ43YSdfe43N4UEWfmHJBgzT", - "secret": "e332a1e2230711753868c5f6c7d71aa7484eac0fe9966ea8955f8ed10aaf2205", - "public": "03a845cc089b46b76d2e81424d7430e756fda07655e67fadc841771d8aa0023363" + "address": "2VErjgC2zSFHYp8upgaUmYTpyqZm54HuaTy", + "secret": "d9a70bdb789be436b144ff6b337fc2179ae4dab76cd17ac61c69f81eb669b7db", + "public": "032ddb910371263818b94e8d5d763718ad8d6a1134bb806c1f6c84358482cc68aa" }, { - "address": "sjRuzzykc9Kjjdg3HLab55riHotwWPHR4N", - "secret": "87ad4c3e4a51fee8def7cc73a7e230d20d0bdc4568e234832af99d1d3725d6bc", - "public": "029729010702e446740b43d40cd0070c6f698ba3ad7b06305b1f3ee7b3524b39ce" + "address": "aGCeAXjw7P3grVg2N7ccWqvM6Urtsrr56k", + "secret": "1f6ac2fb2540969789c1e435cbf10e32f537603beb33afb9cc2561e1612bd3f0", + "public": "03930f9ac4c718599a2bb6dfa60215ea9679d393a57e2f1d0c1df60dd813b0e320" }, { - "address": "u35jsaBddw8wQFC32TpgipB6UgwSGiYkD6", - "secret": "90376ffdbc46f0b11f6ee7e8a091c99d8a4c41b4c3828e6b2a8a7ea812a0489b", - "public": "02402ba5631c52d9255268b7d313bcef689f170bdcbe3f6431e544fb868cba54e0" + "address": "2Amstf2g1ABsQwZARZdP1hsyuTF2To4Qb7E", + "secret": "d5500918f2cf90b27f68e476a7f542201f881f62ab571c1a56f92b3ef2bbde98", + "public": "02d5c5807716a26bd520189294ee1394f9e331b052904bb74529e11af87ed4725a" }, { - "address": "2CxyugGm5aPfgqJzD2MBkJmphCSLuHab1du", - "secret": "480e70eb7882ee236b00ff2c2781718c78f66ea1036e90df4e3e7104a73cc13c", - "public": "033815b500527fd580d5ea9c098e05d0893dba4d7a81ccbc7ce5f5e27f093c8083" + "address": "LZH9W2Au9PdRNYChRYhQQ1WygQR2m1Gv8E", + "secret": "8565e2c08db9f98f6dceb06f01b6234960005f049360f9ab778864b278f53935", + "public": "035c4e48eba28145bf0c949a21b2d6d8ef0bb34112a5f75341372af93aa23d749b" }, { - "address": "UayVsKy7bEQXpW4FTzYQUMZ3Ww1TaxtsQg", - "secret": "4d92c3a70ab8bec0ec26bb5592c713323137799606243dfeeec4e32581fd9e36", - "public": "03c1e2f31e6ae0f229bb48b7741fb23e83b9bc1f804d617265263529174bbe76a4" + "address": "tCNwshNocxoMVaRprwjnbfSoBtNXYdZbva", + "secret": "e5125d5a11dd0bd007cb96b665ce5a6924b3980d9707324961f3a5d98eb37fc3", + "public": "0203fa587df0939b087dcfa338bdf509674ae0b3b8c2554717c0f9bd0accf7c0b1" }, { - "address": "gUBPoScPQAZkdq7Xg34mZyYmBcFhAgqCfc", - "secret": "407b73a489b522036dd2613f52e987e689d827b4092d893ccf916b570875f277", - "public": "0236d36346c4d59790eedb7b7d3ee7a123ff23510778d2a88db151d6905d2aa9f6" + "address": "2KiyEu5BhXanjwmjASUNXS3d5fgk1ra2Dwj", + "secret": "556baa1dc55107be4cfe1c345350aa3d0d6c029b3b7e11287b06ef648ef799ab", + "public": "03003633353160cdf7887f5cd7a1631c28b52589d6349fe26105fc7831822dac1f" }, { - "address": "x9Z78sPcW2uKfpHrnmTGkgNHaBj5Tz838D", - "secret": "d173fa90b477bfa254cb529788476a9478e2351171388750fa794c55cc468f25", - "public": "03689d74effb45045ac796da313920c9c2fc8183075f0b26af35665122fcce441e" + "address": "26PYDLjvhxjrKMaRnqrBoNtD523VdpsbsfA", + "secret": "a14b726d7f34d630b51c2d668c9d4a309ef13caa9d29faa9b25fb1acea77971f", + "public": "024015911a99f20fd61a7c836ef8bfb8c036322e9555d4f87fbfec8a280f251b13" }, { - "address": "2GZ37H4W5e8gpctgpgp4sEjP1Gcm7tQmCUs", - "secret": "ea8d9ba8d32bb6d2269120ba9519654ff7ff4282055d5ecef72a7d1d180d527b", - "public": "036e4e4127714a6d51bf606552f15774260946858401f52c7fa7c1e1e5e5d79a6d" + "address": "2PMnPZxbrtjJBj4HtWnbNEJXGqNVuzg7L6T", + "secret": "1e057bdc28c90b117348301d61b7788799fa48747633b3ef65f128db85bf5f94", + "public": "032c82d55599f47c022b7ec1f2d94a63a980f88ed47e07eac48bbf0ac0bde7c3b3" }, { - "address": "JWwwapJt9yrtX7G8av5NtSNM5Ti88EsRuy", - "secret": "6d9c16b7dac6287e7563302a026fe9eabe28437159ec0bc3fb31f913c5ba7b84", - "public": "025d8da43e74f68e2e1aace0f22defcc03f48cbf36f50a51a4cfe4578e273eb86d" + "address": "ngEoKTA5kLWYecYcHpLUSrP8Renp5xG3Vf", + "secret": "63e673ad8615535dfec17d8d4232df7ce645556517e3a7a9b77cc535b62755c8", + "public": "037ffe90571b19501cc7c0e7619b6ee64f00f2f5f9bffc54b82e9637506a5179c7" }, { - "address": "2YK8gQsiqfrgQ1te2oPqwX1G3pp1G1Xzyb7", - "secret": "da0b0ab5c6516c566e32373264d18266f43c657aa66a8bfd839b0e787e578039", - "public": "0339b84f5827017a49c23b196f3392c09c0ffd6d7be76489dbd5352459f18bbc15" + "address": "2XTu3GjDN1haGmdP15JiedULe17Yvou3PUA", + "secret": "d0354da826bc9131d5c511bab8180df24445d4ecf3ac1d163c586a60ba691639", + "public": "03ae79c37f3806808c63ee7ccb22f82b2f43ac4da2081fd15c26c2361585415d11" }, { - "address": "ymM27C5XwBbdRRDiN2CM5SvaVeMZ3Qn3ac", - "secret": "6ac74032b5d3aea3d0a67a75d173b6e9607b04235e4cd6647953575bd79e4e32", - "public": "02954123f62d127baefbc3a46d5e07ae4fef193ff5166899f4616fc5ccd8a46863" + "address": "Mi81U5WwUVeD8gvQUHk4uVwARQbW6GGdCN", + "secret": "cf4559eb1ab7e0dc0e2589ae74744a6c6440acc1c47c1e20af6597839302cfd8", + "public": "03f39538cbdae0192c6e467950c14e8b78181ac80a4f4be7118b920a0419d4748e" }, { - "address": "2eH7nvJdCXjesBeXqNHqmz3NvF8QxCzPds5", - "secret": "995ba9d4b3bad0d55a2fc7dc7f64d27bb21624849414ca4d57e68c59e2d975e0", - "public": "03206f36b2fc344b70ccdffc8e1882eb42e2114b48ee835c305552e067fd18dd0d" + "address": "JS6ktiN7Ms79KoTQWGzZ1M8VAtRcrERu2N", + "secret": "753330d28ab5b9236fc9e3d2b0e289b61dd9f08f38f1326cb2adc79d10465d4e", + "public": "0369365644818b84383ec3f85eaaf5de68874b2f0993a2ca80e9fd5520a80f1142" }, { - "address": "a2AQUb7h1T2eG34jPvvK3hftQAZCByUQBc", - "secret": "5b64dea1e5450b284c15aa30c2f42a3dbd6c48afbdb0d9f7c786d1e2ecfa2c79", - "public": "022a88066d73ee4974cf19690688a977196ccc7a6d7fa1c2ee42ea79fe31000a09" + "address": "2ZNsWDs1TacJQw5JxiRgVhUAcxThC6WHuJe", + "secret": "fe014fb4af0b644d30ca6cbf94dd56f9489cfe049e76ea7868f4ff77302934f4", + "public": "032efedffc122bff9baef556ea5925ecfa2c67c495cb19d981a1bdcaa44e74351e" }, { - "address": "dmPCkaNwRPbc3HWPnpc4AEtCnhUK6bqkbS", - "secret": "fcc0a32ae12025779bbc4dd3f7c473346fb3ee45a0efd62b05ea2f8a774bd89c", - "public": "0258c398fbf75318a46352d232de671118594c5e74b4dd97c35ec4c0cc4e31f334" + "address": "LxgmkPM2f1HRcRrmzr9N3cEXugNmXsN8qH", + "secret": "a21b407ba7d8c319036912b3959a158be0f06aae3736502c8b6f9e45c3622239", + "public": "0370e1ef67eefb04dc4b36793e1d8dacef50f1956062a41e16aefd0df257ae0690" }, { - "address": "2bdRereu1riz7x1tdnje3YfDJXuWrxE5kWb", - "secret": "eeb3c91906c85d3df45480f41de05c9673582baeb94b2b48d2eb1534d5bfba6a", - "public": "02374f4245db5174be5dba3de64c75d2115e3d9c7a200f638c50ff395fb1b162ea" + "address": "222JtJnk5pvmP8nbET1au9SZbomfzwUKFs5", + "secret": "fd1d0d6acb0f13009f1cc4067456d8b3e2ef43b1cd7ca9a5dceb9b682a29d10a", + "public": "03e193aa4c3448f010c380254a79bf4ec7936b92acda213d33b46f684c52077237" }, { - "address": "JZWYNtNg39aYFDtiyFNzW5CVauibr8qFVE", - "secret": "d74151900f50e27433fe5bda638d4492963d73e2413abf0be48430bea916dcd3", - "public": "02b22725afef39a41c3d6b3f98ac475a3b2a9fa39fd2d684c7af389f60fb16b242" + "address": "24voKQR8GY8aWuDp6deB16Nq8ZQMo1eKpmB", + "secret": "dc2d1c7680935541cd768d6a15304edbd709b2d8a6d2414d138292a707b17fbd", + "public": "03e75c1f8746e2d0c7001212b5a2f81b1703efc0bf9cb8f8b34fb10be810fd543b" }, { - "address": "2UFgpPiJehmGKgS918cz2aoSTcNFG6uTjhd", - "secret": "98ef2a37ff80f7692c74407a5ab8f310f27aaa933acd85588d4c68293877a2f3", - "public": "0201d5ea557aa0353f6307e7bb1baf6090749182ce1bed0616f9e7087a8066ed81" + "address": "vWtNWUB6gkdeCn5YUXbXArYNVfJLP4Cz87", + "secret": "0fb2a5b69860ebb7b5b17dcc20d283aa5f45983cbe0cd4a9fc2972f3b17b90f1", + "public": "02977a6e8bd289782fe6bc933e212fa7f13c6e915b44f8de61bed4786dd16f8f3e" }, { - "address": "yvB7qxCcoDJdagqtMLsAqFSdjXDmobbLSR", - "secret": "d6fc1f4a4b5a86f5c6c1fca34fab5d0a68e60e27c1c58eb5df8235d2156123d3", - "public": "03a699cc1a7e46d4733368c6ec7b2ab3d11faa0fdbb19bd976cf3f47b836c67b07" + "address": "F7vSLH9cg77q973YtGaWc5iodkMBpHiJ3T", + "secret": "57ed144cbfe320f19d3a3ad3d5d3e7103aa2fb62586d42da71e7f987da14b648", + "public": "022187aaee0d76e40534cc89ec0b299bc9e80fbf3fc10bcc0c01fead840cf80eb2" }, { - "address": "bzu7wotggFgyMN6zpUU8JJgY3dcRv4HNhc", - "secret": "0414e118eb3987f0d362cba0495a29fa34f76eceb162a41f4952a73293774346", - "public": "02f680f726f300f7f980fccbc80d21a91dd2515a51de84cd81d15c3ebfa53ce987" + "address": "FuTw7roSkr6CNsKqzpUyQJvMpUReBSFTUd", + "secret": "31ca978b4bd2bf895eee56004c56e7a3d21e8ebdafeb572bbbecb36e0e16a5c2", + "public": "029eb0564cc27d0a4a65c1942e446585105cd05dc22a96f19764cdc8b7d0228f9b" }, { - "address": "NW63Lw736MSqyNzi2V6L4y4z2VdjM2Mxpd", - "secret": "ea30918afbe2444af47554e4a80da75380558882c7cff89e84f1a0affc0eda1d", - "public": "02d26c057bc01235bfb9e0f265e972a14297b0d3a75da40c24a046e3a37dce2ead" + "address": "hFGCMRbvKs4m1zAV1RqEGcyAi5SpMCco5N", + "secret": "68cdd1bbbf0b0b8774a6f45be72e0b561e6d30348d64dacec06b194e4c957365", + "public": "03d126e5cdea74eda90d02651be16a70d0580315e1617a70fe46531016a2c00cd4" }, { - "address": "oVEinuGU33y27xzMagENMrDz2NM2Q2mFcy", - "secret": "5f3f6d21da31c77b2cafdc38d96c83def5d496e872e4122c8951c6bf28042ce7", - "public": "02a623981cd3453699d8aa9a42a56eff96af8fb7c2a51e643fde76d527c84a2d13" + "address": "6GPVFb8T8Y4iBd3bAmyojBiMM8RnPYgZKS", + "secret": "ccb1e0206867f641e3abd217c1e9811ae39ab55909a7711a04702e5603827655", + "public": "02fd2e9b6e7468dc351f32e6dda6ab83edaab1eb3d7e4acdc3d740677f106ff907" }, { - "address": "ppUT7Ux3RBaxqCWQRiRz7FWzN5PGknQikc", - "secret": "361da7f9e27189c06ecb58006350c279c169b38398b9c126398d479fb6049607", - "public": "02cd7c7ab498aa662a86536af6216531ce83e423f64ccf344a8de8e186c946fe3f" + "address": "Ef8qDc2Q7Sz7J3eFnvd98SMEJCHmURdzS8", + "secret": "3a09f2bf6b43df6c213a94214dc65a9ad30c651d09e008be435e66e46ed41c14", + "public": "03cba4c199f928595615b8dbec52e7b20f1a10b40735adbbf7b6f107cd12751308" }, { - "address": "rJoVFaqnr71rdwohNwRVLV4CYKG7e3piv7", - "secret": "a6ce34e821e5601946b38fd02c6d3ffdf1cfa596b1db939affcc785f73075afb", - "public": "029aea2f9519684dfeee9eecdd9603bd4dcf88241a54cd0b3729ee7cc346da0ce0" + "address": "2DHxwQdqxY8NvwXBnwX7xhzs9aGKsspDbX1", + "secret": "e8813cacbdddfa7e48271964fb91a63eea487ca3f462e64ef598d3b5748f13aa", + "public": "02f156980f66466742b818fbe5fc452f7557f9e51f51e188543b746e5496fce569" }, { - "address": "2VGXcnzoA4qQznPfpigS2gVpyANkaD6soQs", - "secret": "73bf91e80e476b648e6f2cdf6a42433ec6a993b1da369ab475d05e3afeabb082", - "public": "0373f4bfad20d5c39f5e89f097ff9fdde3857dbeda316996ab10e11cc4e257700d" + "address": "gecvozAwkyuw9r6eUn8Rg59Y8DcgYk2dFB", + "secret": "fa9f8353f6a67de64f4a7d2719bd0c53bc80d48d05c272d59c7c3bd45d458bba", + "public": "02afa8788e25f7be793cd8c9cb505f7613015f1c0a2de08649757ed5bdffefcb94" }, { - "address": "2iSgnGQPdFbi1ufe7L6QU65HEE8dqzfATX2", - "secret": "48f399918812a11e8f367b69a960320da0a29c66f376908ef5bbce88044e3701", - "public": "031ce767642aa81345effb625637c8fa566f1eeeeb4255fa8c192737a079b3d985" + "address": "81eQpxzb3xiQs6C9R16rTKJKKcPjAYP8CS", + "secret": "fb50e96115ca8e95e5def16d2ad10834dd2c5fc3fc5cf819d86cc47355bf9579", + "public": "02e5f672d5af83ce1aaab51e99a1225574598b27c922b4f1a3feca3c20cd6d3ee3" }, { - "address": "2Arpg2eFmK5RRHx8ehbkc6cUHvpJj9fWUmy", - "secret": "df537418f3ec99cebdb69457652c7eded44a8cc68591df56ca106fc63e7430ef", - "public": "02c9e2c8bdec84f5b2adfddd183581413e5c374843c7898cdf63dbec28890a0723" + "address": "9RckSwNRZvVSWHRYTGW5TpYzWYAfa14CuW", + "secret": "c0c14f4b99871b6ab8da7d3e44e76f943481e7d313f7df492f15512c42fd9bfb", + "public": "02f57a28bc829e1fb9862d0a063f19b99d7a1acf93ee52b21ef838ca5cce45a822" }, { - "address": "2RvWhvjRXgb8hDT7qZupqDNmwyr78nrabew", - "secret": "9dbb8c771ff0e4d83b0a8aee0fe53b0d168d4b7c65a91670f3cc5602e46149a2", - "public": "03c94d8f6d23e0b4c5242517279d7604ab4db6f75568b3b16365b9e40a3b6dc969" + "address": "kR5sYz4U3hpfvV9UpJoHpGe4b5dvSgxq8d", + "secret": "9b8e0a6e8e1ab9f089049a33be70b0ba67f9204227e49fa7085cfb12b9ffff44", + "public": "0271bc6796ff472cc141b0afc0169efccc865786b0d3a607cbaf31dd45fe1262e8" }, { - "address": "put2n6kiZ9cz5mKbXtDTDXsnoKSjkoEqis", - "secret": "5f0ae3d3eb69641adf62fec886eb709fd8256d2344f47814fcdbbfed7b9fefe5", - "public": "03b33bd2d56dd00711974682a4ed69eadd1af4c7e43b60548976b01ccc4f494a3e" + "address": "Nxo31uJshFSDeQqKTrFBayX2Kp4CELgnbi", + "secret": "29e4fdb5b7725afb1db7035cef6d4ef29cd818c81e66981a58d597c5d4259758", + "public": "02e95df9d7dca346d3fbbfb4a5c71689ff2226200f41118f951a3cf8d4f5574f78" }, { - "address": "2BijkeEJWmTEFN5Rk3A4qkfABrCHUAiA3aq", - "secret": "836c2f218b66767f4c2dbf91b765c6e53f7f8d8e2b60c0334ef064b7bfb6154f", - "public": "0328b62485da0cd78cd3d7b67a0b8f73c3957eec5c2777c12ad38a0394b5eb74eb" + "address": "2A7CxHDjsapYNt6NHQjWVKvxrXCFccKi6a4", + "secret": "2087742e97dd285b394d6b2f171009da8b0fb858bd4a0527a4e1fd8d04f922c3", + "public": "02a10f6ff9086e45bb2ffd96f56dcaf5adc8759da06fac9265cd116f6da6cb8d0c" }, { - "address": "26p9YJYvuPPiVSjAhGMPgKowLhzbaVf9mm8", - "secret": "228a3e75caf3a6b3e95f5c73d963bf634f7e8a329a949a639ca3096f8a83f398", - "public": "039f6fc391cecbff1e3825778ecd2745001e48474e1f60b7f3f9d77636050cfa6a" + "address": "MydhPQrxZubrT36DLVBvm4ww8jPgwXh3FR", + "secret": "a7d1a0b8a57b64b6149903ebf0b6aec407c5d8a7f5a0765b0fb62807fefdd9ee", + "public": "02858feda2754c0e692228f459b4f5b563adfc1c0d231d32777c369bfd12025261" }, { - "address": "25fuxdGkHXXVcLatz9qhZ6dpjXfoL6frgYG", - "secret": "95c0ed66d1906f9ac1e99a658250bc069bc9ba151699b1c197667f9306e0b8fc", - "public": "03b1ef9a69eabafce56a30bc5a6fed404968450f4356be8fd1e9f667c5663529f0" + "address": "2RCHxBQrfCpWpDgHhQMx9CDdNXuRSdBvQW7", + "secret": "9e59e8c9248db0067f382ec45f8b50fdb229b7d35145912cbda5a60652e4e2fe", + "public": "03ebf7323c9d07ae87639780e7fd2368dbb2a2be81fe2422a0a6caa3fe95af8070" }, { - "address": "2TCaxET6jamSMt7Uax5WjKMoF87fh1NGmMR", - "secret": "abf6232720017803d398911cb69f322c2bf5acf6f9d4b429b81b9e35f29cb956", - "public": "024950000bb73a880afd2938f8cf4ebe87ee9d56020fa0f33138ffb40dcb78e7ee" + "address": "2CibMMEZLdQNDNUkeGTxukCyP9ZQyKTdTwr", + "secret": "20ef1184fdf206000b3afe262bb8c7c1f7e47779c37e25b4aa8bc9ce1fcdd5ce", + "public": "0228a3cbbdbe7b3c06de4ba6a57b90f0a32353d967b1df3d2a735eea9985483531" }, { - "address": "DpTRowummUWEzvgvfJSjzDEK3EvCSb4VVm", - "secret": "078613ae754019ce9d330925531651370bf407b85e044201f61546b09f896486", - "public": "0291e1a61cd9044c2749a5785ab6d84db37a6da58a95029e9bfb27a47af4f8080d" + "address": "2kS7peVSHev3CmmdN7DLaZtjEzvfvKkk5YD", + "secret": "92bc9d6ddf02530375b614e6dd951c0ae3732ba6186cdbac6ec2f0c85f40136d", + "public": "025a3b72d6a01728ddb251dc64295c7ccc8ece2dd068054c694ff856db247cf232" }, { - "address": "2B7BF7YibHBHLYJygc8aTVvxbfe6KEAMBMt", - "secret": "dc0f45eeeb8a9cac3fcf63078425288ac16c9c5a2545554d6b7c2296ed42968f", - "public": "03ed328475408afb280cd5083f5fb5ac1b985c182deaaf72bbe5505121db45ac78" + "address": "21oC4NFV2TGUjrGcrvPwVKpzgFkKM97kmB8", + "secret": "e61d9affee3d90ba37ea488fc7afc55ab78dd71e8b1b93b04ff83226aa4b73ce", + "public": "035d082c055d9c298234e57ec9871914c996884b2014de1c0eba6f958bd1353077" }, { - "address": "2QkLBnr41U4LFpbFCKVc96yNvwbpGF9Vrr2", - "secret": "dddb3e30a41a4677005de1d3a9d08393d671e494424e2ce653dd110789d0dadd", - "public": "022697bbcc5bf05a74196b358c854a272278b6065fff3ea46dba9e2b420b14c840" + "address": "8u6dLFZSABo5ALndKjJ5ScYpDFv9R9uZDG", + "secret": "aa14f51b05ab597628809bed7e01008280d702fa85dcd8d6a284bdd5d18a5402", + "public": "02c089c13a962d52e5c46a445c5b6b4beb86ba95fa56359465e2308821e92e1261" }, { - "address": "B9bMUHrSVuHYaDExhS9iZiMqqS5tPFHxz5", - "secret": "72bb2f4f6fad1a6d5edc770fa710795cb1024a27423fa4f8848be051d020c391", - "public": "02a01f247be6c442edd3cfd4375b6e069464d0fe210ca2d3a47e9db1bd4ba3f780" + "address": "k5Tw2oc5wEF7msAycqGdG6f7dFmSg3Y1Zb", + "secret": "a6134facf7ed270bc3bc2c69cc8883f8f63e9c937232bc4c0cf6cead6bcce999", + "public": "02a63bff81da219a749e513ac2971ddf06938ecf358c7a0d4ab4a2cd3498deed9a" }, { - "address": "fJa3X6M7UYCRfwRiCRoVXjdCTanWWPpCkw", - "secret": "db6f80dd846f15ea38491c834e88627b7e4aabe9ddc75273728a64d6f277b769", - "public": "02b180b79cbfc6f3ca2db8b64369398d2f94b7c80eb55702808dd7fb7109bb4422" + "address": "JYXHANNbaSnXJhNsCxjytkA2F6rxE2KidV", + "secret": "19b88e4a1a08ca94d8b1a63ebb5cac5e3f862bfd33c246ce754db589e322e19f", + "public": "033ff55a1af67ae3b294be6a2d8995572681e3b71b95aa70aa2d26ace15d2fa165" }, { - "address": "2S57L6jHU9qzBjEvvbMTbpnkBfd1FCsyP4Q", - "secret": "c5d37829ed6f1430cce8344605c2bc6277278b1e41835b2286f33490e2fe99f2", - "public": "035ce09a060a8579eb64816e398ba9c17c5de732f1fe3d299404201a5ebe773e0a" + "address": "2MiD5TDqRpKggn1kKrgrtpAUsYaREZrAcPg", + "secret": "14d82b366ef04a93bde3bce086256e54cbd55f597f9d9cdd9fcbfb17c7fc751e", + "public": "0352d8e915e865373d83be53fc117872ad560b7a82e2f5db84bb4785dfa7f2fc26" }, { - "address": "NBNCJf4F6bPYuc3NBvsVCVzYdbXxFY8Kah", - "secret": "08d1f2946e5fafba96c8c272748d6e97b66932ab8ebf63101deeac2f4ff764b2", - "public": "0261c6489fabd5b2cda09604d919d2c6301a23ac8c0644613b1333acbadfb74bf5" + "address": "2hSv2av4dyyrsA7PWyt8Z6DfRgTxQCZV6KF", + "secret": "0cd99b278bbd4b0c3de49d5ea72b853e45e22b699086efacd3989aca748be469", + "public": "02382bffabcbfd3b8511528b3e0a2a17a543c8739475fdfe750874f3e04f57e3a1" }, { - "address": "DMMXp1Hf5f9uoUTQoxBLo2xCiXQt2fjjDf", - "secret": "363bab3272b3fb37b6d95e8e0518e0646a728476fa8d33971e022f7b82a91074", - "public": "0329e3abe1d84c20fa1a3789a5e3c9e0a615935792c3bb63dbd392649d7dd9c09f" + "address": "RMEbHrzzidye3H366c38zoT9sEHcxbsndj", + "secret": "4d8949fda234c91983c3fed2b20e2122136f027b415c53c3b28fd3a9401030e4", + "public": "03413090be4d221f8a0d6a14bd411c296569417d04efd2a6bb75459a6808380bda" }, { - "address": "BerVRaCqtHRq11mL2XjMyW3pqDnjqbx7ty", - "secret": "5b2485aa76ce0b8453b2b68e9f5218781a53c44545a09469e14b49ba69344319", - "public": "025fc0026308183bf9c55dc5af6b0ac89d58fdb95d13c4239ce79aab18747c8adb" + "address": "Vu9f2FuXNzXHhVZqLPjDjyaNLvF3eirA5B", + "secret": "d2de1f7c3105cbac90d122261c0fcfcc74cca0b0bfbfe9f334f753f3e36f9021", + "public": "039923f773cb3c12812c304aab95965c1a86c576d88508bc8ef97265568684c465" }, { - "address": "2fpPPT9sMDKpKHav7tpxYUzDnPomUs12NEc", - "secret": "b775f072be75f07db94765e82dea08bc7db553ee8e8c1e7e2192ef41ff026b6c", - "public": "02dd81ffc58ffd89d7d6e3c9f40eaf3bdc224c383216d1b511f8a63e85faa1af19" + "address": "PvJvPdr2V2B4rRZosBo2x2tHmWefXdgQhr", + "secret": "2ac57beaa74675d799d24540f398b2f08672db637eda8cf024eea9e458af72cb", + "public": "02ded23068562062cccd51936e7fad88f7a202a55349f54c47cfc6f9be27a78309" }, { - "address": "hYQpkMnMdkdd1673x41bCupXbeTU3Fo122", - "secret": "7be56e03939860b8884a6fa659ddb474d5a7c3b768b779a52ed774c78008f951", - "public": "021dfd5df7b94061cf3a73786ed9d5a1cdab800f292092f0b356001427acc71318" + "address": "2kaCFQ7x8rBJ6JttjYP4psf6ejKwADrH3Ed", + "secret": "341b2bec8e242e758ccce37178a134a50b3a97821c9d8a78c5f7f7c8fa545b72", + "public": "020dd4d4be64e0e7305e59bb928340e27f8381c3659e0b4f5fb3b746882e8fc609" }, { - "address": "y8zMB6DkxF9S2EgS4SPFbxEiqyRmdNTmuh", - "secret": "33ba176de9779eb175b294b4dbfbf793dbd5fa42bde0edb3271cabb1b1fe6918", - "public": "027316068b1220d1625fcb9fdd481b55724f887ddb2fa56dc3277534c60fec7b07" + "address": "2AYJYq4zBgKb1ZtC5RCF4TdG2zbbEAnfNch", + "secret": "1c304b592dcc3f935134a24eb57988bb8344a8c061d2f82c045868295c8be5a3", + "public": "0213136dc207e6b37ac9de79bd26598d2fa2ec25dd0f1fb4b9d41595b58502b348" }, { - "address": "ctFcHsqFGSMzGmNZMv8EXFmJtRiYyQV9Kn", - "secret": "c8ffe2df020cc27073ca0a1f9d01f0673dcab176862545393caf76619dafd8f2", - "public": "032da10312028f277a7ac702a8622e343c0a46d81d3653eb237385b7a6ce0b8a25" + "address": "GK9gno6miV6T9UTUswvc8pRdFf8NfNQLwN", + "secret": "fcc02916da58e734019b145f5850d1859905b9cdd48944de073f12d2115702b7", + "public": "02a97331c4f06faef53ba8936e0965516c6ef605724decfe69481443cf4fc2a755" }, { - "address": "2CVSLZvkiLtNpEWjv5YkbeXcwnRYsQLfdsF", - "secret": "4152a966a5ff8024f2cede4c81dc300a3419c247323052c3cc46bf824494a0d0", - "public": "0305eb8755e5c014fa8e6c53104e44bdceab67ccdfefbf420c2abe656614c49abc" + "address": "iUkqHafpgjy6onWwQnvzdHnZDEe8rQXLdR", + "secret": "01f973071fd0188319092052ac43ffce7972283d98855265d3d82ea6a5c7cff9", + "public": "039a5cab52c9950588ac44cb5ac805d27aca17a6f7515f03f6d8b2ba5f6b12c93d" }, { - "address": "YQzvEkbTgoDeA55u1qjsowQazndX2hzEy8", - "secret": "3ba4270807cb7b6d22d8aacb1e30e2514c699e750c54bdc0c80248203fb132e4", - "public": "0220aa50bde3545aa8f16ee19c14c3ff1ee3677f99c40ac3ef6a670c3afdfa23b6" + "address": "txb8qzZRZT1WRXrg84kQS93omLXhnTF8As", + "secret": "bf709d3b0eed838ff3edf0838a585d48de69b9ce8bdf389bb7d657cdde26a132", + "public": "03a08d2ab339e68465101d9dfbfa2b83265902ff5326b11b7ce53ea7f419bcd6e1" }, { - "address": "7WHqaYYSHrk4zj3LuVMEJYFeUr3mgJ1yJo", - "secret": "9ab22ef7aedafef9d740e0188a2239ab511d0dc301925ffbb291a36a074435ce", - "public": "02c38c63620d5d9a7d0103bc8866d9320221d5cd111fbe0a60329dc721b709849a" + "address": "wydSm3axBbXCtygk3LEoUC6TDYzrASvY5e", + "secret": "8f3691f710738866731a562873a18a11b17aefeb5981a1c528cf94fb2961c1aa", + "public": "0342b15f8b54187e0528d67455f4f13fee993d2ce6c3e0330a48e805cdd8ffe8fe" }, { - "address": "auRCwGSvok9Vy7cSsud3x2HzAhqSaBx9tn", - "secret": "c8d1f21044648b7249ae0efe1d77a82389517017610eb5ea71a48b53c6dcff99", - "public": "03123142f93491f0a401b1c76cee08a0d47cbbc00d4347ae599cc5446aae536930" + "address": "GrcRWScVaDgjfY3vfybHCh4NiE3satxdYm", + "secret": "7e10f5ebf6a8ebf21e62c80ea90bf39c8c885b0b682d488dbe5b3146ae3df21e", + "public": "03be16c5650fd39e75e6344f1f94e56b8e2e32200cde1caea4a2d6a9d0b72260c8" }, { - "address": "2Rv5TBJSkfrZfCX5MbmVXGBk3xXU4zqq1ED", - "secret": "2c5b016c6403c408cf2dcbd1ede8e411c48e3bd0b1d23f5518faf927891090e8", - "public": "02a5ae5696017f4db0c9349b3c51da814d73245d28f58a3a724d2f02a2a5f5d8d0" + "address": "2bWdKXnEMhTD1XUY2aMeiVS5bZkUHpYmMGH", + "secret": "185c0f312da84fecb88764438b48185aad42c7236180dc1961cedf4ca3bcccef", + "public": "030436246f3aea56925db62803f8e30d620b744aeac79e494890e2ecaaf6699fae" }, { - "address": "26tvAPVandu8acaREDrDqSva9efSSHnyE31", - "secret": "462bf31ed0cbd3fbb7a260ce93af7e60ddd029b6465d229f52daf046fa4fb814", - "public": "031bebc4d0cc354c90eb38f306b9733f4ac2e821b5abb67be489e08ecdf9f1fd22" + "address": "2V2Zi5eW2Uizu8mqBoCgfM2wNEsuBUV75MA", + "secret": "21f8705279bc92569a2d0cc3be054f6a34da982c7d8046ba3f92a7165bdaad2b", + "public": "030a582da2554ca666e19603ab129046e69afc88b2e10a643a053f935fa1ac91f9" }, { - "address": "23Yrk6SQpvbwkeGCLnUPcom71mzSTw32hV3", - "secret": "3f4e968f23434df29b68ca20e76b82f9bf225b78dd4b1344486517ee916b4ae7", - "public": "039aef457b144cc4f1ad860a3088d0fe9bce371f74403f298c338fabdff6af9126" + "address": "2eoMqcWAh4CZ6fr5VF1P7JWByp9ZZyXxoLt", + "secret": "596d3109aa4d63509bae68a6d23bfa9b31f5118823208fafaa93e37dfb388ecc", + "public": "0212d52f6325785a064fda843f18936f41ab825adaf9d013b0cf6beb792ef3ac3d" }, { - "address": "f2NBZX8jEZgJjYJf8PVdMb22Mgk8cwG2B2", - "secret": "9e0595a0240a1c95e04c7f52e5ceb00d790064b73ffbcf017a523480c7157203", - "public": "031eb68329968d7030b4307f5fb354b0b06fb54f960b36d84c12fb270f152d5677" + "address": "2UJfBnL4wU9YrrC6qadiNHysCXn5uYSgJag", + "secret": "00e57b2fea94a45bb324b69c6efe451164dcff3f030197294e71c9e38abae3db", + "public": "031fdd5da24da4f04ad91c96c764caff0c9d5f61234446b2d4587c141e7741b754" }, { - "address": "hHDNjSBYsVQHryYbhNBZqQEgCEBNqrYBJc", - "secret": "e1f27b5383c64263baaa4c5c3026ed9b2388dd3c967cd8071747493b9b51e1e6", - "public": "03a2ec4dc026a848e97362a7dbcc77492c003da99358b4ac6cc8c0f303f43c7229" + "address": "Prd3few66cjZHCdB6za6G4v7fnPzeSD2iN", + "secret": "efa8feb48f1da1eeff8a66b0e051127846b73aa22c5bed6966048b8e09a17f47", + "public": "03f6e0fc17b5b3efc249986380633183ae578edd267055e9cb4b5c753414acd523" }, { - "address": "2mE4Mf6Qb6iesWFgC1jRm9VLASvzNsEDMac", - "secret": "7ead47b44a2088e54117ef02ad19c608361b981f3430167aee5bb8c4f9d83408", - "public": "031d78f6314457541e1d2edc91bf202070d960a6328b5df68976c907e0ab59d258" + "address": "bs2oWEVpaH8fi2YqaDZ4VpSgEAcpjrBuLH", + "secret": "2376d1e38d7b79a5edc8db82291f7d23226ae0c9c8e541f8197e67bdef978660", + "public": "036a9e6eee4f778b184b8252ff0fa93e7054cf00e01cdba67907a3d04cf4812b27" }, { - "address": "Qs3TkgAW7MiNp4YacVsseFvgULLGMU3Atj", - "secret": "a95aa2b2c636ff5968f5d426f10860287b5e2a8750fa116486d1f9dd3d3d9db8", - "public": "02038ab1dc1d3e2cf957581640bd583c2d9d8806a1a39ff57e8b79b8fd71f62485" + "address": "jdXefcHXereUDbC6JyM9p6YKDMr48q2WPg", + "secret": "92181da42717c4ef58029f272e56e497b15147268b0c9e3830d8a76ac8293a73", + "public": "025e49a895fdd528d99561d7864076d1067683e374fcdd2b550a8bededeab01337" }, { - "address": "t8cDJC73G6QC9iErMbzt2eXXJzmQKra5D1", - "secret": "4a69d915612494a851fa9097f01ae8bd09d5326b625b5e5c5de7b76e0b124363", - "public": "03b933924f86979a590b74e7b34caf71c04caa0194a62eb3e24c74352e86898a6a" + "address": "5NxWC4oktPpNE1bHAPksR6WRBuKj1dgdgj", + "secret": "3797eb0d846c2bfa231b21a88f68aaecddc3e4bb5f5c40b08e12a30ca5a9a8b8", + "public": "031ad96ab1dfbeeaca199c561a185165fb957dbc9ab615af157954319936759915" }, { - "address": "SpSQasbCmiK5N5DTh65dh9brKDDsAzofCh", - "secret": "c1649fd0325082b951402fbbb22ad36af11798068f2ef3ab1400a8da27eefc4f", - "public": "035e8be2cfbb02cbfcac581942cd2f3e017ebfca4da58dd9c41f680d71a86344e9" + "address": "8MAM31HoWXZvDucv6K2qXDoTiVEDUoTZVo", + "secret": "d8c3a2b3899f1a4564d12960caf8bd2e02135981224d1f1251209209a1a7c3eb", + "public": "02be30b3205f3dd43c5224c96fc73460ba227ce463dbe3accb9f8cdd5e36e05bbc" }, { - "address": "YdetYrrNy2TujL36HMwaAnorxqXQek56eQ", - "secret": "883c0457a6e098c59b254ae21e7b0a0f0162fc1b6f19b26a0934eb3dddb546bf", - "public": "021df07be5eb7e1e4459b1a612d2ad5f61448e29e80b3ed7c0c149bcffd0819321" + "address": "Mzymc2SJmEtizbeBctHtWvLwkejj88PG84", + "secret": "5450122d57559c9524eb51445add43f6fdb9b5b3ef514daedbbb2409380f8091", + "public": "02a630725197056ad33d7d65e93ef00353de3b8516732ad3bf01b227457d4e2d33" }, { - "address": "2ZKzBTeYHymu2pq22D82NKBRpqV23RBSDQa", - "secret": "1c515dbbc26574483fe0a1bad80ba78f89f3c5e0310e9d908ec79cf056d75f3e", - "public": "03a4491d92b14b10a403cbd95c197e781f9fbf5fa1fd4be34986441ca342cd732c" + "address": "pg3L2zkpFxWvZoFFrqJB6rpbLCc6AGzuRb", + "secret": "e43543544e2c5587a10cb0ac69cdb99a46f31cb8fcedf0d1aba4bef755175915", + "public": "035b250809634ca72f8ff5951c8b33b26665aa4d62e367befcee476d654c2db75b" }, { - "address": "JCGqbBTGPisU1y3SV5m3dLQS3G6ikszt4X", - "secret": "b01dca16e556f325857c20fee192206bafed9f93b81936bba3e3d6f2b71c8a0e", - "public": "0358f9ef5bffbf1cc11745ad00ab3a582c33711e6aced464f0ee3347a06e062297" + "address": "2ND4LcwLPgoVf9h3mWCwNzRoMKRWiNtDaVb", + "secret": "e8338cb5e4f5008d4c2a133a5f2c5daef0b9ad807b1edca149a3ce48302cd4e6", + "public": "028f8a7bed139ce4a708872273115dee124e9187936318afce6614aaeb68efe348" }, { - "address": "2KqZKDBHePBFR1kCEno3X87TEBfaKczznhT", - "secret": "4589ced1ff2802830620a13afb89f5ebe4e11129c53e93d30e40ffa2d70e1be6", - "public": "02b09d0232211bd3ad36bc554c3a22237a3d3370e4e1fc7334c506357d0ec924ca" + "address": "JbxjtGo3m6fb9NHD1PXdXiePmjQoCxYGcJ", + "secret": "4e8ca2101270bdf9d18826f5b4cb19d2dad0aff9e848583d4574ca4442e6c721", + "public": "03b1b4eb17becc25c2299489bf28db1bff7d4cd282128591ba6c849d2e76c7ded1" }, { - "address": "U31gJqv8czhqPjYE6SpQYJjPtjpMdxjPKQ", - "secret": "55b0873bda09c7677b4573870d704569e38c76fdc864c18fc7cdd8fa57a3dc4e", - "public": "0372d174ced69046416288bad81a83977144adcb930a4eb997cc0ee10a99b0722b" + "address": "2Lu6tTQ72MKV9wquyaXFja6XU9vLFScmUiF", + "secret": "e5dbfadb988d7117ff6ffe71064f6b0af0f689a7a30a605444f45a22dd998d43", + "public": "03b6764c3cf877df3cd6cc04813061985ca1fab72eeb0fdac8020d491a9b9cc8e6" }, { - "address": "2SYCf2jDeEpHRsVxP2TymkV2QsDMaaodzjk", - "secret": "5b2ce9c1648cbbb239c34360143166cecfdb68852c6af9f80eb670ac1f961601", - "public": "033cbaf665bdc5a501a955f892b2104ceab1370ce9c3afccefdb78839fb212a16c" + "address": "Bk9aopdh4aVS9DXFVteEfnvK6B1G5ZQ6yF", + "secret": "3fb44c013e9119aae6de00c4d31911a9e3c8a8f7574d6087c16e97161b8d4fd7", + "public": "03679e922161ee237706bfb3b5d08b0ff3cd83cfb91b62687ce400e917115e84a3" }, { - "address": "M17zzXN9DL9f136tFCqTZKceyC1TN5xDCs", - "secret": "684e84d11e52a08ac12570a3fc3308e46b6be5e23498e53557a4517db90dffde", - "public": "0302dbf82c36c85da20b878bafae7ac7066b028639053fc3aa9d4cfd4b18989948" + "address": "pPHJkUrsgLHLrTW3W6A8MgdrYTCyb6uipf", + "secret": "e5efc89a01ff944f078aaa553ce1fd81774c5a0b8f74f39c49404cdb69bb3e41", + "public": "035b2e1d01c7dd09eabc905b3c274365abed2a5439b2dee9754bb1d3d760aaef48" }, { - "address": "rhsHDRXT2PC2soygRitnbvFuZDEaGZz7ir", - "secret": "6c9be2f69243fca2b7fd7cfb9bc87ea3eb5d4e717b13a606d16a68c2015e3fb0", - "public": "0274b784d3b02daf9e2f3181caa030b7a0082881df9d8e5139b5e97e06fbcbf6dd" + "address": "2euWrr8eWQUwofQ84zQfpStygyUdLBmHG6T", + "secret": "8985df67d23fe2ed3ba1a487d9f4e6677752497c7690ef1d6b97242bba7e218d", + "public": "03092935e59628015a627db9dc3816d2b6323fc1b383d7b6c1bf0e7ffaebb7ff78" }, { - "address": "9Fp4gdbE74sDjDimR8h5kyGpKctu5p9gAX", - "secret": "8a87b8f9c74180f1c9c5f021eed5ab1bd8d2286b2f970bf4dc04f20fceb35788", - "public": "0266e22c881d5869966287a52453551355c390fdc5b672da70d910b02bad8fd946" + "address": "2JbV1HpUFaQNxBGGzXvmgKgsMRtRLiuu4iW", + "secret": "403c5105e61a06dae3846df4bb9cb015c7073137fe8c5b69633ab5fafb2f50d2", + "public": "021bf36446a0583323f37b4ccf6c3a1f7eeb9c5b16dc164a9222ce1bf58e9765d8" }, { - "address": "HujJ7Qy8JNS2CRCJR75aDa9b5B7FFbmYGk", - "secret": "f8de96ef1eca8288f05a5d2cc599ece2a51fe98569f01e310871cacd0732e421", - "public": "03ec61c2aa6b49f47772b4557bc4f0630843f4827b604f737d3b8bba57629e7891" + "address": "nkSd3RskDcX1UVrbi7McpTWjDDHTatAFuC", + "secret": "936535f0861ab8774e63a0da8910311215ee5b868d2b0fb7c63e9a6bd52556f3", + "public": "039b7b5687043d02634c7a37bdc49763da72ab6dd94e0e4bb9a57f46572d1c2c5f" }, { - "address": "29RBiFqAheWmPGmeFobHcwnRRNMVhMukePC", - "secret": "a4f84366021ea74810b7de8bbaa5e9e6a68e485d411f47b7cd3f9e83ff6238b8", - "public": "023611edbca2c32776777d43ef7d17ba020747a06b7e47a061da7d5fdf265c0845" + "address": "2Tsgim6KU6LQmfdvhdWMFBQmLtYU8HhJ6h2", + "secret": "9e4dd2b272096951ef4776cdc7f176629c4fcdc964034847a482c3cc7de5eb02", + "public": "02a8e2ab0a854e1381b0632b0961633d541f31841512aae1089be8b8a89de1f96f" }, { - "address": "r3KjHqaSX2vRxLkTkSa9RqJc3wHGMVv7kQ", - "secret": "82ed20ccf489650e98a3f8666c998bc6cb7b5d5437ecc9f1500752f4cc2a1886", - "public": "023dae873638308e6d51f8e97a1d0047c9d72f3bfdbd84a3129d07576a78d149df" + "address": "mF5CK5hbyT59F5mjS8Nmxhc8eqpu7ZoeiV", + "secret": "9f4424d21a2ae111217aadf776c9070f9e499beede5c0c6ab9d6a7e8f9e5a691", + "public": "03c3bb8a4676d5eb6d32c53c82c9b2bc6d37b8d98f414e67e59fc3ec4766e52b22" }, { - "address": "UddEBBtoYxyz6ZRE9a3A9Hx4iptd7SWJUt", - "secret": "b411dfd025c35b16deebac6c6c8dc4cead5cd9beb98b1d5fc02db51938dea47f", - "public": "022cad0edfa9026afe90de933374c2a7abc65f6e0919a4258d34b21158b9340acc" + "address": "J5XUnSVpD5BoUQHPsJb1iHXBsmpZBnFoYV", + "secret": "c41cd6d22063a0f9d674e1c23f52f1842bed8938b17bf1f32db7d1ac70b10ac0", + "public": "02489d6562dacd0b39bd71d53c123dcb69b0edda93ee428554a904bfab2d77bed2" }, { - "address": "QZCY6XpYbXvrCSSDyj2mHELPeyuT16yGnW", - "secret": "2397ffa394c8273dc74c8add6f346ee701151cde8dadc18c9ad3cc605d51fa16", - "public": "02b55a33675ba957e8dee9dda232fbfe96585d1184a6a68e0ccd0e415182850b6a" + "address": "QJ9mJXCzFBRSL3xgVRSD9N2qJBZJfsMXDc", + "secret": "7f399ba3f61828187c23d5649ca93a4dccff0170df1b98eace826bc10c44987a", + "public": "022a0380050debb4516116c052c6b6369da3f99d8e983227d1f1ab083a776c38f0" }, { - "address": "SxxCYkp9AwQn3xvrMfzMAAFqn4p9QyKJyh", - "secret": "4d6f582c6bf82b7ecd6b64bd50ce7eaf4eaac19f7fbc50a4686b6279f0d07f67", - "public": "036f241dd25cce0fd9127c42c2432db93359ed2212fb0557a25b72eb4cf9d61997" + "address": "qeSQ75vnGJSdfBwHLdaxNbmmh4ubrnDAju", + "secret": "022965e0753ecc622455ce3e794efc10afd2969f588a5653cd14858a922de550", + "public": "02f3aba0f28b0c36eabf82777f7eac06b65da1b344b4d1564d66255fd9ecaabde1" }, { - "address": "2iejiAKATuWiacBeRTk9fULqrTnr7n9Hj7M", - "secret": "28ec3887fef39d18fa801705214c26901d90f1491be5295877d2057633e28033", - "public": "03d30a0f6d4136714dc590949501555a3a30dc05b11494a390b57ab5b12260ed50" + "address": "DQBDX9kunUZc8EhaCDaTsWCsR8fQdMFqNJ", + "secret": "34b344be4497e6969cbfae8e154d837c72c85f246bff54fa5a18eb16964b3479", + "public": "02e96f90e75ea904486562d31ec162cae8b75036a75d44888e55a2a062276c3c2b" }, { - "address": "2HqtjKd2syD5nQkB6Dr5bWef34SoQMga9it", - "secret": "6e64fcbea975a9b3be82d77e41c5e10b158e1bd13b54160b49eda156146f7a56", - "public": "027bfe06ef8dfa3252c7767f15d01aa6fd139d98bbcf5df9e4c9b5d2d0cd6c9b04" + "address": "2M8ffrt5gQ96ec8mid58y8dob4RpEQeKRtR", + "secret": "d072f6a2b4f85461aef64cac0d2f63134ddec4b9891359295b9a155eae735c15", + "public": "02fd82ff7a4f209b35152da7dec8c55a6d715c3643ffe23e53cd701b7d665da62d" }, { - "address": "CrJpbkYd4htL4ohqkmhWAmgzgysUjedL18", - "secret": "69ade30c5a414b2453bb97b3cecb1f2356e6ed69ce119482f84bfed78f6e422a", - "public": "02bb5c933974f3f708f934ac17a04fa846924b8611b356a95038168ca5dacccd67" + "address": "23q2Y6do8YQ5hLqgMWPLRJoGCgHCpnmFceJ", + "secret": "ce494783eaea98c9c19083b79aef2f8fd4ff0e5ee27acc3ec3ab810706e7d8f3", + "public": "036226b6d29fc4db7410d7887be144b48ec7cf865bc2c8457417f2e5a4fe6c95e5" }, { - "address": "vKLmEcfyH1yfSKfPg9DekkjBxDzHqvE82Q", - "secret": "a4dbc185ea73f0205f40c0a9a2726b36b6568d601e0cec3bd84a159b0ed15208", - "public": "02319b8df76273391b3792996957871721b5f144390660028bc6e7483e31ec1e2b" + "address": "Mj8Az1NanWTB2bmQyyGjybYuVBvnRKjJvf", + "secret": "f75fd40219820fd2984e000c531e758cc5b8ae4fbc422f63ac3f8835b0eda06e", + "public": "0388fc76f02ccc90b86c240d880c9abf9a1a2299f7a59eb21f26f3d8d55bf5a6b9" }, { - "address": "2eJuuncqosS6UJp7S6nnJ1jaGqkhE7jSi9", - "secret": "6f44e8bfa3c0090239566d50bf2b986a34b9ce1d98f720510e484a8ede4dea0a", - "public": "0320ff5691b94032d5038a8fa5c12394c173a845a63220327974eb182c8d7f611f" + "address": "2ZrbqGFYr8p9AHYrsGpMX81Svf3esHnv23w", + "secret": "e84439ec6b8da8758f88e91f33fa37a47ff218098520c634e71fa21897720bf9", + "public": "03db7a56071a216deb554b5b3bba3966c531a63c4312a18504e2d0b5780303fca0" }, { - "address": "Dtz9yvbN94isJVxXZ11JRkmxRGHPJYMh7A", - "secret": "39ec534e113649199343a3fac4841958d607f93568022a1978d1396cf1b25a6b", - "public": "02e952aef286a168eec660f11415a96137c67e57577e9312c3db22522078a0072b" + "address": "2buvFGVozbDCzRpadgLt8gYqwkYApVzWzXq", + "secret": "648af6bb80e569e9e7d8155f81459d717fd7951362fde9ca5521cec0d7a8b44a", + "public": "021559a6f9630c7345bfa81feb9181624af8a21d831a49ecc9003a107619dd7cf0" }, { - "address": "2VebjtSC85T7ohTyLr6a7aUQ65vPSJNjWmg", - "secret": "460a25817c937b52d453698a6dd138061ad4880ba624e48c5f44d7a20b484e51", - "public": "03ac661f9856688e579ec2ef8a701ce87b2219161a4a9711de2e7e2acaa09f2608" + "address": "rYd8g48TD4MQtPbKaCoZt8xzMNx1ppHqPd", + "secret": "fa0a33e154a972151f7b7b371d5184b07ac8ddda8141e1d0b521003ddf05dd69", + "public": "03b12cef132a3b0d6fcf79acac849681f24478df506c778c34389b5a02c660778f" }, { - "address": "2hEpP9nVx7r9ic3tfGahBxoTfv4fQfRU5yY", - "secret": "b29ccbb47cedead4ac80749d953ad0f1b25188ab081678573dbe3d83cd70f8b4", - "public": "02fb3fdfac10cb71b0fd7efdb18dcd1b1096db1be3b7bcab6a1424c6bffed46126" + "address": "2LVoYHBtfPiXybV5D6DRq6X6qrQxbDB6wB4", + "secret": "5a350017532d09953ed6e32bd8abb0f7a47268e0e4022cf15cbfadedf890518f", + "public": "03c7475b5097a89c68652a7aeabbec758aa18f102b2fc87289f993d694f0e89c80" }, { - "address": "dX2DGZhp9iyudAP9u6pq4Z9DFCXQ9p3unT", - "secret": "d0d8c30deeab4ab27b57ec69a1f828ffdf6f2fac6f3800dd5768edcbd5499aba", - "public": "02412957d7547a026cfe5dbe048d23c38a39ebd9a67000b337e0d2de5ef5b013bb" + "address": "nCGXsbdNQgf8HjjRDYzDouvFvQikmaZZVr", + "secret": "f6579d55c6fc7525d283831af9360d8a20a7c856dbf92fb1c5a02c146f0413a9", + "public": "021780bf8d1862a81ea1a75a89a9576e0330d0b4d20a61e0817bf3b9f9d52a815a" }, { - "address": "5VfXGcXFqb5uUAP289TQ7cZgKtwVvuk88s", - "secret": "fe39bd11a5fcaa685875718cd350908b5198c570854c6e6eab3342b7989ab47e", - "public": "03d9b492b4e0d37a6243daf0150ba925d33b972cb63f71dbb90494c81c737949f4" + "address": "9z44BB51AgYhr3Ljqb2zMWQrvLpbLYd27j", + "secret": "80530625c63b9b6c1dc510039f379a8b01b0d646fe569ea2ce35322a1894fdfe", + "public": "02765c54f55f261a24c164a2ece6662d0008eb3a9f3a379d19d2b624d431738a53" }, { - "address": "2Pu14wnZ8qWaJBjxFQJoZosv7uFZzxkSYdN", - "secret": "e005a44a98aa8c1606968431d97a1b144bcf4885446bbbaa3bd3a7ac1f2f6ba8", - "public": "037dd6748392fd6e2c5bd05c7b66c83103afa60272900e476cc47260abfff0799a" + "address": "ZHmtrHfaxG8U7y7pjf9azLyUtvYuX15egH", + "secret": "14b437e7aee69001945c95d203c08f9d19dc8a8dde97c7133d296b883e58292c", + "public": "0394c3de2b6d85c29b7b066318a8bf83f9758474f595541d9154399a790d1a0299" }, { - "address": "2KwdszjTLtKsXgUkzpidDvnW5TnYMpu3KEJ", - "secret": "a1d54dbb7cdbf715948c1ad43a53955f0138068aa2d439b3bd23fc4c6aaa270b", - "public": "022ea5297ba8b7a6c0ac1e9575ab7a262453410c3c42b97eb0d79c828d61a1e44b" + "address": "bd1D8ZA24hn2nnXJFu8BVdCZ9k1TmMADoQ", + "secret": "e32ec60d9815b47f4de798dec53ce29d706abd85838f6aed87bb9d251ef25114", + "public": "036c0a31bd777b096d09636c11892bcf197668cadd72d339a926a404fdb6e6c9d7" }, { - "address": "4Rya6HDUyAcR3zkRaLBdFuEfkg42AfNLAe", - "secret": "e678c845b6e330165a721583df4cfcc15d63442a36951309d5ee7b1dcb21d7ca", - "public": "029cd8b6c12547b69a54b90ffba836e9ed8bbea1c084b5e24f1774e016a2c81009" + "address": "2g5eNKbSsUF2NXqGkPP9TuTa6YuiJTaPKgF", + "secret": "12346069b478a1004cd81e9056a4d56c8e8dbce92cca698916e93e1609bd603f", + "public": "03861f1e168860ff59e647b1b64617bb08133815ffa56fe56a79d95f2a97654298" }, { - "address": "gZpLvRkq99DcYiP3JxgjgVtDwRHxXrToEZ", - "secret": "deb5e07702ce0a188cecd297c65a06727e86e6c021454806a778e4fa95000698", - "public": "02ae35e746900df0edc2d8d2aa32eb9833a24dfee2d83379d3cfdc2c0e22a4b3cf" + "address": "tDw9LMweotZST3PeEAneUJKM4qn2Ti8Pwz", + "secret": "a84d45ad2f527acbb1baa76fb15f252a4e5e79763a059232a412e585030446a8", + "public": "02300b36d580deb81b563d5430f1f91b930ec72838008a1f7304c466ffc70bec66" }, { - "address": "XDDP7qhz5YhLAHEU8cQfC4RuRpRtvjE2fz", - "secret": "342a1e18643f969c2cc4a870d24a6b6ae931386721700f4125a67ee468c97f41", - "public": "0272691ca7acd0fe15f6ef34c4cde9670ca176ef58a71bccf8d0402a5fff888409" + "address": "wHVfmjDbVKmfYntbXYARdPyDuUUoAAw6op", + "secret": "206f1e19e7b1b8c61fa20a1aef9863d3119f348c9b82d4f8fcae8de42525e6d9", + "public": "039a54db3c39cfc2fdd8a2386f9e98e55462c1f1a041432ee5fa87c1fa4f70efba" }, { - "address": "SDwnJT3tewyaWU5wTg6PJ8dU5crjeVcYiv", - "secret": "c592c24f3c90b8583b3f1bb43922f885bd2f300ddab6a7b335866bf08765d40f", - "public": "03c0cdb6afc0fcf75255954ae6599e820fca91b65568cb03c0489463374aeafb2d" + "address": "FgkCgYgEbc9rAuuNUdZgeUwCw3XrnGFX3s", + "secret": "db7cde643d4847775836ec285af69de816f699048e64571cb911444e258cc40f", + "public": "028332c7267e536582c2308c166c5be90c1365fea194a4916bec575f19295259d3" }, { - "address": "2k4GRnrD1cF9HhCgia5C6WKPAuGLyDf1V1F", - "secret": "2aadef08ab1beb1f2e536b7bb17a70c5078338f0baebba37971e5ece619a377e", - "public": "03df098cb79e58bbe2787c93117197daab9ecd0aab50597df542e2863d13d360b6" + "address": "2R9QoPRT5ucDMXQku5T3ZbHymPGkX6SNSgH", + "secret": "9cb4301d96c544ce6f3c19071c5145b89b100ec8aef58bdf90c90aec054ce985", + "public": "03e9b2e1541e9559887ddc09f22f575de87db66b895eadce25cbb68bb243068b20" }, { - "address": "FkGJMP3if87x33yrhLEpN22jtZunqfgSrk", - "secret": "2e610e869fb85ef0a728b32f936d242eac0f454ecabbd2ea7d5bc1a538bbd1d9", - "public": "0221d993af7a452e2e07ab0919ddfdea42391f058b01f2e834e52358ce10d2b18d" + "address": "2n1NfYxcLwoH1jakovQ2sM4ShKH3Tcs4rWL", + "secret": "7b031409b353b33f8921ede8a6b03c6b61a6b1a4fe81769c79751aa7b023ae3c", + "public": "03f024762d6f497aef1a1fb90deeb34da641b8a1a0470040a784fe85dae164a406" }, { - "address": "28U69QwMhQqNydKPaPrd14mCW7rWuWRGqJK", - "secret": "bd2984b03cc295df136f987f1f70c2cc9ded4f585787ff42432b7379aec2e8c5", - "public": "03a8c6d4d44d9a60d3dfeef6dad3f703e2874fcfaf1cc3fb932118b87eba2817d4" + "address": "2E21TE2z5qCtTT9WwXNWD2jQBLeH7nGB6Kt", + "secret": "555190ea46cad100a23dc8261250dce85ae205d2848c81477ad0eec31d9070dc", + "public": "0252684dff78d0b15faadb0e0d4f3fdc9ac9f168b62721119bcba98609bded5caf" }, { - "address": "2Gk164wFWJR4nDj8ZmokrZnHLgURJNL2XV6", - "secret": "56a1123f4938814326dd3e2e234a9a8eddd92c97c6325186607f9a8c6e8632af", - "public": "037da72b0ca43d78b57087c0a72c425180edd5d66b21d20675faf38a8beb693dd2" + "address": "2gRYextJNcQE2TJUSCBxhcnEK1siAtH7mhU", + "secret": "fd895903859ca6a879f8a6214b67a4458a804965fcf85f893d04df4fcc1dbe30", + "public": "037b4075a8e23d4d14e5b2090fb78c0cb72737197f27ce1da81ccd1097cee99db4" }, { - "address": "uNRQcYsVFSsYYFVhpMxfKcqYhjcRRqB7GN", - "secret": "b92bd0e9c1d0d0c144a8b8a1e04e3891a587c66faa70c10f481b5fe359e003ef", - "public": "039be4421621bd717254469a5466d444230f017d8234665fcff2967aa1ce5928d3" + "address": "2M2KmM33LeLGZ18e4G9CioqzSqaAsii44bE", + "secret": "2bd1ff5e663a33f3d36df0dce93148789ec358093ff3e335e88897027a639f81", + "public": "02e579ce75e735146329eb9b67c5af870fd95ab070bc18b80ce8a536c92db98189" }, { - "address": "qUHCqZw1nVnuHFbJZXkeocHdfE6qSGWfqn", - "secret": "f892d38ec26d430895a868de3affec07ca2a0d75bec48072a0b9d08578b00015", - "public": "03902756eae81753a33b5f81225dcf50b8910c8be11326794eedef089fb335dfb0" + "address": "zeUUj9uFNSgkW8VTHjR7AwhcfKsa7xDwMi", + "secret": "ed2b56c6babfc1a1a55f8d393f35b517993a61651b6380d938ab0dc322a00e66", + "public": "029306804e046440a614e43dca6854a37d194dd58867c2efbc109500a63b85a38f" }, { - "address": "Vrv1zeQoCUWW4WvJRx6yTH2fAyCmpzxm59", - "secret": "24e90e5d2b259ed465a9b3ff2863b36dd619158558472e4a7b0f157162c40138", - "public": "02ca56728a63046b5895d59e6e4bf5ec7e7d2fd5a3668cc6aee775a739bacd1b18" + "address": "2DdyebEM9mHwrX3jmcTvzgnmdBQYetyNWY3", + "secret": "4eb31d856d118fbf86e151a08615bd20248315f8ff9666e7470e5ded6423019e", + "public": "026812e3cfcfac2970a723e05c5c457ba99e2298b4ec06a5464e59064f29a10d95" }, { - "address": "UjNKYGBp8mGnGpv6wz3eyGvcoNW1iQSSuv", - "secret": "9a707d09cfc22f2db1045d40400fa91b82fca957feb2c84f3ea6f65dc4347a0e", - "public": "02394153eefece4b67f06e4cbd4a6206679ac26277c8340839eaddc31f3369e007" + "address": "WXAafhTwvot8bnNY1ekUDmad1b3xzW5KoB", + "secret": "98690f96a8bcb814cdb88a6ca5c5bf260586a1919913a2af3e5bf47f4843cfc0", + "public": "03c1ef010a6891cb5f9a34302b52f6cf47e1859dfebbb0d8aec889ff93e95a27c8" }, { - "address": "rhRcWa6Kysh6NcAWguaJsfxfWyBLeBBQHU", - "secret": "0561decc022e77a74378176e253128b6a952a0ba5e996135e26ec417f0b080ba", - "public": "02dd658cd651dd8f42d22c46027cc00a121bfd966715ba5d16893a8cd63d308fd8" + "address": "5Qf7bQMDQgJSGMXPh6nNJdFHjbbPr6vyB3", + "secret": "87cac60697e5670624b0086a10e5a3a29b54fabcd302e8fb22e1f46a319c14b2", + "public": "020edf7e9ddb148abc5e22cca11b3eae82a28832d0069c0dd54d75f87105f1d2b1" }, { - "address": "KumcfLAhZxf3Kp6D1Ct5mCnNGUQmRfnm7B", - "secret": "38e77cf6d33680a73a30a3fbc603f8835b424227e9a03c43892d8c9cf78732b6", - "public": "0343ba797dba67502a29190eedc05dfefce4e9529e368400effc563940f970c63e" + "address": "SKVDSRbKdqMjhR2ciTEc8nr8zXNHAcrSfS", + "secret": "84f3f3b47fc67662ff7353d14f28c64d824b2e877d457fc749bc437e6bcd7058", + "public": "021e6d35f208aa9bb7d4c920c3b4d10eda891efd7f9af569e6e6bc624ec5c8f3f4" }, { - "address": "2GJqRR7wbjKfwLrv11NoRiqFWFZKWT4iYkd", - "secret": "62698411e3afeee1585888a4e1e1ae2f4e836cade3da038e96ff021e416a9bab", - "public": "0204320bf79168fa281a403509979d62d5ed76cba5fe06083a14d484cd79a78171" + "address": "gowLNZDHBB9tNmEG6qz2NNwGkY1SouL1tm", + "secret": "b25ece468580847a3857d3d694924060e1e385d8d6c85e98c1b495bdfd8cdcdd", + "public": "036a8d7baac3beadb20bf1b5b6e900c99f1a476b91e3ffdbd8ad6cbc2310055bb5" }, { - "address": "2RaMH7MHS1MEQmK1SUnZw8ajWYh2RbNwmiD", - "secret": "54c6e49da4b5bc3683cfb6492e4da97885ae1d3d2187dd258c76ed57522de4e3", - "public": "03a1f050222dc8c192de4a6abfe5d65feda3cefbfea3c54e8a48490cca22e101bc" + "address": "Fsh4tkUymVnqmGiAYC9wX48fw2fucNipFb", + "secret": "e3877a2e5b413ff58ac84a792cbdb604d38b960dd5e5ea978fafd0a60850f746", + "public": "025775cf3978b487bf7aa201683a82930a0c1e8a61d466936c07006f719bb7fdf5" }, { - "address": "Aj94U9X9bXXs2mM9xjsD7RPZrsepaf8Q7L", - "secret": "8bd865606813a57938a9e39c85889cb5aa377e864879dec2960b322aad3f987e", - "public": "02b38c6a21cd7fd5c695f930927b144860a6f5a6f37f0eeff85cc6838b74c48459" + "address": "2Ma9qXTpbJ9JmYuUhZU6y1nwXKzJwbE3i5B", + "secret": "6625fc71d334dd607a82f6cc4e73a260eb9ae5a08b31f323bd896714eb38c7a0", + "public": "03132099778fce50227afc5e41c65d9830ee2930bc789e242dc11f153dab5538dd" }, { - "address": "fbRa9ziR4zCbybbencadwgHZeoXkbeMD7K", - "secret": "8313806df8760428936d1f330b66d0c75ea5c50a44527bddbc591ca2fb397561", - "public": "03353908792d7f7bfe74f69a0e83b0489ea2f09c689c9a6232083859ad17cc5013" + "address": "nsjzo4SXJK9AXaw8fSkossG7einZQxmjuj", + "secret": "5665f7c5048337a78dc75c98c591b31901ce7fc43a8ba5ebe7f45a5ab062d80f", + "public": "0263deef3218d427110f58d0d72a66d0deadfb2d9cca0aa2b2cd283ec805cf87ba" }, { - "address": "2AAmRmssE89kay7U9pKUBL6Gm1pZ8eN8p9e", - "secret": "c3e25e058ffa87cdbdac58935239b508ee0d56d99b9e04ed4a93c53c1e365a58", - "public": "03d5c5ca22c5121836a3a601a87d763fe3055814d9d8a078b391756ed871025ace" + "address": "2ipWusQvA7UN552H7e1zY8pXb5h7z9cvwaj", + "secret": "e0842dc4b26eb0d3f04ac0aa9abe86fd1bfa7202789543ff34fb08078457c419", + "public": "0252193f968bee3c45adb88c4881c0770b49440782a1ebc5095ef6c1453a3a039d" }, { - "address": "2KYX9vrUd8jyQKrGeMCE1i9f2ias6cU5ybZ", - "secret": "8bd583638e0b74ef3cae3f446f3d8afbc6896d7848f7419edcc7d4eceb369d62", - "public": "02e8115a7c4c87aae3bf0834e76acee70ae16d18a4f97c7a95a8407ed6cfdbe12f" + "address": "f1xfUvKjRCeBzvwdfCu399cebpX1vDFESV", + "secret": "f7b7138be61f2785e5d7dc9c4e987c1dabb7913c5c675d68cf0dbf6ea3511238", + "public": "0313f2f2a40cff2672943935a0b529624bd8be43d65de1eb076e983b2f0b60d36e" }, { - "address": "2BYZfYsaMh8X7uo8Ro44DWmGL6BewK7Vsin", - "secret": "2da93053c0b63e0edbccf3a74a5bfc2ce25b16eac2f058e9db1b9089965f3929", - "public": "03907fe3ab171e641e7a16049239a0fa8e6cd72edb8914c0d3c87489b4f2c21e40" + "address": "o3YhEi1J9QoEkk48YwCdhdSPTZVX3FJDGQ", + "secret": "2acfe55aaeccf96199403b04f37e350244b04875946bbacefc321f5514de675c", + "public": "02eded9af107b76a0339242ac409f01664979a8edf182760c393a2a67e9f78ed40" }, { - "address": "YbgE6xVWNq7NvhZvmagefmcPCeNPNorbF8", - "secret": "89b97a16e8647f1c2ee37fcf2d3641fac171f890f7b24f799b202b06b29e7c08", - "public": "0259a5046ddbdf5ca640755033428a9b5e1d85c8b87b70ec01f36020a7cc88b25d" + "address": "49SvQFsbWdBB5y7ijBYFcDJL59Aj5NckFY", + "secret": "766221b7013f73b64fa328c2633456eb66fbc9dab7dabb17d3a87d1ed1fb1517", + "public": "03268b627d2d62a7541c7a376738a170c897316d93a07cfb3890414f010fb00db2" }, { - "address": "LuuZ4VvHRZDH8vDb7t35a7PdQW1mwjudqu", - "secret": "77e65cfb0bcf4922193ea5ffbb3d05c6db701181c9d923942f56de6b2e6381bf", - "public": "023ca94c803cd0ee925c026e134f5a275aa656f09dcca4704cd3ee5f9a3b5b907f" + "address": "joV4SQMdpCUDUZftsKLd7NNLshkHxeysLY", + "secret": "83fd7eaa0dfd5f7e7897994d162de93d91b09aff9b9b685133c3b3f372e00ced", + "public": "02afb8fbb2f77e29f3751a5e3c9be92b4a42e05955c7b58d5c09d878c233571460" }, { - "address": "2S6u7AdMkEAoxrCnNuaB5KjRDJZ2Bvj7y3U", - "secret": "b53cb6df2479ad5da3ed5c7fda5ffe06fccd2ced03af5acbe56641fc095c3938", - "public": "03b58cd84cf7bc55c4305b51500925fafa9770bc9f3aeb8b527cd92e19e9da7dab" + "address": "SmSro39dpb6RCTSd3xAVpQcXtauUk2zzL4", + "secret": "88c46c1b53ce49abc62814e5564496b3b0c1c3a51dad775191f8ddeec522f30f", + "public": "03cf3e3cb197c3746187b8a0f3550c8389e2a00af834dfcb81ef3eeb21c5143dd7" }, { - "address": "dYaf9imAYjqggDbqjReC9obv8jU2PQHZ7L", - "secret": "5489eb15511a1f03727b946418324df0133d37c70f0a11f58f28c983046caf3b", - "public": "0297b497eab2e3415ac28f418bae48a330e4e743e387b571218389b03dfff9fa74" + "address": "QQwrjn5k3khUgvHjPst6GVHn6F2AwNYs1p", + "secret": "c82e491f70f9bbadc4bc518cc6d74eb9149b1a10e67529874dc9292339277d74", + "public": "027ab1776783179393527326b64836d737832cc5b9909cfd1219024e1e0fd0fdc3" }, { - "address": "fYivg7JNbWn6hc5YFtEPDcz5mb744T5Fap", - "secret": "b5f01003fbff1c1046fec0390a55f9bb3c1b01a5e9b2ecbf20ba6b96df6f2ffe", - "public": "0249c0c6fa5a8c1782b68d49a139b878de5ab18a288589685441830c13ab8ec265" + "address": "JAgmiif855wDZgaC7U5wYg9dyuWi5nxPHr", + "secret": "25830dd91c4037776b390ee7f598aa8fe65847169437dd925e240883b1947b8d", + "public": "02b9f656a6ac504eac5f22cab1472e4760fd5064589ea36492dc6d7ba2753ee5e0" }, { - "address": "225UXdZ2Ex2sPKjsjyQts2MrzoSVQGrWKQV", - "secret": "8aa0d0777b7a365eb68ceeb44318ba22b4df738eae1c7aa2a2dfbfdf6a5fac0e", - "public": "025c8d5546b4d206284d3812a3fb92a4bdfbe41e91a3009ca108c27f7ade8a6004" + "address": "26MHnfJWUL4uNee9LjdAGLGa7HC4EpLH7S", + "secret": "e70d55437795dda9fae07616b2eddc1f3ea6f3ab0f971e5f7091a225caf2fd88", + "public": "03440d9fd95ada18ac1076623f92f9e2fd7d2c4493c504bfb5faa2250aa7d50cdb" }, { - "address": "S3YN3mVdcai7pueScgmbu5mYmrFHMMLUBR", - "secret": "4d0c3b6234d5fd3aa2cb1bcceeaae1a8f3770c635ab8279b389cd2e5a05301b2", - "public": "03fe21c53db6bb52b786c73803a344f0f7f5bfc1ddf24a9effb11e7653fef18de2" + "address": "k4jTLy6nhFhpxXKogNAcbbhXeKYJXKqgA1", + "secret": "fb3c20a167fa642a78d55347fa54d9e1d7e2a3a0f0b43534faa6d846b84516c8", + "public": "026648469e9a9f18ec527885fe8f2665acffa546979007758fe6ce2892f0a26e65" }, { - "address": "8QMZQ4cXW92vbofqpgVjSroUMmZa1uzesE", - "secret": "4618b66c36aa46d3bfa515cafcc729ee503756ca778294205a41b1919b5536b9", - "public": "02af32cbac29d41be67611971007541df79af616ce1f768918db09275aa25fe734" + "address": "gMDDYLmdNigohzJbpH4pkZEVHGzdpJC9KR", + "secret": "b06b09ff98110ed0e7b76ca84288d7a0a73693d0d1058310b46922873b276252", + "public": "0298bcde4659aafc2d6f55b394de41107c400ea786460e01595c1b0ce568d0f928" }, { - "address": "aJCGvgzsRhDvrzn2nSSTMNaPyVffFPQaDM", - "secret": "361c66a370c6397e6696cd8d7d19bd20126f59c6e273d138758f465252d8553d", - "public": "02403c11dcca76aaf93525ac33ce2503ec45468ff8f70246c5e941194904f7f8ee" + "address": "2QXKE1KgQvHLfrUuP7pK1xDo8BHsNNR5wu1", + "secret": "b476c0ede7587bb5d76532c984fa5a4d810aa4341990837ebdb70e9e4d4c2099", + "public": "0378972efc8ed0aff8fe5a9b530bd70b697150c45799567bb21fc24542802157e9" }, { - "address": "2ecAKDuN3JzEraMTWrc61MzgRhEE1bYWA42", - "secret": "2decf5fdd6a913491d306f2bdc231792bf5e656b5d6939c89b4397aed82f836f", - "public": "02cb3bfa1f5678b3f6a49a40c761ea968ba1cd231d3395d2c3a98458ce68d1f95d" + "address": "zRH1vs7WRARth893W7ZXL7dkp24JJEHLfm", + "secret": "137303696ccf1fe9c4a3167dcfdab890f10fd46861634c17b75203d1ed181bcb", + "public": "03b241d494fff26c5fc1a8f9c509284151794696e4bd5736184e42bda7a2d1ceb5" }, { - "address": "2Lx56Sk34796ysZRHv6wka5HfGPdC6efFz2", - "secret": "c584ae60ff8fe8b7ea09f96aba60189bf38290ede4638ae2da063c4707ea6ab9", - "public": "02fee60dc81a072e3d7d81ce11184f91c44f443d9f78c433272dda55beda638bcf" + "address": "2bgEuW1vkDRfSvzVaHrsN2V7mahtMsopgJB", + "secret": "7584cf68badbf5cf89950fa55e92d38ad678b320a2dd87baac186ed272e3fc73", + "public": "033697a7ff566de076c1f62e21964078876ff0bf00cb52c6b0ec28885a5703b4c6" }, { - "address": "ZYSCrtG21ErWXRJT9aGsFbU49MZoruzwg8", - "secret": "c0ec98bfcc9845a1f5707c4998e01385e53eec893438d62f575307e21637fc50", - "public": "03f4f94a9f3ab83ccea2cba716c9817bdab4d771b93febc8d1b425514b0de39527" + "address": "S3M5uARXPFWon4dVxJbFt9oL5cPZDLGEzW", + "secret": "34b07e4545dc8d5681058630b94d16b76e302020a295fa72f1f3ea5f9e555ec2", + "public": "021f506a48039b0b9daf3857207c85213a2e6e9a86b9e7f19174835c0a7fc7ff3b" }, { - "address": "7gnx4caJf9V6ad1pAxeX4DTDMzN5abkbeo", - "secret": "d66a662893916c96e586de6549d7278264f72226b04f87681d3868e817fd4f9d", - "public": "03cd0a6ab54367803f7ca08a537290f539a54593f1c155aa47f3920127f252d999" + "address": "29LsJE9Rp9EfDjMCoFSwhsJPy1BvB9v7iaY", + "secret": "dc9574c4593e48481e7ed0e4178289f238f63cbeaf659d9d7d9e67a919b60ddb", + "public": "022922ad2cb0d3f22f0d7c8b990db9b1c98bbbdc5c172598da5c9b0cef6d8f3537" }, { - "address": "mNQQMSXpXyYzS191U8UnCR9wJr1CRg8vPz", - "secret": "e5d82146ccc44ffec9b2a7d707860671782d980f1295fed503f2b10d321c8c8e", - "public": "0268c8baf50adb636cd948c9e08fd91019ce2396dbb930dfb50189e3814cbf084d" + "address": "29gtaNw6Sh6Eza9CLNTR6AsLYP2s5RqxBcZ", + "secret": "a76b65ce9b49e5ecd1952d117713097b3c8610bd6a024190fbee18e516e87d86", + "public": "03428a59615bb06d26ac224215f79b47b3b90aa677db112a2a80d8a9848722ec25" }, { - "address": "2g7mYREgC79XPHX4Ufu9HM7ND3E1EMu7rCN", - "secret": "88885b47fbfcc7dffaf6894dd7460e3002f5391d87ce70e00400b9f81c470fda", - "public": "025d1fe09e322645c7f719c5bb8ee90efb92e4f45794706790d28f8282b8155f67" + "address": "21iG54TP9jygdxhcdceUrk2Szvg3PRHteTc", + "secret": "67c4ef1f760b5953ebb32055fd76d8c2bc2415c72ef8bfe1a8eb40647b199d7b", + "public": "0397a70380961422ea32c25a34b0cec7cc58fe7f62f9501177ece0b6acadc86c59" }, { - "address": "2Mevuobwuf96RicmDNyuJt6UP2cGJ8mMFs", - "secret": "c3ce10fe5a25819436ca347eb3e6e2870c7188d1a3dea48740f1a91e7e89ffcf", - "public": "03f2980b367323da87429135fd39e70f598231886a3c1ab2ce4692e8b94c15adfe" + "address": "XEzXQfHKhQuMtgCHRRNWYZ7VTNCJUCy5Dr", + "secret": "8b71c09585dcede6d668bf0020787ac50c9556714321c288b4e0eb8302864386", + "public": "03bbb9313b566fa2e5bb153af95992adb39d1f3a8f77ebe6d36cf1d9e874dec0fe" }, { - "address": "2e3UtzuycYC95uEdfF88WdNrxQDoXpnsPTp", - "secret": "ecdca6f36fcb5d3df38cf0dd0206d54384f967d8d2891afe4d8fd76eeca772d3", - "public": "024c2a107b5eeffbdbc83972b58bdd9ee35ecbee4e7b770b478f13c429156eff18" + "address": "8safALsBasgBw5U52rryWk5vWa3XWmQfks", + "secret": "ebb458a1777415e80574e94ba3fd381ecefd7871dd3f8e231ac97948d9d6af2e", + "public": "027841bd654f450121a3730982808e7526365f4ead99ed226cde64fbf460c9ef52" }, { - "address": "2gwS9iwYrzbmvtakw2H4FT3m4YSHFHGy8NM", - "secret": "d787756b8dcb76932ef211c5e4fcc2b05d092a1bdc5b48a600734f1acd085f4b", - "public": "02ac87becaa0d23aad6b6dc60831b05207be320afabe6529bf816bc35af256f6f4" + "address": "o5j27rParabrSJPUGGC26yX6pBqqNcDi7", + "secret": "5091e3ea0d50a88d12c2f331717f87b5289f26f12aab3145c017e59823617b9b", + "public": "024a2c3b28276e59db236ac1458c165a30f6e8fa8af411e663aa815d2f0e0f5a1e" }, { - "address": "CQfDhyaQ93hYN4m3qSVqoYvpKzhoSkD9t6", - "secret": "62b639ef0905f4d50619b0e30b85a6d7de9df8e33635a6096154e7cb24b3cd8d", - "public": "036792097dc5fb9a87dad64f5662eb862a65b99f11b3bda39a12b1381b1607e5b4" + "address": "26XbTkFX3sXem69GaSBHezQkmRzGJLJsdio", + "secret": "dbad683919d198390157accf51d1c246fa6282d0ab494aa418aeae9152219445", + "public": "03e4009cac3088edb22bfea5ad639016b64b36debb1f12475cf036c37ad4e5e69f" }, { - "address": "252Fy6sCJfJNs7mYrDoq3THbebQRzY7GJ2c", - "secret": "f65a5924db1c3cdafadf3008ee6304298f9e7f1a5e85f4bc28da18b08d095f80", - "public": "03ee4f3bdd3657328f8cfbaf8d15b1b5cfb999501845afe47ac327591672f2f40e" + "address": "yuFUDW1RSa226gQKLG7d8GcCFxFVaSb3Zk", + "secret": "d2b5f0954912e055d0dd56cc3e921147c62942cb665b4d52e60530edb32d72d3", + "public": "03d12828f548687480d31b41dcc6c4e90b6abce46ddec55586a6e8acb7727157d4" }, { - "address": "26VBKxqjer4SF9EAJZ752ynVYgxqEryK3Dj", - "secret": "c9cdd999325f69a651e88b2bad4645d7bcbdb32f99037dc6b8db4328494c6d56", - "public": "03a9606346013d780f59cf6f0f53cec11ebf31f22373981b0936403b57f8a3785b" + "address": "2kmy4ccRfRCDcaFJw2G5WwikcoFCxTyFmTM", + "secret": "4381f86b3987baf546fd72efa280b8dc6b0819fb463d8ae5d591ff5061b1c12e", + "public": "021b20bd44372c14999ddb5f777d7d16bb7c2df0123b210e1a8c7e56701accc848" }, { - "address": "2cKoutVfnq6A17qonBwQ3tuSdaXLLQ9mGPi", - "secret": "268c58ada4146e512c1205946211bb442d053a9a71ff03e097309390bbbe9e22", - "public": "03f7f2572bf77fc08decd04bcaf4bf11309e92c74027dfcd18fcf39889038ab4dd" + "address": "2K5dB6rem74XYuajLLhmxk1Ym5ktyF2rHK6", + "secret": "d6aeac3755497bac024965298fa8e8c02766122c5e99af88091751a051a1a84f", + "public": "0243b5a4cb7d2a422e2ab703520fcafcad3a62c071a1e18e827cbdd16b982af1c7" }, { - "address": "SJMSoLs7y2xz7JtzNwfqdydqwiDHFxofL", - "secret": "e41ee75c4415e7c1227a81fdf5a1fd9856012060ac1b12cee3728c2580d2d4c6", - "public": "03d9af62411eb4195161e3cf6e5cf4b30718bc1478756b67a8dad276fe5f249357" + "address": "DS89RK7MsmZErHe4vc4a3zqp7BCatZYYh1", + "secret": "198614c6bac55b6f1ff6561051c70cf4aea344587f637e526de39e9179d3a4da", + "public": "02c92b2f731386e94d4a43f965cc443c19e5da1b7915084ab4888cb8348944194d" }, { - "address": "2ApDiaAeRdCzXqyMN6LqC2xJGGgb3UesN33", - "secret": "3c3c0d41800075641445a97b6b0b00385d357f21c38851403ff12bc2427aa354", - "public": "038c25b93d27d59db0526c1043965eaecc0cbf4d57adf9e04a7f266a799e4c992b" + "address": "ccuSWwS7Hvw7UdQgNaZGqeAXH4v3kCsoJi", + "secret": "b1e8829213ff5231968cf5e7b9ff13cf83d945a7de3eb903eee46d857903f544", + "public": "0334c602e039256862c040ff3200bfd591fe65c5f10e0ec6fa8b173a03ab4b20c1" }, { - "address": "n5yyzZtqjNWiiaWwrenNKhYhcURTqdYvbK", - "secret": "0d0dc8362262732679417286c2b6c2f59af0fd402308105b68d320ffffd34307", - "public": "03c193b13c7f741121552db0fd17516cc37391ddb69d4f0425dd5fb13150e19237" + "address": "QxgofLYmG7Cyyqg9PPbcYWUE4Jf5r6JMmK", + "secret": "9e617dceff8339cd34094b9ff8cf3ad9f66c702528b58391e94f7c9b775a2313", + "public": "02913bac8d16a9df9c8a94507a2d93d21d7bbeb5733e3f16a1a619c8d4649f610f" }, { - "address": "iucwh9dRNAvZ6rdyccQfZHa7j7P7FgAg9h", - "secret": "241c762eea9d8f23f7a2889caf30dcb3b60af2a7a2c7ae42ef85b4efe797aedc", - "public": "0378c61c745397e8d0b72ded1f5f0af212baa93ec7bcc6e0ae900fed40abf27276" + "address": "24BL6QMtEsank54gFDG6JfGbKkzcfmbYHvH", + "secret": "64dbde8e8125fc928c4805122ed1def7a968ac458d949d50e77b02a9b72ff16a", + "public": "029a30417b752a63570caf8b4caf3bbc9df6ace56320121f59d9f3f73ee5c66419" }, { - "address": "ufQpsMvtHdVskeSrEV7U2GgwNi28iRXJ8j", - "secret": "cbb8382549a6793a970a6adbce7d673a26f53abed079f040c4b0ef052790ad5b", - "public": "0268299a9e05dc04db3ae4b554979d0d27cc321311835d55dd4af1b1fb3a69effe" + "address": "iNCaYPUY7iFwuNdKkBdF2QRbuJG2Z89T5T", + "secret": "4532262c82d391663f96fb922d3eee86179deab0395f32e658c243dfc4b259f6", + "public": "03e9f19634daa5aea15533f097d2e65fee7e427a26f690530f8bdf8592e08563f8" }, { - "address": "2jYefcFnHuv2dQGsZLLVB5v35K3XZHDfjUr", - "secret": "97af9febc8ccc200c696243c62299b88a096ab48e9282d80ab3b04f78acc6540", - "public": "032701c8d7f8069e9920e5659b48f5a0c936fae4a1cf71a8183be2df8c7c5b4e97" + "address": "B5PrWYoMX4X6xQy6vavi6aSB7niTTxBEUo", + "secret": "e43f066ecb51d8b88e92ec6bdc39b62482ef349353eea9daa6ba866f336d12dc", + "public": "03e36925d3826236e41efb6fa4c7efea1c84979cdcbb299707028fe8deb3344140" }, { - "address": "djcyQqVVSzkBPyVCon2pQ2Y7Ayj72gWbKT", - "secret": "898607a6c947ed687116c476247ee432cc548afb7129a30807126e133a60fa79", - "public": "03b3ed3445343b1c1452c81fe3af8e0fbd3806f673317a5a70e947d9c976730d7a" + "address": "huYwnnc82FHNNdF6MomXUGE2aFu4Apo1eB", + "secret": "e835d2a47abf7865afaf03d7399e038ade3c79ed40ded121b3879010ea437ada", + "public": "0397c04c78b5f17306d04bdb8aa986808e2aa9f736376cba5246bc3c766a552f29" }, { - "address": "21V7YvwxNYcQ2vtGuMoK1TyEnEFkz4j8N7w", - "secret": "493c42afc9bc346f9526f75b3226c5fde4cab806113ac20216c97346e3dd37ff", - "public": "03dc14c3af1477b99629faa6014460e03f746e75599004fc3799ffe93b304367c8" + "address": "2Uidx5h6vU5ijGsigtrhtCymmXgkdScXu2A", + "secret": "9c97a07295238b5e968fb6d256efc0298b2d86ad339f41a22aa99208e441462f", + "public": "0366fa3afaa882fe120c5461c7831818ad771eb4454ac1833be66e4409d68c1d5c" }, { - "address": "Tte6PdgRPR1KLKe8xBo2pS6798TEGCpVMo", - "secret": "e2c0b660362ffebaafa1607b4959dd3410489d439d56594fcf5443cd50aa200d", - "public": "02bb3087ba226ac1646136f9e6ae315be2628911547481ae33646bed718af96394" + "address": "sssGhHuMTELS4afckMa5xCfFwUdoTpQogR", + "secret": "b682db37d4e64798e7ffba455ecef95ee7134582f7ad72a4f077a4612dc71eff", + "public": "036b3043af63338f60227ecd8b810e122f6efae22fd83e579b7cfa75dffaca7638" }, { - "address": "W4UZoyaHfMAZ5BF8jJMmiJS3jBySduuEsS", - "secret": "40072daee82c46f804a0a47849bf410085668e0d2624b9048f1466a9ad646560", - "public": "020ba37663a0f5269f7b4da5e524ee51132f93f7b3ae2c5df170b59cd33f26b8b5" + "address": "23FmY9Rvb9WWDZnQegW9HcwPcSSWXJYy9rW", + "secret": "92bbd9023b9bd5a1871b23a4ec30144b4a9403a27aacd207df2072096fc74a92", + "public": "02530c3e0158aeb99422c5c23114e494ccefbc6581b27e46b9c1163fe71973fbac" }, { - "address": "uTYV9dgU62sBckhTPnMThvKd5zgkumHYmS", - "secret": "6893ae5050c7d0aba328a8c401d439e7c5a2e08f120047e5a566b5c98d306033", - "public": "0342f2b5003bb01c210305d8dbb7f168030889f3ddec8a54807039f7fe2e512eab" + "address": "fqdRNStjfsNdmpK3DQK9WVTtSs2mph8Kwt", + "secret": "66fb2e78682b560c4ae978c5ab294c8d7f6d710cdd5914b4d613aebd89d3572f", + "public": "022d6a236600e6672d9e4f7f10bde1b42f2950fcf21248c8f6488b95303539a3cc" }, { - "address": "yVjjUSNx7U4fWwAyamkYbcB2dT1v4jVhDa", - "secret": "c3620f1a85880c45711ebbcf454a4239aee70a3c5ea3f55d20b1b638a9f285e5", - "public": "0287c969632337aba9676d5b26e7c774d7b2935c5e98579bcb61af1227131fbe8b" + "address": "ZJiG2CGoqtSx2GkuxFvoToLdcnVHHzDtHi", + "secret": "6d95dac69ac754af9e1afae5ca34aabdf9b810a108804c58723248fcf4f05466", + "public": "02092f669a4858e627bb5a371f629aa9de2db91e1ad7ba633d027b6354af8b6811" }, { - "address": "2gXbtgNEeGgj1FGPDMytPpMAK4eHqr8SHfP", - "secret": "df11f4783b0a86a6dd3ee36ed2425d0cc3becc7c12aa6259ca7f8ec1cd9b15c6", - "public": "038c0f46cdddc2676c01428b870c93dac4a6ebe102fdc935b635687bbdd9bcbd25" + "address": "stC7w5uT6NxykyuDTr8wa5yXhHL1RQHHHC", + "secret": "61073b41891fb56c71e5f7483e63807b6912763019630267c19ea9d9cfc93d84", + "public": "035c445fb99914723945b2c1e1b54b7ac35bed350284b0d93e5d492a41cc87d86d" }, { - "address": "2KGcbdoZzuiwrwp5SQSTw4pNNTn1s3KQL3e", - "secret": "d783dc9b734eb73863a50e1cb695ca05c70f328794115929eda8284532069305", - "public": "02c4c450e674908985973458feefba06e829a36b92c0272e05b097602ebe3082e4" + "address": "BpWeZBhPNCYMpzBiKMcUNaR8qX4kdxdy3E", + "secret": "5ab3d7484566f08ff1be3c9c9dc74d001c5531fb5ecdf98f87bf4e36b6154153", + "public": "0229270ef80ce2340bdfffa6e4809fc43f9a033037f63a865acc69c12773b64054" }, { - "address": "drGpgVd9ZNsRkaNHDeyuHNLyvjy2gwuRA4", - "secret": "33be5d5c60d5df62f514713ce2eb8db0f84401b7a9cf21dabd0945f156e8e57b", - "public": "03765ead405d0533d84137a49769021f2c55959a09db5d52effbcaa81ec67d9591" + "address": "2SMsFtscMGLu9Sx87HBebRG8naW4iLA2cZz", + "secret": "1e528bd5632186db07cdef8449c1eedfae575ac4c56f0bf9440b4e6be28ccb27", + "public": "031b597d85b54343593060588e1c4d820a0295ca573cfb88b066be174b69a93a69" }, { - "address": "se8R1bRxr5LLrecRsAU4WmnbrJ1uJpdQ6T", - "secret": "6f8788025e80c5409f7a7337011bd1eb575fbeaef3a9c75475c4c8da3a5d4330", - "public": "038d1260998058894d41cce0d5b10bf8cf29c42db7ecbdf45a063d4380d43aaa8a" + "address": "bnDptZijEK6av5LjjaywjhgkqyU3xRyadj", + "secret": "abaad2674b08b8869a3c66dd86a6197c3f0505cf07b1f20a8f9ae934ba2dbd1b", + "public": "027e4a5d95c683171da70094a3a12c2bdf9012745d509d1ee732e58c0045035a9a" }, { - "address": "dTnqK1n5umSTQf7rPPDjLJ4mPXQRjpVJMy", - "secret": "700635d2449e6d3dfa33ca37363faae69cc10a7741621e0fc3312736468c86bf", - "public": "02167e0c60543f5ec1c92333a6a6e1122c992553b143abfc63ce751b0a41a496ff" + "address": "wwW42DUNggV9cmupj1Qf6uHU5RmipL1dSC", + "secret": "1b9a75bdcaf6b9b4d4f4994233126f28d63f56ed11d7067a69fabf946b313456", + "public": "02a842939d4a77bfcce9994708751b564ca29233672149b4d144da27586c98ecde" }, { - "address": "2KbNtU6nmgJK2PrvSYzAQMTAuB9ZkGc5inp", - "secret": "c6c1b73e2f97d4504c278c872642af3b1990f716429730d1aba4b1c244e6f9d0", - "public": "0324a184847e95a7feab6652fd90925ce408495814ae973a125c361e4bb2fee568" + "address": "BnRkAyySwtJ3RU1AcqLfNBFUwi1wp4SoLP", + "secret": "9d3cbe92944aba5c8c0649161a398d3f8f458c269d760e9b625acce3a476ed8d", + "public": "025e1cd036ecbdbfb9123ff839f007ec0feb3cc66d1a82965ad373508079669031" }, { - "address": "2AgHhnu4FvE7UHagmQWs5q6Fj37PBqUthj8", - "secret": "2cde6bd80b96ceb7438452e69d7acb32a28392dc2b78960b47471798eba1e150", - "public": "02f68ed3d7ef96bdee5c9118434373e6b143e63ad009db9a3945a63304e9f37f8a" + "address": "jdgX9aogovnV3BLVg43MoRmSBXUKAaKwaT", + "secret": "3291f3e77bcc03cb913fa0aaec62c75f43311037ee80c80df8d162969a8756ce", + "public": "02551abd2d1ba1bbd28d2e6016bc5e41a56d153313c762797c7b8749643134c4f1" }, { - "address": "qpKMPB8YrZPh7Ub6nszLaWohhruEzAcqBP", - "secret": "5374c6bcd69b4b253c17ce9d82fa4a755c6678665198c24032c5dd5dcd5819ac", - "public": "02a095ef9b082863f4b4ac0877225be02b19ce29363af4034ce9ba1160555c5bc6" + "address": "ZG3RtZogdoEj2gUGkgZgyqD36EJnGaBKFL", + "secret": "3dc50dea1948cac53baa20453eb4e457c545e7b6d07c07eab23952188bbe041d", + "public": "03a100b0493995563b865c1a58612843e9120dc6b0577f95b04e5839f0260d56c6" }, { - "address": "xcxqtz63Jcq8TiE5GBX4KEHqc8zEFGPXLE", - "secret": "c4644e558b11c0a3d84c6b93259fce59252d99a7ac183b28cfd25a00f8150101", - "public": "0263e66cbf29c7987561c9d0096438397d170b8e25fa5982a607553441f5378ff4" + "address": "HvNoZMcknBtSHMGmkNAdviAqmiynJbkbEg", + "secret": "6ba1222dddac6d0a5bf8a3539d01e4117e69b559287b0bf56afdd6055d927bc1", + "public": "035559216c7f0bfdd24b03208e5d77c82dffb7108570589b4c6e9172e982c9ca03" }, { - "address": "2bmJfenxhPUqEnjP6AEhemtAMHbdLSXjrTf", - "secret": "9ca5f5add9da53b1b0d066c941e6af41fef70b7ba60d09fc6d618c3df801fb5f", - "public": "028a4c2b341c9fd92f6429e1a9f04d26fa38a88a52a9fe7e99a701ec3dcf06e5f8" + "address": "2R94sJXypsCnnhWauFb8XKtJrLfNJ6Jki7G", + "secret": "4c8809559e07f860b56132a1cb6ab660db9bd15bee02991c93dcfcd9c453b7a4", + "public": "023c9af631584445b2a6c7c22353478db1ca9d546b7af5c7384e038dc6dc38085e" }, { - "address": "RQB4Gg6WNZHRSFwJK2BAUducFQDfVG73is", - "secret": "48e95f84d0abc55966e943b333e4c07eb92c0fb03f547e6a9545b876fe7d641d", - "public": "03e2fc4dce1cbd582737fd4931099b98f45d3c82b8fe42a883cb891e26dcb08e6c" + "address": "Bf3doov6qd9M9iTzw6ppuNSiv5FnsBnPFj", + "secret": "f513f76c64ddde08ddbbf2a38a39f864218d65ae23bf457a790ce5e1c5b37893", + "public": "0304b8ecf1a3aac1eaa6b67032047848389aa3feccdcc3cc6dd5ea661c85ee5f35" }, { - "address": "2WZ9YQbrW1FN55u61kRQq3chKsQ8D5zSaiS", - "secret": "a1d7120cac9b206cf1c523c323526c500c53216695557586c5a02181919a031f", - "public": "020717f35c903981a72be3a4914c6be36b7cf8ed91594090314bb6821efffeebd7" + "address": "e6297wnTqHemj3UjUsHEcfkWgoYLY34ESP", + "secret": "9d69dc4a3bec0c7c706356c6ecd1c7ac5162dca35a6aae6c9ed8df86885aae50", + "public": "0305c56afe0588c191b0dc1b0ce37df4dc8e71cf6e9e55fe68c18c094ed9dcbb5a" }, { - "address": "qXduz6ug9a5MNjg3c7yLF2XHw99RwJTZNU", - "secret": "35b0fdea995fa88d1498e19a01224941af965f5313d01186b6b18bb3c25f7ac1", - "public": "02b8541e634532d3b214127665b223bb52a3bdeaa1eda650db728c78d2a8436c07" + "address": "sFwqVVHrN7KHN41F8jU9g7kwYpAJkQ2YXf", + "secret": "2fc60a5c19c707445faf08a76ef89f1d4d8ce0e6ab883711ba859851ceef19a1", + "public": "023e2ee53efc59e8516a65c36f5655d57b67ecf64afa4362235568d6fbdb9aa872" }, { - "address": "2fHcCwWFjX6aKq7uVk2cL5ZeuiSUAGFUxXG", - "secret": "5c7559081fef141ae73fbee256770fe1909d11314b6e0f6783da6ae7ef63c23e", - "public": "03c17f088dc2436ae5955c3d15923433e3bedb1608aaf592c1f8254703e0461f8e" + "address": "wTttDcbFvgPuniukJhxKV73XKxTGjLt7vA", + "secret": "545c0b9625e5b9c9929e267c4f10379447b7c5ee9fda6f6f6b3038ccd563266b", + "public": "0357953cc18907b20e5516dfe2fac4b35c33a778559fd21f2a7266defcc5b0b8c8" }, { - "address": "2cc1me3ZfNs6Rut3453xUqYVzxDze8GFJPd", - "secret": "c612a9852bc6331873537f13f1631a39b6a3d7554851eb91a6faa62df7c7a8e6", - "public": "02fe379b9e4fe972a830c4b101b11a0cee612849b3334f71987bdd4776d4eb0104" + "address": "2SCgJ7nLb3To7LihhrKWfZLNoDr88k4pcEE", + "secret": "8f37ec0ae63e299a6ec5db7fe241dc30acc8bcb1f629d66326c7aa79f5263d6a", + "public": "03eba8479f757c91703601cafbb601db428be8f9acd9c6d2c05440fd42d87fbf2f" }, { - "address": "2YXvgWRDccMMg3MG7fR18vWzGgk3frKV1Sy", - "secret": "9c84d62a1b3a0c392c6961079c1892bcc32045aac6ea6bcb4e46dee274c69b9d", - "public": "0397a09c0152afad15f42522fb7dc43c2017f55cf80c78db1b7faacd15a825b535" + "address": "265SGFsQ5a65k16Mifui5R1GvtuDpnuN49Q", + "secret": "c98ec995d808922549bcbc5217c826bd3e0369754dd09396bbda8c5a7be6b1d2", + "public": "02cd1a00f584cab9c9fcddbc21ee8ce269d055ce230085a6318922335c00f0fabd" }, { - "address": "h4memSN4A8fnD7PcXwwG7PmTH5UoKHSTtf", - "secret": "0f30055dc0d22acf40c83f2fc3c6b94098f192f44de35286027df86370f19a27", - "public": "03f06cd3cda1db1cd7494a228b3d01b39ae79207621ffec0f2e6f9d9bd033b2182" + "address": "WJcJburNm8edTpbPVMNqnTuWFWWGRFUhTL", + "secret": "3d8e9968716ef2e8ecf5c260a78af235a76be4c35c33b7ef44c9612ad061252b", + "public": "03aeb0564afd126b603a47116caa9a6a9bdaae72f6b16b57c278c8850e77669e63" }, { - "address": "pahk2pPKXZoc4kZZrePoiRctvrJarpW6WV", - "secret": "b040d5f407c957ab952043fb899b46842d5e7ef7d96bcc10351a1df248fbdd68", - "public": "03ed3b5a4d090e416caee4d54568a6b0e3f6c9829b4c4e8004f2fbe64c21993642" + "address": "2ZVfdVcExE27kEsqXTHRvH4CWhtrgerytru", + "secret": "017a418ec986559a235f235e40dc1a4847c6ab6c8379769ca1e3f53263608a1e", + "public": "03093f374e5184893941460723c082e6c03edb07a24481011dc4913045e1988f3c" }, { - "address": "PxujfzhP3Xp46hbDP5keK7cwtUPKwxiT6u", - "secret": "0fb6886256d7df82322b28236772bc14ca416d238af2aa59b714704f0a56c39b", - "public": "0226e16544a859b002964774544b11904bd27189b8341b356f98d479d0fb531313" + "address": "rrzosBqV6qPrLcXmUi38E4JuT5HK9p5EZ2", + "secret": "2be9b2d68a22435750341c07bfca519a0282f6b8e8a89504cf327fc0361d1794", + "public": "027ce626a4c6ed8ec8442d196c2779eefd48a1dbf14136cb4a2f1fe203d1a5488d" }, { - "address": "9mydnH75ZWEX3a9McpgPpc9mcLdmGFD1hp", - "secret": "f7109e52132fc86dbdef1c022c83bc6c0e24b2af5b7a1018f82441e1de957a93", - "public": "02672fc7e3dddc0b4b6f9a195c11f0c8ca8b929cd728128b77d7d97f78e87c7e66" + "address": "CAh4fftzSytRiuoD1mhKPr2odx1we74S9M", + "secret": "7d86a42ac216a345c761f28412c606c3ddc518021c44ed5d9316469260eceb77", + "public": "02369a7e1b3527c29616f6b9cd7a9264ebe7c4fca5cec9249ec9c2fbdbaa79fca4" }, { - "address": "2DXZ6pN4FbLNpNUyxv44KJkRD7UGn778WLS", - "secret": "abdaa18212b164d37bbfd5542d63994cfa7e72b384266b0378cda790aebb9163", - "public": "03f4959f8d094f29a7ff5df72f4535d730fa0648463dc2a75911a2ec33f54b8ab4" + "address": "hT9MrhFKQ3st4LaCSpiLYMvHhKDjHsWhdM", + "secret": "88e7e0a3b6709d657b686c3b44c7c94560f4287752206a80c819d18672042bbb", + "public": "02b1fe72058c93ef78e3a0d766a577d0483b34fb8e1310ebdfef3072373ee380d6" }, { - "address": "2aKf2R9xMSReUqDCurV6mJedmZxdtJopqJS", - "secret": "d3eed1b3612a0d24c5c050f4618b870d040d9c18073de4a23cdcb7e843b26d3b", - "public": "03dc498008e7c4343f45ea8c7968f421d0b3bc40ed615f923abb447a557dc0f6dc" + "address": "24U2xuWF4Sy7H54J84cTwMe19tZpJGFpYv6", + "secret": "f66c96e161c59ff504434ef31cba28cc01bae76f9782c0ddff2b7a2b3483b44c", + "public": "0369d6be394fe7eabb5340fb2703efb82b07d92fafaf46a66716ef3e158abba759" }, { - "address": "LnGGTJeocBDGM6FcQRzky7PKo8nCuwzRXL", - "secret": "757a543fa3617eed3c8a6fa02d4bf88d847e42266f2ce0c2689c76cb32a470dc", - "public": "02ed2dea79ea11ddf3b09e631e6a3774f8e5900db3f5dc591c3854ec95a9e388d8" + "address": "2GdfV6jEBBCq39A1TAuReBR6MGu68NfAzQv", + "secret": "ed97ecfd2dcffc1bf79853d1b659720afa9334b3e94650a4a7561580e97699c4", + "public": "02abb05b3015f33f2c30230978b680f1e8e9ea00d1ee067521cb54ec3a5320a712" }, { - "address": "AmEaYtZ7uBQJnewdPDJ7eeTn6GRVzb1GEM", - "secret": "85ed530cbdb5f3307849a2245070a17caa2f304847e174f70365fb6c915ce1aa", - "public": "02d65aa80f9af3d47688970bf4e1e79fe7fe739fd0c271f7eb3b8d3ab6f0c2b620" + "address": "G4W6UDwRi3n4s3erXq5viKHfD8Gt6Dv6Jc", + "secret": "36240bebec42b7928104606f9f939eb155ba296e567b8c62dccec004ad603339", + "public": "038808ca90a168226c3083378e9d6a43e2637d0a3ed61ea1ffbdd5619a3b2ddb03" }, { - "address": "2MAH2cemPACcTYE7cRQDYK53JK5VnKLhuU8", - "secret": "6d0b84d3add0b9af7b4d7a86baac11b0cc7ab022a8ea049ad2d86f7aff8e8b7e", - "public": "03391ecc142cca6539bd23b81232c4477066fcba8530530635456c7ecd28b01375" + "address": "2EDc2WfM84fEXwahWNynu3iDXLZeJvzSunL", + "secret": "c9604c86f8a949e0d186bc656d6d3625dd3e248416e408a5c2ab8b7f70835926", + "public": "02fb89b41148210016e8ab63bc4175b0d3e8c07784536435f1535c37db523b5f04" }, { - "address": "8fe2it4xZzE8HzVC39Hs7tP27V28vNCMSW", - "secret": "9f5726bf93c6bf6752b7501798dee20462a90d3c723ac0159af39f296e8be4a4", - "public": "032e0e2da9bed5ed9ecc8d3066e519737f06ec1a79f236fd0b1d84df34ee9147ee" + "address": "2f7WZfa6CMs8YBuBpha6U7H2eSj93ePBX5j", + "secret": "e6de015f90b46bff63dc0977b3e9c48338865bba24a09ee7012696c4cc56662f", + "public": "03fec5fff6df86f8783056e7e7e0d0ce9d160a62394afdbd7f4e73e1ca7f2f1a0a" }, { - "address": "eQTNEPxyuvZqkkp8FgssiUPXfj996Eb2FS", - "secret": "f930bac3fc42eed343a97478be40d6f66262e38be115cd352e86b30c6b46365e", - "public": "03d93fe94f1e6394fa364b8fe199a4a0709df0279e262a7ff428d028e7f25545a5" + "address": "6CGm1DqHawvJrfQjt2UfABWo3bhkr8UJQD", + "secret": "8d5e6cfd6440a1ca8583c59cc1f0155bcc3d3aa5e9b084d2490603acabc0fb75", + "public": "02357f3dcb10b5630bd904259bb75137889c04123b509b77cb9dcc33b9de2e1a69" }, { - "address": "g2vPitAn99AeCpdHoviyciga3sXUuEUua", - "secret": "99927226281e200c48ba76b82f94959bc2b407a1c267c97127c00f236604d9f4", - "public": "03846b639f780a78a06c931ffd0a62f1f27f0a174c8c4506f99ac430d1ac570fc7" + "address": "5yq6MtxX9tP9dfM3A8FKH9xLY9UpAcxm4D", + "secret": "fea98f69b33c8a708459a4c224c4fefa66a152a0e6a853b85585f7147c0e95e0", + "public": "035a2b87b8d9ae00d39606bd626ab395814e2e1ae1fde6add2dba581ca00dd6200" }, { - "address": "kHctCywMWNRZwUMzTCt72MiUfKsnGVe7XA", - "secret": "d434ffa3762310058994c24835e948737ff31104830267e1a37c83dbc4d920a6", - "public": "0228f2f9c016e379dc72af5eab146094fd8271fef71c673f09fe2ca6ea4e999dd0" + "address": "GMaMEgBcs5csC5XamNTYyniVTo5ngHD8k5", + "secret": "0da55fb8a6846a8a34e3965fcf0a33d314050c160bc3b9537cab8a385776ba42", + "public": "020c3aed49b27d6c62d76f209fe5227a2d4fbfaec5d7eff7015c5cb2c6403c2ff5" }, { - "address": "21oztbEZJbM84FggX4FQfwFJQSEqDE2Qasq", - "secret": "d8ec3c6cc6d638b9762208783bb87c549569252fdcbc65ebdbcc3c5a7c30b193", - "public": "02c010ae8f4b0e8df22fc1f8f3b0e85f1931d5d4eae90363245bb7459579441516" + "address": "VPHFDCFDchimwsVGtc2jmPtycJwDnbp5EU", + "secret": "c9dd55ca1018b0d8533ba318ed08f1af73f9b98eb919f4b6af4c360becd3658e", + "public": "02b0dd156151a6228dc4cd5cc1ec9642f3215b919d793efb9900266bc18937345f" }, { - "address": "VfLCepVjU1J8GCwtqhCdxoPwuL6UNGahmz", - "secret": "9810fb468d98dbdc48cfa060133b3033cb8c44cd72f75da4bf12d870a95d2cc4", - "public": "020d3ad4c5cd573a4ff25594a4bc268e08d56b7496da36f357951b4093acb455e1" + "address": "L3qpTuDGH5wem8EWY82fUwo1oYzFctess4", + "secret": "b1e2ffdae4f2aa3b20df169a5034bd20c5a939084ac1539efa33cf673dfd1534", + "public": "0251e2d2a31adbf37e00c3e0406a15c0f97ae718ac2f284013154bd82a5b8d16f0" }, { - "address": "Hm68MWKvLwvRsSCKNicwHFJvSRDYjkiCuL", - "secret": "23c828fecb77b112fb7f9e03c596cb208f546e83b0a4f278bd6e09e5b155fec3", - "public": "03dc04d56baa5f712cc1ad832941f6f8a3622f614be4e4e9be440115fcab0c528b" + "address": "2BKAxsB6REMxDhQt3Bg4bRjvQwgpzYrpHGD", + "secret": "94c2ab6880546c63f83e5704041aa006cdcba445233cf0ef710dc774c917af83", + "public": "031fc9a3ed32e2ff9ddbf8d64c5de39ff74847812ffd5a426dd35f7eb8ac56fea6" }, { - "address": "28zvLHhbp4qmFksvtKm8EuThqLjdmv3rc42", - "secret": "e67e74b8f9b26ef79497c0bba0e3787ce739fe50ad70e6a4837853f461c7c300", - "public": "0378da07e32035e5e5d8124f1e2aa6971817224413238c725f4b88a3efaff9d5b5" + "address": "h4UF9sekW8WJDERLXiSU6JiwBJPCFXCVQz", + "secret": "e256c250043f7d7f4a60421c378c734a1b956dcbc22ff828b57e09f68fda47a7", + "public": "02c942fe2db3ef7c37ae64a7943733ed40da2bf4c7f479a5b1210fb5e57aa722cb" }, { - "address": "e42vnxh5NDanecRq5FwE81WqHRqK8VFBuL", - "secret": "c641d61c9b6cc6389b382a88ec651e988070bf64c34c01a2865a635ec2cdbbda", - "public": "03108580e23e59ca93fa5199551beaa55c3b3ad11ce1ec610118feb2f28483a82d" + "address": "2C3wT9Wf7xsE5BNEPSj8KUerpPiYSeM9PLo", + "secret": "85023f5d7ae3a15a82548e7785f9287d0d39b1c59920d08cd8f2dd61a227df87", + "public": "02bb78ffb03ee30ff07ae445989b15108df51c1306d5d712358ff3a77356fc928f" }, { - "address": "gMhjALz1wiGhdCxLT1tywR94f18C2dpfdE", - "secret": "cac39238cf1ec39e8eeba0816729a4bc8052a5fd1c320b06e984e5d485e0289c", - "public": "03a93d4602889c48519e9e4ef381fc45e5cb730472a72fabef29b60ef50662504e" + "address": "MeUC8cndNSMJdT2P7THbb7TzhfZEYbQwTF", + "secret": "abfad820eb18e0fb504bdd0dfadfd98be92ca215d738c1d4c21aae87ced8fe79", + "public": "02bd31ffc3fc02ddc9c6bcfd3dad9ad4b2d51965cf368f854d9dff66f33b27e87e" }, { - "address": "2FG7tbPTaSTJGTGJkz7Pi4VdiuMqhdNa77W", - "secret": "43017c647702fcce95697c427b594585edc2a321fbd261a51be28fc0e4b0348b", - "public": "025092a77d908a7ef3d29e953a1af8779dc53a9bc97d41c0fc33195f001ec59c97" + "address": "MW7nP3oRdP1rfN6kpBjwQZ8f3MWrGEpc3F", + "secret": "77b3b0b050d0ceb25ef73cb3cd47c16afc954b1d87b57e0b7e7215f4a1150c0e", + "public": "030ce0bdf4ee5b7fb72a4dad6d047832d52ddd34ecd8d81f81645f989c8dba2107" }, { - "address": "2iMGd4kgzjGGPCm8r7akGqB1ocXBxNRWk1T", - "secret": "0550302ddb055181e9895377b86c8613ed7d1d2748037371394faf6c8619422d", - "public": "02cdf66c45ca94ffff3bd1513ae1d6c3d6bbb3ded37381cb47917a7732dd6d8e69" + "address": "xHtjPK1SPcKTKmA6Hd3ybsL6GwBD1xyxUb", + "secret": "2a609e0536a025e55366035efbf9e28c3283f15daf9b2273e43154466e7afcf2", + "public": "02ac89388615f2b53f6890a31fbd75b31c6c27d522214843364da96ab41fe70e9d" }, { - "address": "Yk5hj1Mrj9cBxjLMxXNFrnEvzz4Vc9YoLr", - "secret": "7271306308838a33a459237f2a0455eb0dff12f79b5c3dd1ebdfe8e5fa317f33", - "public": "02fbf69856dd809404e012e187d84b8cd1001bbe18e78ef0f0a566293976608457" + "address": "2EUCXDL1Pnr35Abe3BAmewZkNtJX2Hqc2Ro", + "secret": "ec3bfc75efdb69da3ef0f609ded06b9848e7c5ba69cc76b4ba8e0f2fc5fac011", + "public": "0385bba88e897783786e06b55e535f13057ae68ef6f57b14ceb70e9dc4e34e92f8" }, { - "address": "2BFWNWkPrBU8FcneeTvurwLuUjg4F923hZ4", - "secret": "bfb2987ca7f5002b8cf9b334cf8eb85212f2639e8cbadac63579af8d30d02316", - "public": "024bfa92b556d2148aae392bc8c6b791899bc0b39d13af6dfdb60bbd042141c267" + "address": "2icjs7U7LjPRWArUe4dfKWEyXPNMKYfNqbf", + "secret": "81995ff5e709bed9cf86966f88cb8da6095831f7090bdd64382b5e539246b454", + "public": "022f1466e726b826363ba710ab7575000f41e71e0ee7994f1af7331246224d766b" }, { - "address": "2J5EuVB2kXjLzgaCnDsd8DGi4jmxDq9wE5v", - "secret": "203d7f31b5a47b4aaa80c99e78733d2980e0e82a4d9b82ca5037ce16b9aa7a14", - "public": "0330242a55748e4deb541fcecae4fb84a68c2e9b4d04ba36d42e3ee0cc88885492" + "address": "RJXHk1XPZv3gyQfydsSLY5vb82USLdpUTh", + "secret": "a627d0c088ae6c6a004435f93be2019e9735930e4026d14fbe0fb0309039a198", + "public": "02f200888ad6d3f3547f012d72d264fcf780e124f04aaad4acdb2617bcd901566b" }, { - "address": "98g749PiGCnTSmUqcetduior1XZE99uXdJ", - "secret": "520f37aadcce164c8426eea04e560bc6570eaa856f79bd0f14c9e212bc72247c", - "public": "023fc6ab6b9d3611426bd0e445839cd6af81881e4cf1305324a785e20b30e6db02" + "address": "2L5QFAHBPcogj4tVPvviCGgoEgK4yF9UHqK", + "secret": "1fba9300ae3acb7d9d02b6be35bc7cdfe3fac495d79ef4080d25656632a75035", + "public": "03723bea8eae042c976de6884d9b54c0aa19286db7ee4c6e9740064301f465bc32" }, { - "address": "ngUchGbzzdTByGoanaFDGqj1KJstJLBPEW", - "secret": "9e67db621489cca50753c9f246e5b0823881d81c89af7a792b002ecf29dc0be7", - "public": "020c24282b6d405ebb92d4cccc1df40ddfc3d486709452c4742ceacc28409f8fc1" + "address": "xz8JrwJdYru4vwnNbpt1wrXRF2NH89Khst", + "secret": "a785c36c66f28f4c19818cbc54faaef43e574b2d42f8df864dbce43e177cfaea", + "public": "02ae807160537347a4eba3a0761b53e2f9c464b47e526d6d4d48052e888f434e0a" }, { - "address": "28GvhcfNXRZaXMEgGFj4EymExFvzrEzffEi", - "secret": "ca5f869b98db97e795a24c07816a42d1cdc9cd20949bd32788921b23e17ef30d", - "public": "022c52d2025042da6c6ccdbface05c7c76b10af597c92fb9254b3d1b13b7b9f099" + "address": "2EyfYcC8rHjycyL1yQqCBS16BtCvA1cwYxY", + "secret": "bb152d93f18912155551d152c10ddab0c6ce77adf9092545dc458dc34dfbb603", + "public": "022c3c113b27a7726a6ad38e198b827f94a0de62cd319db41743dd08a740ed6b45" } ] } \ No newline at end of file diff --git a/src/cipher/testsuite/testdata/seed-0000.golden b/src/cipher/testsuite/testdata/seed-0000.golden index 6233cd9507..b0869429a1 100644 --- a/src/cipher/testsuite/testdata/seed-0000.golden +++ b/src/cipher/testsuite/testdata/seed-0000.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "aG9iYnkgZ3JhY2UgbHVtYmVyIGN1cnZlIGRvdWJsZSBzY29ycGlvbiByb3RhdGUgaW5zcGlyZSBzaGl2ZXIgYWRkcmVzcyB3ZWFwb24gZG9vcg==", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "cfb24jWcms9pZtvEx3UjUuLPdT6rbx6r9M", + "secret": "6614f0956f4e08e07ec2d4c2767b9f7121449fc2269e2b22f1a549d63e9f719b", + "public": "03b79123b2a3100420b19cccbfc688aa39f510b8491b67bdd296a92a021a3d0d8e", "signatures": [ - "b2fabdd2576ec4ad7099ca5787226dce29dc8c86cc8666523d5cdf0bf20875445dd4b20bd8890afcf188ee5bfb8ed8c7e879c73908c1d4b9a470c596df00c6ff00", - "ba85034f675b8a284537a0c23e4d55d5f8b4cc1620eee077a478482b8f7bf9304d17c16dd5aaf70d24df262c531f37e58a57469d1161d6134075ed8c203f7cbc01", - "842a55ccd9fab5a33a57173281dbd632e1ba3c785a75f5a6ddd01bd918086538166d4814fdf1178f516857799f539e612167a543afba81096d4fa834559e1add00", - "f370a0b2217d3cba80ce086c6fe4be15904ddb0a24d7eb1a7b459a6f08b9688e4704f39c7fb85f557ee5b525eb3994ef8b93d694acc672f15822e95e1be444a301", - "6f0b4f9c9dbd242dc03be260918d825f5d48ff07eb055684f0f29a69f14179821b1f4506bfdff12cfa4b2e6cfe49bcfc3b6ad847dfc3c63fd3e0f4a69dde17e701", - "0e6896a7cf0242e1c2de4b75fd73a3cb50462523d88c2c5db0aa161ef00299880a039be362860e51f214682b9089f371802d3b2abf327b362740c9508e0dae2d00", - "b43bb1ffb92e4e0ab005efc1dca6c55bd13d04d4456d13c54d6e31585c16aae85c6cd5beb9aeddbb9332ce7a19bb42271f7fde90a52de925399b2cc44190779b01", - "7a390e10c666327e110896ff273a3b4fc7901fbdf794f615008d4753940656f825877e958d5546a4587fc86bf6a7063c5ea9c8374cc4316eea8879c4fd21090a00", - "12fe1efce3c10dd7b679bdece2bdf31caba56ae053c52b35f18511b9e565af7a69a277b13127bf0f542f95d338652f492ec6a108569832178faf09c1551be68b01", - "d2d794871e4a716cab9fd979da97b3104c56e191d97186bb3c5fcb3a9bfc71866acdc4830ebee10bcbb7da05d7719c45dfec7cbf170de0957c90c6cc31590b9f00" + "9ba679ebbcf6ebe265512d46265bdad40df99b5cb44a34f28466143cbc5f152d0e522018b8f4298ecadc129a1b471b0fd62cb51ea9305d93e3b189dd2b08e06c00", + "cf17711343205a01e4f5a6eeb81d3dbb523858cfd97e11281cff9617bd70932067b11313cde8b21487cfad20f7cca5f24fd7f1687fd073094eb2becf2e2ce37a00", + "1b45f0df19184f9e6047d2e4ae89cf5cc4f929fbcaed499ee7b2fc57c14e973f74ba3813bd28ea910a3e3d94ebab060353d564bac41cafcdc415226e9b8574d901", + "6e65a200a5a02eb1298c37d82005ced3e844d7065271db5752d242b611fef8ef2e3d811bbe83eb872213ca64bb9008bf6fe7edb548fea97e85dad05b4766cd6e01", + "7c020637b7d0f1748ad9891091de7f05f9b024d9bf4a68044515426f65d57cc3091b52ea7f72a571fcdcf629eb006523f4e173f0ab9fef7d1a906fa2956ef5fc01", + "1ca1cb90743f5599b206227ed8ae620b6e501cbffe662369a447f9846277d70569be1ea604c2c4d3af99ff5b1e5c4da0068bfa412f58f9c505d4747acd04962f01", + "af95ec5a6976f1da014accbc98aaa62340a4efd5f42c21a2ba73a53cf388b19022874e03e56cd77e9410e39fc937da8e02c23de7e3889c731d652c0da9aae16500", + "d1154d77593d24227e95233ffdb2862145457b97d27b4216e56b6a81523c9a455e37a98694c465d86573f0a55d20397a25f089738475114c954fa746b0c5ca1100", + "7d8e327ba9d328bd124b43f3d472b2a2ec45d4dd44be4a6d2a1edac8cb019c98675bcaf76e531e06e2c6c96294e8fefb1fbd29640e528a2d7671b1091c0a55b200", + "352d7850e4425012640dd63540d7fe760c728b6057bdd5722c862d59337dfe7c47bfc33bf439465ec4f833f10ef658469933765be14963982f6c112402e26d6000" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "nJUPS5CrLV2iBdMvdMzMiP7iA2dzumaWGc", + "secret": "93876705c31fbf77f756c7a59616ebafe12b5ec6bf6f0c85014b918fd79d6df6", + "public": "03e0298390270c0b67c62cc35b493503ae2b3e02d2d2e7711e03beb2b6f481115d", "signatures": [ - "b9961d1867f4932fe1423b04e3bf90070c1da55d3420188422cf8e9554f91fff7d7d5e1ddbf92a8ca46b9f09ecfc1010b30e6e8e40b6075a081fabb8ee4eeeb801", - "d0435b6fa8b3c8b8e7d03d8f6692365814e1df43cbc8d1723716e82d54a308336d56d94bc09debf5ff85f56af9f4d3c2f035e3a8111c8ff069a4da3dcf6e0ffd01", - "205829192d2674fe19ed54668c5f93535739c9c2fcb6ec58be2899272b52d95555826d2debfcd5eb777d094171b22fd96970f9115fc230aae3a969acbd0cd9fd01", - "8d970c8379aa7b564cd04b7292b3495052b9d328e70f38374d1853e3f484eefd6804eb824c693fdffd6dd55f1d89675d8edffa24598040b01282953af046886201", - "57922ea1be6dd8e2e310190e3ed041bb1361899efe61d524bbd22e6e0d1d1b492977045ea86ac1d027efb26e76876fa6368629cdc603545feef8d0eecfd31b3101", - "f01eca3d2caab6bbf8842013e2c1954d5c5a190f0aa134ebdffda364b9f628756d678f299e2616c394abdde4b6b1f7dc9f6ee9da0534aa08ac03bd8000adc3a801", - "4463f006ed022a3bfc0e8df9ac2d73ae02df480291a447f09f5a380259fa6a244f4eb0fb23b60a3f6a974c6aa2b49cc3eba65bfa0b2cb9b86ab25d662d52947100", - "7ee3033fd9e600a238863f9b1da5b61578841e8a51895d09989bd3a1d2634e7405e16c102770702b09e544c75a30398869d4894065ac3b8085988710e822cc9f01", - "b090a2aa1cf74dcfa3c51e555320acd4dc92c52731538e4396deee3216830a014551c514bba6a6ec6d9718fe9c2dfb6a91d2bcafde2f1ec6d2514a7a0a71a1cd01", - "040596a54f11bbe6841d23ed2c2912f6a6028c53d83fd8d7bc8e01665ac3c4245ce5c9c8a61a2a6c883a827fe994c1d33f447ee524bf98e186fa147cfae2b8e301" + "d6c5510639c65b5c78f2964b0d42e1ffbef3101cbe51b23ee9bb9bd627020bda7fef7c1d291fdfd46ae66825e0d419a561be56bdb4e6585a6d65bf9b25d4206e00", + "789de29db7d31f0fd788a2cb161290abe58f48c2538ea620c1ea9f1a73d723bd3d75287ecc450bfd0c401ee43f67f45ef003d53dd85514f980e69d6be3fbe2dc00", + "57c4cec61bcfb07af8d934d28afd239caa988c5b99e12fe3b157010bbb4200882896fe9d1aee6b53ee0cb59ce34e3184b347613d22ffd18d34e5ee32b14f4a0200", + "01598d2f3248547c4438669dd9cd4ddd43528d71de8d91493fa65297a88b6c8d23c876f2ca5e0e2ce2d9106342faf4cc2a5d7e71e8c363244e5e0d0a1723f40700", + "721a84e14995fd84f3d2b65d45e79bd012e59e1cb4f0a801a67129739f7949c91634cc5fed042d573d552b9e5b1c9f043b77b23988e2b1ec60f37a61c1e469bb01", + "c557e15d55028b279f899a6aed370aec27a66e59f2d3cfff517696b64d74a5a05106fad5e5b795f45383c358f554c4bd97d93728fd0bf41940005a72f85dd72c01", + "54241216147f863da2d7e0ec30bb61365343c498847fe3a788568e343e42fab947368fcb8a879766e99a85bd7614c968bd517e5ff1975195a49f999767b43e0e00", + "85c2649489658ab69ee9936b616d98a38d6c639c73d6dbc4bd434e0cd079b605131521529b2dd6d50b1d45621b7974cac8e7c6f0ad836ef102df53f60a43d8f801", + "58462dde6faf9bcfe80e3aa81e3976a3c1a5fbd4d0090b925641a15c21bc6d6a26dc6ba374765e7c470ddee3892c01c310c19a2178cbfb7260692fd3e3e3b67e01", + "ce1d26440fd13d4a4501b6417b8823c8e447f507c7a198e351633081e05a91df5d7d4fe3632c11a7d69cd1a646a23bedda6e4cbad037189b145f97713436e90e01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "UxnG3PoFvKtRuLu5nyFdb6eu6pu1SZadkR", + "secret": "c1b8c857a2039d6249d3bd4e25d40b34c358e136869592d03c1e3ea85e2916a9", + "public": "037a13b47233d512e123c180984a67571c6b0ed10c012351842846a4eb33b26e37", "signatures": [ - "e5bdc1d6cb93827832e7265951f38da54b4ed9530a15f75a4211c689ef24bd2c30ccfc2ce77468e5177c67b31550f4da33de7fcede6b5fb9279578cbc6207c7e01", - "fd4be179c301525ddc6d5a201710806404ce6f0fb9890f773cecb4cab0e7d2634b355d90e8d50ce51077e7b0f4330071b07726e92b53f15e0ee8cca406173cca00", - "d6255d2ebf2ecbfe6ad18779a8e5ea2d0aede41a616c3b508ac7a575f0bd3c7301f4ac88b851b2f627f41e580fff9370e431c23519a9b8109dcdeea8cc08fb5701", - "8da101a2aa75158175c281f478bac5ae02a923cc3d4548bcbd71871013b657fe7dbd630e2aef0aa03a9e22eccb4a618598168d3d4bc9e48442ec800f96ce580e00", - "5568fee07e292aa66e92e4243c7aedf72da7e6abdc485eb22601eb644955cea00d5f8bf5152b843e7b692f3e2bf6096cb5a9be07aae16561a53c527ae22c8ed601", - "017fb23f8fbf7dc2f594de6a29f3d0050a7012c66471a3d2b8677821f857dd8f2a3a6da1960b41083bdacb1aa161b363191e40db987faedb41e55100e7fadbb201", - "72a2a2b45855e97523b94a4521a61e573e102a9202d65de32baf6e56c08f317856487f4db3a00ea5b81d5a639fe855d797fe160828ded0b7f72da53f4ef2f2b300", - "79c2f11cecc45144f1e0f05c69ff98c40f23592abcf58afb626dae5614f9f39a061a7c08b8fed3b26495aa9ed9976d3f9bc59d2e3d5c127637ffa5fa8ef5564f01", - "eb2fdac8f5ae67482fe625ff7d74d3199cb8306c25e1e03d3f3cd7e84a3ba76f1e38d129b08b884ca34616e55e805d3c468018312cb0078c8dfebb6ca63d253e01", - "1bfc8bec9c0e0a6cd0b6ac02da158233075b4ca0c2079a508b34627eb4cc38ad373f9b00811e0220a9abcd7305bbda983988b83dee8dc1afdd379eb7333212e401" + "d08141df6b5627105e2ad7444c6ac67031eae74fffb1ac993038ab38081b05841c591e997942501dea90332e0c8c1c8d8d1fc041cb0284819935adac9998066a00", + "73dd6d14687efe1ba1a03e8de150dbcf16e4c91f14eb626bb39b0fb64df9156836e3923a84d95d6aecec4afb71b406c71fb6145541787830c6ca8bd07b74017301", + "033beb311d4a6306303d3e7c7089f51b06e8bf7ea0f49c2450e26cf228d0cd347e4aec6143db99a87db6bc4f25c3ba72aff652b95d8f09fc8c2bde54624540ca00", + "d045036a4c717792cd1b76d2b54218cbb2d0c3347cde1b685635ddf76fd310dd4ce356e1c97e25cb304f3850c751fbdae646f4c028c68bbef0ee0dcf5fb0ce6801", + "96ecb1fe556f543e6abdd72255f8b844e7574afb928617fa7f347030d17bbf8c745484dac51073ed18a9a1287844fa22d5b46ad5acbd67096d857da1b303e14801", + "3bbb6961256e153fba0c749b1cd73bc5d5aef993e37c28111a3f10218af4a8625d263224b43193c00d0b383c0dfd6ed5017cb764f0be76b744d0e01d1df8e66601", + "ea391ffb47c13a48f74a70b96490f7b0f7eefbe4222d55f7bfe004b1b04b983a56a465da3e033df40a3b51e63becdaddcdd38bdabcdc33b249a30a13689e5aca01", + "0bd57e44ab89c2c677eb0c491b6ed609c85018f0e875a7e1300d4699d60529e875e7850562e96fb90c897f316e5fd56d54170b3cd6320be2ce3eb5362d03cd3800", + "b27bb5e4a094442b30b7d55ba2c4996cce6e454f79c88c339ef89bb754c2b2ca561086e3ed647881fc4f6079831076d413ef027f942643a5e939ca41e583037401", + "26faa7a87708f5d27731e866ca1cce8864a4fb2e258eeb16de8bbf86c1fc4429736f07693a5e42f0bab79c696024ade370fd7374c93cc8b692bd56fb7093295600" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "SZRDLCVHyoP7Xo5FEnEw7ckibmitbNx25V", + "secret": "2ccb1679652e9bad28f3a316dd8d98ebfb5d8d72d679655365c4fd42e07089b1", + "public": "0284eefe3f4d6500fb563b69d52c7cfdf3152a3394321cfe1dc8d1de1e2868e3f2", "signatures": [ - "a19463a18a762aed314548a238a0dbe7c7c68b600c414d2c90394e09564292b74506d12db62ab024ca464be9f67e2aea0f4c4ad7eb0ff6a83563e51beb42ba8601", - "82a2a843ed80e58a6a39ca22f943ca5319abe1bda80715ea687c1038c8cead830ad8fe6fae8b696aa0e1f3d399c9628ec896fb003c36a68658febbae3599e56900", - "5a06a8f0a1790d4d0b2b291dd7febb3b7186a0847fbd1e5f82c5e911f72f3d35218f439dae5ad78a1a089faeacfddf11c3340d9ceb46edf91c6b5768ab6ca5ae01", - "7a3812e0d7b0410f6c041579720db3c3a193c78fd534c90bff281a1b341509ef6ffc9d3aa70301b0cf651f5ad60d4837f9b8d35b643c7c11a34fc2ae545799f300", - "f2b69e7c153194f5e02f9e81ba9af68d796409421d7c92334806e5440d3c345a70cc34be35bb9266d32e28cea543dc0b321d1f0f3a1fc4a45169a1b5bdb7b8fd00", - "3b71d78655ba6a38a37f16dcb54f694b4b4801bfa5067522c189427d972d3bc1597287d061889c7de4e10290d91da6d4ddacf4686ce0180d845be4e9a59d710400", - "59207c944c7f0279eae1fb3a34b3cebae24b97150b593cad65f4678ef694ad7d4778eabf868574090256dc7d04166128a8a0d33042d4a4627d18e643a297e32d00", - "d86488e2dbbaba9e5a03924be78e43809bc4e52d000262649e4661ae5d3872243df1945a4e40757c7fc2135b8e1e01b4f18592d39bfb82c032ac395adb33769001", - "86862e7318bbf250e17ac5f057ac24902eddcf6374be2db7cc6562331759c7e2643cc030b6811b33c05eb6e3384850c4c01d0d8d235766595b7a47df16c6fb8600", - "972dcc24fb668c096c296742c672168e98718f0c4a13fffddb74f13745ebd6aa044369676af3a9dbe4c018dd6505370005fd5468ba15b2690e4ab59e3123995700" + "392f6b36bf19de26894386049ae581aeb4f358296a02ea0666fa7a0c4732aa950d5b0410757644af454df89b1b6c6e8922676b21e095dc0fd094aee93e4be6a100", + "6eb48f725ed820f3001b88814a7ddbfc2dd60264612a29c2a6fe619dcd227fc3641873b78539dcb14fb74024e617b1e9c59ec71edd33f7292b5771a52bb6289d01", + "4b81f2caabe43a42915a7e19b34234f624f0dfa69353ccdc613874264bb5335003e6e04414ec7c84f4127f720b84772209ca59382fb4f38d102d312ecd4e64ac01", + "2428b1fd886fd31eea75246479dc120746ced1a4d97e633cea7a22ba67378f5636a09f06b6e9c66824efd5c761f1106b6aa15d4e0594c29239f4cb9dc1089bb800", + "627dde5f3179cfd4f1256018e59f17af2426a23d2131c4bc68d6cfb82b19a08f70e0ae7fe7d1029c71112272577c1db86086ed84ee5a7b17c112badcba0a601d00", + "8249b9da32a7f5c94035279ac4eb27f0e62cb50d230d1b30347d7cb0292dea8f2b662f54585a7bbd462858210010298abb3f7d1c16371d1221ff421a74a3744301", + "cd8c4985681c319ba9f7c797f5b9ba9c683776367dc4a90370ec09fcc8f6e0f07c7208db052e77ab6d595879e14423579eb2e2bc55ce04912e65f82601abbf6601", + "0aae569e4ceabbe5b8e1cec72ffc180fd9f93d5f17bc1b7df01e8951cb4c35a675f55a49ec380f8f33b561ff1647a063d4147808e94e2ae99dbcef97d2f1139d00", + "5b984636c673f60e7abe58c10a2e079f3e01da2fd8b41a239e6f596219dee2511ce4f0b35b1531ca8442137764980163509a3c05c219106c79a8e2f62b23d14701", + "9c6ff83bb5482a96c22eeef69246cede55105641018ef2d9cd40a265e45d402620403f555329262e20a5a0d053792ca7ddbdfc16d80552e4e0a8d6b83da86b9400" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "2hSc4vmw59H1FEfsRUQ3eqvkceAAv6nanQE", + "secret": "867f5d21e6e2c3204b6c526ddd8a5d3b7fdaf8612f5bcb5423956a0d9eac9761", + "public": "02ddfd5d6c55293a925a7003bf23df040a91002f603c5db45c8605822f79caea01", "signatures": [ - "3427eb7478fa696bcf99d79225cbf3ee47c2a40c9f82398d21b6d858de7205241be1da2863e8c18515cef6bb1c86bd1fa668e9658317728091bb6d1a8c1f9cdd01", - "48793453ca3099bdde4ef115e4ec09fd19ba8b67ca7071fb8736d5a43ca0b5a70a3301011d490add6af8bc194ce05c339edfc7da66a009ae99c7725284dfc2fc01", - "92602cf241ae444771255fe0914f586ca80fbb6700f56f43145a7b7239219b2b7d832c926f6f650a9064fcd2622d18ba4686a6fe55b347d3d0deff3967fb993401", - "6e36546e2afb708dea6571b9fb65b433e972cf53907f7fb928f7bbb68cf874272739a4e3f0250fb4795cd689692522f7690f997b29dcb756c84f86356106ee2a00", - "33f37d6c7a6e4c8a45631350e384da6a37fe87d36f8a0b76fcd48ed83b420a302ae9dd5928e84d70c8d6540035a2c3b25931bec6efd4b201c50de836ce2bdd3d01", - "110f0d473fb023f4781ef96ff0d8245dbd520cee68e38c9c0e7c01c261a556420cb3e7241b9c00e87192332ba80ae93727be21ad086e5c7f8a9cadb436e3deec01", - "066ae4c71d3427198705ed2961bf796203e53280a441108faa0e196353e049ca2c46ce03ee1907e210cc12f793f6c461a9982627b8e94ba867c17cb8f7fcf6e100", - "76a7d47b56b793a4930d2fbb54b03a610fc2bdcfd2b1481b5da5b6281b8f9c9b6a565f2fa08dc4bcd8e363a8e9e7eb1d42b693ba1979be1687a04dc198d3b11201", - "f68de2f7b8ad5f3df7623e2e685f79de33db1499b0b7ff7eefe571e010f6b2a76a18504614484cbdc323a01c52cf7f6b5103224111986267528f17d9cab8003501", - "cccb157c35cbab2dd043d46c90a896bda358c47b09518474928a11e4f3918fce5f969d85fa3fdcdc44a7d632944c1be75ff38740722b93063b6e13790325ede901" + "e2255269e581bb78a86cd9b056d5089f03b77724401cfb900373571b5bce0c8069660bcdaaa99dc5df44214ffdf270d7e5065236867f20c2e692d2c4d7de0a4100", + "959d6ccae8bb8234634a5b15327a3e5ba03a15a6ac59341ed45f4e5767731bc358e2113667bf1fb15f15c0bde8b32d6aa83d4d9f91a8e479758373729641901401", + "cc8e9ec5f38f3d0a3ff71d507b9cd185ad7379448c2d33f4fc0944c4cf8d072f756e7cf1c38022375865105dbfaf5b7f71725e8c7a6491a1468db8ed93aa72df00", + "b82e4a33f0d9c4f6bdcf8a20acf103539bbd29d6e34dcbf15e396b980985f3a21d7903f83d6c61278d28de465f2a7ad2e8df1ae5db2bc823902bc63353e0937401", + "0783f3743f119b073a1ed59dea2641b5546fe585831597c655cb9841bc8ac16f656ac3ab9d16c57410bde691053675126c739cfc49694a3cf3030d776bb8def001", + "bfc6d5273d529ba5687a925e177740f33035a7677f366a3cb1660840954b417c0b9876d130231c1cffba939121d9ea12de9cecd88d6e84d5e9e061b4b443cab600", + "8edbbc3fa3c844abc1263b9ea429cde5df75524bb2acf2ffef42f65e4c1922b5676fa50b316ee8afec86fbcd116dd55218a44ceab2645d4bfb9e277822ea305a01", + "584242e0143eaa13dfb4736fab23f6a5e19848a3b625e59b9bf6c603789b00047371314b12fadc3b554437220c6af2ce6a406e694393d8e3da445496891d3ac800", + "d8fff1e095c12c899d7e993f5918e99164fa362d6262227d13f0e1f6ea40caa01fbab5f7b0252f306baa364a29e6824d4217bca7771b98e3114a6d9ddf72970000", + "6e4241e151308d5b33cd8256c7d614f804e668a61a16b4b7273f023c21d7e3006b41e1aff2703b4c8ce93da01484a70b6e9f09ebe09390f6f611db0694df44e700" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "5vbcxd6wjxfVaa2rYqHXXYkW5cjFLmh8BS", + "secret": "2bf3f42540a08a15ca280560e43efd112e843d4de930a2ad8de07b1befcf7231", + "public": "0243e58f57f152aceda76daef9332f9ef9f844e4ef5c1b15685359d0d0dfa07799", "signatures": [ - "c1e54376c0d048fff96e7ad48c3876955e27bf32ca3ba3413481607e9b866aa84dbc6c106eac0d0a9aa049a03ed509237c3583de85e58a60ffd08ed8a1093e6700", - "89515106693f4eb2fdc1c79757baec9afefbf97e0dc82d4ca43fdc992deb2e9648c1c28c8e06aac0ec14585bf75a53a5bc27c95a388e78e8c338c23be888782601", - "af6870120f4a262a89c36d75ce220c3da9fc8a1150ca853d98b0c3dadaee449a66e4c1be15bea1e6641555aed73bf3afe01d46ca91e00953fac46150c569709e01", - "318bd7e503bbefb17e30f5c843e2f6908c5e6b9f3b6e35e0db5dfbe58a5c759926ee1d73088600d75ac06708ba3b16c7df08fca6ad2b360c8f0557bcc4cebc4900", - "720394840fb8f59e9396ea108c3987b5607209dd549ae2cf5f4732b12dbbf96e233bf30ee1a8e71f727bf4070365cf523f4b4a99ac7d4fb8d6a5ff8cc6cc0f7701", - "08238b2285ef8ea1a76902ebac766a1a95b14990a9ccf7f70d696a3db8f4ebac3440e9d65f1cb6e0058fddce16faf8a22dc1c6c73f49b0180064ce12a1eb3c8301", - "82057aaa3d30d10e8a5781ef8e148195e433b6983d7a4a5bb9142ff54c4e06605ec661cc653d27d8f94dab1b8f3fb23e07a1288739938fc4f396f83b232edce500", - "89c2ff045873cf21ae1aee52120aa8250baf7845e650144945242989ac926689196945308ef5c254ad5be0360d739c43fea00d13431cf2a4139b7cf7a69129c901", - "8cde7ccd3e291e523b4e998d668cf141763c6c3fc73e8a8810fa45b0e82273cd2384c8d6b02275ea470d6e1d983475017fe86209dae4ed83452d0766bc1ebcc700", - "bd3db5850166044955402951ff6e8da464cf99b4f44a17cc13355ec7b27202f034ae2d1a245f8517dee5c4eba50a281944af0c081271ec8306fc1ebb3c3692ec01" + "c562d6f8476717a027f1ab8c14f95e444f6a5c0eb789a640a56f58dc0339ced44a62e983abecb139a3a96ff2333a7561df23fa8b1705b8c06bc3b921a51afb4f00", + "4cc7e74e1f2e6136e1e122817f39f83faac6e9e022bd9d0361506a26b368ee28128d1ea7f0bbcb6971fda0caaed4e1e52a0270aeaeaf3daa0fd833ca1e17715201", + "88674e6524a76d0d2e1b8d07067b5342e890d9bf11091b0993b6a5cebc74f71e29dcbe6b0a41446e3d7079c1ba2a6a4df34a8a9cc9724c3dc887d40bd7f5f64401", + "488a99706031b162594963d5bbf78d426fb22dfef8491b32ff9b30a0dd18fb5f085021d97d2bebfb1132d86cfcf72e498a791e19811ff1b3985a499b059a1ebb00", + "438fec175b65eb9644fa9c88e4ebdd7d77c760822eef3bc0bc4ddbf7d04e5d5738928c1ba5e2a31cf006a21a4a888d1986043601a563fcea71afd4e7a46fc38c01", + "f7e70b4a33131be328f844d0011efaee24b63ae60c38f3e79d9cd29583f479d6125c20606de51cd56ad5bc047209f4abf0244335c8bd666306e318dfec5b11b200", + "c61983d341ea122a3001ad70a9e7bc009f564e57b0fb0b8af60e3d72f9326a6248cbad7faff8740da7b907fdc2bafbedd1593c9b83ceb418157232c8fa1802d001", + "afabaa96aa5543d5b7fee0b63c84a9a220c6de4fec3ca7a351b793aa417c28391455cbb90f298b873349f9abeff8fea461a6217a8e1694c69fba51a1d1b10c0500", + "faf1e87ae00172aa9832fa7aaf13297bda608165fc583623062d13360bcb4ab42d8ab9a9f202885030fafdf12c8c21f4bb2ff85a7855e8190b15f52dad3b122601", + "50392beddfed77190bc6c31746006ae525d6be392ebe65a71992711456491031238df2641834bd50cf119074b8f44cbbd5d44bbf8d939461d4d2d09cb022904101" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "2ACC9xnasQo1uuJQiZwyxtLnCBxMACcZ5HA", + "secret": "c2a0cef659813cf70809fb35804c0f6446524c039e4e14444c54f71d99888527", + "public": "0286b5204bdac7367a78f615f9cdfeb560fa36a7e2c9cd87d7193fb6dbd856a403", "signatures": [ - "ba0d29c744a86dbced80dee49efde18316fea7a3317aae8ead7306f6498e714054f96a8fa6cd91aec19b2021297a774b3519db1257301762e9698f15c1ce3afb01", - "25a654ca404894435905505541a51c2fb77fecf1b2ef57ac58f10bed0dbf4e6020f91a5cbbb56740f54431647b6d9501bd2ef67441442e1796f202cb87fc545201", - "83f8047f541b812cad79a690a091f49fa2d49828479a0763f7267402afe01bef5acf8f20ea0ebe8525b0dcdfc794a77f889860c4eb862fc1b9b0e568d106174801", - "bdc31febb7bbd0ca0bcecb536927cd3fec9a6b4f06de1dd750385cde66c01411504be1941e275afdd4275c4f2e99b72f2ec5d1501b8a8e2bffa87d4720237e7e01", - "1c106a6497a074356232bb796ee0b6dd0bfa027c5b21c97eab24b94efce9b2d370c333c227ddbeca2a9aaf4da786dfe45bfcd7e643f890b175890fd4dde0891901", - "e505882222f339fae773d08330a16a07d09d6adddea7f8e9a7699ea3746b99b0225ec681cfa41066a3bd778d85e1cdd418c97c6231848ee263b729af5e24211100", - "cbcd8ae0c1e00412b653c78c4eecfe71fceb9d2aa961c7d1597eed1b9115a60b594bb27853fb6ee5f1d80292b0646a090438617786443e9ea234f0bdc6c9af3901", - "86843f1dfb3e9060a23532b44a0cb70de263339785ef5f1b0295c8d84bc0bc0a29f70b917e6906a8973793117c81edcdda7da24812be6ae977c68d5a4f60c9d200", - "23252cc83b13a5cc752ed76cca539f6c1cf4ddb49a4a32dd4d69ee01230cc57b23114dd15bf21a4ca93bd96fdc9dba12beef7e1a6044e1a054d2911c92cbfcac00", - "e84e765d6cb13f809ccc3d4f65b8c2a37b19f093ad8badb9c59000166956544a38f76f4a92f58d23b151fb1664f5ad933420d941da00c2f442eaab298804f97d00" + "c77ab13d8107f4965708b75f24bdda7df11bb99b5cf0b8f7bdc8e071db62026b7179fb6256db5e36d926d8fc5227683e52277dea74b95f12c7eb6109049f813e01", + "958d52862b8f9c93bc63c3187a15e1f08e823aa0b4ce36b511668e7e082d05d976afc60b13012199bb5557f0d7726043f25e11434129f6bbc2ef665ad148492200", + "b9077e49d9f986de93cc360e5be3dbf8f30d91fc0f815752eaf0cbc64071000b16fbb965787a4a40eeaa8fd58d6f19e3ec49cdce059aad5f3674c4adaab72da901", + "3cbb3e9169b6116aef09e671e1f35cdbb7dc0fcea9e6f8152df98c371b3648491eaaf50a0cc6e672ed5e69f4255b9bff79532f8da101fa060d0b68ee0e86a86900", + "002895c8bd7a3537095f2e7670a909fd9502e25a6492278d2ae1b65a3f75642364dd31b5446c251174c57bccc5f40f9dfeffb959386a85b9473fabf1578be9f801", + "e3d5e49b8889cb5d655f4d4bdf16a2e3a35c88bc89f1a5c4a75aa82f93c8acc213770b1784c9bf5503f4ea127f4f928e36127d954b18cd3a5d75b1015966da1401", + "990c379fd3f47f08a6899f82f218ba9350e2a94fe046f9865b5ebef04dc734a808769bdfc057f45ea24ebc2a16363dd215c2656fee82792a34439c466a0c3fc201", + "60f194e854753e978e18455dfcd17ed6fc50dc9ecde80c9e78e9ba84238627a815f47b9a7633d6c0e963571a661c7e3896cd4fd26555df11b842466efa4de2ed00", + "12bc90a0c84c73c7b3331ac5106bc5b33202fd28428411721fb084bf5b57cd1517925c8f63265583c50ddafeed9c53c1817b1668a64480226161ec8aa43a73b101", + "ec850e2bc4ad3c96db1cb54cff954ed88566ed2046c806afb0f8218f92b66c9a2a51f2e948b36c5a0137781b82a401639e58301c790d2fad02c17de493bd9f7801" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "kaVexneJnxkAbJMmmStgksNmJnZLC426Cm", + "secret": "af9e2a6f2298c2e47f1d77aa23707fdd2963fa83ec431bf48a8b9d15de8a790b", + "public": "029453f88f667c4f636d2461e03fdb8edd01376bf04c0f67ecdac93c38eb869f47", "signatures": [ - "03482a90040f901282ad2513025728542e12df99c166b00d86a3b58d754c31c4539fa24b1866f86b8f0475fb064af275c9eb8f062ad8e511184fdfef78f8e00400", - "33364512c9dfa727209fcb5ba5aa95b71b5be4adcd7b1ca8ec5f420405014db805629100ea949a92cffad33e7575e0737b64c078ac13dedc9100e733ddfc4e5c00", - "fb2e37161e77dbbb8317bdd9a49e7afea5ecd4130734b1a00c6afebbcf2d16287ef09d231c14acee5a58e36732e65bae78909b30129537f6a00f645779ad646101", - "82ef5ac57320b903f7fa38663ad622ef75eb1e53bdece2099de98425dfd99aff78dcdb5f3cfe1743af96c443ab97a6865a09233c3b72da7578878722d1308a5b00", - "efc922f4b7a757cbb1c7a3233fb139fd2fbb0e5d0ad338f5147e51466f9abd8d2116d03dd359c9c438b2043753268bfab936983af6daef8317ce8f958bdd301000", - "b79ae5a8f7c225f5e7f7aa1363efff3b4f6db2652ed9e4c4c8705704f00684b70e306d35048844c34865ac6a66556c46ee0a81f529e1ebaee086fd1243ea0b7601", - "de52cc8aeacd705fdb9d0553448acbb3fc82abd5962b8b548dea001d51a69849558be05675824abcd4281f48b48690a65c40029e05be2e3606ec633fba37f80f01", - "2a556ad0c08dbe730f2241e288084fdb84674fdf8ca5811e272dd4d6d37bbcfa77306c606807612069a7b1bff600068a1f86fbf3485de119cd1d13bfc24787cf00", - "dafaba3cc2556c14a35f55e49036d816c0c4473986ede6b168e63eb6263075ac75769a61c87b1805cd55dd167b1670efe7f5d4dc7e6b512935d44981f6c4c70401", - "85e710d74b722d58af2a569d4083916cbc51d788fc30e5da4c41cb759a96c80473c32354612b78be1f71ba196f5a0637090488cb250cdbd760af0dbab0b6e98c00" + "821915081c72f5b5c953d31cae7d74e65f4156aff94befb9fe18f3b6b4436102488d841a3112eeeb9cbaf1e07450fba1e76714983d5bb40cdbd4581c3a42a71700", + "2295b3fe78e5f199f8eff8648ddedb640dea47b46db10ee38a8942941ae1f70b25da39268774726427c3e77df81e338a91d1a1228053b417c33a9ea01e35854100", + "ebcb5e094ab5ff2c05ce9e6731d879379a59cde87168fda1c066cf8439bde9e53c463a4fecbc1e7eb72f65bd39ecfcc0e67f57dee9e866766e39ee3431e0337c01", + "afaec530e77e9e2906857324943441e574548873d1448348b4a754267d68217707bd6a5074ec510e6144f0dde0dfc8bdaf7e4e7dd58cdd83cae5454a7d0cac0f00", + "61f7f2667cec398d5f03b4d59abab20a7da2f9989efa068659f884bed748f49a449cc53a84a1d7ecb717902d4600c63cd2a4baeb16504563bf5b417157b43c5600", + "7ec0f56f2bb9cd8219ea83a4ac71477ce20061ac77889568f4e26633c68cd35b1cc2177e801eace67e7e11ec23c4d68a7fa324e6c32496cecbe0745eae3fbb3f00", + "25fc127004c1ea09e9f0b0c5bcb62ee8425b2a45484160ba0cdec8c3834ac2707963c59ff546e96f2912107cf0f808fdfc2c56562e19f9398ea37c888dcdfeeb00", + "9db1af6c0c87542eb3af726044951cf603faab78865862314283c48f608aa35846d660253b7d09f77a5b6873f3f77597e8f67f1cc02df53a7072da9cb7fe867a00", + "4c0308e93abf3ac49235e2d97b35f7ea80d18e7bd8da96cabc24c324e97705cd34094509727518ea807c20fc0b54b5d5ad0984d39c5c417b67db098563737d5701", + "6031dd2e342edf16e3d6de88a462a4bccab609efc48deb8c7f1d4d31de655c845e0513a38e2146043eaeb03f0bddd77d583e0ba55dd01379570f0c3116d2215d00" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "JAiiQdrBFFSAgY2NxbU4PgKSzzycdjAJN9", + "secret": "2e6a21b2b939aae41056675f2aa47fa9015ee2472864b0da10cb0b3ab81c7d83", + "public": "028022f636b47fd06b43abed097bd3c0fadf44689936cc5cef4e40291281964aae", "signatures": [ - "0159bdf22ea49c3e12c1ea984305cf51a5a5cbfae20d60b63f5ac15625016e6c05a9a52e530b5c6be4a8383b713730902324dd6ff4ae827b1b729445eeb7f3bc00", - "1ccfd382e9072146323cec8e11dc676bf2150a7a279d5d360820d312935f188224573089906ebbc1c06c6ff0ca436273c43b1dfad10808f6d3173a32975c27a100", - "b0c31e9ef32101d951d95c58d4c84f6296457fb106b109c44fb4dead235a861756caaca92246397752f5d0b7299668ad7c1c3fb6dd82ddcfe904c0ddaf58c19e00", - "2075aa1bd3a8b1b4470cee9fee31f376fc10084dcd32a1bd833c35eb6267736b700e0c3cfb688290d318e314ac6d32cd5f3eb7e49606541d8c14086115e34d4801", - "3fcb4e49b4de0bb52117741ca08f3a258a1f640c329efa088ab21f8f94cfe62f49f218893572017f611848378d5cfc121d345cfff55331304e8282ca4ef23c3f01", - "04ab5ea6a3eb623694b4be2ba6e740d5b55b7d81c9eea4d6f508d6033ed88b2373e9c395027e1abfef0a247cb346cf650f16b928b66de0e97b8cd91beb54538800", - "cb223aca662a05cd09f1e52cb5838920b4d82af1ab1becd63551745d4b81d37a2bc486028449bc70782845f281d957175954a5cc4a5b3539ecd91ea518f1d1f200", - "d5fe4fdbc1e864ce83c546ccba35c08c29e1be605f77d98c95cdd6d229e460ca5c374b1db83755e9acdb2f1e0157e271b0224e3b81828d763aff49734923695d01", - "957b24830cdb90792d5fa4a507ba91f60efc4e52ec868b10d2f561d53d6167db79b83c13b18b96287c9f4f91cefb8e1abd7860d7269cdb1fae4e6bc2fbc594cd00", - "fbb8609432bfacd041c0a4b702903cad39d300a88047965c496c83959d3660717e7ec493013b1e9942f1dd073cb8b5b183271ff699d2dc007365d98156b7309801" + "ed6a323988302ae35f6bf4344d0feeaf6ca2cc98924c61d89d2baac4756f84af157c96fab9ccbf05ac1f3bbda3ab26c01bd0de2ea5d7516f1740f21990c0582700", + "816166e485e7a1fc98f013bcba8c86929b81d2b4ee98b116146bbfffc51405d61bd43d91a03969f08a062a74dee64eda518555a2f71ab2fe54606b11e010d23701", + "fa66344d7212ab12eefcdc2e30bead3eb015d9e328a09ee342a60fb50fdb1ab91db7ad1b0391a2c5e483435e177d2190dc9624212b02b9c4a8ebb6d8e23e5add00", + "92e6d0c388cc9bc4a2a42c7cf7d4eee0e9969ee2673d1b3f3cfa049cb069e361255f0e5e3fb1ad08eabadaf8338b990b9a3c03775e20499952144653c7d4c56701", + "491cd9ddb98909e25c019f93f75f42a3f3be73628ad5c822e619eb63d2bd47022d38afa0b1017529cc5afbcb8ffad74cdd216ba9dfd934b48b1d5a5f47f581da01", + "5407be85be4c256f186dd2b552c47d3a5a50bfb6bba489f9c3dfe3d95b7213372fb5a884beedd1ae250066ac2b264a5d60fd8520798ae0f990c1459bc3f79f6a00", + "35ab96ef9cf604e2ce83b7a2475700435426789bb56b2a4e3e39f2fbf84692f85b4501acb8129ff57f769a9ef1d5826509ff86474fd12e9882b204e956d7832b01", + "b4598b238badb2b0b06c6bc3f37ee59ad802cd45990646c1fc2ac157821ce159497fe4b0cb90dff620b1516952007b12af295aea98d3dae4d5b16820f17145a800", + "971802ee62ad7818279facc0c549f6a54da277b69d55e01fb02d557ce93788f32eddbed9fc62fcb68fe0429fa615369cb0fcf9dde3d5305477348acefd19e0cf01", + "4afc9fb67f058d08575ba3eea93fb6e6309cccca16e359197a6aa838c9be7c065138af45c012aca1f74914402b8c3d84f7094daf6300c9045db74e7ab1c3fa6701" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "Z6XPgNGMRjR3dVjcm4A5CBqLS3aqVQcVaA", + "secret": "0deaeda9c4f6391c54bb1ec5d16a31474b297f33d4e7af256286cea76e4fc40e", + "public": "024945c67ebb6749835872e06e9fe8d3f0fe13c154a5681764072daaebfc9f6c60", "signatures": [ - "76c55a6a2d40c6eba323c6632845250476ac34934bc4da6682c4ebe70230c190572bea10de17ed4c4ff995ddd2977d0e64e748b3c1342ee9cdf87b0f706f6fbd00", - "945e564c99b9889c537a2a52dc445b7583918fa144ea03e1bbc0376f5041dc2d1479629bae2fbf55663bce2c3c301e15f4b26055168248db6809df0b8887c5e900", - "051e8787f87a96b081a07e03205cc87871f6ef0dda21ad93156878a1ebf8aa525c4a0dd2755575e5c9004134fb5e0eb40f1598dc1cb27b9b6a64d1de7a65c49501", - "0687eb502b5950ca889ffce4eb3011d11c120986b0d9ec302b97f6ce4451b71943dc674245967f03d1cdb96a9e35bf83d9d59c74fc450823bf0c9d5f1f82738e00", - "3e96134e2110b53e497bbe4e071551686208c51ab06dce5f118d5869ef443c7846831b4a6816891ac7689cedefc9c8d1e588da12476a09445720dbf19c4097cb01", - "f0f3a0de54f27906f9798e3635215a4c98b9c6330feb8acc2b3e3dc2c35d481278c90e003d510e6d46bbbfc4ee51a25f5f19a64e0a2b3a0ad4da45912d46652d00", - "2bdd7d336c1a6d5c618d4788f56712a4fb929dc8e771e739154e5fe4bf5524b9095b6f20de481389238af12195c50a17082808156e52e8fff63f00205d22dd6501", - "feaefd755f892393617ba285465842a5a5727398f6270008d3a4571ca69b034215cca8e0bd1ea367d441ed57c15dbb5cc3356da557eb7de23e67427ca1c23e7301", - "95a38cf15629b275ea5267f4e8fb85d68e4dde70064c5149d8171f4699381495623824581c6b091f3ee65952f02827a01e312a4835efc366293bf264eb57fb1301", - "84013ad259dc85d0ba2deb0409a50b515cee4fb5f5f3adfe137c2744fc2c90d056964c57ba9a4f983e88559e017033406c3e0cd591f8ad055ac6dd99a8495ccf00" + "e8148d32e2bace9e7c8e6017e7229c3ce809ec88ceb83a01a2a2299fb87700576f79df74e7071e3216649de4653807a1c94193ac38f0d74d0abf25a6f8de750900", + "0ab4d582a506ccbfe351f54f676a97830fbc3efc24deb49f9410d8d80e0767e16fe6e0890c72b16774fc8aae801c698072e001b2d0c6ec2cb6637cc52517692900", + "1c6bf51244d387fae3b6409e5c42428c5a39db4178746298e29cf397b21335fb49deeb64ce486281fe6318f235213d016ef7142c7540fae3163a5de94f209ee600", + "f18778602f0cdef09fbc469c219e92c5bc52a5dcd7d873c2a4759d0938e503dc0d022341130004e45be1c7644d3ec3a338039d9c410352afce7e41dcb300728d01", + "2e0978dae226b1e70b46e88ab1fc2126fa1db334f022b0b960b3611e341b6986233ef8fc90a1a1ce28183b18a9ff5c701fbf340ddb4c45a88b1dfde74f7f39e101", + "3fe60797a43ffc78e26e55990e3eeea76e6e920e47ceb4a51a07ee22c2c0be1b7e51d098536a38537aa99d24af3c644db97337d51b65d13ccbd218b9839f179c01", + "ad77f584346779975e2fa12d3e7aaf0ea35b025298fde1f211488ed5b92d25343c86b4c2c0202748b80c2de9008fd043aa1d3f60262ec1f9f0f0e95dd4c2fa4800", + "27d66336014a5a93c5e2177ea72755fc0b858d7ab79a5976e38e5287549a6d0d0cee44bff45c3b7b89d6a1ea30cfda80c13f9a772d38bcd57c72f938db85afc101", + "9417eb0a9be763f5fb0ee8b189df8cf1a52657b87e545c28908802a7fa0c06442fd47c5ae49bd8fbc4e4985f82da6f86c2149e17fb903303420c7fe4d05a6b0500", + "421dbe10f4f49c005f3918511f9ff71ea6701ea76226cd1e6984329adbe4428745ce14e5768970e2e3fcd1408055b2f194f73cfff88aabd933bc8de4d607426f01" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0001.golden b/src/cipher/testsuite/testdata/seed-0001.golden index a61ddcae64..db7a54248f 100644 --- a/src/cipher/testsuite/testdata/seed-0001.golden +++ b/src/cipher/testsuite/testdata/seed-0001.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "d29yayBwcmlkZSB3YXJyaW9yIHRheGkga2ljayBhdGhsZXRlIGdvb2QgbWF6ZSBicmllZiBhZGRyZXNzIHNoaWZ0IGNyZWVr", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "2XDHP1JPEun347k6C559npPHT23V5GWeMkA", + "secret": "0e1e9ad1a0a6c688d9d04af22b2e07a13af293a05859ffb557c841daed509127", + "public": "02fbb044de5c57fae0a3e95ff02b9054ea82b54417a649088b76b4c340a38010ad", "signatures": [ - "09dcc7fb54d0174bfbb8aa23f9714b2ce6c36669eb4e2f75fcccd37682b55dfe3334a359c0df4a6aad45ae51b9e9552e623a9a1d467eaef51c1d46606aae6d5000", - "0b7604da133c37cc3a63688a5e02623c39b0100d6bf13fdf1b7473f806cafcae285390e821b74c9cee60d9557550bf140c0d8c37c6055320ad9bdaaa3c8a781f00", - "dc66894bddfef0de2d551da473f05e72176ee9d7a32b2d8383b8870197b43cc95080d90ced04784baa0c455e59120ce43b23f11530e83a8fdae4c10fc33d7e2900", - "9c42f78aaeed3eb05bf8ee1dfd05d5f160218618dce1146094b31d43d790187b08d72581ee935594f744bb4b557a66b6daf84e70969a6e0c6e340ef4620d923b01", - "73ec5d609f9bed5465c6092589afa691a4e25fbd7800384a2ac127624f6034522347168ad94442e4c6b6eee8a53c5920752072adc9b29e5f3c93bf9396c8ea9600", - "3dbaed6785955c1799a11921a67465c4074fd421e0c314df1a90b3bd959df6f70c7cf0513df2698d92571066fc06873d52701ddc5ae1980c5b8a9c870fee020d00", - "dd66a1206679cd3da4a75e2f812b1c54eea6210e779d8f741bb3b22ad57f31333910f34d397bb6a2c978cde56344325bcb90034c64a0f5ecee8dec5e63aac33400", - "beec3647d7feb745947f25e53f08bf59b8bdb10bc55120191d4b04da042b21d83628f129f69e52ce882bd0bfe15e011c54492f07050c1c49d3d796fe4ae867eb00", - "05598f9d6b01268ef593da0b7a2d9827363ee611f55c53bc8c43f810c324fcdd2acd380b3223360e849fbd1233ab582384dc0bc3b6904e0fbe44b5b18411086200", - "32d6273a993e583e65b0e515b8cdf87e0aa674683a822732879d25852f4ba919194f6f8aa76af8ba835569015cc0965890f4f69efba294d5d2f6a1b23e6a864f00" + "7d3283dcdfb1405890548d18839f6b7ecafe2087c5059e9d480e6161a79d6454213ca3da4653d39c269ecc909602f31fc7b3d6e7490d254baa166381281209be01", + "346269476c810294bf435f0567d1dbb397edef6e14e933215beb5cfbc07626c654e3012b5b56d218bb06ad9d384e19610824d80d618eb9c319ddfe206ba2655c01", + "1834af9a12d6a1f445441a23d320ab4f8a33b838c2055a3ba504c2e4b4e778fe5e2f7b1982f21129ed41eb20fa045f6bc0d248af77bf85830699826bf5b285d200", + "deee28aad8b2c995811b297d38ad4a27bbce26e7cd3a66e9ef69049a0336ccdb6a5d10c95b48cc561d1138b2eb21441bc83e7c02b7e759c8c270b17184d6f1e300", + "4b3657dff134d534749c5843eb3ddcccaa4f4c0cc7cc8d1916f002975dbc49d7731a595924b92d943a8c851f86ad78a017b35333302d51367b7029ab4750bcc301", + "5e045424c0cc976af4aed5c82418eb552b65f3daa5faed4ce7252e58edf6055c4ddde6b3769fbcde1daca74eb7681cc675cfbc2041d9b72094fd8dd0b87201fa01", + "9c5034280942f96a7dc805c436984a048a5f69b66c1dd1e8ebf07d9a34997a5f2f839a6bc4d6f17bf0f36fb3aab950dc9e5b62bee81bddabfc7d3aca80edf69b00", + "ffbda2b52e5f3e66b51feadecce7bfdad2fe28599233c5d458bad947f8760d11290a822629788ef521d39d7e0a7acb8b4bbfb7e69d3b45c88b98d594ba2bb84c00", + "0a21297c3a3b0ec4175428c78b656bfbae6864b4175fe02fa76cd9b353ca818a3ff3016c73ee471818f59d56112afbea170618e80eeb993d187bf7e4e608099f01", + "5edf4fb85781e57e15ac862da6bc40052edcb038a2716ddcbeaf99c6aa5e44037903672256d3d7959cc519fbfcbba47632f9c0648869844713e57dda74b87b9300" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "Vqab1WiLJNvuijFgF1MMpvBxuq6sFUCA3T", + "secret": "2c7035ee76f97882a5c42f9876dd754babbf09acb0b78e05e7dcc51abfb41487", + "public": "03e775cae88d586b8df030ca149b93a71957a0a94c7e46c1d3a73b7f3c6488bea8", "signatures": [ - "6deddb536e7e9a3e6a674590afa78fc5b4a6ed8cb9fd0feac5285b195d304bfa2ffaa76236137682226ae4f84453220e836b578d4011b2bde46f49a79eeef6e300", - "4237be8200be136136b1a67c8f62cf740f9153080197135c345f2f1d34cdb31f177425abe2d6b550e17cb27713a595bad349face8106e3861170396f7f68a4e701", - "3d7466fb759af66af847dac7f14db5fc14efa11efb41d2ea4b51b16450111b3f6de6bf8bafab17d2ebde036b398652611ebd204d5e1801eedf27807df91cd58500", - "0d3cbfcf30dc81b307992f2013b86f46c4d74557f30a63920bb0ce0e209ec5d90b7f1d367560757384ba87f833576f7225dc4f2a5d8b348b0d3d7787b8e8a42900", - "5536576a58044f31c7cf22d47e2edd5306fe2077c7c42db37c5a88da36b17f702d2a0f4979a8c9153b4856730c57d107fde50e44a8ae3a1de9f7f7fe2b8fe31f00", - "62fc84fd0ee4e5f5fb0739c2c1aed7a8ee3d140c949fa3a5d6629707a1398c8f308aa4fd14e031a64d7ebb9cda0c8aa1a5341709d2f2b8554709ef6d8123b6c500", - "ee7febc8020b83327deefe867d10c161120cc2f9693e7e1b4ef40fc90057e304751a368414a3b74cf38b77babd4b61b591528a6a156f000ac8f9b203e945ed2c00", - "d83037073c03adef283f878c20aefda68d5367b0fe437ff000447c86bb67bf4e076cb7db34794427068a59dc8c7a463aa9da86c5449f620bf340cbd8c254719200", - "4da52a412c20835901e446dd8d79f7c4aedcce5746c6972367cdf01cd25ed0cc4e518255ce488e081791d0130cca28bf323afb2c5c2277270a9b8e077a6bd7e101", - "77b881e4da1276b689bc73a339153eef56dcf8b34963a002143336cd09261f551716d6a43c12ee14ccd96c7090f9697f5353302275021f766639f50a848f1ff700" + "f33228d492945ea6ee40ca7b70161a9326f908f6153c2de82658047a0569f51f248cffb24033dbe9fffc6d7a9ec9745a3e52352ce3932a536fb6b4989506ee1101", + "e0509cdf76cd8a7dde14751190e8aa1272a04fe7635a51f454726e914c81e9a7744f189a3b62886bfbc33df0e5e56be6a16d555974955c124cea192cd0fed73000", + "7bb2e5b1162127af297a6cb76ab5979b1bef18bd309baa96e720aaf7188219ed58d0d520700c8415d4d5fbf75ad2d40960e63266d7db8a1c922940bb3770c46001", + "db6426d28e2345597df9aeb13b12a6921b4fcdd2c8017f33b98ad0a0062041072a1a270431d05a4af1a5f7e75eed79bbfe375682947e793011c31d4e1ac02bf800", + "01c403fd1157ebef2233dad324262fd6ccfcdb4a6537476acd9dff6490219fd214395056c03118f9543854822556667f1380bef6004b307683629ad0787c219a00", + "59eb6e47198963496cf86545e83375d5681031561de90e3e845d59317977a7aa4e70b08b87106f149139fce3514fbcf9d63d9da31a33c52a259b438050b86a7000", + "85e49ce059db04f9c567766831dad49aca85f1365d9a87e3b4cd3a948a42be82105b4d54cc47684c135b453e685b73e0472f42565d6f7d155937826cece3ff5000", + "f49bda680022309cb2480beaf3eb31dc88b6a17bb4f6afd00b75097ea8a17aee4594137fa0de216ae3e9b20846eee984e7cc4d5b68d9ea156ecef90bb371728400", + "93fe26c6153eb35fce04f0308ea84a36d4843f474c6afc4ab1ff8415b8274d1236f1d0b683b73b3098802d53e5ac2a0da06d9cd62de7cac8695e8d167baf15ab01", + "a65eaaceb3624a1e0ed73e5b04bd499b818e1636fa4f3145ba571e0d811a8ca42b8763f27a2a07b521fcb4c1f19e5e991127ca54692db641cfdf44d0bf39455600" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "zAvpEnXXBKqLqUuqW4SXQKKpMSPRF78Pod", + "secret": "ba66a37d7ef52c9145221b0b744afdc2a39922e512af4387fa6d109392929566", + "public": "02b2508601b986a275cde7ff449580639c8b78442ce0d87539110c5fbec4886f8e", "signatures": [ - "aa1879ecf05138833291226c71c1468d7e6192eb0ca216a6c7577adc3cf2cdf06231dacc8726981e7adb1a490f2cbbbc41c711d2fb5572ef2f8039f27538ab4101", - "fa2549a2a8b18a0838680c5f0d50b96166a2d3732e040ae1e89f97f1646ef9b92c4f8c36ebb0fd7a0c392946104de742db5df3d209f17bbb284c7896cbb9ee3401", - "13fec66808867e311ac38aaeb37b9678e74958c010b3f96bb825b8f70b4c72bb0754e961719d4510f62563b6f190e7e744866eaa5b479389ac08228dd9d9bcd800", - "2174947f4cb3331f201978f55c674656178201b77c0afcc444293438813f9fce566947ccc361dc3372da3f0c331403f83d813e9726a767069aa9396de489b8e701", - "d916fff387ae792ed11fda42f2111661c615ed30412d5105b2f834f4459dafc318d7d7701d0f80ab5619c44930c3e5f2f844ea7c1113a3c93d0cdbecacb5870e01", - "720acebee0f7f2a369b3bbae97f11f95edfea1bab19472c6e1120afee810173a133d86d44aa2f543a1334484897b62fa50cb2ad1e5b4c2265c5289b8f29a67e000", - "4c5f36600e2641e73355e64f4dc3c8c2e4fa715165df6083cefdd4d8262226ed76229dedc16e64a5b58a6de00eea2787a775e8cfb86bcb2465df203feb26c5df00", - "36cf9a5de0d3e79a16e7fb735a2d32acf09bc81ba9fb633a7e339511c5edab660777935554bc26558e56f33809d09f209798c5fb28beb21e27d41c55e618e16401", - "4dfd479c5a99b12a4b0e8d3b89fde7d4fa5a908ba11e1c46c4135abd38ab955e1bb5db21e1c112c1c189955d63840cee4a7a01e054df265d0d821a2f20bec3b601", - "fe2822c57a65199240338eafb6772640d04f6e612155d690c470dec28d95a9691aacbe4c46df71142d03ab6585b4feaba76940cfee41c0b10ed3629b6ade052001" + "8c2202d04ddc46d2fd066b440c263e00102a2c62efe4ad53bbbcfc7c119aa7a83130d56f7e7a117876a0d4285ba056ebfd2c66f8ae81272d9f0c39d0602a8cca00", + "50526c8372452645fb21a4f8b5a7cdeb4c937bc5d051beafd389911f6360514a4ec32e6d08c6227de99d7e03895385518dd5d4948b392935b7f8b69779ae1dae01", + "e4eb76d581d4f99b1904be74387ab7954b52bbd387e6f7c033083dd7024ca3c31952acb23da09ce66af2ccff81a2d59baf17cc454ad71d6bd4a109486fb4fdca01", + "84c8ec314681261c43bf9120544b9be17d2378d508ebb833a353c34216051f4d28c9713bad786d5a90b3a3b228467085dc05f4da092d6eba4c8643b0adb4e6d700", + "f46706a56fb07d67fd6cc2a4071af59863669acf2d7f1a9941f8b36bde42c47e767089a7e26eab64b5bc8a6e116044a9a5eb3eb1f2d0cb7d4f51f9e50a76ceb001", + "56e4b18df20901bfeae20cc9c9f45ad7a7a3c7d6d2506acf7571c04415308e00379fcc74cbef49823c51dad0c063f269596fa1ac434b8405cfb9d1b125b0a47500", + "0855cf0318fdc6d0c7f106630911171e7c51106e5e837df48fd117be59d92d5144d0ccba6a42791f48ba49f3388686176a2ade9f0a7d91a103b2add7ad3d682100", + "42c0522ac061f7d596462a20c5994201e1912ca4c0181ef7002570b0773181306038a5e0221b971f069599a1600d20cadaab5908d3944f885e1389b20ea16e0400", + "643bba11d65520ed42000e94d2da7800e7b595475606114d87b603c1af4276780d83db0cd39999ac96fa35cf9977ed5bc8352c2a94ea4629bb7d6ad733c73eb501", + "93b65ebc83179381e53c4010a7a63e95e2daa9ddefd4d05c342a6aa0a5891262764c21bd85cccca2a8f040a00b983836976540968e65f26ba62eaddf597d977801" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "GykRXwXiz5kjHyBsrUkHRNToHWSKEEhkAd", + "secret": "0c335f2076e58db76dde9a26dba8995028512180208c9ffc9c01928682814d91", + "public": "03a6963955bfa042116dbd4670361b989bcc0d841b96c0c402c83e7e1e23b64708", "signatures": [ - "42457b4bcf7f722dc274b9eee53af5dae94e14d3d352c6a8f7626397626f53e650a1c1476b7907d322b3a07135accdfeefa1e347e93696349d4ed1d315192f7e01", - "0248ebb82e0d7de1cd56fb5d648e19c10d77c8e2990ba4979b8be71dca969f8173ef1727bd5a4fe952cf5c424fc598ada0b8282bf4bb1b41dd8ddc6d308764f101", - "5e4c22d7d84ba3c7a2bcbdc63ed30ff73c422f6f93970fe0de7b807efbf6fd0600e961ef684036beb70176edfb96e8c8d6a9c0e0e312a6fc91159f7963d71c0801", - "0d8053a2da569c31e43b355ec2b4a12d8b6aca92dcb34a7f8f6ed68b871ca2f54b92c5c917af9faaf54bb2a4862d1602da8aca19de81227d2ff705dffd67eec201", - "4c66cf6c7dff463117f65fbfce406886fae8c266e1965fe6cdf5feed6b9034dd2a68525b63e294754265af15db52ae70d4fbe24631c7a56055a29bf68932ccc201", - "f4a9420b9fd43b6e8a7ba38ab6b231b13981b7bbecb8d6b72ac37e94f6203c884ca667e9a4ee86f4a4e5a263e17c34496be73f13b8c19b9f218fbc42dd9c99b900", - "37fdf4fef4a533d4f149b488580c5e4318ff180925c026820a3043a583de42024b4dcf0713a2bfc73185cdb2fee4cf213139724a2e70efd0d1208a667c45a3d600", - "16fe3fb857d0114569cac9b1cf6eab4da1be2257fbe6212c2b9326906e7d056e69e9cd3efbdb68c144d0e57a76f6809983a6886ec55e961d85ea0a4c73fa6be800", - "29efb2145299bfee80a0d9d38cb6f44ce14d0d5ae61291f812d83848ffffd152171e0f6d2f7df99a5dcb2d32f8c1de388ee8a28fe44776686191573db0c2dd9300", - "61d23f0478dd4c3c2d9c511cb583e763dd176628bff9d8b575c3085abb241e895bfed93ea341b1e06e5beff80f9a304007337fd82f50ef4ca410bd02525f705800" + "f9c115799f868fd84a1201021830966916a492e68a56592d5eb8dfbaad0d9c34564f420ab00996831f19db39bb94d81af763baad2d3e71f670f53e0e8003e1d301", + "a1ef2a9c00f6a4581105f586d735121f21f0236c48b1ad2d5466d392c53ad88f4bbe91493b909e48f6fa5a9ce5e7ebd93fc3c9a071bf2b760c6c771f04ed0b0601", + "394fee301cab788f7cc4af12f245a0b4765519cec1af7208409cabb06986add670f6c8641c4b40b7cd516d0283fe6c2ad872d953fb34fb9b554ac272268fb7a201", + "86493a09108cd772ed60f67ca2e5dad4c61d04e9dc24809247156400ca41e7ec31af35d01d71e24a3776673e7c825100678e9b7d060a7b5b5013160ac4f0a10e00", + "aefdfecc52c33f074351c497ffd2508d0bdb651f7b5745bdd98ae384c266f993336b6bd67d575d749db3c54bb2dad5d977958840309b954e3586e5b01fcb7b0701", + "3b032eb1fd883530a7d8f4fafd023f83da857f8c4381c1d0a055b8ffd1a3ad8b5554a1a295d188cca6ad6ab1ef9964610ea53d92cb868fc83b46a12206c70a8c01", + "e59f70fbfb3b23e75e290a0569f323ed6c82e721ba7b268b75b5833dbb3c739f4ee0d92593ccba21970fadae8904ce4e95e6edc6429377229b74f6bec34ec77201", + "b3936090c63f04f6a52720a102f1dc5ee26123758637b98e23c01dcee3d6f280266963e980439eb9bcdae68095fa5cb1d8bda02a1440be90a5e597f8c426bdb600", + "09cbc77d194f64d03a3ef27cc4716241f815e8b3b46e5ad4fa68277c5d8d1ecd72bdb8576be4e325fcbbc67aec516de0aead8f871ab9087ac53a39bf6f9db26601", + "704365c292a1d934d26956584bbe34ac0db54cf5b03ce3f9b1367805cd488ff830f0e2fe34727e8c7409fae6bd4878e10ae2b452fdf15c9a423afc79e653ea2801" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "aZ9jLZm6MWpy6kF3kpjJTNo2eo4oLbeeXx", + "secret": "ecaef882b218b8e182f17883ed7462b4120064f26d5c7880a596e9f8bd0cff52", + "public": "0268e2cc53ec1d81dc64731495428a98db2331e9eab7ff899251931662ddd6c12b", "signatures": [ - "00e25dfdd5178cdfbd064b19d1b6e873eb4bbdcc327b4be4660259bd3b92987d21df2bf1e2bd3e4a09e94d551e13d33ac61d74650127a93c88baeb9e71499e4c00", - "a320ff846eb7e0703829d759907e22996e9ee83ca04a975383930d96622c16606a75abbe251a0b5a7717178ced97eedb1c9b49d3f6b5fe063aa061b8e4622bfa00", - "6e53a41155efff377d449b7037c262b9ede26fc509c340d3c9da28d457203a346c81237590103f1b16632273e748243ac9738f1dc1ee60cc2feceacf1832821301", - "5624e17fdc8cc5bf9df80cfe8852205c9a4bfe6ce490046fa5ee5b29879da2604b14ddc0ae12f3516e75423990775b463e63556fd5621268c976b3e77c766cf700", - "8d29a9266c1504d4a486a2a3f4639b506491c21605f028442d336c2584e731eb06795a2a8024e2c922ebd54c06c86506a1e31cdcda3682a9ff7bb8a967144ef700", - "e8d7a7e617f13695390d2c7a346f92daf1c1c471f3c15de17c3ab432865debc278ff2ce6cc52dfe20f58b0d3795255912264bf19dc1d4d1e1613b7c77f9ea27f01", - "4f0170517a4f6fde60b3ed2ffe7e98e05a98f4bdcdf3663ed74c3d05efc8ddf074f05b9a6398d239ce00bc6eb5e3a180255cfe9e97eceae499d947188d391c9800", - "6138c0999ed6e76a8d97393c96eab77b23bc08a9d1deeb89401b8c9da580ca372f44bc72b5acd2d5065d9deb83b948ea5a83c414478ed3add29b7643bb74549d00", - "37a60f776427ed5adad022f9aab06659b6b6cabff52da3e4739f320ac8ce479e0a0f7df1cb10f4653ac615637328ec7993874ea4b14ab2954ae47a6bdcc9ab9201", - "2595ddbee02b5d9557e1776c18f4c059695fe04d07cf601be4fa452e719a855836bb9dedf6a150fbb23a3feb62ff0435ad6868b497173666dc90199be29ddbd701" + "b56be8c206b65c96cb8e0d174b289dc0f78d3d1657edf35eb2dbeae0260a89b96e7bd8847e206129348e0ab303f2a7f331d34fbe81d11b85aa02a6c0e9d3ee0200", + "b4bc4d5be6e24a0fb415c211f4420dc92729f0a1085126342d04fceead2ac7c1699542e02aef4e7a5b8426915a1a68beb1687669344256ac899e5332066a455201", + "4f037576467400a8b68bed9f47deac9956a1a6eb353677f10e21b5a424b2a0656efc0a949f9c0b125dc1c1208c80e708c5ab29eafdf97dd40f26172decd1726601", + "2365b10f2be2fdde0b7831bf3f9aa24fadcdf4713a6efb422a6790e353dd71c74d813e137da07a6f9e1ca515b10abfc316ba280eea0eb8d1645fbaba20c2e81800", + "cadf2560137316bb8827417e8ee322644cad64c4c1ec9aac63967f4a5ac0ae7971f5260c83d792c044332f07da13a0d573c9905f588b607486ffb00755a94f2600", + "a16edacc86031c008d0b5cba9365ca9c39ae724d030fa288d11726adf59e7e3f4060155ffea336028d03ccd08393dc27b427121fb5b63fba892171aa0d00920601", + "e85d863e3e5b30e31ca57c511614f6a53794a48a16197d2a504f6b4347e8417f73b2d1367988d687568f8b413c4d3b854daac8df95a64c22153b76e7ac03123201", + "a98e2e0361339e11417f4d8d45585e8fb3a517735793b2c4dcb7d06838ef80fc06706b99f91dbfdc7568ef720d9915169e63003b435c2e2d03557c90baca319e01", + "f2b62c93fb7d36e0bb6152ea57b7eb158fb93984f12fc7eba7151a8a4ebfeec902f2c2205a910c79288063e3b73896429f162cc253360f50aabe4372d81badff00", + "3d99597f0d9f53dbd009640fde0e7c44ff567babeb4d5eb54b7f00f50c337bc92155b9342cd817fff6291d70e614681b3d890a1249debd89a6d3e14e6641e2fc00" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "2mLzdkpXtaLWvFuVvzNgZFcQgBnd2Nz6wEh", + "secret": "d35734c6a9df59900f8fac59396a1e1e735eb0c43443bba39ff814c9f91abd4e", + "public": "0272b067783e0ae0660364318bf3b408b12c105f6f75ad6da46bd88131f8cee2fb", "signatures": [ - "f61a2f5d15fb6339528db90e50c17b63f3104ebf8fc4b152a9ac40c841fdfcd10258dc93cedf1704a0143e9511d944ef1a9928e88d5937be171a0b1da7fcf41500", - "b8d737865ce43444a3d3636e9d520e9360bef79529ef802b2f350fc0ff0ba55e14c9926bf35e31e96b6ac4f309e1827b9cee6ff4a58fbe504fedea367682bcde00", - "a50bc8e332a0e355e46efd5929ec2c54e02599cd5ea5d64543ad02927894a5c02d6b5e3babef329049675c7eef3cfd9ef6bdfe7127ce6912cb94f5d7bead0c1d01", - "dfbc6be1e1e692355cb98eace57f659aeea00fc9c400a84adcd1179cbc7829b52940a19121e77718621b84b159e745b63399d42446b3d8315dc7385e78aa94f601", - "24596a2e87a5d40a9f5855afbca21bb98841533cd12473c6b7370b0be34399682bcca3822fbb3d8a3f4beca3b33c172baf781c5622d03b1c795d0d620697372e01", - "ca7e7e28d92c43ee113bf4edacf67b6a78fb249753e3dda5822b68ef52683d382bd6503aab4c6957c55126667448bbf690a8cd9179086d39e7a4a8262b4174dc01", - "bb6aeb2ca029b1bd44e8d54970756f3be714b6d9d6d9d0bb141c64dff912eb46158dbc2b53c8d40f5130bcbc924c49babaa37993d716037c887c16939ee0c00100", - "99fcc4d15ec951b06c8369ceae1dc1637d9de4355bdd391a71c367d352b363ab58287429382e8bf28ac15e62cce52dc5638eff527732d36e7d14b97dd09a8b9401", - "9191806ff03b3c998e5ea529c7f15156dcedecc88e99dfa3cf2c1e146d6bd89b255f56a763880fdccb1b127be48e5e01e35f0f04629f52b6125367e9ad49ac6f00", - "088a911b9a3ee1900225c18c6eecc15b9302164dac6b1b10d1312720df2d8cbf0a696bdf23b0adfd9fdba243ac9355eff9040974793fb9f8b52b1d11cae0ee9401" + "ab9ea96f4f3638fdf6b5166d7c971b7e5aa71c042704ffb4c21657ef29cad87e2ec2c8b1d220ac68f40efbc7f9236bfb28c02762d52bf1b5677a7063682cacf600", + "e16e160405c0b410d1037fc217b32e2fcf626a27a5f50ee003065a8059bd40757e18a5f1d469009458725b936ba581a99af1183838fe7b0b3931cab941814cfb01", + "80c491a4668da1a22eb4eae950c1456a07919286656e327c0b9190c7004922ad50bb59de0620ef381cf1c10515b2f31d2850650ee65d3cf60fe44276bc7ce04f01", + "3d3f547e2644e3b8c49dc5a54882100bdb499879017f51949cf4bb8ccba9591040b1036483de48b27aba1bb7f8d73ac90a96fe787dddd233ee5406d3d8fcb4f600", + "72ccf7ebdef8e297db0a7348ff83bf6149e50daa24a29e38dd2c5f0d8ddd689f58034fcf8eafe64eacaba243dda0bfcc498743521f569301c9b19f95ea71d9ca01", + "b7347269ce29185b3ac9bf94f623307108dde70145978005d09c396d0739682028a3bbf0460eb7c848f3fd1648af5e90611e42b49901c40aa22e4f73bec0290b01", + "3658c5490f32f423ccdd10fbdb2c5ce674424c8635c1236ed88a37732f253d6212656ed16c70fbb31e9980f27ebbd34400a424d2110baf67c348c167033c7a0400", + "a4111d9b5b8ab7bbca90adb0b4c93faa45fcb03b717a6f11ac485b64ab3b0da505e2b749d971c700eafafea370c9feb66a1385943515950291fb3253b255505300", + "34e8c561770c77c2aa14f6955a1f5acfb29b7fd9ae846bb537c50f02833a35d656a8146517cb3312577a751f8fa1d3a1d48377a9ae6f3fec5fff3806f335fe3900", + "ed91dc06187be3c4688ffb6da8fe16392daf976dcc965faa4dad753a46cf2da476db8956787d98cac6af62665be2f31a9556b76d1cf4684127f90502d9a4ffd301" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "2QDx8n4AqA2Zg6BjHPbvKa6jjTqn8GuvDmN", + "secret": "d65af2ad4afa373ec16c002605d384c6dacc8e6f5b803eef066626f518eee964", + "public": "034591c117b23c0125cc41e78d887fb64d3ca4f4ba6c14ba9e5a03380114096ccf", "signatures": [ - "8fa13f4a1292fa8e0e5cb4475edcec5d0a4e8e7098d39a13041fa989483254070fff891a7a7d89db51ca704a06631bb899a6bfac3d21b25e10f9f8c60114e82500", - "988467b10ab3ef193149e67adb014447ec75a422d2e091620102d4fad7c271b0054062692ba1e7df65721c3824bd9f31295b6df46a0e0d9bd9199c7ad3a9f72000", - "c2497b5b39bfab4d6e06c97a3fcbeb200a3e29677f3b12fd2066b2c6114e32e51c275fb504ad463f04fb402842877102b56ee13be9eff23dd7a00f79b56edd0b00", - "f8dba6ee65167de3fb4faedbace3f95b25b4de8c01f4f9f21be2af4e5c6a31115e005f0951046d3d1863395de2d698bd3e9de6a79be3c30ed3bf90fc56d510ff01", - "7f09ea2e5c1750aa8ad816287921916d49bdd08e489f97937972a1b8247fca8b646405a20c1294884acbc50173f4e2c886505e855e3d765d0de0622bf044a43201", - "4bfcd30ef0b754342ac4b1628b5c1a7a7dd29ee55362d71d8a1a4d12d1d99a521205875426fb16ebd7b7d9b956f4ab8e1e214af23eb4ef071d50296d30dd6fb901", - "b59bf66c55f439c7858b22004bf48161073b468273987a7bed7e3e6f773816164ee3766877a57c4434c7a871dc3706242d8b5a07854b9b9bc0886bf4b3f6b25000", - "082044d81177dc921c8c0e7cd735f65d679904c31bb3134f80dfc77289f1c9a909d4626cdbb6b7cc7772305ccb91b7a74c975b3aba812e2ec748bc6cf3117a5a01", - "0429e651ad66cafaa6e02e4f1ba93070d82cc02d97fb7c898b655ed2cb1eb28c1216a13546f5c9c028a2ad8d7cfd05e302ca6154a85da3ad0e595ed0048030cc00", - "7355b134c1317be1b9bc7ac1c357e55d5f0d72ddbdacea06ae49320526ca9d2e1985740bf61179dc2d1cfe70cca1bcdc60514885a18f7fc26ee8078dc5d8c3b801" + "0b4418424dc07e0ef668f9363ca9e069946c8f5f2e0e733177fc37ef9e9a0b17626fbc899ced973cd2b2794b9980bfe8004c5bd5f9f8e7545fbcf3d45387844600", + "18889e1bc48c7ec850fedb15d991145607c097c061c78eb8a88b709b01b7a996479f55f3ed9e44c8e48551d56e2292011e5e2af8820bd48e43a0a572dfd2197801", + "45e65bd3a99910aa5cde9d482bfb5ce61b138b8d3f0269b7d892e5975bea8c9b7ac6b85541000f75f7eb0998161357fb7cc54fbaee11436fbaffe77ccd0f0b7201", + "ec56ea2c59898f2885313db13dc7386d7d7339968139190905c0c8f6c1b93dc868b03b12f19efa0de748beda1727c9e7d2ad5b5f7121a4d77c38e675c70fcd6600", + "893f74090ec8b968a3576e22280c946f75fb59b6bc8b32c1f5b74485f1d555ca050285b91ee0ed5a3d3e997a7c9c2f3e680092025065f5047631de41e8b7359400", + "018748f5470e0ba9560ac9b284265fd93a7e65284cbde89cb8bd17c7bb570cc94ba0084159d0046769f2172152e53652e29c176fec65f03d8f319c1187530d1600", + "8abe93c4ad0a2860274a38adf092dde1e49ca71501840d66f1b3f515e99ba6b05f231a7fae44eaf376030f1727a0bd60d7623573b85198e6a4d995b84d89c8bb01", + "7767f6d6810a2026620886014d9197e67f73bc091b6c1356eca1eac80300f0a6080d8dbeb24785d1a53ee87612d833001b7f0368ed9699c559c7443c3148a95700", + "9740dce7801a4845fa194ad13ceab4179441f2cd708797ef1c1720bec9039d1a7adfc34098b756dfee4b02356ff86160322afc29ee603ba4a8091108ff4c619501", + "e75ac790094525f7eff99f14d92e7ec035b0134442f1ef55c6ded7af74d42a6c6f689e9fcbf2d9b3de722f9e1415e5c7dce756946e8ae8174a0866c22b8d9a8f01" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "nSXnnQA2aaLHdzg9LXgyoY1bkRYyoJcPNK", + "secret": "3a6d13f46da4a800ef8c2e350f48e53cb601efca9c1af27f0650065d9334583b", + "public": "03865c2b491360dfe2afe6e918261b9e909cd87e53b61afa3edf4fcf47bc4f9d51", "signatures": [ - "69622112fde9db50d35144a8da1f1cd0ae223523fc1b3e90e2d6de1bb7f80ea42e3379fa5fc0b430bf1f88dea6c0c8bdb7b1078c22e70eb190a2ac150cfeab1000", - "d55801021b0977a8986e813cb2aa6f6a5e818ac4c9b496bf418fdf4862d1bbe826f787b9aa01b66d141dc1cb0a1db8c5349309fdb75f46a4aee34a19a56c80c401", - "a3c485a0f0f799f75b502c51fa1056ec95104ab12006eb6ed92ba2847f23d99c26e4330b0477ae294b2e9589afbebf4e02bfd033c64130af8a62aadd8c97cc1e00", - "ca40d686dba17e9f4eddbe9808ce09ce5a15bc79244193a4eea29a4d7a2323be374c99315a223cb328f31d478f3c2f4717604ba7a91261c93b10cb05a879965c00", - "9f05926e36e14dcc514f8381a3121c50747dfc6e42ea74075d88e6aa1556e21e31dbe4e6915899067c033531bb041f5981c4867f01ef6662b920afafcf24f9bc00", - "3f6a95a98b642c434a692f5a44540d7fd191c1b95b6116c0ec9cbc9223c462f84b3d1db2e952c4419316f393f3dd0aa6039ce6dc804664543446e7631e525a6201", - "6a47b677b93f2c70d2ae09688dd537f657b62dffbc86848ccc4a973136efb8a01216a84d070cfa233987ffd96cbbdb845f695322e649442981e5b9885b51b91501", - "5f92a0bf44108e127d755fcdd2faae9236070edb5f95213a173f315c9e9323d74d53a6d219ade46c1fd5df2d587bd54332d9b984eff52674c487792cf962e4c001", - "0aa0309a18c1d8fa11ba59529f5441e3cebdcd2349d141408148b27d84ec572456b0d49179f11fbbde5b4e6a268fc52a6c229f36aa9629878773f0ccb358cea301", - "757424c8b0643a29e5ec51c33d44ec05c8b0340899cad5fe5d503d41afd4bfc2308ccd9c6a1a3e64343ff4ee04dc5de27c5bd020409d457be6c41e2cce3dedee00" + "1d9ff908a3bbd7416efc2a9ad50ef9a3b7db795857755c79ce0457360812116f516960d1c6f97d1d8d0ac3ea2975cf2f4ffa0d08b1d35224ae9799e91b04fc2a01", + "957ae4c1a90e1465564112a513597c3bd6c8a1e341f682b8a251a0c6272e9f562a0d3d81665425e7f710fc3d20a9f8a4a28b6badd63c92922b1933fda2d8376b00", + "d791eda6f4548bb24fe5f0b1eddae7db453156187a10538fcd837fc63dc189f40359ed7cadd04c6dc65946488149854e4cb5baed743ddfd1c49247e7305d9fcb01", + "7188ed823f256af8a430f9c6e56769c3455b093fc649bfe6e779a97219b9d3673dbd5748cc3bfb8097708f997baf7b901290ba0daef661369738a5f7794e72cb00", + "5b5bd1b9b1ac663480cc4f1652151aa0a27d456392dbd7fa5c1077f14c523d200b9c677b150e4a03f68c363c987495b05cc7dbc1498f9347dd7e7b1c598f1c0b00", + "1d9535097480035b32e949d5b678ab1bc0a40f998eab8f411d8917232ac58af0022d32d709431a693639926e36ef70dcbdba6841bf8a6edf007d4b2b339b02bd00", + "f99830f86e5f4c812104bc7f7d4b0f2dea4e1afc0cc338e93f378cd82f044d4f2647771d665af37c3b83fa4ad153516a120f6177cad4c6b151bb7fbe057432b801", + "d28e2d7aa2964f048b262c9bcbb9a462196d81ffd491b36700cf1ebdcbe51a6104a97beff3265896731d03e7f98239358c14235e2480d10665573e838b6e6db000", + "97ed4c87a77ef0bd231debfe414bf1335e74be8a1d56dfc5fe7d8f611246506f1e7c6aa6395f2a0e31547d71e766358ab048581678d83b2ee2362b3e52ef7c3c01", + "d6717596c6f62d6430c475a46f6ae0e062cd667c1bbbee66cb448daef72e6ef1093011f7e398488b280ac763f3b11b93b2d643380d1e0514dbaac2d6293271c700" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "25qo9WDafW5bL8J1rrfDo3zAFFmUbWM545B", + "secret": "03a71adfe4f3a34087b6b0f303f0678b218b386c3d129a8366f9fd40e11c1050", + "public": "03d5b421cffd4fa34d0aa36716d7b5f34c78ec362f6b2396d1104c490ecce196d0", "signatures": [ - "444f925ef52967524dea8b64124a9759e32ab087e8f2191facad3dbc2b44d1af72c013ba301d211453d3e8b0f29468fa88a9b3fee44db752a8773530ce2a9f9100", - "f89b42b37024f1006f00d3068f88807a795f48f170fefa7676199f4fb69892ac51eb180fd1e29bf04e584f03f8af486ca1da1a0fc6f3596fde4ed8d34bb2dff600", - "2b91c3febd769648ff6b3673eb0c316ef43fea272cb52021043d45695eac9bdf0e716a96618382e0437e1cc2091bf51ba5833b9b184c98b8432b3355ce7c4a0c00", - "386fa2d3b3fadcfd10479932acb498d82226c0162f6d44e38d7fbef6854145d109aee91421f3d23c11268f5d6e55020b45f2b392ef0a4380e10cfdca35c246dc01", - "b32cc46fd773012d0b7eb4f29402eba7323e03948c4e24f74a7c27ad1b1c24354e6b38bf46f36ea3f9f2251e166f174869a5e08178a00b6454c377268919458f00", - "091aad4f576a79c9b801cda59f5394400fb1901f5632c60da561a5472ae4c07f7fb2d93d4654254eb38d7867573c591a1490adb6b9501cdb1f38417f59b326ec01", - "e6e6d68dfce9c1612597f0ae2ea19143b5177f27c0372ce44c7d2b31773e585e6b03dfd95d48ad003a60a733d861cbb1e12fac3249aeeed650ccd6b4fd9cf10e00", - "401ffdb9886729a143984af51bf07799ab6cf58a5399179875208d64448e306c1a78b1c16430aeb6812e5fb3d2efe92b8dbf70ea3d9bed74778bbe14060090c701", - "a22a8f893c3ccc1370a377f74fd6b601745c836680a95be6a760dcc899695015521535e73c6f6bf192100407671de60e271d3c63a6cec92b862ea053d756abc201", - "1cc1b20283d27fb01e737731a9424d9d38a0db18424d480c4169230402f3130a4bf476c3a4b82a595347190618a4c8d2e934c52f3b58f044d651f30b3f00e55900" + "2aea2918de643baa9bec04ea49f9c3bb7858b09e7d0a2dfa8ac718367951ebfe6e3825f4a5aa08f3a8ce3ac1fd021aa8dbd68f2b05ed18746a53d70cdcadb26400", + "c0475aa5ee4dc3d3264703195a145beb28731516684194fee43c9538444079670f30eb13522ad7ef654deed6a7a6a818f38d79219bdf6138461d43d8ede9aef901", + "7ac1e3195f1ef8b99084f2d97250b8dba8cd55148807f8d3437406e252938f1d78d86fa5f9b6949942ef4579fdb0a8dcbbf3cc37cbcecf51605ec4aa2922cf2500", + "af2afcacc960b2d12395e1de8668a456eb2526b250e5942db785fdf3a0b055d56015c367ed6de7efd680eeddc1a8f789ae787eda887b23a7e4f6c2f7575f10b000", + "4b9ab114829349ba27e34152b51f9d3c83198673a354a949934399088508d3d014baac7e910c367627e37a1544bab8ce1661600be92c346463497e6965551a9000", + "7e5c5d8f8f27d2c1461b6653089e7727c7a0f630ebe5012d07d75979095658ae0b5c679b3daa5ae34a528993d6c9f60319668f36e583bf607782766adc7d9fc400", + "ccd7e23d4de2f095d77d08b6e34e134521c5aeab84c9ae78c427cbdb0f72c310261444cf20d21ab84ac2ee6472b8163204323b5108adc59c6c01e72fdab6eb8100", + "f7eb4299d5b9fdecc1ea7b366b1d82713322d15390c057953d6b42ac76d0bacb36d9f3c5568bf2f5c6372d4f0fbcd630588f3c27c2309e1da4e02a09d4d6ce4201", + "384b61a3719213b153ca45d788c34738860c6353d6d15751225ae3d6dc35bc192c0189edd24f96f95898a29164291c047a1d11099d397600820e171dd813b94201", + "9392c342570352667d1d6ed8c1a8438bd8caae455e9901194f788c4fc653e04f43d328453c9818c0a1b009767e36a630ef9453a51b4aab4de80581a78119212000" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "2U9tv3pcptMson7aVDj7epyVhuJBQkSTA8W", + "secret": "a7832a68c6f1ce353b341c78661ec2e39291a3d02676a7804c04eae2a638a68b", + "public": "035bbcfedafcabc3f0bd26f3af4e9046d01e96e6d596e751e2a3922815f586d70e", "signatures": [ - "b80e3cb08a152dda4a849da60ab2ef2e0b527ff8fea692cca3fed80a12d2706e0827b8a2e720cc50d7127d4151dee9be6434ff70d8a8a937a0e6f4ffdfa99bd200", - "d83b08939ea56992cd7610917785f61c411b4f5a419e3b570c412913567b048b4a9365bdc0af36fc2e54f0e3a1230f050ba4b830f650b0ad7bcbe1ab4191571001", - "efc3cc277e5da791908befd42cc106cce3d6cce991f72e588c6f871b999ad65c3d66e8861df153cbe06bdb584926c66e940f6d57923d4fc75cc25378e66756fc01", - "15bd17e609bb338a2414396de947f17d08fc54e352350d85af91bf3f0fa36a7e5384949cd7da102e06a8218c8e19c1c91a6c32c36388c15317fdc220a132339300", - "0f730a146fe431cc50b2042aba249e8970170a033707d50559bdceeeca1eff032cf3a9d5a237793015097430147e9ee5d5052d123be0511f5f6fa30f6bb6127b01", - "8b9598a43ebb27227c4aa1507977f8a6fd885cbe261959fbacc323dbafcf6e4c10e88aef46e63b9d34484cff6a1ddfd3542304e5fb0c8aa1327721dd372075f601", - "d98671443c91fa1b8fd87b7f2317db3ea4e1bd5ed65fd1bb5ff345426db8e12122af75d8537f15a14317aba13f087b8030a297db6195ada078dfb78851e0bb8a00", - "88176da5c3a411ff8f13a63ebab0c9807a7daf5b2b2f9e2c584c4f7bad1ed3e67051d3097be4d9650eabcdbf597803c95d98e34d2b587a955177b4b9a88834b201", - "1281c43529b2403d7e151e1d5b2c93ac5ad7cf1dfdd66b05ad72c9b209cb1f1f5c99135d8569c6100ccdafe68d53d5286cb9950d45ea965769ef327521e0ed9300", - "0fe67c8cfca79d780c2cd769e49f8fd870bee59aaf3ca152b76ce4f769c061c97b525dd698a95290d8eedd2b0d6176a10cf48677bfde5462072abe06cfc9986d00" + "d0857d3237ec891c839269dafd3df42be1e8429765673bcde990d2e760f827b9189da08b0037bd8a0423bc541798925a4396b79688cf9e329cf42881aff93d1a00", + "bd143fbef42414fc7520308c6492dde2fe442b19deb2d2c8412626c0f07526292ad3bca282cda727915408e14da782d3bff8047eec4011363a8db4ad562cba5700", + "4893755c3b2c465c3a503465a0cfc7828169fcdd52139f042ce4799dc9d0a4003cb4e40c271de767fc8df0a6f93745a591fc2dc13f6b17a12c95473c1042857a00", + "62f03a6284039b98acac22c0d64447ffd65be2101b22d104eb098e4a065d995d157226a117a6d34a2e2a053dc199b41a6e23074a8a700554c76fa45ffa4a1b8b00", + "99d7cc90fb119c8b722c0582bc097b5bb260b0a871c9c05439dad466d1c970f112cb4311efe7753d44e91dc0162c3d2befca32848767fa642b50725e02e02b1501", + "de62021fa95a4c90a5cee0b902d03119bb801ef99a6c575577b32f432be9da047e8b2a7e32e9910116219bf1c41dfafddf38f99ddeedd01ed1bed9853779e7e800", + "dfed34d6c672783dd664ec8f4444467b1e15c2e3aaefb21804545fb47398c3d3728c86c27e1507d6b14bf3c5f952d7a308f0fb5e5cb947dd0971cf37440086c700", + "4d410ada413d3af780693aab75d8280da0d9af542875f8b71f50ee194cf9829a33e23686760fb9a07f3bb37af99b1c97709c124b15c0fa89ec3f9709a1439fe801", + "a5ddc28a3ee448ca1cf28ea8ac3991ce2f1fe562d52c8a7634d58871744253f2132e8bc1e7c13a370429eefa26c6956c19cb548d5e4e663e47dca12fedd16a2300", + "3da1a98584f6ed35cbf918d514fcd5074157d91b99d84ee1267b10d40fe0d34b42d552f8ea1d09b44de9e32fc2339d1d784046d834c790c471fcb9249d4030a500" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0002.golden b/src/cipher/testsuite/testdata/seed-0002.golden index dd3a89624b..585fb02539 100644 --- a/src/cipher/testsuite/testdata/seed-0002.golden +++ b/src/cipher/testsuite/testdata/seed-0002.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "jvgFL+YrrDSJWjeXY3tJo3dek4BbeV+UzrMZ3yir9Sg=", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "JQCEabhVC6ZbsgxbmA5MHTzhifUbX2PUPR", + "secret": "e7c807f67e53438daeafd79a7c52ffeb8d80bf5eec00f281515e7c1d7ceadd13", + "public": "02661206c9ce3649dc890e58e24763dd1f102e7312cf778bf15c0838a589736c7a", "signatures": [ - "ef9d3dbbba250f9f93958c58c0f639422aad7ac6376e5aabba7e31f4f5c5d9b0234677ab12e5e366a5ffc34a2e3bfdea5b34ea29970f89ca10599164784b1d3400", - "6cbafc097f4f4f2c0933e31460f77c472bde70b1d86522d8c6d0698bec86ea1f71032c807dc7753d2bb90a620d01b0598903d001e212c57bde05cb637a86f56f01", - "8fbb1daba50de2532afc45b219e3b865e1066ed322acc1ba282c7d89b6ec2e0c50b381eb9b0ad1c2eeb063513ea58bb0c3caf2472a0c0ca6a11e0bd39e4b8cec00", - "5b10e7a02fb90b36661d1a396fec3197cfb42c2653bea7d852a1a2ac301d6b2e71a740413d1410239a336cc9c3c4fb560a1d5e2e213fea0c1f1ca403417e457f01", - "84c8cf131af502ef630b9dfc7584baddc20d698fd48bedc5bd8bde6868d0187c716d39bfcd3d990a85b2302243c50b4b153e3da56c3b52d33d1802b393f47f1c01", - "57c6bcd37d1173de9fb620df62c867be22c111c9611d2fa92709dc2249449eab060d4fa36bb455ccdeb2053eb927876946f9021146a51c7e61d000fdf23b7b9000", - "ae8a960d4447820a78073824c27c12fd783f4309f41aecdcb332f083c6387f3562985764923112935776c1ed12078e1fdb15f1ab6b092d42dc24f441cae948d700", - "f5d7ca6e40efa10104a2ae9329649ff807b315d79a04d3db406fdcb278d298e861bfc414cad44a0869017032c768513989afcf2d49cf62b592173ba4cd92d07100", - "23e5c063a06198e83192a0378e87fba69aaf495dacb9bb0eb4adf55ec6fde95c743cdb06750752c722e3ccde043038025eb725c32e3066888c7a9b8d49731bbe00", - "888d42b28bdd78470c11d0eb07b6b3b97aea2132d231a377ef8f5385b14284b23a173e93788ffb85509f76a820e4990e75f92bb4e354f0e97906d9e45dfe5dfd01" + "c8d3fdfa608b495c14fd0b47d6f8408a083986ddb58336082f1b0b2aad32aaeb27954f329267c4f2387104f80451a6abf237f40b5e93dbdddf39262fc35cc07e01", + "411f4b6179671d9d13233d9dc9ae4c41982b1e7ee5beeb7389435f8351ae1dcf31d2fed790a49d66cc74c714792d2029a75dea964dc2737428efdba056b4a7f001", + "87ab0f994df1c137ef4b0cdeb657630509eedab2f3fa390de2d8ef51f605743522119933f6751f446975616a95577398e7b0c44ab997634f716bbabcea9793c300", + "77714367c993faaf9162c73cff53f78a0f2bfe6be96b71d28ef2680cab54145047f69c6b592da393aa48891f87fdc261e0dbef1ef718fc0fac80cd11b4d9089200", + "1ee6bf3930d3220d2338a50e66c0e8192bfb98d8ab19e2bab7d0fca6aaf553d95e3f4dd3063d0a6ebf1f9d34a8a0f42c69c2050ff9174ec5a93269e7d6d4c20801", + "026c0be15dc3c74994c403ded0ec0b62982a4916f6cf7acbe644f1205b5cefbb1353ded02926f8450274ae95c89892032d23fb6a03ce192ee0a4408af42332e401", + "4739117ae45320d82e2e1b41ae3f60898e9bc0258d1d7b3f90de521db1ed8e9c67e4d9ee8b5d9ccbb1e5ca76d4cc3caa7bd1dc5fe343a4792b26ff29f0d894d301", + "1c367647b6f9f5da5b1d1ebe3ca06028cc285037c3df4d52c95c832280312e9833e65fadb77fff05e5d649ca5a65b57ed33135d5e190186f376eab30c195b2f901", + "21437ae018a00fc75f3ff8ecc69055fa20f320786bfc87e5a3dfd50767f5e64a392ff9dfdbfee7b28b25bfd043e98932ae3c2019e62bebc5ee09ce0385944a0100", + "93232ce00bc5f85f28cd93237be83f861f1fdae74d53c2ad024d4036420178bb1f6df282a829ca5b7361ea348d188ca88c537878644f8e1ccf3bef0e64536d2100" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2xYA6Ty5ngQSGxUxLarPiVpGexTWa7kmZ4", + "secret": "cb09609a37b47ab42e522acc616a8276488b255b07c7d592a03de5fc19bd3ad4", + "public": "02be247f8c246ec549cd378ce34bcbfda52a59bb2cffc92cacc26877c2d0d4e06d", "signatures": [ - "ae8260e3022832c9c34210c7678c60bbab3f13a32c8d4e8b0b7764724e832ea3555f4317e1ba5eb303d095b43d98778abc66c52480f2270b87cfb8b7b75f8a6f00", - "7e41c4e13f67d35cd3d3757e4bdbba822787fe2a592c701afc33fa0b86d74cbb000e4eb258078a29d2de1485751d361bb0fccc31501f4bf8041bada9d7e6cc3d00", - "18bf0cc1b89f5f1279efeb01c9f9868bce2531760c64fb8d8aac66e59e019b2959892f16f89e858df6f7268222d7bee2b6d5f43faf2deae63579f2d7cd4a10da00", - "d12537e09d1a7411569d0ee60ff6758230b9bd7110085dc9b47792aa3516f6eb7298fbd769407494fb2ea42819a85b3f4087940323270dbc5635cec9b922c84200", - "6200f390bd8f501c74148fc1f37838f5c640a8115b595aa5101d4a7f5a18bfe435b98cee3ace0350ab57733a7d27375b9ab5cb499a25129af52a28df46f72db700", - "f91d4c7b92fcf948a80496f527a9080e5c1b6d63261178cfc0327f05631a6b8c4420398467e8f613edf357cad140eb25304cb9d7eec5b8d412799eb01859770401", - "996c22de4b7ff12a53da2bbb4c11e41122e695b913503f0c72ef75b85c8f9bb21cd9d2a34a90d491c76d65f57227e850bdfa086deb6496a8cc1b3eb20b8e988e01", - "fe4b23f3cfa79c91802febea7624f1b4b430f7347e78ebd3358d8e7986490452164b89b9a6360690e9e1ed4e6bd593096a0bff7e2c50477a8e88a833e2c63bd501", - "bd029c6b36ff684aaa3dfec7f10354966c874792d8afca5cd44d7bf3b4b2884347449ce4e26b9db5d83cc34780729a7e6a309a5700fdff07a0f44287961400e001", - "ccce0b33f35a7a63666efc784442c9541985ca9a71afbddfea543a176046c6454af95fd001d03284b64cce911af59490ecac3fc79959c3bcc91f7d97f4ffe87000" + "b218b9da47c96150d6477b44c656ab5bd4e3098f0a36cc37aee30d327e4bc1d37dde4dd8a4167d0fb54dae0b56fd7d7a7aaf7f7671898b81ed0958e4f51bcc0b01", + "3efdb6bd6b772dc8039ea5ce52c9d4714a3b075463180b5a45598523da21a7b32fc6e730a2b7cd48b7e3fb04f61bc8acf07ed6b97922dd3600a837a6d6ef601301", + "fce5664c0d550e19256dd04eb20ba1ae255a855702c7cbfc22576b9057ec32875953066bb020030eaa9a8c7856cb8c2c58c6a3e4cd2dcd7895de8f6bcd5157e801", + "95fe28da7561ddccc725d2fb3aa540bcc8e4571c60b0e744f0ada9db5ec772885a0efc8de1dbee4d347b1caf601f37d8d74a075a6dc290f4960cf70c8370563401", + "b70a88c6c2a2c76df89b481f3546e2a7ca08882f70447043313156a2d5b90e8d0de40c0c27e5dbc565d6148247582b6b05410d9d69998ed4332811436c7b458101", + "fb0f74606f4e239fb7134c6bf3d91cf3a2b76c4cdb08d4c8189c6b457b0663cb7272c6673c93d94e4d7cf94bbbf3af983f541b46a3598a0efe60bfa2fea4508b01", + "3c627b20e0298231599e59d4c803b8a49bab9baba4f45a49d616d4cd06660ffb1c2b60189845cf79546322b22396f613314807e034163e66d47318b9d0d35be501", + "4363cd2d43a6c23df3304023887d7a4d291645c425aaa1afadaf96f1c1ab51b709c054741e5ae7837de4238d0587634c2e189eeb0f01f6bec00cf273a9028c0b01", + "71448bee0563d244d32a17f4683da5c20b786f831cf32bd30f05cc12e376fd9f27c9c60a1130bf9887f2249f3286e4a855232091f1a8900dbfef9b1ad863f70500", + "10ea5ad3a7699ec6de2d3402c333f2fa8ba7b186a3eb378214098a8d1e829e6a4e42505ead889f03113b1a4088b583dac42830879876a9bc74cdd53a815c379301" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "zNyfR5GRMNki3HcyWe8da1vhnq1Huf1pYE", + "secret": "1469780a7a54f01572e2a29326b8726a1e5147a2d96222b1e8220b01e7ecb428", + "public": "02e8c038377cba9acf5e6bc9d886973538b8897eb34de689c957caacabe8db839c", "signatures": [ - "96fdda5d17a466a593b2b65145355bfc7c443f1a85214704f21b73fc91980d3375b2c47edbaea7a6a422c096f02d5f69648f74a2fd04d7d6730d75c1facc57ea01", - "67da9fccc72609a533854db8c4f27456e69c2e0cfefb894d97ee3c5911548c3a59a25a59402bd34377448945446c50bdbecf53a3030fdfe432629c556b98d8a700", - "e298b8d7089a695c7bbf04722feb0c27ad55db6e3ef50ac8ea30b807dd1e46c95bca5f3bf0b67b33cf5cda4aa1a1623615fd36d620f5d3744420c4bce326275700", - "0e2c0fb449a3ecdd8d1fef78eddb5ca3d5da129c62f074faca53516f7c77deab03e5bdc2cf426c505e55f2aa7c948c6360a3879b83d020cefec179323ba083cb01", - "779d6fedc91c9e14d8e7d8265c4bf23a2d51ebb22a7c47279f86ac71432f827d257ebf129b8b4d561a8cf8a083cd30c1dd63a15a2b6ec246040ac60f634e10d001", - "7d8056b55133a8613633b7fdc1c375aeb6280dc2454d2db74f99974ea427f5bb2d1daa80611adfb55e7a85672b0a79fb405284d777e6020b1e7c615b716ad0bd01", - "a28c5a2013bcc6809981b137388ea7c9505f3281fbd39e99195fb54ed01db2f452c1e180d3166a3a9b43d12d14894e20ebfd7c83ad25fee267baa72d49e7bd5a00", - "efaf8037de09ea1ece5f965e7426fff4e3c41dc991b2c97d43aae0e074c41adc5246b38a8e771577fc9ffe35148c8808d9f28311f7a6d8cf86394585348e97d101", - "4be34adc9cf7502656ecc8c68bf1d44c6fc541d5f40d848051170a22363072000c296a23af5e9474ac15dfc9bfa8322f1530ec2a68fe06e876ae974e1553cc7101", - "f05263fdd53c077598ed801dc3c8a79f39d31854353f9e163bafe3fc7f227c104ecbd4a118f3527781515e829cf77f94edafa620bfc1f94c7cd9d4703a77087700" + "2de7268716605679f813e044d0dc9592660ec76d9fd77eb6286c3ed9a56cc8726b63b69874c186335a5acef4477771748a33d4ea4c7040b6b712aa38e975a98701", + "e320dc92764ecec970a60a0a47fe1580162f2f97438bccab0496dda3a1d985d8132a3d7c5c2eeb7f0aca5ec71a855f9121f06778150d7d0505135304fe991edc01", + "fa5edd7910235a8e57b31fced17ae73d32366642eebb7919538ba17c565e40e37f3730ffecfc7ae42207e531921b7e0ca87bdef76523640659dc7337fba57a4101", + "04c046ff48bf60c1ae74b128d71988f5ce435ee99af83cadbf14c6dd7edb1ec61051fc0ff3c18b020ec642219c72dd45b7c76f4828bc432e181b37959f82d40301", + "b676b3cc400f3362342dd1d279a7230c57dca3973f5a82486717ccbe00dcddd87bb81cadd29fb322d02b2dcc59a3d47b78cdf25ea788ecd3e9ba7cf338d248c301", + "f8adc3b7f0c241f45d8c3ca7b4add88b819ff8388c6eda817f8fb44b5d46e1cf4f1a2554f68957ba82a36996926f25292b7dbce9a37047875eab3ccccea19d1e01", + "1c5c583bc903de18d020ba9dd2494fb9249b387252c3a7967f93ce8aaebfce184cb3edefa7480b886a944d1b1712e323fecceceb70a34371eaf1d87a5172a9fb01", + "7a20e7d8587ab4e612033448e19cbf2d76309ea3914b52578d6000fdfc8243d53ea7f25c81acba7eccb9feec3d09e20fe8947656beaccbc9d63bd6ef79ef96d701", + "800f68685440c16a9fe8eadf94e703b6cf750d798c19bb21df50e0afa2ab85e10a67b1773e571e55a26bca2d9c40ca6661815ad8723c5dc077be6a125d9019b800", + "479d3e035de00b7dcf5cbf5e5ca641b8524f8dc415ec6c60170fa367b9bfd3002cb2a9f477130f105d0ae4ce2d56ac4c4d6cb8aef7244f65ca04c149f469caa700" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "2JLkLasmC3aZWegxfrFBMegUwPMMaTRHezu", + "secret": "0c0290d80263d5ca9c3a0d4a8425bfb340387660feb48de1e0020853daa12616", + "public": "03491b93d73f48083311ae3c06f3ecd8c16474e795a58e3ce301ff548e9bac33ed", "signatures": [ - "65eb954c8b1563ddc1bd32ba4ee2f7219fc37b3a9130948cda46637f0004a52f15287d383a26111ec0c1a7579912c1973f12712a068cc93b25f1e1f079f2d63e00", - "262eafbc408413be0ac2311ffc66f1fb5e117d36c3a2c58336dab1338130a2bb7c6d7c721f91ec1200c7a0cfba337b05b5f36f4c3aed809e4a43086480d4a10a01", - "8798b1b6c99ef69a5d763bde3d517f830fda88dfcc059fcc5b2e9af3802d679444cb3d6a0deb58d6e1e2a23a15be2713c49f691de33f5080284b422b37bd0edc01", - "716aaaa4040d05725634a7829d798b22c22865f5ff46b68958f492604ca5482a153920673ab93349081dfd1677d7f38c691a1c0a4f6eb217186edf03763c9d1c00", - "6ae3d3b220ebc852c2841f28221160bcf579286e22a9272460b7bb50a68f7b3c3aca34565c2631dee82e517d0eca9348a336160e3c3abd66406de8da6eaa1aa400", - "4e9127f421e63c02cae1c3b360ad479ad3ebac8e18af620336eaca172bf0ccdd7cb486ae6849d9b67c4799e179a04a8a15aaa0306c73b9ed62d17a3e736c36d300", - "9ac73d1da7cb0bf6cf071bc68b28ce2fd3f843b147d4faf558908c62f9a7a9d60ef306cc9b9a9139e9a5daf242d82288b894f3192626926c4bcdcc4bc2312d0801", - "447a9f322f3edbac0a7a28f4c3d0d50de4cd9d3c984293257b9b7dc18a0b36bc53d9ddfbe806f10d970332aa56d8ea017b4972fd3cc23cfb2493aba408a20e8800", - "37a8cd3b61901d4358f343d025a69b05f5583625ce9fcd9789986e243d9cd7956de565be200b1074324263944fcaf08200a23894e306bfeec886a7bd62b63d9400", - "ff32dd1a1ac98406abf74ee21bdec96828393c59e813fb4b97b0383afe53902457de6467a8864dc3828800542b3f2b8aec1ef96e89adbc79913364fe8800f2bb01" + "13728767950c9ce26b4b7ce9c520a7ad36044ac27fa72a7264764b15b4fdb2e3404d3cd1e716907231fda3db6d4d7b9f1055cada44d72fc3939fe892f4bbf82401", + "d257c55f64e001336df83863ce2b065efab6c60799f7b13839f7abffed5bf5dd6a108c7db8b00dd4cc313150966a88b34770c9d963609054c3f791c15ecedb1401", + "531982656772e00adf2d87834a532310a1fe018a7e44a26b110db88cd51c240e3501514398eeb26ac535613b35a2f71942f6e621598d026c18d29127a8b5c33201", + "4095c7b25fc5deaeb3ceddbfbf65cafc5b060e5a790e9cec3b9b791d2e3a556258eea375d87839bbbd3e277c53be855c51417225dc9d586568cfbce1d542da4000", + "87511d32bd897733747252c3373a17849dd6b87c68f3eec30e30f47ff75a40982546d22a33bd2398d2525ff99980aa96ac0e17ed8ea8574329d427262cfb5d2401", + "d2011487bbd4b997db6c12978637c3c042e397d17d9924d65417b2134467a9d36ed7ac74fe0727ce3727dfff6d90e1607062edd16407f93b26e466162f188fb001", + "5f65d112bc25524334e028ac597c3f9e289394a0afb2e0af6b038eee2a66a40169246279115b5b95e0c4c79e9ce738ea79636c0ae7c1f1e2178a15acf3617f6e01", + "3e87be40a4d5a3c9bf3a8c5e8aded3e311788fecafa3736495a71e06876f55055d34376352cdc8c99de89ae69e48c7dc7f845278408562c681f1aaa02860995600", + "a92ca8f889bdce1c2bb27b1808156afee9c5448cbbf9eee7941e379797261a3346258d418dae445da9c483c55b68c10285c8c5ac59b9e9690b3f0bb429b8782000", + "138752502a10679ca518c2f1c8394b0f49a258a8f92f3e07752a72700817310a08e76da5600f15d214b58b0f3fa00a5797a23e294cc76f72c3913ebf624ed2fb01" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "fVQJVXDCg3xx7nSK9NtLm7xw5wfhPenak8", + "secret": "7a64f76a55d52e9ebcc2fd8703153eefe458b7983e8be501cd7b53e99eb7bc38", + "public": "032849624ed86775b96a940bb4c3ea30ce87d2bbf1bd78a8dffac5d5a26a32edb2", "signatures": [ - "8a0e03022a7f9a09975965e5aa2653c93a4dae0a70b1338a6f61bb8e70d1cea71c484f67659c76a28b78a443bbc2e74b13d179462567d11e6a93bf1fb3f16ca801", - "07c466a5e42a731690e9faf454c6be545c3f641b1fffb6d42defc1931fd352db69215603d2956a7b9716fc2128dfe33a735d5e0a39536ae8900a110052586e3b01", - "868e7a8d32e8b061286ad92655d27882ccc13bef1e4005461746cc943e015ac470a867ef8e1fc0febe82a34090df7a49bb7011d46e8afddf4d3cc7bdda502e0300", - "3b787ce1a473598a517ef15417d44f586e56a3d871502651e02d02827e51153446ba34875faba3d405335541d0f95310bdd52f21f3b75fed371a33a2258d1f0400", - "a5ce30e44a0bc91285fc59956dfa8f243467270844462e6e8a6cdbd1fa8cc0fb7a29a2af1cfd63298c4787b288811557f816694203be81c32cbf279ed29b047900", - "3b176ac8478cfb5e418275a5d1908b54e2c4c45b92996c0799a6161a22649177362ea1558946be8b8e6bf5539448f97cb38f7db29f58372ad9eaef1cb6f9a07201", - "4c2e2610fe33d95a1596fa47324e0dc907ff73aed4e69390d75124ecfce3ea1c6552d4d02a767081289472ad90164f831d52ebec4bfe7062fc1104fbafcb4fff01", - "e8a8658756e8c398ecc5b6a1f2796523b00e44e880f6bd58eebadaf2b4ca8c972d470928eebc9eb2f3f4d91bc14b45480b54fa190b5ac625e428b5422463874800", - "3f0fff35e1a37ed13d9bf826fbdda3100a5c16074ffd6f32cfa273ae91e7a3fc3e4c25484b4204a18714243a0e6067f7cbeb9bee0c1a280db05e59e6eb38578301", - "0fe3e9355f3e9ff376771451d7efb3fb563e96bf4eaecd3c13819a26b6a63eb87d92f94bc25a1014e48fe2c016a2491272a2238f21bce53f06b3b06b97a48e3600" + "ad8e2123a55c325578facac3b33a4f893b3f2afb1065b6ae51b26a4937d4ac094b89ac89036849a7474539be19af5a82a10476bc9cba60a3c29eed8e16cdd97200", + "3e3811c10b7e1644e4cbb4feb05713be87055c3692124abb51f046d3572ce88367cb91dbbd56208c0958482730cfade12f481babc35839e37c063826f5b3165900", + "c3cc2e9ba9068e6896f15e522dc64a07c2d8767a50e3c95f5d591e708101575655006f4124a433c8045248737772d4f8c49db07bb4fb7e4638592ac2901dfdac00", + "f7e7bd47eb319bc33e14d340b73340c78527587e470a92a5372ff4d4b10780a03ec02ee20ba8387d2bc1f6faa4661c94e2193009c22bd3ae3c7218b70598dfd601", + "d25814fa5075fe6f6dde48d0036638803bde3cdf6162d284cd49182488cb76985f3a27becf6ca57a04a17286fd6479ce89e6e137e47b01a347db4df0983193ba00", + "d9db8532cc2595e35e499319e2193e28024d08f845c6ab83fc069009c3e901f9051953eefa426591d56d092ab7a4b7c8e0cafe3e6704ce0bd10466589cf7e75d01", + "5a7556a143df94e47195afd3ec97fbd8e5a10d970fee7135674a5cff47da053171750083f985fb09dceb762dc97582f87ac312331ae2d2aaef9f34c536bfaa7b01", + "b7e4cb3d1dd9405fa7c4342352fd0920078ceaacea6dcfb3fa5fc5b95ec4e9550c50500507cc8584f9671c8f2c52cc7f773451d94b34adde0438e14aa433461000", + "fb48718e2d5f99114064c368f825842544968cb59a59fe3247a21b0f959397723b838a8b8a9b52690eb14a404987206f5408600e5afe1f03918a1a91fc53451501", + "13cb6373816e236bdcb07c5700078604cbb6de83324ec4f952d9ce046991818242b3730f43bbc5644448fc65097c450191a3cb4a07aaa3115bf7b01de5c0a46f00" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "65uJtfRcuUQnQ77iXgusuMwUUE8X3YypDu", + "secret": "1e83fd70b9c3c83271856870fc194779562aada020bdd771e9db16a26fe0e699", + "public": "021733c35bab05988350a1a4012f1a960c9ec09df6581d0e205de3ef8b5589a006", "signatures": [ - "cd40e20356fbba978fbfc52b034d4f7f6c3fa4db64755d82740e1050247e9c474df9469705102832179be7104fa13638491674663a278487a645421a682b49bc01", - "fb36b277845dc752a14314072f656a21063c9ba941f0b7290bb08b4a5ec3f2064a3ddb666503300c6a78e249ceb590139bcae9911856033e8d264675fb8b73da00", - "a60f99b86fc0ef187772449d36b8b2d5dbdb6454b295d5e55c563ca927e35e207e7049b4853df2e966dca70fea5102248d18d5ec6518928dfa9c3fba4abbbd4d00", - "b3ecd4c674782e640e426c97bab35d4f2a99dbad11aed20d864b296f9282860321a8dd28704fc937ba710a670c5dfeb9a8b697e061704dce090ecb780affc63c01", - "91b8198beb4e462079c0c9f989b50b79b41999ce893a170adc5910e1c30f1748541f26a9e37a1afd1a769d8bfb28b0b869dabbfb5a25b4e5dd2e4b043da658e301", - "75a4206db59381d02537ad215c57ca78a08661e55d8f21a21aac82d6f0ec440d76d83725110e7a04267867248f2151bbdf337b1386f44038728ed9659f79bac100", - "694bada15245f46eea329b39af3580e4976ba8c5bc5423da7166b815ed93d4c275b973d9010d5e1b709b537b1a5f03fd5b52cb60dd3d5756d31510d2fda1fad701", - "4ba1900152b6e7c8259621739141d71c6b8904ec7440491382ace96a82039fc946114b824db4ced5b7b308b82afb669b4bbb02aa8bd2db1b2488f63d7da8317301", - "30ee79c80392fafecbcd2e8bdf7497b63d8c4fba7603d9b2ca5c6f3352af709144757e34becdb63372871dcfb126c3ac011f446a79fd0e4a73a076a4e96227f901", - "9e7500a93bd1c6f22a7022b22e1145bad7ffcfad90b8fd42a3f51b8d17808ad318f1850c44e18be5ef76dc7b4a07e2944f31f7c5feecfaf11165511a0b0b673c01" + "2d41e8b8bb40a4f4e7a6f3d4e62ad54a1ee0606a968e317bc453a45632384fef6768fc26faafbdfda6893b6cd397d11f25bceab298bdffa0d15beeefebd4f51a01", + "9c7b0470d72e6adc12b1a1bc3cbce3a94a6a899f7a7cd29e4103f8ed25f1ea284dc034e5a4daaa44046869093bf65e5a918532b5f7ca9f3e5cfc5fb41db1341500", + "4376eeb10daf7003a33f1e09c8b308673b51395c607bb64dc2559dfbb669ecc84ab7ce243646b4f1078988051d1c2721a1ec834852313b2f0b1d0473d703914701", + "9e4c7b2251a21ecfa279428137229e0689e5d07fd045e5937996cf2ba36bc85e28a80a8dcc0d08d71a9aaf69e0681002dbdd0e7bf996220fb113e73e5a75d7cc01", + "3ce1f8df018a64a9d076f8418f92c4766aa48e4863b4dcf9e5259f844d8e93d35d04853654e953be812d13282a996efcf7bcbab951aa315e3f8bac3b4c0fad9f01", + "2f86dc5d8c351fe522dd28c48154f9012055cf84efe1e5ee852c35e0c1beca515df764310a3261656123cbb135cedb066f1e2d15c6d3da50809108b1dfee957100", + "630ec741f809aeeb3427b0c3ad6b87d579fec9fe1783f927a9186df5059d5c1803b9d0a91d1f4d7761b374cea2ed1c336de82f0abdbeafeb718894f0b2ac253400", + "211d06f41bdba332658455ecdb19e70f13533319e25e2d9e701201c4f6eb038a22a04478802a9fdc5da0ef96b4e97fca848d142c12d831269641aa013dd3da3000", + "e35d120fb5a7ee7d644bc0b4b22a81b3eef841ec1388d0d094c3aa85322f04325b208770d47a5d9dc251e7551d63801fb502d9d10d6d5e216ccf4f456408350000", + "7fdbea3efd7bc036fec0ca9eb26e0b7a257acf779ebcec1689b206f77dab863d0508e14c3cda0411f958975646b85ea99d67246eb0e000f96f7840a29c9878cf01" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "DrbwF4PMmGLwV1n6b5r1yUcnRjESsB3xER", + "secret": "b2cac97f1fc63a1e1a16d1f322f4a33c173488ba3ebf5049931103728a822624", + "public": "02fefbbfe2f400b83ae244bb3bcd2e4073335d58c35659100f2b323d887982918a", "signatures": [ - "1a9beba9bd1cc13e1b286b30d7bf47c9692fd3e9e803aa5d2704b25889ee7c0332034c47959b54df0fa3c44ddbfb3a975be99dc6d54e9f442ed1257997163fe401", - "f4b55ddfcb3fb2b74606a1da21934ac7ea0ae3d08d6f5a847392da03bb976c3644e22cc9b5a667eacfb437ec25cfee2a75c761a0be4d1a20d221fa87935ec27b00", - "57a4641841f51fb7769bd43a2e654c1f02dcdc3fce03095cae4c84d4718213c84fb4f5706b8cf337ce5eaada5350a7ba6f65aafac72e529f0993969c6160fae401", - "11ba741761f3169e669fe611b1b93d236951cf248b908937082c6b8ffeebe7d63e0bbcc59f2a47416320c689f89b9598110aacdceeac27186a0ee21a82265a1801", - "a0da062e65b091b99b608500da0404dc9be1cb8ca012aed19fa4f53eb85b337d00871530f4df18a50c0499829d0ccebf7502e9aa1a55d63e6e7fae7a70f6a72801", - "6d729d00054e602620fdf0f088194a32409de45585eb2656be4d3d977c0e333e431c2eebd7897629dcaeb3416f9228475d19454b9d08a9f2a5ec6f9db858cba301", - "4a4004ac20e8f14809c77502b4723d9aacdea4c0048451d656cb41572cb34a6023b8e006c1ca1a9c62e0e76c4e393f7cebf8cd50c4a78f19fcb1d246aebf8a4700", - "05ac34184d0e5952388815ecb92b9b090390764075797de8562a8dc81edd044b2602173582933c3cc16ee85c11ccdd6e04ea1cb47e8174367ebcaa440a76521b00", - "3fc67480e14312e13ad4bb051c8e4f41da7e74f3dff28cda01688d2ccd16a6ac40f09d2ab9ebfd19a713012a51327520f44a1a44d0fdc880795ae4fe24d13dce01", - "77f2f2ef9501564a107569352a513f7f1e0773d2525b92284002435a6fe693cd1a231e0f4849b5de32cba3a6a85f48e5474595a96ff92b758c3b4c6f9e8ea5da01" + "d412750a5c4e7fe4564bee6f221389f0ada48c6ea612f77a9b1aeb586d8dc4a7129ff3e8aab7cfb9944e344d5e2129de4730a21e20d612a2e37f097549880b5a00", + "b2fa691f873903b0154d6347be1eddf989e67f390ab1e3f1e4c8cf1470acf4804a5d55356807561d5c6c3cd9ac7ef70d54f845d0afc42734a05310ee7bab55d801", + "e21e1102033378122861e21245e0ff0752aa94d7b097a26a16b92aebc7b7291670b5f9efa09b60bd72b21c1e386779400455708ffe36518299b25c1bc4695f9100", + "52351ba65627367f19b6ad38ebfc57b2d797770aaa45a5441e61857ba0aa07f5452412d20710e6ad4e15a9353244cd69fa01d09b17d1b2539774c0c2ee477f8901", + "129d602024659785f35229d08148eeb270192b5600a4f64ebd30bf1721f40ef70312cc10cb97cbcf2dc53da1e8b10723c43bec6b380344f635130ddcc89403f000", + "e7e63d42e064530b329837dd38955731fe3cb68c7f8cfbf7bb7452df2976842b299624c6b91be28fdc3c70fe80d844104d4f35b5c5a6f550471975de4519b66400", + "800fc84bc5cc7947c1860eb2d84e0a4a16995c75ed6023b34ba69b7b3ca0da10146fa36b391e95fd48af4e1281d129b73c66b7ae12141f1db72a177efea7835301", + "5bc5e990c347f77cd4a0db7debcdc92bb6c8d8f0287b2ac7e542ece2f5df3a2834490e90bb3ebb3021f444fc6638c6361a51f92b62616eb31730e53c74d17afe01", + "5b9537851a702c03851633a514750f4050f08430a287a885312c2b0db992879c5ac20bc4725ee26a83551f220314572fd8f23e5aaccfa0df80b8e9b38f357f1100", + "ef0c38e69e2a6f90da8bf5366984a20bcd1444e46d5a96448f7c7fc2026f13150822069375ad746c3502897ecb977b78df08e3c65cb4f2c26981f34a9e0dec7701" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "8UtRig63MLaLcBWz1roupZjzgNFWZjFDPC", + "secret": "84401dfa69739cf31e040af784a9f2fc92d2c403b77244c0ee1fda554b26609d", + "public": "036affad9cd7bae39d491c37cffe118d5b3d23a82cb7d251bd9b0a26e02ecfad91", "signatures": [ - "1f045a93172ecfaf1f7a728552a21a7b880ea9a9bf01fb4b868a3fabb1b29f6161dcd0c0302b6ae1b02560d3e6198e4cc7ff7e1623ee24c6237b9467b985376900", - "bd16eba32ebe669e6304089710fac03919cb517393152c5b9c91c41c0744df5c54e8c2329bcaf1acc3560f85a2e4447d61443f5ac65ce56e62f0df1b5a210a3700", - "ad9655e31f462cecdc8cd94b87f577f298f5f05f2433a5509b2c39cef7646b7519f59ca3b3b13efe45131b0a3f485e91fff6accf64d93be436e84cbfe23f6b6f00", - "59b5ab9c62b7fcc9e8640017e610029508586619bf811cbe29adeff32d50f06a338ac11fa683f2e086c8669cb6f65533503ace92ac4ebfabb1c337615962532200", - "ef9d47b193697f6dc5756c894f3fc3508d3d65344296e8128bcadddf2f82f2cb4a56cab92d21dd77480f78036f6569b4abd116ad38520bf35728a7aa1055614c00", - "10a5523087fddd8577745c95777841b05d87372a39b4737bfa192e7d8af6745f7c89d379bc5f5d7e37566ab1fb87c4da921e95359a016459457fdd86ab7bfb8f00", - "079aed2acc244134709d72c4a610b90d0f5a7d9356e5e4a7769a00636fcd9a4465525871e08c9420b490e12240f72b2cf0691ecbd2f18c528c8e5a4977e25c0e01", - "002515389cb2f360a5208b3ae8547e180a692f3b376a2696b16ba8cfa1137bb8302757874c09ab4dce81b1eff01b747f1b221ebd6454ab3ff7e4ea4563052ae700", - "71e17de1410ce1b24e8a15ca07daee58c71f578904920ea5b4db2933e7eda5745e93d1f591b5cdac35c10941e46206701b8549dbbfc5861312db29cac827c09501", - "d5ac35cdc788fcbf8363a01e279dbd0cdc2f1cb375eb24ecd3135f86c9ce1439531eac0bde86f53fea0e8dd5a1fcda3127ed0987497b6ebd9bcb6d86cd6803f700" + "93b45998033de9db250380fce60a61e3ade7e75eaaa616752efa84756278a152260b96b3d32033a243c525e81b70c7b304ba6dda691be1f031e1db5b8e40de2501", + "2993e15ae39378a443662deb0a2389df953c1b819c760b05bc8c57e8b2a47df76af6d61d06a60d16da662ede2e0e608cdb3a12d8789a8c4fe6a21f1eae6e63f601", + "dc85027cf73b354bd47b8399a22057baf11c4c59a133a335f598c5a32e3d0b410060a0e37f14b4254def16fc8b93347ab0bfdb56325dc3f361be6a45239c5b8600", + "cff714d386410016878b11ea5a20c756e2b8eb5126cd92efd668c48d4b3d1543499aa234bccd23730bc745954cd901e645763d3f0e25472ecf5b86563b15448a00", + "3a783749b0b78225ba0e6391927e4bc8093c1c0f7d165e79241d97d77dc969aa302a4447bdcf85ec3d2807ec49148dac1bd3c34c46f50ce835c408210d449fb501", + "f1fd6960250d78d7773fc114cb8b08eadc5616fba800ecbfe6591ed4351e0da77668b8691157742ba1046c957de85db1c2337da9c852270906b5f1edf262275801", + "8559c8902387ede48f83e19e9b9fbdc6aa4b30feaa5911c02311e02e683de49230895dd2de9cbea7cbd2c87c62705e3ea669f436bd131d2e14c946040a53c47b01", + "3194e03f394b5f5f73ec5cdf98188be9cd702a4b23650d34dcbc6ba838c449c6346931eca359b9014dfeaf59e223e49977cd48b997b2b95ce612934919583ee500", + "b56a1b1db892f1b55157f4460baeb410acb9e3941375993cd9487245791c45667de87e6a27130deac8ad53930cc7f4f36f60c194a6f9738b9b76099bdd9d258f00", + "fec84af4b8fab37a828ff011beed6850e12160d08c4bb5bc41d175f40b034b25357589de2f8a2c4031be33f6cba385782143870947d2238f3071bbe6a780492a01" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "2FEcDysCMv4HMzwXqUGYdpEqPPzJmAanfo9", + "secret": "e44eac00ad22c4e17a0749103e842c381db7bfdcf5589fee225d0171b044fa19", + "public": "029f93f0c3a354d1b89f6aaa93b80ce26cf674988a9cb8042b9291b47639b621e4", "signatures": [ - "175a93fd23b87918f9993c90bc43a17e037256a9c204c563d302c93aef31a7440dc6ac19bff396df265ded4c4423219bf14a79d3f35159c8b36ca359ad3cb04b00", - "5c539b696c5db30b0237d9f675fae49fb5ccbf5f3afcc3ae5f328eca92e20061019f618bef014ccbdb94621d809939238b5b09e9ebedab752fa40b71bd70d9ff00", - "73705b79b47ec82e5f12cf67ecac796366eabd1532fa5ab740d1fa4bfcaccd74690fbd374f0ea40dec6604188dd53b5e21e288344116af0154759259094d2e6100", - "6ef5f5274c07c6c59500986e71f1f35af0e09b8f83c4f7d1fe44413a1e912b7e3fffe10633045b9801da0b58c42704bc4b60951ac380f719bea152a94bab1fc401", - "83fd1b16aec0bafb36e025ccc8a8b490e32ebe7580798b6bbef12347133e93315a2fcb0ac7b8582bd1c8d3f6954f893e9b2f66fb747ad01ee16b5c943682a3e501", - "d15b85c82bb82bc6401b24e80006902638947b25bf78ed2f5deabceac73fce0773362d3010c2ccdb61b17920823de1ff9ce6f51627da4d4ac10bf7dd1aeee73401", - "e43c24871e933e2d9d5d0e99951b5eec07ee249be433ac8d08626a30c1f0f0b8242784b5d907ea1110acf58dd08a75e11bc024e6ad097d7661eef2e5d8b83db401", - "8367ba9c8a4f7cf3f99cc3536a37daf81b9d47806d1f076cca107cae792b4c75786fe8cdf3f32b446283ec9ced08475d630906d8106e567719bb42c9532265e600", - "9ec67087640570a96543417da7cb28e92dc4c9a1bca35e65ea269a0e19c7d873391e9cb0b1d89b14cd1b8588ff46d85a42866eb54ad1c9b9572e19483953bc6e01", - "70c76bfff37b00eedc9fd9cfa29fe49fbadd9d69ea971cb18a9796e32ac378f90081cd3ed1d6ce36332c45f787e51b17232e7a4e0c56e7c4cbd54bf39671fecc00" + "61d574bde2ad3a35a6d7ed33b47f5885ba88536f1dbe54bf4e61a4fad6eb383640da8d0e4b6f5552172cc7d0c9db11c4c7b4e8329223ebabf3349ea1dcf07a9101", + "4f2c6bd0058643ada8225fc910ae42edadd4ed77894880594fc6a14587d56d9b5b1689780ff5ffe0550e336ce8340915a4ed2e07d5317eeb8e8d4a195b31251100", + "6f4339f187cde041b7f4eed3171066abb1ac510afe00b334cdc6dbd460cff0be41ad89604f191db6666cf50a2cde47bb6b7555e6b200d4c1ec1ea22102adcd1201", + "1d1d56be698880ed0e3edb50071838b0cdf622cc9401c63b46497d121c7a35b44aaad0415496ac0ca4e7a6efc2c28aeae509cdecccb469335cf7dede8301b86401", + "8a33f78cb1e2767147a40bb33b2aa5ae367d4e07f9d954a11489901a49edf823431b7da2d23d48958416e310e9089e00b9f2695fcf0508993e8efab888703f0e01", + "02a2752aeeba167d66f8ec9443ad8575570d766bd226d4fcfa7f1037392c33e520750a77e8b62577d8e469fb05a3d33f8e9c18fb3a02f2ee69ca8043b063031c01", + "7ae9f070f1ac3292c3fed78d8676351fb330a8cccd016876576ad3d50bb861e41963bc58a736ec0f515e3879dd36ba86fa71632dfa1627b6a5f092d228e990f301", + "a9dc1cdb26c36c56346f0cdfce899db2dbea965e695846e09623cf09185e17b8495511b6e5972cc631f71f9735102585e744144ea36e990fefdc215da688c5df01", + "70ac0d8ba64116397c25d5515e9a9abd9a80eb028dfb44bee9b3ac97b2c00e9f0e8690ffa8d0ea8aa6bf6aca24b2fba06476c88170ef621f3002da946de2a83301", + "441200b55b63ae560addc5a020b56937fd25021b23e1d951ba7c57d90ff7672a371513739db52f4294bee054fa2ef8adeb4ed38bb4d0a2e83cacfbf9828bd8d500" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "CZQfJSz4sSF5t3FVzu6kyvXYDugW3aSNVu", + "secret": "c7a2c3a4d66588696d0bbbdae561d44c5ebfae50965bac29a5c34be86f9f2ad0", + "public": "03e40a507b0a3a2e27734098d565f8bd1892db382c325838b4bae875453a0cf5e8", "signatures": [ - "1b961996044a0dd087faeea2cf512cbc109e147cddfb616cbdcaa91d218f1cdb101921ea1f559b25d6bb5d61b91fe6fc428d2e7dd7b87933a0044e963d211a9701", - "2f9dd836114e66381750947c00cb3419805a35220306ecc2e950070f036812f81d17b88c64e30e5cb4777406eff1b4f934be232966a57ff87658bf7c481ee0db00", - "c083c1b60c7ef6ce79a7f85115e965cd180a08d7b6f7e855406bad1d9618ce5f7fbeea9b3540a1ede376b996f137f338fb18aa847f3cd65aeb26bdaa79bf1b7401", - "bb7521599b0f7e50540e030d6c27a6a51c544931b07ed1e6c927449256eeb39d05a8a20ea012840f54fa0624b240e7286a99610192ffbca9a18ff812e3cb3b9401", - "53f6bd4060911e5e5a621d0044ae6b1d3e4c725b9f8725911421a011a323cbd929d5319cd693780dc9506a37c043a0164eee5c456dfd5bc6169f614466d4b51501", - "48139be4a54f0c51848a8b091ca493859b93f9cede004b0888daadd427def0a17b82f5ea914ccd17fc5b7ffb2d28ffbf36661536584ff10717a0e99af121679500", - "2ec8b50c22da3a07a37fd171ba4a85b882ec1459a09db6aaeb84f30cb139f1bf645706d05dd696cebccf58435e9a4eee05f96d66444f98e98ae1e6775f295fd200", - "1e6c6eda84bbc1c7cdcc3348622975a5fee7ef00c78fbadeadf2fe217341b1a82982f6b304f0a7534de37f025c2983e48fe99dead791fc34e7f3108fb08564b301", - "2ef95af8707fe1ac5ca4a21aff222c10f646c66663b5a506ae868ca087dce53f4d879a02bd84a36eed2a25c29dd46a4eaa3c2be19f6577d969575319a466ce8c01", - "df541a22dbb640e31c29e1a119c6435e78aaed4d519935b847939bda319b5ca84f96a6bf00269372855659c105b76a4860c4bd0c86c1accf6affe8c51b63fb4101" + "785c64e60448d4c3c6e1e56bd0a1743c70fdfccfa0866385db6c86cf64dec8ea76e655a5621cb0c8f2f1e3e20b8aae8fcf2efabcb0539831ec7962fe310ea92b00", + "c0a18cb45d85e65de31fac27e60c602452ccf320e93bd217e001bba8a96a2fec3c51f6e6983386310a4f3ba3e06ea8b4fb6c62ec7698d12a41bde9fe278dc8f601", + "de824e91917697141f4d1ab5174477488468ed853dbff47710805d1abecd3df9454f497eecfc98a32189e00b5ccc0019bb0a06b56f6df7c77afbb4fbb65f639e00", + "1a54dbc4c6fbc4905feb7d3cdce1143f0e5bb1836c12b6e4bbf9fbece2987f6a3fc6838fe5704fa6fe97e0be3cbf73fead915bb9a9b1fd555eb6dda4ba69082700", + "7ff1df7d20ae44dfa8d03232328d0c921dee85441065691715b6a5604c74af135ec9de99dd075360893432889b3a4cbcd65fca62bb4a4b7de9d72ac9bb90e19200", + "27bb1cf484ee097e6eb0e0d1c09611e162ffb41479d172c8fd040d89781c268732dfabfa77c1d8c21b8a2be1167c24054960273005432edfcbe82bf86c7752fa00", + "adb2af1376af5008e9e59d1d7fd09e283ff2fabb9a8e0f75fed093418576f103311064ad3228a23e34363142f5415333bf97bca296f20aa2efaf11c5696428fc01", + "37135bb0ec3ef75b4490c32cb476bf80d04a8c175480a755edf07bd87a0575dc213e25cec0cbf100114daa083875390dad119f181a4044b61c1575414d5f38cf00", + "b0af6e597e32d5a34c75d1c7bcf9dba46edf8980a0da02378a4fa80e13c5c8e6684ab741a8dcc60a4032aec17310451c21d167493e4f91157f9054142090882f00", + "df3b1d979e90dc35f5f89f98a29f041b261f1e18d9c9ab4cf323b797e7a077d45db26932095c28d3e7a2cac92ed38079c8d3f3f2bfc60173fbd2ae64d51dfc5300" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0003.golden b/src/cipher/testsuite/testdata/seed-0003.golden index c4d62345b3..ff562a063d 100644 --- a/src/cipher/testsuite/testdata/seed-0003.golden +++ b/src/cipher/testsuite/testdata/seed-0003.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "osqujzBPUMZxaJ3Do1Y7kNVJkcvcD0MeduHY9y0YTG0=", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "DC6BLZG8zpsiSa1gGefwdPzuxpUccKrbXe", + "secret": "325da6487b7076dcf1eec385918306aa041351226beb3781640eae8a432e1055", + "public": "020f3512b4c14d806f71faaa21dac57a07649f3b6871425f654e3fbc7f65be1497", "signatures": [ - "25abf27fddef1649a5abf3fa2ad7c0728da59e61d2e0ef42d423ca7e6ce6fa751a3d8e0f4e5b4fb08af43e6e854d3d0a69d52b9819c5dbf5924b629a153e138700", - "0574445db924ff29a0ee83981072773ed5cf770b3f2b221ab5423802e228c15375c2988f0ccab662c971c42e28ce9cb43293d88c0359f101ec921a73248279c100", - "a91e044a65f264d2e66a9bbc510b25bab55a1d04d4151aed5ad29a91cabecfc078425e7b5d236e76cc55ecf67aaec049900e50add0919ec3fc9ca084dc8ddeb301", - "00b750be62d9ef743fdd898fa52f1d8b85e83a7340ad1aac7cef9c2b861469cc689d99ccd47c370d911bd65319b60c8861fa20ea14a07b6a388ff11100c0623701", - "455467d00bc91ba2cd2025dbdf87725b5d0cb536375cab649216da273a81426d1ccecc0d910648b2aa8b998d48ff998fd81769cc6b2e770c4235b7826a9763d300", - "7d2a9071f178d4c1c8df809daa0fe3a48a1bdcd12b09072debfd7a5eff34e5134670791ff33bf2addff1f8887588bb01c1425ff8c1a8a541942222141818295801", - "e30c11a8a065b6b7bd7eb97b9b839be003f098847d15256fc826ce381f03027d4efcbe730479bec63bd9eb8aeebf51a1c98acf60bdcbe31938534f282010244500", - "3fb87c559adf3c00c9a9f77e67614185b5b9e162498a0fbab7892437ac744a881321ba8eabfa44acfe155067a30370a8ed2e906559cd023d8c06ccb586fee3ec00", - "b42b4c0ca9aba18ac1a7409d77f3c2fc7da44ac980cf60a2c44407792945b61e7bda48925e6b4371a885577ea24011f9dfd4a671046e2081a0c253ce1fdc5d0601", - "f1a1b979173d13d9a155e4d6643612bdf6971eb9f1f569ec8657e9c360e93cac41125d3d793a23ddbb167c42d1061caa77fd1d5d3f4dc2b86ef7849b9a2e117401" + "809c24982147fa79488cfbd3940e73e2ecf2ee9e467f0e18e39fdbf18db776de60419e3535bff3cf67ba2791457afe74722744a872e3fe18d3bc37d3d8d397be00", + "b4296714ecc2176ec0322cb6a13f9bd75a34f09d5365ae5131468682d1f674412c61a0c67085ad839cb61b51e9c5a7eaddcec7de4743ade77825b2e746b4963500", + "508056bd0ffed1dfd2c6b0cc0c9c6ad26225db5c43f315a87bf8251355686ae212746fe8f679b7a9fa1686e6fd4e20dfa924ad9f0d186431bd0e5854ee58193c01", + "4bb6ffcbdf92372d6b34fd216197482fc25a39492641e74fadcb54f461998a4339480cc1d2a6f9d082b8603ed0bcbaa3981ca871f515e32ebb4ad6fce804556701", + "2b9d6fb8dc332b4c35961b916ca8a2ff62992fc841302ccd8dc199b3795e95d0750b6b359841fbb1f9deb5d28040d3a13e8deb759f8c3d5e95a7b51de70c1a7a00", + "6295a6d33266334ca84e5f27937ca2eb0ad7de6e28e89607a061c6be2d26714f3dffdac337c67840d78dfbdcdef5f175cdcc681d31bca40ef33c742da9cdbf2b01", + "fa2c67f056fefc0345e38cea031b98deb7b94c0e8b354e4e14aa8a28e7e2f88e717fbc72ac2c7336f000180be95bcf2f3c72704027e91fadb91a1cf3794d977401", + "4c2e02faaa872d69564c1ec25d6ff77893808cf4b025a8271f716497e16f9244079b7bd642877f8595c5cec0a009b5773b1627017c2ef31fefb558e3ca87d09900", + "116efeb0211296184f0c6b52b71f43b9dfb7dbca6a641b6a5daa4646b44655b3094dda11541899c235ead9ee5ed5ea9888ed68f9fdf51a77c973dc27243c055c00", + "91007e5048b024ba6ea799d14c5d907d7febcb896d8d6b37c528d59f43f0ff033ba752ad336bad95cdb162c6b2c991e06d4e2aa72769de959d536a15049c6af401" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2dJiYdLAPrgJtNxmYbmx6Yjf3J6o6tTQTd5", + "secret": "ca3448d20174e2bef91842c97cc89961ce108b634798e3add08349d2ebb3b7af", + "public": "0363cad05bc20e6061d1687f02cbe2c23e188f7272bd06a17f5e1035b434215d95", "signatures": [ - "388cf11948ff5c46a3374c8a6e75ebaa8659f5b42651cafa5639c34413e9f6ac031c304b0a085d7fc92470373fefc086e86c600095c72243255ca44f30a9f04a00", - "78e0425c06cd353f2bec21e8c439782eb7ca1d79fd79bc4bdce07d3ac055538515bfa1ad1c1a9f0caff6b455ad0041820b3c2266b2853c7995bb8802444536fc01", - "cab729751aec674a4c53b60c1f70aaa5478396dd88711759cd523b5cfd78ae2a4abbfc09bfd9bd0ea335d03baddeaafc22a527a716e752742e36ab62d1bb6b6b00", - "31241164f8c2f543648cceced67ca5ef700b36cc6dd5188cecd971f6ca67f9983dde929dbf0aa942baff701f0d4736b51d98785a655ea30c067c64ef3a48dd0400", - "d7848b1c4e1d9517df47e95f33b238d4e05891ee18b6430229e22e6ce5a4b8695671b1b642852631535256bde5d97b9c49a5b6ff6d7dc489d360713322ab966c00", - "0d1121cd36be1b817eca016f1809232b765e3dfbec2611685566c10d0c31d10068c7e7105c289ec47510df6209f7179a93f439266045aafcf59f796e3b19a51601", - "2cae8c412b4828d8241b8cda6e609438da3ee15972ab25bd1c6fe9e9569f69d37acc75293ee2edac6a1446e15582e928589b72e3a3407c6da6a1ee9c3c99ad0600", - "754d5f9f611bacda6bcb7ca03761c011052026de600eacc684a4a88b0d5cdc2e28d1f9dd8bb28c3d21c06233b03f4c49ac4f88d9c89e881c787bf197f7dba98300", - "af25af768b016d9f45772a7a8ab0987e249bbe56280c7455b5f204856c7275a839a5dba3df2f87946572c66be6c02f7497c9cf60e5c7e8951c978486e3a8daa700", - "255544908ad9b36d3cefe929dabf930754527e397924dce0e2e76276e998504426331cfe467b345919355c5d910e1676f362fdc11ac32bc49860fd829636622d01" + "707b5c34007269e88ce9898b604a1c9c9ad31e5989f8ee6fc682a5bec4b98c3832f33d84d9efb2f3ade0b8813aa5f3305517762719278172645d842bb0a3175600", + "ccbfac78d5323f046a6585ba6b6fe674edbe1e565d33207b0f662a28176d0e1e7711309c9df63edd6e08f3a7c454d94cde4fe146cde5f4cd686a2103e788ee4700", + "60b58eb3b8020113be1ae1025f5a5d57ddb4cb27adf0471f653fc4bf5a937a805d523921ce98c3f2f3f39811ca47601b4c1a5bef7ef3ae47c87877dfe49a04bd00", + "1cdc3524c0e0a18011f5e8a627979309606c826272e1339444349c356cdbc2c05728c3aa674446b38f076641ea3c032a007a030e4069a570874545c4663667ee00", + "786aee30a6087a5687781b3ed888907d1c067148339552b90c022b21728472613aa715b75cb141839c02b3a3e7d72b58e6cf1a66733be1bdc7d9f209a0cbcf2b01", + "44e13e6d249dc2120e5920a93ff9d14b6d8b9f4f76bf3b160111e7247d816a0d673da37fed5407fb4adaf4974751d17212a88d646889f3c21d18dfcb8236847101", + "d0665523c04db55188b1285f0f6fc79693f9468446b0e2209f1573bf2f1781b16d06368f0f1d7483ec3038e64af75569cb474eff030838397e1bfa331394f26f01", + "d73c18368eaa83cc36ed1ba70424ed51b6889a1bd184e8e63b05b320f0231c876d70bfbd5e287e81ee947b1961c88790285c70b3167197f04a3cbd026b4a9af800", + "d99efa290ad64474bc2c650af2e4623d491aab54317d73a4cbadbf10f706d49447b508e2874fe41fb5d62d8676df9775d3fe533e26c3b59e8290d02473b29b5901", + "e4708608839de5df88e9d8091816566060ce16715e6488c0b376a31dd977777279a6f88316f3d2c0716d92048b8d10689b273d83dadf5d4b167799abac89b59e01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "tNP6Z6m64tN66qv8MNbpgs3hXphXY84rLm", + "secret": "52296f8c8b894ddf388ae2b000a023b6bd48817b9139e2495997a74775f5205c", + "public": "0229a7d3b520548fc3ce2d2008368d9b00ad9ff5ef045ac9ac7f3f8f3036434917", "signatures": [ - "01756d46069a6cd005e8c39b9e332a63ec14245e75b71c3ecc8aec445c7ef4ac508c2044f3748193421a390244cc5bc1aecae772fb53320e6c33c43288f5024601", - "9f464bf98a83503e7119dee09e67008fd0df9a48829f039fed1d3e920135f5be1cdf1670cc09565d3e05d3aefcb2d25a19f11eecd0ff6a63e209bd801d0e60f500", - "8217cb40f218e9b00629beaf5645830dbdbed6386a4e6feaf6fc3c1f0adda6d22bd48f11b228fa2389b658088f016a89439d1a36a419be430c1816481265115701", - "cf2a159e32a26bf6554779750ee8590a02567a66effdbf1b655b1ef67ce398fa6e2e402331762cf12aa6e5c96064e9c2fde90a61fecc0653070b46232b10673f00", - "072624026e5846af7997cf1dc590b57d911599870a989401afc49985760b037b46a85d0f57b5bcdff44ff67d07489dbc4e49c7f43ac0a4edb84c07318deef93701", - "f5db2adc30d907a8da9dfc480231da38f56b06efc739258ea69b8a3cb0c578ea4fc38e3f9766a2f030b712d097294ef86b8bb18ae46bb5be56b50222a354859600", - "8130e2ddfc95449b9c2cf026cb678524c970437d7ab3dd2aba82b0b8d68dc2e520d017923ed9b017705df2cfa8ecf6c9776f3ebc79a8e7146a6a23535fdcd8cc00", - "9d85ea0e7281f93604e061d2d602db6031acfed3e59e09b36dedc6d6e9b1492213910dca278cca8356aedf268423818dd70d9f10d75a4a7c74d21039605af1db00", - "428282a79eb42b688d3bdb73229cf15dfa57afbaeb5ce71025a17e1d020816c6600ac2fcda296cfdb4a6c61311920aeddabee706e4a33c97580b5d9035bc56df01", - "605a9749f2d2f62b91bc626a479220301a1c49fda1eb2a2d4ab9ef160bad93066f1938ca65c23f9070dedb9baae5fb20536e11d94a7a84973ba5409391bb717501" + "4bbfb348b79a401708a6a2a420e14fd003fb4a1a705b375ab679fc22a0a41f4272459c5d5f85282fc28566934d4577ae9b1a7089869331185a5f582dfd0e94b001", + "1c5c40dfd36fe3787fb6dd38be1dae85f6a6fd4b871916cd1b95c1034429472e4934998b8bc82bf166e14aa9367dfc18331db53224a1194ec97e506005cff1cc01", + "d90f16cea7f7098d6ff350a99a75747ae4d09052434c11d60d1f3bf44366d4fc310e19b33618ec4f3be097cf01c24fbc3cb5bc9289659e5b1cea5229490979a400", + "3ea89cb88d288bfe01f48409a9de0f869ab9de596ec9d01df313f5362d33b44845e96e60146b218a085a0d55526a6418eb02c37355167b0b632268becc33731c01", + "9e497a538a113c0872cd2427795e37dc0c6062065917cce07a6f406f2bcb1d203fd2fd6b2a411287cb253a6595da66c2c253e3d9035448bf1a867fc54afa719000", + "c19122058a54edb872e7c010a2fd7fd4f2c0612f5fe9dfdb69a23c257817643f4ff5774d3714b6efa9b5a585f5b89f1bd3febc43031d10526b78ba1c65a753f400", + "d2d796df07fa14f76b3ea84efef72d4412aaa67be7ced6b4c0ab2768968878614820fd94dab1b679a64548a4854f0beb7d6ce495d59b32e7226c4aa55b04be7800", + "7f9fa76140303717d61f6fa1beb1cb1d492599e8a4e9758a76c36f9bdb0f2e165a86cd84066d094b7b5a5b1f7e6669fed39ae381f03b54862662fdfae9317ba300", + "351feefd233570aa5390987f9dad774999ba97b2c1f39affa31a80b68030a4ea2afcbc0443ad0e90d6198fb22bc99a42afd1a264cd4866e2d7ac93a9bf03a79201", + "12683e4bd838a9ccbbea355a374eeed3eaa0339055cb90040c79570736175deb5568ea3b22bb642067a2db8245e83fa3e9ff14cfa17bfdcd7538d91784a8e75200" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "28Jw9pmX3U7cckrah9kEkp72nPQ1rsRVEmN", + "secret": "324ea8f53efd2dbd840d97b8eb1a81f4446a33ca0694c9e91fe87e82f0930d43", + "public": "03dfd1e1219d411414b1dd12efca1a54e96ead409cb810020af7c92c8bc6a03d62", "signatures": [ - "abd66500a8dacc892240b1464c0d7a495456b9ac920708a6de531e8b2a3e2ee376c8030cc13ba511dfc825a50cbf4b3fa4330d33777cc28d58d6bb447d72eb2a01", - "162be23094cf64c3893ba4dfcc17675092cd5c436559e3c7b724558e4187b2d03054c6ea80a9ba7e8a638a0cf88ecf55657752574e7644d37fd64b69b696640c00", - "01093c93b12422243548ea2f6ccf7fab93b7940ff3de21df3e3f4d6555b469f573382b38d8cbf915bd4bfd0713d5a27e9fb164d315adc8b658f96f32e6a9ce1e01", - "9161c5efe3b6a62b7aa635df52530c6b520b1164d6897aa15dbddafb7b2995347215d04249a0c2d6e0069f803b84d339aab7478b552a144525d8a57f4c1df09501", - "c9b241ae2e69238e3920d47a2d421e300c12a09ece534d802da03d58d0afa6f84405c9c64ce6d6293fabccc934bb7b7e2537796b7f61d1fd6bada38d7e64504700", - "d7cfc94295e39c961bbaa9d5960da2dc7c58a9d77846815afabd5b05c0e97a884263862e9aba01b816f33d520df90d1e7c9507e3427e68c4cc21b1097d2884a001", - "504177c98d7308407dfcd9cb9767311a4b101c9ab74dd4689e724d2450603ef35462402b1a29a10a68603d3c6fa6581b28c626e3b35530cf8881b4a03b9f210900", - "ccc73f935375fdcc85ba534c16168908febf874a25ded59efef1006efb31d659757579d5a7ef26e4c910d67ee2c7a845929288f81336fdf79becc07892e8177500", - "42a4a6c5c24171266de2a129c621236bb7d59a8f68c0655dedb81f63aa980b9f6b54d952fd963eed124cdff16a9e5667d123b670e1f4f25cb93f254d03d5367700", - "a223900c8890f34cb7a64709c091d5817980ab539c7b678f4ec939494bae43d72f3653caaad4c8679a66088c61e2e0c0f3dcc06eaa5ee47930b430edb923955901" + "095e9e13403b7b398249ba6b07121adea43086c9dae49259955c77bd0c42c84a66f58bc0cb6fe7e471d6dfb085f3fa936a730725ba551874b90c12d1f09e463d00", + "1872730df7a78b2400ce26692298c979460552a7e1bda64c702fd10d8df1956131fdcb3c53621ccb2032585ac0e11a5d685e12e658c7f3f0d105ff9b4176c30e01", + "c048a79e93c15a2820821d0a9f5d64ed5c1560c4a791baa79320b865a636d48932ac1db2fa43a58fb9e422da818bb971aa9a25be0e13646251d28ae94c5e2ba600", + "c7e67e2222a5243970e88be22d5cb13620635e2e2e93e1d81f441a4c7298c14f29a897b38b59bad93aaaec08c5e408a374804b2418cb6044ebb3cc3029afb7e401", + "cfe3f39d79f18c868bc9cd227f8cb32ccaab48b4e6481b72f9f3e74f17b87b5e5af1033b0ee04f410ccc20fc96242a5e5292ef40f91e3caddc3ddf6e83d1912401", + "a06f1eae2fb6125574ddd35a586b2034630d672a38691b459206b8ff1ec0a6e8681ea699daf0af611faf1e17fbad60436fcd5ba7022a0401c1936b77ac6e081e01", + "9ca4ab63017ea7639c8c17195e090c7d1006289da7ea61adb27cb3d647a9f44e756791099fbd7a380b780f6818eef289e7576140620a418a0fce013de7240a2701", + "08d70e714be4493282719e96c6ff7ca063b003e595e3c1fb7925c8494b17d2aa6d17eba028e8419fc2fd76e7b1352074d711964e9b2c3818eeaa6b611f4895b301", + "af0477044a15ecc71fcbf118695030d582930842eb49c1675a969cf2575dc2eb0d14d742ee694fd6dae8ca424143a5f22e53e01cf077ca8cd95434f0ff926d7701", + "f0f6f7da0e96362162e433b3b3c445ea90f1d18b32d9cc1413248f0dc27e68c6703af07525f4dfab6e09ca83bb360d9962f8b67e271fa1bbb485b884aca6bef801" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "NBhY9RijacMUvN18h11DmPVSQTfiqwVd2a", + "secret": "b07bcb05916fa130aad994a1d7de445acc2c28b2acfe97c1e6fbee7c95baaf5d", + "public": "029d8e3cce3767b3ecf6f615dfe46d8ef93538f2748d4f0a116eb4f55d6812d4cc", "signatures": [ - "23be30d77816fff9cf20d159cb5fb9ec8fb9aa348cb7b6cab415faa75d1ab5b571b0c316540df75c52117cd58c3661676a87928ae2f0e9d114ce40963dcf8d3b00", - "1bd87a1a4973261218c016656d0bfdf16d663ce4acf90fca64d3dead8f4da0fc55c75b43b5720a3ca4979db327dbf79d197be732c8683423a7fd8fb81a62493600", - "8a83ba6764c419c9e40b4bccb4ebc532f686b8f2a5923d2009da46e87af1d65455c3a94931c0202ebf729c9a382901b0bef6c7e799b2ecf4cf38836fed16bf1a00", - "085d5e74eb669b102e393495f5d283d776b9393d8a62d5e5544131b517727cf23a74a2972b9b7c5312203d824ac2d444fdb0b0cc7f6c2cc6f242d0d69e528ac801", - "70cb0041315296d62a3d33e11661abbd78f77b8d2027be103e71cb73c5e760694f9a7c80a23add6ce76edae1ed2f85b6f881dfa07cd4c622eb83ee354ecec08e00", - "6400dc07017bdbb28c9513da4aab685b40d4fefa19607d0c628bad261b2d9a0c481865de1f3ffa7f6ced5138cab03df5988f4171fcba7690e2afd3565cf85c7000", - "62b09d794adb203104842c38685ef906093a680750186a940e7da53b43f9f8970c3cfd0fa44a98266c8a20d8fe611d12afd412370c9f9e7fa6f736b7c27b7e4400", - "d979749bfde7cd88644519d3c023cd733a4293cab19980208b13fc4571fea1b9179e70ced87f3f572992cc8d5b709dc348b74be0cac4d85e0761f06adb3b3e3700", - "be47990c90c4ca9bfe1cf8fdecdf92e20b9d0ddbe2e50b3106d2d699c95be9ed77a8210b0ec0977dda1476445062febb4763660dc520b0d465d31f9f576f9fae00", - "ed24f72b68ba87580edb3d3ef1317305df57439e06e227b729c396d5eea4e07e343ee26264cc48e24b377e86315c169a5bcd7db30ead9850c13749ebd75c812900" + "96d040001d138f7e8e8facf6add8ada3f2b3cbd73a9a7ce4184de7c6c8da694964df193acceb01fd53007f5947fbc035d8e85e84fb59d352ea746a068229326001", + "67bd4e12abb98df97009a415984c1c494f00946f0fe58ec8b93fb40a05bbbd571fe50029c7de9142a2466b60e835d78c33e0185aeca77af671be437a8abeef7b00", + "f4053547b9dedb47b479966fc4f31162f7d63c749beeebed4f9d0de0e59aef85145fe85cc249a776f35f0798d4c140f75babe24db0898e8e5aa0ad094a087d5900", + "91f63bb31c6ebc767194b073b81374d6748cebf10f46d8aacad986c450641939490f6a3380186f98540c5252882ab19d8093c25275d656577a67f2b4a51b573201", + "5fa1ac1fe4fc4e07923241de99b7a3d7471ae5d601277bbe3c21cda7c5ec9db44c89674432eb551580175e8001586203f4163b9686d82378c5b027f844c0da5601", + "c4fd4007a107d2b58389eb9bef87eec5e8e6721eab888a13a19b5059aba4a329162c64e9e7bcaefb043fb1fe677b2d6434fc99a9cfb1f60067c00d98b3cc5f2c00", + "4b2c0f225d0a94279ba2f99859a730aff20ee09eb161c9f74650f4061c8919ba364504dd91ba52e0339acedad7d65a5ef9734d5aada7aff1c3b707e28431772b01", + "f28b175b0ad668f075c998e6cd1325515dd6795e506b4e7f3b1b41167f8f7fc84ddf8eb85bbe32241347fb81c22a7ba46e052817b168102f43d630ed909231df01", + "ed07e4b55f64713de65af6e2d65fe9c88c782bd9f54b0cd30fc0c95f2b4d8e48244398e72b4aeb7bbe698f3032a5cdb39329e06952683dab69802861cf3f325200", + "c042e9d6c8a0919a297843013b0da4f16f62b0fb98ce047694f50f433ae9ae9a4dbce35a715a374d54034386efed191de09cbd4d1e180c5b292f06506298a74801" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "2FyNgfqHoLncq9y2Ruz29KwueL7oK9aKryi", + "secret": "f46a54411adb3a34ed4a11e4bf01d3d87ffefcc2a2ce158f415078c20e5b01f1", + "public": "029db862d6ecaa866217c85468d7b0164208dd37087a90c5c8428524959e982d79", "signatures": [ - "284f03ffee1681bcfccec4569928bc3664aa208c4d7217ecf12c2a65975f08ae4459018fc54a71f6352243cec235eff580d85b855b1ba8c5cbb025b04a7179af00", - "ff3db5c07e65594523332827558dc59e724fd38a47c63d74b30f73ec3f22871c0ff176b7717405fe44e01ceac679c12af7c6589d29f753a6b7e5d567e041ec7501", - "c21cba2e05e9e206fbbc280453da355e814ed1e4e9b676dda8c0fc21c478ead96669db2f130d808f6525872ed749cc4e8b348619737efdddc67209a7e9715d9201", - "f05581dcc73c034eea72b08d4a16338c84fc392af3d298be8aa503739bbf03bb663c8fcadb9a88c3e36a5a78fe2bad42d9868f0cb650055142fdae78fd9be62c01", - "6ff9f56588cf071ada3c7fee0cd2ab0b31d4dc83a386bc166847bd42ef4e642a7972f224d774dfc19258c80f5ae5f531d9aaafc5a040be3e699d0eda48d712bc00", - "fc4fc8208a96dbeffe58be88f81a3c050ffe45f18a80db6e4cef0c9e6bf357a164481fc02598205db9e7f16fc12dcbbb42153f6d0f95f5661d7d7ac7c149e98500", - "fdfe3ea9957d53a6811b0a43aa2b1de751ea4dbd2ddd4f0a04596996fbb0726d5bb72e84f0bfa5bbcf1c6b7dab520bd9fcaae6820b758a25a4f6acef0b50b39001", - "380cd1472f2b5e919cb69ae62732f43391d768742d8e6106399cde859ba7c0a0759af6d9f02bfa79c55a98ab35be106c1f4304ecc6249565c0261c3ce1cf693b01", - "7a186d1925ae271c0dbf2e5e6b3bf6c1e3139f6ebafdcb2f8be9fd072f7609017e1f69c0b7209f032f9270785b257b3ac2733ecf3e03884fd1492459d4bd85b101", - "bf50ca7555f2c40937f40cd4d5e83d6bcebd935049294bb2a2aae1a59d6e71ff662a67d670374b3b5312f5eb064a8c7808664ba4426d0093a0bccf222714a31901" + "192f8833f7172283c5c9c0294baca36002429782595fdc924c987099bddc7c6065683b14dd858eaa55ef7f87441e6848130ddba06b9cda2a41e635ab072f378601", + "93e6c81c91dd59aabd9247892a73f3939f1bb0b8ad6229c08e1f308f72275a066910573dbf60ef1f3a72f31bb0848e66e14c55771f5862d9d90b230c6fc8d02d00", + "1ce3643c9c018800ff12ba0a121b98a0f858ec40c2e6a9b5fd37abe0fd6d9e7d54612e64474ed28831fc0175bc989aa9f1aaa436a635207cdfa085d6e18906b001", + "429bc18483a652f86ae32e20c917de9ef043abe922c6bdc95d76724d95aae40c7c9e273784f58255e5ea873de4826b81686789470895984c7d8aac2a13365d3500", + "f4dd8039559a894885d1cf76043a4c4bc69be4e439050d965c4e2889818f582021d0850d7e2691b941d63b79819d9d11ee443f953395a1b76a54c794125a95e901", + "6f5b2ad4c639745a02a5633dc6f336ad1f8d4e035573abb8b9d91960b2ebea7601f62bacc3eb8c89b1707dc0ca3da4d0f8faf5b34f18ff8c0c86578d5340674c00", + "e9e052fec6c7086b57d7dc12ceec2f637eba01863336e6bc5a6d6405c8721ddc13f41a526937e82725037feef805603ce6a4c97421a28e5804c74ca66434404001", + "10c5f518ffd52e5b0759565706b618401d958e994a8cc48773b4081abe5f1c693c3d33378c08e29703018226148079fcb929c47389cca503155ffb7663c3fbfc00", + "3d943c9d9290f0c01410175ebfe7d33926c309b5a6724742632e962e2492181809596d7f5b712f64e82dcfef0e5f2dfe76d85911146e9920e5ac5392da1589de01", + "67bf7d8eaf1636985fb661774a0c4b5377184b5a5ac1f6f8c6ee4edda83ddbd22f161d315e924331ff5ae0919f83b1ce1b49cff295defe5617264e21aa75f18801" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "24sXyRBQRq1kYZhwhfHhLU98DZGcTeHwQNz", + "secret": "af178cc4704bdd222cc94016d529c5420710de96ec8926bb0a395855875163b2", + "public": "0306b389235982bd983d081f6584bb45123bb45e8055a844562b37ce7971c539f9", "signatures": [ - "dc34f7890c3ad5b284bb3afc65abf6b7f5ece6e432a5fd2173ca3d007bbaaab863a6fc67be8f002dc0e8fd85367287e75d1c9e1f488576b22fc1faaa8f91a92401", - "74e15b81f9f1190ef345378ed00b709a0fdb54ba2328b363f462cedc8fcf529439e57ce5a627a79c12d8fd8f3e56cfd3ca10baefbde48ef7421e4c00c62c04c801", - "cdebf97e7adf805f60f7294a18585ca43bdd2ef67686ee0637a2eab3a2b24bca5914b7576c882733ba0535aa614834bc05d334fa587c341f5067651e0f5a6bbd00", - "30423f3c725f127ac169ffd6f89c95446e16d05b3c7494a264b4dc944517e1de27da78d919083453c59b32edd74b6da653fb7e3301b72da75c5303e2b15b7c8f01", - "8fe48130d7ab689a834a227afee5522e08e1e9fe83150b1c1a597d616aa46b86110cf4fa6740993e3d0a6c213a0ef9abbeee2a50927ea837d902051a5deec70b00", - "cd5a630c5b56467d1de68ade1b644e4fe924b15ba3292503bbff4d5994d1c82f465cc8ab489c5e502bedc5af8166df255a96804af8cb0b77d33019dff2dbc71900", - "fb3ae7a05414fb1e77205a5dcf66b35f9156a9135bbcac4f8813dc3cddbc7df92ea7b89127fb5b44204a691caa9bb562ddb7f6429365db83227dc988b3c23a8c00", - "a29ff2469d959a100cf19cf2d145387473790fe72348dca4877d91c03adf87845526568e5913a5fb15f265f0a23ce2f94a9f0052bee42bd01d6105536a2086d201", - "ab6c90d23d14ea04d1319677c7c6f9cec79ecc526b3f90203ee609c7af5a12b24ed3da601de81eb51a9c92fc08bf92fe92359e259a9c4f770d6f2abee2cbe47100", - "4fbcbc2adbf31ab7e58a64009862053f40fea8716380eb2907b1e7d33342a3d50c7992048d4c73494c8b1973a0492bfd7f4e53ea88c72751299b2fea2d6fd3cf01" + "a6d3d5d20fdd1620c4a60e665272657e24fbaee36f61121cf9807f2207823bc51900b811ffb4ab32a2a03081ff4faeaa2d16d73fa82dd1814c683d53add34d8101", + "a176b6bd3ca6d38d8b38492178d78950575ae7ba22a6e4c43c30010d0b88e37f7a59d1da6430c92ce9f45276ba75cf48a4ff25f4dc73be8428ceae7943c7a79101", + "ad4287bb732b1d2dd038d3a3efff7c14a617d1fcd14d5431a5dc3264f082ed0a4aceb53231c0025fff20ace3215755d83a4380e61d1762f5b2a7139678830be500", + "394c94399fea17bdc9d5ba2ce5895c671ab755d10a7b10cf9e414b779762b5a309960d0a5c6a63490959ac2aea2b78e3a46ff404d001bfb89217daaf6aac135801", + "2656802a9978b3ebf7bce6153e7ac3ceb227121a2a030d0a18c7555c30d332e80f75e0b528ba372f44e457989a5879016b84c06b2d9ba305adad899817ef2cf201", + "e9a7e15fc35ed1b76dd33a5bd54893e8655acea9313cc3c2c4e5561b07d97d9e67e953ebfa256470c8c680bb80ba373ac03d3cec9c8a11a036665df7db9001ef01", + "0fe18385d5e354c2d53398351d94f0c4716a27e8b2ed564643939a2ffe8f0bae79a0b60e15ed1d26a57277f25440aa1ffe87da1311e735f22c76bfe183f777c001", + "96ef9eb7cb0d210642b35dc139d86ec9bb1244045faed3b3e81fe03874aabdd316fe4c261d075373282a678c57b996f9c38f9aea0fafc7f95202fd057325492101", + "7b9fa00ed2687eece3dc9ebfd517c76e49cc435048320699b7983aab895c196a25eaa9c3b423aa5a56ebd27bc197ee40ca0705ed0bc082b5bf826d9f1faacd4f01", + "163d0482069bcec72d0cd9aacb4601902e41ff7c5268f8a80e3f3f1bea5390d2592d8c24c2784b645f5c1776835614a85679da210b9e2d67fcd72462acf73d9101" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "2eEijADfBZAFk5WpNhQg24DnqPPWaUwd8G7", + "secret": "a3d764738e2dc9eff6c1d423362b537d2e2d8346483d6a5a034293fd9d057aea", + "public": "02e7f5c694d4f4b4ecb146a634fbd3fe450b017a0b8306f4f351dce5773e81ba8b", "signatures": [ - "3fe1894eb04e4527a1e325c73d372070f0edbac6a5fe357e9ce2fdad498a81250a42bc8d67f297acb1320f1cc85f77b1e92686ba85b54383dfb0b51fbf423e5b01", - "294c6f074f90b4ed894cc9c47c3c1b2472e9fc7c7730e2728ddea94c71c3f90e67e676b91ad6b4a4e1c44e4785714bdf62fa3747755343e5cd996ea579e69b7901", - "8dc1b6990d2e3161b4178a9a98bdce4b587cbe8e4600370552a165212400af2f65f82f78fc3a31880532e2aea1e98d4df381cc1d4d6b7f151146b2c184e0641800", - "d7c80e5487c4eddf0e9723f6567dbff93ffd54aba16606b37d8bf3205c1dc80f6776393eb5db28e851f7d12b5f5a43ce7e0d02fe2d424d24906787aa8faee42001", - "8e64a9cc750b6fd12cb25df62501d9bde1ab4a651002bf0fd859e02435cee8e438b2b8330d17d9b51abda10ad7bec1ff52a75797e30e201350a11b80ada42eaa00", - "ac1d25f3101549e207b5ac382f3596f4d229e3aae4818b1b6b82bbd83b9a8254428efa1ce45073de8c70ad81368e6525d78c12eda5d19138fa7895db8372c31e01", - "c1a3c391fc798d124eb36643fc83491e7b7c7fe06e366542093a9eed52c4f8a83bf2c9635755537f7a73422c17389ec292a45ff265ed097cdeb0b831cf457a8e01", - "7fceb02def1c7aa0e978cab623bae1a721d15f255ff5986146287b87ef9e718f7b4b3a54317ad06a357529aa2421da74f5e6dcdf2ce88e5b9148ca424400f00400", - "fbb5662e2f4ef5b4fc4c7c544e10fb23866f24b036364c97250a2cad7e7b60863ca6b70363f7e32dcebe8fe079291bd1ed14a59e024ebe38931d52ccc171c28c01", - "75a42ff331b314c513c935d56c880a576bf124fce1af15e6f9280462ae3e7efa44aac27e5007143187d672ae0f867ec398a8558aff1cca3ec3cdf3971adb604b01" + "4611b93df2c55426447f5bc13cb2dc60d738bc62b90e823e25cd0607154fe0b6194df3869d33c25db8c9ad94b89443440e01d617b26d628fe090a70db05588eb00", + "a7102de3b33131aaf1462c9b37c31da6c5e8fd8bf8f6ea5821eb3aec8672a93b42bc359635a36bddd0a0fff3ab605776cf63544adfe5044dfc302d6665f7d98c01", + "2a78f73c5fe82809661e4ab087fcff0275aeb6dbb6e5200359352d708705f6855828916a6442ee15e3689113ff3a00b0cd9617fdffb429d96885a5b881b1f6d700", + "b0d5621cd30790b21e32d079eaf465bb13356aa1972d91017ce5e53aa8d1acaa06bfb3850f59edcd71b5b7a5df72d87af038f1ae4a5bf19b6628a8fb046c360a01", + "ed1fc78e0f115aa052a9d3146b057516c140365176da613af737d1641d7c70f71324a533c06189f3bbfdb1420febb09917dec38ba2bbbe5cc4bccb89eb8f82fc00", + "db6cf55a88608ae3d438cb994c490c0c99a036c4254414f0c04be67475c179c95f5d6be14f009dbe391dc6c5c078c673e2b627b9018f425490d07e87352159f401", + "b43fc4b582eb91acc18cb03caa1b8460e85364115268cb4d70236b87fa58140b0644123f8df014d3c7195b3ce081294a9a7bb2946050ae24cbb98dd643e7e30100", + "5a14a381c75753e4f1403fecbdcff1ce0a0207ceceac88a6264b68eaa164a4263e419903c61b455b5894a3e83fdabf4137fe27ef57501b252a5a40b1733c2d8e00", + "1bc9144b3cc9c33032864d23c42d58da1cda12e782fcc20ff66487b6b4eac7655f4ba61d26aa2632c9033e9b5231da547d3737ebebe86c36d7219562e04792a901", + "44fa785abbbfd89a8dcf6bca7785e1fcd52188baf3368da756b7a8fba7d6360f54a974a54db38877cf84ff45ed136c0cb36573c3a26f952eba03a77de1a49b8700" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "1CRfbjpqCGsrFuU1iRWQcCEfiS9vSDGDnb", + "secret": "7c4fd501bb1a2f4dbf7dbf0bb9d0134fd90935d7ae5689d2005a030ee64ff0a6", + "public": "033f24693c5e97edcab4c2fa1a3cba46354af26865b055c6b7f699cd61b0731d69", "signatures": [ - "a7178b58126ed8fdc625d5db48d50d1dbf028ea496590f2c00c98cd39366d96d47ffd82ad8efcd56643acb07d6650b1a899e9792e286a33e8c9406090fd3a52800", - "09913a2ce003114fafb4950196ee9e10c9120024d8267da8aa218b6b204d97df16bb7d353a8dd8cd5aa1f224ac07165c8cd71cb9907f677b9bdeff8d293aaca001", - "33dea1086986affc7d65d0fe20209da6cf257fc6990075f8dd0d109d8655cebd2ac067387a6cb42f66cbcee81b009ad88a1a93aa58da1751b6da222d3176df9b01", - "58eb295885c52087a6a7c1659852ffcf5a047538e1dc055b53af34a981588b4967d58ee5dd834bb2f25ad22e37630ce596f96f35472641d23c38a4c1796c8ebb00", - "5f00f02b280b4a233f66c59b9ab8ae314e3e82a4ea7532efdf15ed26f1216d4d2cf92f3f950bba74c212d9c6d160978c3fa86feadaca916f0bb19930660e859400", - "227d01854ca26f10f97c7faa28b14c6f2267566995053842be59720d76f94987441edf5e4c86ee2127bf09fe379b30bcac9af897551f8133f2710369a1f4d12e01", - "748094adad042989e38d5e7e407cb904e2de8d49d8e632314e1368acd7fceeb95e3c501171d455b119d1790a6508511a368476d8a1951beb70bf96368da729da00", - "5a0c0bb3b326797e5ab3937e2fdc0d58c25268151445e7f6f8a63871f77f36976eaf995ee368962664b308ca9d725f92bb131e970c445b40fb32641f04932cd400", - "8f6263a6d75d73544cd34e3f837b25753eceb5950ae801b0c0905e227943380a7c0c8c447b314babd53670000ae54144b6f45b7d0a1e792fbc59392921a4040e00", - "859f8607ef780dc513400dd0155c4ebef7932c6c2c924aa1feed2250f7822989632e222ca37db5a9630ba98d94ea243c213bcf00a117fc5a31da119e0266424400" + "9f01d4332f3e069d930d98ca5f7c8f23374924c317503b2859537fe014ab351c07c36c8a6ecf6a4c8bfc571558399cf3c31b4dbaff4b1d5ab37dfb0c0b0e384601", + "7e18b44021d19c3d4d36a2fccd3139c6bcf8f7e3bf2ecd0270d3e01eff0b94ca6366ba2e8fa086a6f2ee3d5d9197a47114333942b754ea9cef3e210e528af0c500", + "8912e1fa6852554783c4d77be8e45e7a14c0a4c8b0473201813430b1ea832a700031ca373e48ae06a78cb3d95f2cc24b93c0a2eb4c02db2511e3c2db7fffe4f401", + "1591e3f7dd9b74483bd6c65846b9e59f94aa2f6dd02213c715f720e098e19f517aecaed7eba340374cd69bd39c7c9d0accd78bb9c3b6caed9704e7751a27710e00", + "9ab1221cdb071b3baa1943e1e2065f581d2a81c1d33d42f00b106c0e52c03ba5326e99bad3e1a4fe76a5fec41a29a82a366d2df1ed7b5688e1c9c591a8c937af00", + "699e98e30bd3e769bac617bb874a84137e279a420e09acb1bdc85f69d1d8132509f958813b914327aefbde00232d2fd860bf37f0aa085c2c672a3b47cabe0d9a01", + "e731c954198de65dbb56cc586274804ca0148a1a9f0ab562be25c7ca5ccb5556101dcd76b3137da7a8847bf63465fe174e537a80e7f507dcbcbe29e8f99fd61401", + "2d8790ab17a76d20e1b6d213505d08fb95b0e949eae75c4aacf7e575680179620be72cb7781037aa4e5e9656eb8b6f86eb81644dd102bd4b8259668e7eed38b401", + "ddf5b3672691bb851ada7425a749bc95fda1fc6f5cd2a14e11881cb06033543619ae8665086e22c308040b5488a2c7885e4f73e506b69c7138ff7a67f474c11300", + "a835ca7b0a5b355dd58983932cf1d4d15035a86e49df81128ecaf9fb783317115f69aa5d6d75302a0c128e3c531577f77ad0d5b6d215d25b890e941938d3bab200" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "2bDMZ8tKNd9jjpaxor2mNN7eyD3tvGQvGrh", + "secret": "5b5ca59c4abe3a782c370365bb9b85cb64ef66ed194fa2a0fb6b66616735d9e1", + "public": "0372ffabf5e1fe4289af91fdcded36bd3841e20926f9ea1e1048c1125c2aefb7bd", "signatures": [ - "1b16cd6153c262987bae619289699b573f07c4ac91e8bdb86f00df09985315c63bc0d30e2ac10bafd4b80a314265548791ad0fb6369082cf850cabcaaacb6af200", - "c0ae8f021cafd4182de3f3518905d9ca4daf6fc939db68b9bed1af4e72c21f3d5afba44868cf4955d625b8fd8aeb76cc28d846735e4743fe66fcd3ade79f95b900", - "42019d2caf460abab821bbcbefffe61b74f955c481f5461b66b11813ff85b30f63e5dcbc61f790a6182e49a9c51d7b3911617c1e744111a60841beeebca02ed601", - "25905a76cc83ec3f65c26363385e7f99aa0a3fde1c83ae058006f344691b40fd0d7e4b362478cde7e6468c2be2a4cefc0484124a5da54019dd34ac6f1fea7b3e00", - "d0bdcb40a5bf7fba224e777aa65976512f822d0fae6a8e2a6cc57c43e6e8606c56ac335bf8e344d5dd7d40c7f9c97917f007d08d13f026b6bf2ae71f2889939a00", - "d794f013a7dc99441ddfb712b85b3f3bc9bff0161091eb3f68ba6bf8072676df3e4fab9d25dd809e772c9973132d8a7c6b9c29cf75c8cfbb44f821619198877100", - "4bf29e9fda5abb7f4288ab20295827cba8c65ca3adde4a615fef2db8316dc88d3228f39ced7be70f24a17b5d59c9f8356503eae68a2f8fc201312b315256032500", - "7d53e41fb17f6805213a8a418c34fc50d9adf46a6178423bdb3903714f4c1f8d24451ebb4e380fb5e2ab5f08077e9dae0a5f941d87b61492069cbf8366a9f2b201", - "215e038875288bedf6e81e129fbef11823c8bbfbb60db69e47da5e00dba76f303e4623bad2be5a3098d4c7f374c895efd0d153eb88e4f67c3789ac20958e32ea00", - "4909b8b816213b695a30a8c66c6fcb4b2df3da8ff75b4ba7c0304f277150bf2468d33ea03a0ffcbd0fefcc591c21d573c6d1d2b456cf5b2c8516ff97217e8fad01" + "9760ad87d8566f068df40cb8b7510cc58fd5d8417c3c24e4a640f29e4af047c13fbfa476656295689a0a4543c0235af56a2b73cc310f9433f8392e8ecd36645301", + "5136f29e66edd0961f8a21511d04230ab71639aede10447cd21783ca79af10514420c3571d364112b3236e8e2c4613a1b35d365d522d7e57578d06bad5d6dd5701", + "206af9e7a04b8ff4f34fd353ff67c74723abcf6947c897901ada314ae14d5be60939fbcdfb0a19abd7dee745d4ef41d536dba5af63ff4ed51a9527f75d7653a000", + "39a21464e465370c3303fe9615535efd132b2a9625a5b687bd48dee0529cbd7926e45514566d8800bb0d730adca3a81a70d6092be7e0cce3c990585a37954a5701", + "177e0155ab098387673b2b95627f10437aa81aca8dae9d485f0a81d3a1954bee644ee54b2fbacb76ea2e3990d5ccbad69b6048adaad9f365627c3d4d62ff44a600", + "0e1e137d69c9b30ca391eeaafcc3e6c43b4d8261fa591ef9710e666797c214b54cedbfc2057a5c4c7f30ae3328b8286ee33bc38e301003b7d96a696628948f0401", + "0f6350ba71a39d629a37b79e4deeaa785dd634d833667379b5f56425632be10a7be104ebdfcc3304e6d2e7b672066305ee894187a86b1d04be617cea14d3b86b00", + "89d2aeccb2685af100c6df043f2ac618abffc9c25aac53e459231a9f86452a89005a26d25559688e543c24c23871e2c374a62237bf2d3c308c4b4e334970038200", + "e22ff4a474f973a28d084a842a3aabac7eea8c6d7f098b8dce13a327f9b4957b625ee95f947c86c072490a2606908dd6068df998106ea2a1bfefbdae1ee59f4c00", + "98902bc39b4e4d58dbb9906384dad91b0b2ba15f9b59f47b6d1985e1e48da08f213a4e785d5a1c18da576f5d9d2a37b4a6b21c330a26d4cad23bd75f1419e2cf01" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0004.golden b/src/cipher/testsuite/testdata/seed-0004.golden index 0e3abd0a78..646b5b5f8b 100644 --- a/src/cipher/testsuite/testdata/seed-0004.golden +++ b/src/cipher/testsuite/testdata/seed-0004.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "Y292ZXIgZmF0YWwgd2F2ZSBjb21pYyBzd2VhciBldmlsIHJlZ3JldCB2aWNpb3VzIGJyaXNrIHNjcmVlbiBjbGF5IGJlZm9yZQ==", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "2gSg5K2Aq7V52tPkQFMCfgHNhkae2KsTE7x", + "secret": "6f1d4cae19bb875ef2588591612a73972d824ff40bbc8ed709831e71764e7897", + "public": "02e28e6d645e070e698c35fbceb8a81ab5e5d4912c8957d3e065e8966d19ad8960", "signatures": [ - "8de5a95256503435dd3e9545cfaf559c4e6d6ec1fc34e53f1d43b9a43501572a3a19728fdbfce5ac1c7bbc97f793927705877bab774f613ad0a528cae391de0b00", - "3f8d1f2200678a3782797e44b1593d7d44e0f73ff9c0d554724a24450b0a4b2b74f4ae632e4322af3568371a5f7cd1890897f26eada336255ed7593964dbd21b00", - "1c5cb22fc870950870b9727325cec5baceaddb6c7b4f2058141f00b1ddbfd8204cbe87e332bf3aea38247b53c602b7428ec59dc43f01f7dc02986e5539e12a3701", - "d38f3df16343eea317aa983d435c005def69e1d7063c2fd404e355bffe227fdf043bddcb6524128c864322087b57e8d482d2cabfc3d932ea8f66206d4010652300", - "45a992b692855788d1f8338a6b900756c5f870470c65bd6423a3ff9284483f085deb1368e739457f72d6270f9496a007140798f404db5951b9a00cfb9e860eef00", - "7d841c149eed6fc65c27d5c8a26263c1433ebeb4b9184b3ccf0b5934f2adc4a044188e4b39303b98c1a2f5e4b7965c27412bd3ad40057641e7360cce32c24e1101", - "e253115e72970e2fafe05c9ead9e5a33313598bc768745518db6d2b4ac8e56a66e4e208341807b8f268069a69a708d81f71571600056dc2b40eed85636d95db401", - "ac422e6560248d1eea932ebf2b74eef6ad445e552f677a8875df0f9c3135f14e724622af3a1bb55c01564ba0fef36978bb3aeda14f5fdfaadeee3c5c013aca1c01", - "15165ed6866a941ddc1952587390896523822e360fe66f2e99798843a499996729ee9cd719421f3922a87d686fe64bdbaac76701c750ff779896be5d2be4a4cd01", - "9d5442f7119440229a1bc086a08ab6bf1b67d12f3e231d68a5fffbbdf995130335b0d66f72cb3785020568de4728aca2efa97dab5cae40c22e490859c05df59700" + "ad1d4a3a61606df19d2d56083c4754f158a3cd76e60fbf6f12ec5293fe45fd0f7053bbc931322c3b6c289ed8b69eddc4517afcc9574eb6abf85dda7aca90eb0401", + "ca7cea4a7b3b705aec86d1cd5730ccbbc3521c9b4e5916db5df089307c14d89b655ee0d17da0729f7220b6ba79f39fad2fcf4370b1c1ebb1ab8d787868090ef301", + "f485b3a381b0f88629afddaaf895ca7dbe0f173db225c5f1bfd05b80bef18e5e330b2dfa46b460eaa11a0434010a76c8c710e44e489fa879091112f9f7ce51e501", + "c3f369e6685732b3f07deb7a271f786f90b3fa8cd69f217443c9e5d05aa2e9286225f6435ae60a3b7a5206bf35166a7960bbb640a5becad2d881f3a953b6887901", + "800b70203dea088ac2fd6e6e5c8a26b831a245998d540292cb2a69bec83f15ad172b805b8670a485ada4069816efea4c50fb1603913e00331562894c7df87ad001", + "bd558108807f9fdebe5cd192230d0acb651b992fdeb54f4e9b2e5fa0a13e069f366b8442478a62032847a832cc5462aff4b7458f18eb104ed8aba8501e4470a801", + "a5604f914b5169099a990f95dcd38d9f78d145b99f5c4160118c0b6f8f8948d47f0cf1a41887efcc6f821cb72eff0b66f5b7befd824ef9ed8f3a07ca671a1b6501", + "31455eed1035e50088ec9ab7097ee54a8e9f6dd5f233f1b95f2c6cdaced59dac23118ee87da70ec88056e48ad033ba81fa8c14ea891a6bc4b65ea2e08182f2ac01", + "5cbcbdfbc91b05bba7cf8a24ab13d5872dd0b148ec6141a4eae664b03b08e6795d89bf71203a6cc2021fb3a16429992c3de07d3a8d3f4504a0c2ff48e8dac5c901", + "0a42a468246b2807cb1b1a83edb251e1a81838fefb0c2414d569b593eae8d3932bedc14a5daebe0edd1910cf64e18d0ce70dffb536eefe8b7b9c27f2a630cad101" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "DwLc3z1ff7uKUgcyAR3gQhfzJUHGMXktyj", + "secret": "8592f9f419cb7b0fd4216e314b17cb3b58ec944979f8f6a34e21fda09e01fb2c", + "public": "02c0b5b53873ec9cba0790588c64244579b0b23eda646d6ddea6153cb97538b3bf", "signatures": [ - "ff474923b75d9e52e9f1fa5ed78b28d763066b7f7c96e170b87d11b71331e9fd459b8b1d986195d3afcd75c5be7820caf72fe55f883d16b8637f5eb552d49b2201", - "cc635ea54501b7527da19c867215a792faaf31a45a4e9eb88d5f033b4fc045587f1b0a534d87d6323e2ae3a5940b12cf202ec1d294f3ff1743b64e093da7d4ec01", - "aeef980ab8ef1b93dbfb8d861ebfedfd88eeac3a04c36b3ae287a27051fc7d40107995d6c1d2f7cd24c89d49a816ee74a4fa07b2d13facebc7aebd97994123eb01", - "d000538ddb34daee2dd915bc19dadb8efa8b5f5f2fb255990029e20e0c44ec230a1449534f524c828d883f4e1d7807b82e574298b93d555b6fba9b059705297e01", - "afa332dafb8e4580d74f83f82ccd7f0fa10e72a39ca8a951f87d6d1ce1db521745c7dd063b55d683dd8b0382b2a82e7ad4a988becd2c9253e06dc65d20f4d1b200", - "baf7debc22a309b5088a079491af737f4fe9650b317daf8acd5644db4409412966952b35fb6232d2b3e27a5b54a97b65a7f0d6ee37b0d5086716685f12ee505501", - "d50181daac0ac1073d7e301f76689b3f4d6425dabbd8cecf9dd766d9e7a591ed7cd19e62a8fdf74e20d59a1988e2f9ebe5c5d46951ededf75f347603bbf9111e00", - "21b6b80cef823c7236a6d37f157f409a3937310253e14010e8882b8b42f08c92530190bca832ff61d5d6d483f388688e6a7bc66a29df74d01b3efc37983559c201", - "bfb7b4cb1200521123e5fd8b905367769ca034376e772f5cba050c5533e2d1c549aafd613e4b68ebce8fa1a3fb9ac008e4d1fe79187e226c681e3cf7c0c527e800", - "85a05779931dd2fc6bb4c10f44d2b13a945a6a518f6e55df6a5052ca544cb2fc1f985070070806a8f4b634d76e4aa672b5c3d7f32a8d1f18151f16cd6dcc506e00" + "f174e61cabae3b37f1cfe3d1abbd606621765d02ed6bfa7124dae185aef762a51f6af575745d33d4b2d1664a0d95dfc82e9010bec8830e13aec03cacd6ab158801", + "28cc5c115b8bc99e6bc9d6281877417a2d5b45806205f4c430210157794920490d11d4d0de202357df8e8603dc3c74426b98d3c30fd7963198a0ac15a6e6954e00", + "c28d5d073b95ace0e2e0fef8c34bf5288633f5d60c33d2fc5fcf427c1d70a8a9045ba9db1510b68de5cd9ba2c8709a6cbd0e8c5b57cde5a601d1737f854a4e3f00", + "2c67e279048522919862955b1afe7c32f432deda62d90219505cbfe7473a976e1968d180f7d43b2b018e7f4f265d489358afc66ce0efc1836348f065fb03197c01", + "f8ede7998f1110729adce0af5f3926a3bd8927c178e98c45ba1529943913ea337d4b6661c54914d323be43a9d7596fe7ecba2a8717981ad2d9db835b898e08f701", + "8b8b94e9962b5332f1289a299b3b99529edfd4fe17ded5c0b38d6a23364cd41759f40ee4454dc9889d207a920fd09bedeaad78885a0af853cce2d1c15472412e00", + "697b517897a92769b59d9cfc86e2ce8650a51a318bee6808a10ae9e752e8fc6a587073b92da7431ac39fb8d7e77c98de1b19ae90451df69a03dcda911587c06100", + "e79c81ec05b0bde926a1ad3310ffc62423016213895bfcbac1e120cad6db1ba872dce323156b76bfe316467c26475a3ff1468e2e285cbf0c23e2ea542c3447e901", + "4f90c8736b8081e2d354c22f5e2f7e15f5fbd230305257a3f63fa89276c21c9206716122be313ca3c8560fe86c26c09b9d6e9ecaf8c7d4bffaebe20edef7444600", + "0c3e651b2b03dcbb6cdddce3612f4d0f414e11f949d046d9befb8b34b0baafb57fd3d8968f27c994a08be0fdd6be016bd55c73b4a9fea07ed44801e3dab6086e01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "25F9ZVk6tvues2LcxpRUCCjh7yubBBUXf1o", + "secret": "618adb045d65f9c1f99bd8e8ff6098aa1c2abea4c8424a9ba50d2a46c7a4340b", + "public": "03eca0e99aec7896b84c683db6eb93fff2df7cf03389720ffd214eddf15f901390", "signatures": [ - "e23c79b7fcb937947a0af7d140308a469a7d1dfb829618cf6a216fda41a836d53c7a4ae869acc30b2b91229f51923c530009728f20431efe9c28c5e7e08925a100", - "4e73f88511d7466ff24849cc1a29e8b07cbcf85e3bb55852fba90c277a6dd28f1056f252331f445bb16824f9df4695eb83a96fc78447f791aec0c650334dbc5100", - "fd5111cedf53857eca8a342f3db07c26873e25bd3465adcae5ebaa42285dce6c2caee169a8d855441c15138355a1d4d232f286248d741ff5185ed506ce1d4d6b01", - "02987e4802e7b9a2a7c380b07ff235f8c80ae774daca227ed6f4d8d88c3676dd38eacf2854b0277867d51f8f45ad3cd06d754430cb15f40a09394e42fd7ab8d200", - "d18c5a079496a8a72f92ef5a38a9c6f58fb3f0ce28ce1f690176d7b054c3fdbd4d9c74b6f35c3dd76a2ef6f920b41e10d5c1cda7851ba0bdf665c6daeaa566b100", - "7c7b953c644586a94bea33252d5b20645f4199bd0f3b6000cf0f37dedd1f7ebd295e2938aab307b3a65e467b4c9ab105c71a5400f287888f7e83019b9ba7b28801", - "af384af44ad940a49735bb98ffc19b1b6b542a695d39b20299d0f80c9bf5957252ed76f3b0d77855245da4d0468cf7132684fa5d29ad56b32b02c4364894aec801", - "d0fa6d1e6707bbdbec349348dd4ae8250fcf8757faf0ca8af44a5ab9fdb78a9943ccd404c60002625ee10119152afc586a8e061f358113cda05ab15f7eca1f8301", - "9bfbfcbc88d8c02e5b3f89017263893410294e07533e36e37a55ef44ce2d2b500ad34326ffe6cc315dfa0fca1d0e91c54c36e361fe2c005eb5fc7dc430bd64f601", - "8a8b4ad35cde701cebb4fd19955e0dbbf5ec0bd7de5668b415bc2062cd1bb13d060c4fad1ea497f22abdac888cd169f96e64282f656deaaf1ce66febc31f47bd01" + "c19580a393f382b914baae4fb0861c4bd667914729dfc2a2ba04359c247669e55da6940023902e17d1006bfb14b71e2cd6abf4388ba0f18964f51d8b4ac272ed01", + "97920bcbb32e3b0e853a2a7369d0c777826fca18037ec9711e74fc04e31de4af309a5cc22311e13d68197ec991abb351f3cdf8e0d8c112d0774d1ed0585f93ee01", + "febf199c3d88e46fd9aad05f1c612d95dc2b14a0e81113b844fca9152964fd8407866c9348572f70f8b1a8f6d313ced36314f04a616383cc3cff9f6faabffbb401", + "e5da5885db7f22a5aecc0bb7b8573703b450ad8fd454e65f658ce3e99280495a6201bcbc756ae9f7bcaaa387819f6e7bb921ba33d142077344bac8bca489cded00", + "52086e02e21e9ca4349ef74aadba227f30062a46b150fa6ba478a238084617dd48bf5cae7823683b1dd7ed0c1190ef301a5a9235fe0636fdc32cfd4a4effe0df01", + "3ff9158189c485c5dac9ca9b588291e8c7e02e148be3ac5dc15c8d1e744483b315c6c6d078d025e9537ef2a03ec813cfaded0de7afa37f329e94b6688f566c1a01", + "369c2bf1bce93ff4324683029bc35655f45c2214f7137a2ca67da406b982a9bd53f5e3a728abe88decc966ea4d7516523986b504ddc9f6e4038a80848a81ef9301", + "e673fc1269619a2bb56d3a5ab9d5d25412e8015074585abc94ec66bd5179d8c0272b48914b95f37e8ae92a25fabe6714e79ee90ef32d0d6a02fb55b72191ae5000", + "1defb8dc62e55cf8666b6f02ba3814095c686211a5194b214ef01a655f3ad03f71fcabac8760e2be64448207dd7a94e3c6502d272aabdb1bb2fece29ec4e82da01", + "96b40f52ac8edb532955af2b023078bb10a8583e06f50cb769aa79f27b6b1d6c487c1abfa02cade78f960698439569fc8fd75f88933c745ada0bc2c6efd7611201" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "DJGUeQoBFUFmCeVSGkVY6DTcDzwAn3f6KX", + "secret": "4fe0e662f034a0b4937c6d8ab1c9f49e6f612e8fcfd57d332705d69b05a2bee4", + "public": "0340c46145683e5aeb80354625ac586fa8142eea1894cb2b858a162673914701e1", "signatures": [ - "8c444675204b07e22fb4ae85b1ec9c71c91f29e291719287097f265a5c769ea528fc5e8534b91126d13a1afa252d87f23cdc3ba68b97d379c6af9ca36473943501", - "711371670473ab4b72ea9cbeef16988bc721dda8309d3df13a068aadac0efad42f28393f6b1d743466b364d7ed6d937da4f21310ed87c29bcbef20bf48756f3e00", - "56d44c1433efeed21567dc2ad528fbf68e8526d403b24e970093cbb75388293e1feb89a68b41efb1030019359835dbf435368edf5b508da3c6e6c50aa37ae4fc00", - "c7f9f04a655b27de2cd2862618c7a490f0d78299ea3426058a6078ef058ffeb0134903600aa322ccc1ad1b28660080069f55a9584cd7f02f3ec2d81a4c94b19700", - "e2d6d82c43dee8f1f7a6fa3d0c28a594896aabdd2c562fb196288dcc85acc86000b666cb2972d8c5d0c080c004a623ad47cc5b574488e8db606efcf95c17a1e001", - "b6f360aac22e19da6e42830677b5faadd8b5cc09fbc2b76827bde0cd803d501f41c57c04741729e7e226ba243b0c58c7a85d1575493bd62ce336b1eb46f8804700", - "f07158a80afd3bb901ef9ac1d74cd675fbcaf4957f46efcc2bbda6f625a1428d32ec0c7dcabcacac3ebc7dc049c563dd3c687fd77afaaf3663d6396e2b6a105601", - "db524728d2e5ba06c0dc18aaf82b7730360614ac0e416e6829c2bbc58264e2331fb7404706557f73da0d7cfbe802682cfc7e36fdc109ace1de4f0c3bd29ef0d401", - "abfa2838b413313c5ac6dbb32ce4c27077c611187d1871e6c5793672e73ad0f35cb977222152cc9d033e914166eb2c90f83bb654202a52eb5ae01bd866e0a3d001", - "92d48184ccb809db7033dac506a38db4ee84357117edaa954d7bfd28025260415aa4b2a796fe3a6942bd9f7d9cef0a798b18595ee2d84438755cfd4fb9b6334300" + "d7a1198628f61f4925a314cd3468093d3231c99defa06f40bffe364693b5a06905d47a8a380666279e7a701d952ac3d148d99cfef84b60c39239cd2669ee641401", + "cb68e677160ff64bb60f5ebaf34317dfa0a88977819f807e5fca01320a493b192841804684874177c82a269eb867d118ad9e7e785d577b217b86a694a322c94e01", + "d901fe90a9b825ccdc5a0c7f154d839961658e6b0277310ebce6e27ff94ff05459b3356686cdd942060efe49413445e86ed1be410f5bbf88f0b4e5df35f9098e00", + "2c9d4bfc9ef82226b0b71cc4d725bc0b35ae15a8635e4c5900230b942ca0303e3a4ab3d5d57a02af7acd4bea6eb9d25fb52c3d0d43da43a854a309231ea9040f00", + "d01f41a7555d7d232e34dfcbfa6dffb0e0df120aecd9f6cace922c87ccc08063437073c07000b8b799ee52bb0cc438750502455141b5033a974eb3c4c7ead62000", + "908c2b370bd5a5bf23ee6e45211dd823bbc381e3d5b67b1a0844c7148b556c6e077ff844f4a17253993992be91ef1bd2f546f2847b9a5490fac0898e7536673b00", + "3fb2652982f07cb81c9b4df36b5719f29f42b2cd63f37227727a66652a757181620b676fe314394a9161e6a9193f6fea9244107d160bc02850484ebc0a2b1bc600", + "f1c38343dbcf9f4da4860554eeefa267cb18a35aeae5c0be0d6f4e81630b507860098120ce12924e7e237f4b72d0a3eb3669e687aea9b162db21417945ee679700", + "39332bf80f31e75d34ef1300cee7dbd87b5605d0714907e08d0cc552f86baf6e6346b68501bca34feb81f776af53053eaf36c91343d15e6e76d25f79c47fd6e801", + "c183c3f38336efe21ce302b914dcb06ef151f70bac7220c318b1cd68cc5d90f90a171263f5f67ca870fcb680e0307f1d872948d7d3458010864f0a3f284136b901" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "Vh9Zt9oPMjsJxNVphCjiGUxHSixS48J3dF", + "secret": "c2fde07e45562dc50c18c1e7552e03ef28639c44b2bf3a4d363314203e3d5f4f", + "public": "02d40df519e11c34b78b2124820d5dc04c6f59f465d6263b68347a9f74a98048e7", "signatures": [ - "9174f5c6326e9fceb942b5460eb348a6453572d948f86a24f0b0091e9d9bd31c6f28ea59bd7baf4b8b0e0484db4d6d4b813c646b01c76869cecb3f6d1cc13f3501", - "f53f066a2cda23262d56a40e61950f6de8d10b519e723740e986baa8715250182abaf7721ea4c27542e15512aedb1953b2c6a1a5e3af02e6d701912027375a5a00", - "74106a38c0bf79c0a49b61a2f7787025d9ca13054ddf316b2e7e2615e636f4cf1b10c437853eac046529cf143bd4f1e74cab82c5fa3730caceed2efb9864397301", - "b54d5082ecf2b1f54221b88229e4180bfd1e9649c9952d23d7d78b37ddfbcd2e6e62866fc82187bcaea7e03370c0eaea6e0862997bc537563a01c9ebf039705301", - "6e733482fec0d36f4a00b770aad5bc9b09e4ef9fb01216189fbd57933bf7ed13335f3c72cc0156eb044a074e0563e686277e470d8254578bc87849b2c08c2da900", - "bee240a23186e951add49fd86f8f127f62e0e72858f4a3e3ba56bbc819df416e4644f1756a1671236e484e336912b6f72115ea97f551c343d54b4373c334328300", - "6720de8b1b23402258a235123bfa954d62a50f948a0cf91a55053f073eab33ec0bd0a51a35429650f297ad1300eb027fa99d58f1c72a08be62093a72a81637c200", - "d05885062dfc44c691bdd357ecb7263eb2eff6708cb1c5af4e45df3dfdd85f6047d48e0cf5295e773a32fe34a363f6d7faf93c4f7e29ceb767ded3c91b88145f00", - "e86d26eeb6f59607e81313339429208c6283293bc85e24867e6608099c495d5202a59207d2964340ba520edf00c4b1d6297808193bb641d24d5076dd8517a74d01", - "da6186b08fad93bca8ad590d4dcd3242e56873bbee9ac5074b70925c5e0b889b380e191fa6447e89075ddebe6c9606066a05a4a5035f3fe2f39b992fed24ca5600" + "a2d420be32276ba19ada464ae8b29eab9b07b20be80ed9a2998d7ed9cb872b767d4ddbaa6babeebac811a6dce35915d9279cc6d3c0a813fbc82a54dada6dfed401", + "4459aa264b6e3d724abc8043de82bb8eb3f2dbbca1367d4b36327738a37c2f842d92698747c24602274588a91c8b191d17f0b82fe10b48ef01a9defb14fb07bf01", + "7c890ef0145c41edbb3d56f37919efdc817b3d5e82976fe2ca0f98460315253325c47f553e91ab6a6c0531fefe7061d9c79f1f3983e46c7cc5d21fe7d4068b7701", + "20ed571ec5dbf4a322c3b447cc8d2b454150ddedf84ba086e5735451698f99101f86f82802643c9e49673f83a988d7b8193a011ce0a3c52e84c6fccb1172f8c700", + "64325c6f0ab86cadcb791a37de986659a83df1faeacd4112216b8ef2f7f0c1337c12e6af249244ed03a460c3b12636593cba964cce2beb052308d20777343b0501", + "1ed1e4d8ea4b5d925b7bc270d5013d11c5b99992c6f22fba3699c1b7fb08b79835f7ca88c52416b191cbba7cc275d7f5d9d6d693990d85c41e4a305469d0aa1400", + "02b1d63de47256007c751b9b7854ec997bf7c543af9f3536d831f2758643885b3e22d15755247365b21a5200aaada52e603b53187ad8ee5c73306ea8cd0a7cca00", + "3b7680d15858017a6795d2c3a3e292fbacf2604c5f7db30ef2270d9b6093648411dd4f1c1868a9cf2cbd51cba1a8c68f35f3492abfa9af493db4260e04438bf201", + "c1b24bcc8d83c07ab3bee8fd90cab612421c1e2eff21f03a26f49c933d94e4734b79ae74268d591b6b58d68b214b3458412f0585e9d2f9a7ae1b17ed36b0102d00", + "c0ba9d290f95ed0068e90cf68c4b98ee935d463820fa35cd152ca085b548dc6b08035498a6f23cc28da907ff320260b9aee8bc589c481629070673d4cb1cbb0501" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "Z8JM2GA3ABPuKYwufFGkhvQrD2y52NFT2s", + "secret": "bdccd360c259b643e5f48a52043602ae46cf5f71a4604142794b687d21d1b8eb", + "public": "03fc611f00d187b85fb2d056a6a7e03a078939b1e9ff472c3f7b9575f5b459145d", "signatures": [ - "b5af3c511aaf85dfce80390b3eccc3ce804555d4a409135edbdb40c7bc0fb37d5648675af1549c0ff1e6fe70b7cf8af0a0bf7444c75b86711b9e781607a55ee200", - "5b5b043b2b7e2272b69eb1fd0a70cce9da3b583e0799f2691d646ef390e452d54a0074ee597d8f1c6b27d146312002d4000704d78604c3fcfe6f573c41ec01de01", - "d3f20cf188875a9b860d2ca1f5c7ec46518c59540377967f90be257c2f003ba95aa474dd99059a6896da58131ac2651ad0e9013f2b205fc75cc7f303b4d7c81201", - "ad5c9c9429aca2ecd695a9c1003148284c2ef7801208f4d6ac9985b260add5e53c673f0cc4ff365ec786b1bf29558f44296c99f5898c93371586560e218a9ae500", - "6846b47da19fb90c413f087da2dd774bfdeea8f58638dc2f864c2319da211b9a4d9d2a0805c856d2b4ecf6442e7af6e0ea461bcc3b4d3697e888310e0d9e328f01", - "6fa092858aee15828a8bb12aff5df4d6b644cbbcb9ec03cf722e331d6eb9c8501e0d31544eb0a994ce1431a90ac98b775a4c14ca0b112dd0842711fe257c596a01", - "98ec9ce7e594d6ddc7d5c4733efaaaa27bb3601a92ccfb41d5243e0e6b084c766c85e0ce8839de49bdeeadc2867f33325cf7c3f49301c9120f22afc6ddea537301", - "d2d17bb165337227aa8d798256fc4b53ad68a805c64e310c60b425a0cddf628c6fb8403fa8252bca0e6cbcb34b7096ccc005a864cf256bbec1fc56af149ce38c01", - "05db4a9ae413721585849e1f8e282ed3a593ccddf860c4b27bbb0c2d12b6dec903e48262fab48354366be03642eaaced84a305eaa2e8b5c849df85c4c33c169701", - "e2d52c4a77c6d47c6335a78f3a373aca7b9709dd18ec8aa540140d4526e10d473dbe863b9e6676fb7dfcd8bffa5195bf324fb9cd928488483359104e2a2d85cc00" + "7f023a6462b1eac2ad7226dbe884ffcb79cc640247f720a653cf62e4bca47d8519b98c45a7f5bb348f15f75cd33f5bdad5041dae85e9ba3ff073432a77f36bab00", + "1f9b6736fdaf0bc3934c687a0915acb1488f1ba30fee969c73f7f2dd16d011f65bb030cfb3738ac7dbed8b36585151f5adf2138075fcbe61ec7c3a2e0e5a6f2101", + "7fc3dab6e22ad333206069656f10ecc9600916f1cd0b49c5cc874c42102907f33bd20b18d4bf5bfdad1456eb7c8c7cfca1a676d525314f37f92977156af808fd00", + "a7697698ee9ab3368b5c6e75dca0fddf3f2ecf0378bd73481fd49e1d4f73a8b73988ea189cd301cf35b2bf4c9c8445f0a88bc2ed1d17f2e79f46336d6172442e00", + "0f6e0373d049e5cef26325258bdbc6d052826e18e26d8a7d4e7231d4c2f7f8af7f783fc5994c609e4acee8bc6777fcc62d40ee4595a2962b061475130b1e584f01", + "5727d799b297cf70b70c7267424f842cc78ff7853c7b56f0e47af60fe73a305f7713d11b418a1c4f214cfc2d87aeb5f90654e957a1752358a8bf160de86893af01", + "6abb7a9d88d099d1160ebb9f0f76e54874447214bea3d8bbcedae00c4eee34df5da3e84fb6cb35faa42688e7075351ef22b9b8543664dec354725de47c1f83b300", + "ee5966c6140b76fd30c4241c55ebb4e6e59be0546b41a7a2618a845b56edde5d63a0644551cca495bc6d1b4c8f8ba7067c3849391bba13a4a38a1c040f5ba44500", + "0692808145227bab7af3087c5e45f0fd2a468db2970c5fe37f0dfd2eab8dfc5752f18a2475a008f439c94d178a4b335304d4369096dc7e33735f73dcfa46e0a101", + "d6aabbf59d8b2ba240e9c415f95955892c7ea91e78e5c097ae126934a3ba6d592575f48b9ad58a1e65ebdd9d0464d5bfcbd4af4b849dca17d1dc2b17013623bc01" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "22GWk6z8PQVKDoRNR9Mt3YusZBqf18RBdb2", + "secret": "02a29f33493d777d410677a8ffb9049ebd37c08e994e48ab7664b66f02fa034d", + "public": "03c2d659597aa5b59c6f64f7b75321d824432b5a41724a74a91a667d3a183e9d2c", "signatures": [ - "9307fa42eaa486a8b464923f58bae869032a50a198ae94bd82f48966ac9b48d802a47c4f2848ac7e09d91c5fbe005b5a929e9fbbb90ec374f88d4a4241a6ebea00", - "65a4be8cb1fae8220c9ffc2a8ff762d5e0133015fadf53e49888303d7064cb3c5ed4c69275d59a568279dccf6805c4088110ca4c922bf989f1002ba15622571401", - "8d13270d1a283bbf804ef943e5d0e755e36e8a03ada2e56d5f0a377a911b55354f36cf85bb44d2232e182702364f27b971591a35eeca0f19bbbc35f2a3439a5501", - "658e32955db087ba687e803ba3ff69807f789e9c718152c331a0d5055e7112735a62d2641511671d003053be982297f3d72eaef7db46e3665242c1d5bb70998201", - "f732eebc449232bd2fcc8e1f35654278eb35f43c3306392f08f19c7fcaeef0823c935b98d5ce67fa354c449996d57167e52821584cc931d18ecf127a248f7ee000", - "46f97c0b3c22937f5b3d9c13933d1e64031a257e1d2b8395a30a4b8fd4e043c509d66de6e5a455f99a763c683b3c5f10b0d89c4525dc76ea7b19c79780da6d5f01", - "4cf9f7b1974067e02e821ca1c77ec9813e9f69c5ee6314cb2be89726ea39eb685e4021df730dfa448cfffc739e4d33eabed4c96c90a58a41deb9c82a0013a1b101", - "cc5db3b80985363f1f4702ef18250598db516fd2e5d1a0f3e3dad287fb5b9e9a2850c091c8e66a93c2eb6c875b9b5ed5bfa97441a2ea1da5081e402ea7a7e27c01", - "6d1a50159f4fafc9e443796f4d8f29c5963ced2a0a91d3865dcccb078ff7940d06835502bdcee110c091e33262ff81ce154390c5f27c70c597cd91800bf9cab901", - "79e96f5e7c7ee32bfa03d45c2a278d70ecbae7315a5b4b57070192bc15e896026ced76942d853556d601083fe39d150796771c0928b255df49eec0791b262fdc00" + "94ba8c0c74b89e5bf2ea16b610de49b6cb82dab492228f7e2a08317fd32ffc994c0c440715c24bfa144d5e8f73d6bba3f66dedddd6524946eabad7733df86f0a00", + "ac497705c165952cedb8d8060cabc5753fa0de358af047a9569c0b989931ad25357887605eac25ecfd15fbd0c64eac6ddd65af25de11dd16ef24863f20886fa801", + "7a3c728bc7aeaf467d9285eb8b5200f9a9fdf97e9cc7c5fbf4fccc8a12c2d76b7a652321bba91e9f8a30569b56b5357a7b19a6b1870399dd9ac24ba5a199986d00", + "68bdd162a269d6536d8f03cfc395f5c3fbef268a18d6d85c535af73aac08d87d77c913500ef9fb9b5d6222d084111953b8f04f14ea7a73e1aabe36ef884ce32100", + "dfa9cb7e3a83c637e8759701edab94800808e4ae0611c6dd1a753b01431a84081ec0fe95dd4b0ad18884fc307d81292806ffcf837ccfec38ecc99f32659564b501", + "2ce3a840fa0cc355e9f0ba33571580c177753bffad543ceb20785319832eb6c71414d06f9c15e06311b201f8cb595f5abe5deb471a9efc8472ec1ffbd6765b3200", + "5b87c2450e587f2ba62fedb4fe46dd8b487ff19b24632c3dedc1999035457a37088c380db077ab84fd31cb414f80c99b05444dec8e0295f337a13f079747e8c300", + "712c0e4c8b261bb86d46b458c51fa33de865414dc008229d9fe523bc97a6eaba22b0b5e70be850b833a78db5e2cd4a3c64ec8380a7566d72bcb9a986234c84e001", + "e4671df444064977c74fccc8692f11eda6a7460765e437edda902d3c5aae2dd1353c88d783dc0200d769bd420d989155cbafffda4762795343055cd3d21ac7ec00", + "8c4077f1f6e7fdf022e0ab07b55b3f6c876e73879d1af32ce281f77cc936d4ad5a86667cb593d0c142efc707eb4f8e6c6770c8c72c2d89aa1fce466875afb7dd01" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "Gy7bWVonUXNhGeuba6vuf9VCMxSDopVwXC", + "secret": "127e2ae002a0089db7c77259210be6b39559f2de9e0dbf1a16e362c73e8e539e", + "public": "02b2bd36f4f2cec30c5679311a2a918b61593c46b6cf522908daafdc337bf6c73f", "signatures": [ - "308026810f8cb03ca0b87199936a21a3816d4d47f1891a68b996ee67b6ef374043a51f4d72c29bcafd6bff0d5b631cc38d0df0c399150eebc18d8327c73a57ec00", - "bc751b5853de85c1b8fa4f89d76b1caeae5abcea968c63bc9d4862e9c1a4f0c24a0fad8dbc6a994c36258f4c43211683fa8d76c5a59985ae711621544da599f700", - "781a98b18486efa890b264e94ae8f58087c9db69698cc179374d855b0775165c1778883575b56c6ba70e483b4bb928ba4ca6f9d9a9c12289a096aca7a3ea1f2c00", - "c2428ac846ad708f564bb05ac1589c4898667b091e2581c072a47204863b62f547e10e078f4ced9ddd27be153b755c4549f9e6eaa86c3206de71400d0d440c2401", - "96957c7171884d154075ba464272fa8b347ea3b4ae1bddffa17eaeb602a21dde0b3fa3bf19cd959115c767660ed9b4cc502b799570a112758d8e5d3b7f4b174c01", - "b265bf954d3da8d86da89aa544b9de0940d16d47840bb2dcef6778f02e2562c93dcb3bc17bb0ae830c314e3a419a64b1c95be0c8d0bbcb8fc4439efd6d3b2bfd00", - "4d1f0fdb1f0c4bb2b75e41700ca18ba38427b0aebaeb5828edb55c39bfe17e3b3077a8e44a38cc8ef40f5e6d24fabd2c160a8905cd7560ee87dbe62d4c6b304e01", - "6c72b0ab3ccbcb81f9ebc0f23efc8730c6fcb399bdcecd6d60d80f80d8ccd5554bf0ab6cc17ea10f6fbfb712ddc295c591dbcabf42d9af1b2d5d7f28460a453200", - "0a6b7abe2ec75f0d222318df486a10161b6a2624ba0ba9940cbb63f148d7736c01204c42953d6929955be29db814c3f9b81ebbfc439871f98cf1c39e02a643c701", - "1b9923c544e07c417463f624c09c11defb307c74cc29a66fdb1af293b4e93a933cb8a275bc03bc81b2fd032a9a1cc0162a37e312ea2d8f431bb08906ea40207901" + "3c7e5cd75e42e58d4ffa2ca1a6f7d27df4c29454162329ee4395137fd911f90e2b3c855f37b20fdb915057be390de611ab7b9f8a306585a98bf37c9e9f9c74d601", + "5924e1c81b54945b3f1654ee12010984c18f39cdfe438339e672bb24b3ea245f55d46a79bf6359b41f08bd5317e7f52029ebf6a11001c184a2719f6e6312f94600", + "2dea341a911245608f6b92037f2ff9389ea009dca319db7ced270d766631d30043b8a627b5237d89c12c75085c84e0ea96e1a1cbb7ec44eb9b45646763cbba2b01", + "6270ba0e3dbd54f697f440cb4ec22c6551332ec07bd8040f6367df6717470fdc3957791332a244d270046d164124c80472ebaa7978d339df19dfbdab5c109d1f01", + "25ccbc38150545974f3b9cc52ef96130246fa9a3f64e6069a762989f5f8e9d8f015bad4faf0100a6eb0078770cf32c2bd997dea56facb314c47b3cdd37cc3d4501", + "6cdb3de2d53293aca9bfd74c6621c82af5f6e7102ecc4d658189d28021371791728c859162fa51f8b1823ceb19aa3037090bf18ce50fa5cbc56e5abd728eed4500", + "8253acc32c056cc0f10941e21ff25b17b4e2ff4ada8716315852e6ce459ee3b82f45747d867ccf0188a6b3799990e72298c31670f8bde9fd788c986e1779899500", + "7ea062c2bba7b93d31073f90df27a26543b67f357992fdcfa8e3a7db368cb0f141629c1498f010f2af86f1805556ccd4758fb8fbcc28a043e8b2025066d6f8b101", + "2e1270c4031965205ba2b8a4b85bc1945c0eed13b758e02fd627f96d89758b9f2f9819f90dc9f19fbb7f27c8b91adebba02055f72cd7ee3a07481587481c975001", + "8806abc33816a9fc503bc6f560f399b4073e8c27a42ad3e78ccaa643943164f41f8f0d016f9f32b25fcd98259b8e6d9244cdace4e0a813ec78d7ca6d9a89de9401" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "C8jt5AnTY8rbxTpbY8JwWkPXYfoAQ4fikt", + "secret": "6612959069c41c6ed02d7e1a2a868a241fabb65bf8361c0082c797a87eafe119", + "public": "03e0f8e7fb3d410563352dbc65fdc0a42dd4f6c3702440c63f249d76b96585bafb", "signatures": [ - "523f668f2cdbacc198fd22827469d4480c849894ca2dd11d94ec01636624fb4e603aa011bed07614f4d5f8a39b5194a2833dba743ffab078b68a4237418b17fc00", - "0609dfb4eec33e4d04dd6a66cdd480c68e359380692b8211c3fc8a03738ad68a5874a05e4d51fe733542b8d5e266feb995dd75ee1a502fa62f4dbffe96de1eff00", - "c856981f4c83324fa2ba33e22fa243be197b7ea642a030430c1c4fcb2fafdf1306d4c60246e631d2272d57a5ff3045890cb5c179c6835ba8532cef62925cfd6901", - "92a949c1294166f5e4bedac8503f51917a0c121bbb003d9c53f0a5af3b304bf11b9f9c4058bb7a21c08f51cd118f48aa00878c64b0997293c18feab9e5fd8f4e01", - "69370dbac5a0be0a017684d9223084bd6463e07f8ad1d8dfe3d6436fe55288994ac6dd627cfe1fcda4d4274d7573e46e4f5f5288b48c5aa128046ddcf8e049a301", - "c7ffdeb44c5470f662cda21cbeec27c8f35767468c35ba44a566fb6b5eb0432831ab7f9b45269eb6107615487b85ca12da508959f5dfc4006c1a0be4f662fad601", - "eb7dccbcb3c0ec0fb721d2abdd775f43b411fd9762856fa6b58bfa812748b3f00fdfffd0ad1175c0f6e5dce1dc11d3cefccc7d8400841eea371bf0aab95ff52f01", - "b880cb78555421c045e6c8530d2747fde4b224e472fad2d6be9c4094db4df4680a23a4f83ba620ecb8b87fb5fd5424bcecc3c50068c55edd1a975c013eac1c2e01", - "1a21a7fe22e964cbd485bf08ccd04dc32b6d39add7e332a7fce8b4ba565587610bee06dd5c88e6040b5159e8a4bb3c861fa4b0b6c0ccb05069b465ac0c524c4d01", - "2f2ad725c44f969c2a577caacc717f66ba8dd1dd65ed8298458e9b3e32683c78379fca64ec42cc6b458e09c4af38633f1a5a03f49c9a6e9a84995da275e708b600" + "03fbaf561b2dc8eb519fdf55b887286d29ec6685ab043adcaefd84a5525a4e406d62f5209001e0dd07a5865603d36f29575322b21575d26e5644bf19bdaf46bb00", + "a5af3b7b26b4a0ef7099775a9ab9155b9619595146e584e794f08ccef4f870ac74b1cca792622fc0932025cc88f44a2b436e1035a377aa2fe31c51ee76fdcc4901", + "28bd55dc280a0d32cfc09325ba0c10cf83b45148d3b8e5b6e71f518c731426ee670a71850ce30bffd3faff287a75f338000b5faf4d3ce8e3625dbce87b09774d00", + "61b4dfe751c918060ea390cfe695b5284fddb0e260ed4a8fbd3bd50d2de7dc49260094650012c89f5f0a93fd5a29a0aa0a23a34dbdc46b0837801e6a2b8f744600", + "6ff07926f05fb316a1eed1bc6157681063c8545aab1b05b37f6d328564659cf0621bdb4935fc4d5dacd751132a1513b2ee23acc7eb7cc395e8a27a83b26f7eaa01", + "45ba72c2a125e68610f5f453709f4cd08e3be050f053bdc9d1788e65b2da7b085d36fee291feff41430a429a87a4b9cd8d43ea005e3b9f4b099a0c2c997983e401", + "4ab3341c870bc25dc9441a6e920b11ebb47cfda4f4645e51cdcea6fa99aeb68c06b5a0e4b3b41da3ecdcc5fb162609cf1f71d49c0461cbce484fd11c0a8557b700", + "aa253e2de851ccf7d3a41096ce5c0029cb4ac90f4ebee3eeb4395a54ac50361d3d16cfa3e8b764dcd8756f8d890bd5adfc72a43347c9ca81b072dec40b75ea3901", + "ecc90584883a76a56b914f73fd1367329db16d547e692a64fc59ba4ea86e5bf93598d53f0236834c98c3751795030578ba249fcbc69da087dd632886611ab96b01", + "0b9462cbe619e461b8a72a52194d0599cd63d130f10e905a1ffe8af03aa1584311953db3006f00e7d7273036b0d9c5347c3c586a8b8eeae315dafe6f8bb2340901" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "baYpCovQfbz8Q2A9q5zp2AR4Q6hhCBL5pM", + "secret": "1ec466e5d354246ba0b60dd2de440908d7909fa5c2443b67ee2d5d151b94bc3c", + "public": "02edc9f522f60e60763359f6fa8d55760ba814552961fba4e3035c2b722a89c2fa", "signatures": [ - "6841f67382bb3b555399a30f0530e600f6f39406cf0b76db4f9a49cf7bcbcdce6de3a429d95001f5d13c4511b243128beee26de464a5978bfc2d84e135ca374b01", - "6492a5de63a23421052fb94ff7096ec9b6f4e62d52472e93d6dc7399ca9fb678182b9ce4693ac2129575a818d505e21db97812b0ce5bc65c32b0283f62a95bb400", - "269ad96c53692728d893b5ec0e4fd7fa787c551838ecb692faba68c533bba399596bcc10abb6ec6687ed54223d8912fc96b7e3da91d362585f680c077452e57400", - "8eeb62c1ab855fad3fe74bb5c162ca5b22b91475f60c08af6c78a4b070d62c4b1206d6a2e8ffd8ac12da56a242ccde766621ab98b7de125360937838adcc02bc00", - "6c5e0124bf234772812cff8a379ea3a7075ba0fbf793af6c4006418f30ba9b5a280190c064c2fc74be188f76331d196ec244b1d522d25ecf41854fc968176f8500", - "3742570c13e056d6b73d95d2c1058f9574defdff02b195afcb319d1723f1b08d25e4c5562082ae445f927c6a13bd4f2dfe0b2440d585354a419377f2b15fdd4d00", - "50f62557cadeb8edbcd2343cbd71c6095ac76715d2b2f0211131fa98028d9ed8692a8290df2f43241e07a433fb99e401f30f3737981c5c7dd20debf0d0b7b9a400", - "a896f62d4fc2e9f47a4ae555919e550103ea8e19d7418b658ca74853d1bfbe667f7be14b03048e87b752c09737c7e893c19e3e0cbb66368cbffa0e28ac3c559d01", - "fa0805b6de999a137cfa4f5db618eccb93bc07680c8d4caea6790dd720b875c626a3cc3f49e916d3d0e736c5f38066c594de8817f75717249b1177c78a405f2800", - "f2fa927ef98188d95236e1c05c7bfcce2a2748428391397db559f3d773e7b8884aca0571508476b7d87df2bac6d879445a40755e8e31a7307f46b978168e107900" + "7de1174714dd3ae5dbe8e6799cacdcbd03ae68b0440b04adeb46bb1136f333e55bd410dccc8489b3d01c5e4073a956caf4388bb803cc8d0105f22a585237a0ae01", + "2864b63a0ea3bec590a1cd4be61a31e086cae999fb7c78955fa86696fb3ace04753e70d4f14c83cb20b05bb9a30528aaba1f6f5a952995343495a4fb6c05079300", + "703edaf07205c2cc3bcfd26cf1608d679458bf92861880d7856489c42c50d712460335658b68625f9083430f5338d6bf42d3ba0f144f5ab533679556df92000a01", + "d4be1600c0cb92e0b07ca0263cd57d6c909849fdbbe5178fa97d983a406839a94c8b964b06066c27d13613d6addf21e151c630bff8c38092ed00de017d1562de00", + "c842070d8c933f4fd86667ed96cae99037195a88d5033dc76b95969766ccd9ac41432953188335399e7b2224958aaf08c5262bdff78a65f9191b5fa13547915d00", + "0dffc1ef0f4b1d62b997965a884728c25702d6fce447df95a0549e4cedfafcfd056ab44346bde268b8cd848b4e61d3c0ab8939cc251a935336ebe599886bde9800", + "d59b89ada61d412d26eb7a1451ff13c1872d93250243b359a368a1dac24566b0617172f14b76091b80f49bf8b02a8beaf85a461a521f1a977bbcfca1ad81225801", + "af4db82905ab7d4038d17c6c511cff360af7140ac3a99e5f9c4165d197f45185443fd0090e7be38f3be83cb3bb6fd2ab7b5f913fbfbfa0fb8c676936e995499701", + "005009764d6b272d9049808915172c3e8e38060c6227ea8fae538bbd273cd815393c215b0c04dce8400084dc3d83de618f7bb3f2f98f30a3a930b1e3286ac50100", + "85281a5f09289a2625bd5f23012e98c16ab43596c0bec18b64f47e0c67265b8020132a12b3c9e32c95c7155122ef88da0143d629f4256beb6c77db4077c562ad01" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0005.golden b/src/cipher/testsuite/testdata/seed-0005.golden index 56c431c2a2..f5f9a0a93c 100644 --- a/src/cipher/testsuite/testdata/seed-0005.golden +++ b/src/cipher/testsuite/testdata/seed-0005.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "rg==", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "E1YWJLum4Zo67o4HvSHcGwgTRRS5jsbM1S", + "secret": "28cc037e29023331566461ef67695ec84cfe2e3963b3284cd39ee3be4340cb3f", + "public": "039f1cade86afd2d1c2aab43bb91f346dce39aade4f1c4539b68b220b2deafd2db", "signatures": [ - "a712e5c1fef0a3da28cb2a96bfde871c26c35ff89547305552fa7e1e99cfad842025648ffaf8547046afea26b27b873c479c810f6ce57d13047c0e6d2185524800", - "2c23d2898af9259d3684ba7ea42b51895d00c82030c078f3668a99d146d713e86d392d0a80232fea0e7a19f5a0b817b577e328b43e8bfcf03d96b742f8bcf7fd01", - "d1ff132293587fbb58aa0a8c0b0f4381e2e47f6089c569a578e8e4d16cad0bea7b1c4c490c662e94e71205971fa3c94a6c3a7b262473489dee8e48f02e8cf8ae01", - "b750124d1d3b632951d0dbda966fcb51186635d2e39df771473bbff85f5add11247b8ff1b8eaa16a6913ce80154a2d5f74c2a738e52f2514aae9ad40956c8e2001", - "6438a8e4f8d2bb0cbec090dedd526d0cf966aa28c43c44294f186032cf43763076c77222c3bc3c33e125a4b9893d156aa5284b37bf4a09274cb5797bc75a194301", - "941620c99d11f5f486ccd171b3ce1d030bb700b8918b3205239f3d36be8562063e7c45fe08f18636019ce9b040177b51a50cc526ab0f21cbf34550bd1fbc5aa200", - "16e1f139922ec63f199f45f22a52cdcce80a90ff4c593ac343f3dcbebee1f766074a8a00b306150ffe488db603635c43c93274f4e03b8eb6eb23df672ea34c9701", - "b5de319a4c079fce8a4e5bb25d73c1bb2791f32747928974491521b547e6974069558cd75f4105dcc8c3f8df5bd98b976998fc26b165c7dd2ebd0aeb77032a0100", - "0af50745a210e8e01c9002062e870c2b24a598fd20386b371fa815d631a3d3313b6d8a22b61dd6f35a7854f0dc5fb4b21c9bef40be1793d4e374be304c412ece01", - "deeeb11a4e9639e02588f70105eb45d075e44864e3778efb54dce4277ba1f8762a676b58c1062f62403883aa6eb4d72b3744adbb2b5a90122bc763f19f00350a01" + "582ed859fd7ac1047451c96dece2fce048a7a2769dbf7d6e26fd6d8665ca77d74de3e4fff87cc8eae6d2be699110bdd461ad3d2cd26a5f3b0a1ee57eadb8926e00", + "65147b6a8bf3b95a29d3717c77c0673e03abfb2e1a1d087686272130b3120d5425970e25ef2f2fee5c094c41d3a6a61314b73c1d505b53bce259904854da270f00", + "be54697842c0ddc05fbc4456ed2d25c52c8cb6a421d63b69c8a74717a70245a9574314b50a9da78ee7ae1456693887b662699ec495e0192d6df6acc1fad1c28701", + "93bd2264ae0770bc43304dbf03d841044b92a9a0e1bcaf02616c9fc27981efea59bc48fdecde42419d8504889f2142d1912f68c2526ea6bac7bde4cc6899818900", + "279c3f244cd708c0382585497edbb979542362842f431bbb2fb79c1e32c349b95c53b90d170f18aac97fd8cf5f7a44d3e3d4ce80d44bfdcc28fdf96404c04f2200", + "790bd0d363885beb9ff0fbc40c2731a09efe3239a5c1bef3770f20845e15456967dae17ebf7672c3520b3f2056f1c041723d8adf6035a79bfadfa3538952368900", + "f7bd0099fd178cb133e8d756dc78b4ba9f35f0eee557d5a6cae15adfd3b5274c7b41077a8b1d938d7864cef8654ec0154f6698735fbfdddabdc11baed63b180f00", + "29e7751f0cee32a72664925334dfe384347524b950776f19bb8f1f65a6e709a23f9f8970f3e3bf47536a99ed2926aa5a9275b75f3383b3d34baf662c03bfbc5f00", + "a4db1d71434b9eb07c3f75e9b6f4116a0ce972420c1873e588410fbb89dc31ac3d812e71cf4909386dd46824f6baa9c5c3b6b27a5bc7f9e5988c60fdd5ec506f01", + "fcd688f407736fcf408a7aaf27f1b2cedb72f4f9f6de248c1b1be600d1a79d8200aadeb8d330062861b4a93c948d1be588d062d02c36bae498d3d969c4194c9a01" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2TXZrhjdPPVWX3mropZdAJ7C9tfKA1H5btJ", + "secret": "3a6ac4318cb089dee2fe368495932155be25dc2cfb1994986cdd5a4eeb97951d", + "public": "025a9903b928ef2f66596d3fec381bd8ab02be4dd419d6147a2839f4883720c424", "signatures": [ - "cfc60129012e9b7e7b2954b586e30be0231786efb5d79d3dfd1ce995530d7c9778e9d94e7125c851ee8d9f0ec179298638a0269938f9c19efb00219300c19e4a00", - "9e89e8ffb53e96106480235e0cee27ba74e6fbcd92a210403d651dbf7a5795ef2617b210c84407ba0baee22b418357fdf20b869967e59a381e1f94e7ff0db8ef01", - "6f09999d708dbd7e888db3f4ec0bbd589134ad519e4cdcccc7f85913414599c967829666f98f11d7baa41ae4034264fc183e34fae776d7ecba38d1fc95ced44b01", - "0f15c1cc8cdfca7388c2fd2d0d274862c45c06543483bc1e4df6696a4829fffe329954febb0a67609781dc93f310004cbe7bd00f34fcf064be024eb57ffc2a8b01", - "22e9d9660b645064083f905fcb0db1162c7af37ecedec4db2e64b49e6f583ec603edb7295c6d44d2930614e06030cd3c7a24c6654c09bd451014a051fda2aed401", - "5869f01d4321cc063b782163907e329e7f35226edcf22bdd49cfae1b3e558bd4126f26229aac3c12831567db3d076852f8f754a547a1cf22859cf46be9a120fd00", - "fd140ff76126c3ab1d30041ec7fcc1ccdd12cbc469339dc6bf7ce147dbac02cc7002f096b24677cb7ee28c0e12e7285d5e0b13ae523ce45f69beb96de35ab5c800", - "326de93046b017f1e9f538a04cb66781103441641546f814b7ab8ab2b4c1c20231db7c51344e3135aff52be0740527bf0a8658498b3be45635bb3ba32986228700", - "26e8e1ed6d65745255b5a3f5bf4828c170bec67f6c20a5dbf927e99b2ede825b39b02320ef7bdbd4fcf12601154173bb4a0616b3388cca9fca3c0cd47accc2bf01", - "d5e0daa4f230fb128c60a2f36805493464e95030c2524475ed879566ca215bcb6587368b5418b6b92faab18d7d6e2da2065fad0f419fc38d0411b56070ba5ec601" + "0d1ce484bdef0becc50ccd02245871e1bd28338313ce57f754c931edab9a822638f9dcc028b722e0738d5beda6ff9ebe71db9a1c432bc144608a58da7b5a73a700", + "d1c15c29c7d9cfa1312ce992120ea80ad20b79d46edd91815c4bed09f414d4244882d6fdc99d7416a35f2af2a148ebf2adcf66d35e6f2acf9fb61d23ed31714201", + "8b746e791bdb92becec684471b0463aa4191ea1735599b5c48850693f79a1b4e195d559735e0db727ba02ed790cf17d724f2c8085bbc755b3e165eb7afe52aee00", + "4b8fe3f64d924f290d451cb3b34ad3433cf0f5a1e63e2ebaeadd8c19507a8f5d558d012dd1a348a7143a995f1d6fc87d476379843271c1a3b217eb835d6c1a5401", + "06548a750b3a35ebc8408d251aeec0e2deed67e37f297120acf78391ba611ef625bd64a40e2521acc1110b9fe4fbb47b8130a70d10e7f16f8d15ebdcae50cb4501", + "75d7cfcaaa4e9f483d11087f4e1460991b96a47e3c13be1c7711dab7f9fa9cf577085bdcd8be8f852efae4cdb5ff32acbb7c62f944565e5fa2773760279efa6401", + "2ab8f885369a6671cd27ff2990a8c363a7c4a06b7f83db97421443241204a410170c37e10c8912aba3475ed773b80853dfe6d17ed7d3918191ccbaf84640a62c00", + "8590c0d45abb75fa18976c9e5c9f28aaf157a5d00611321d7ae86d1adc4ef87a560dd28f3dec5db3ab0156c19431a19d900267a36d88bee206e42c17e0586d0f00", + "c4dfa4c79fa9ebdd739a89fac870cb8d38aa52480e63c59f42aa0046dcbbea5c2fca4e64421852c8dd62ff7870ca24fe44b5513374560d4aa49f60921ac712fc01", + "8a3d9436b8230a13ad2c00173e819deb4117fc106064b044ab560c89d7f01a065d6533d1d2aad1565b22f1b69d005ece97de62c6e8c45da8f853f532ecefa24f01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "PTu4VmJMkpSZNPyReRoH8n5MG1o3gaicPs", + "secret": "a9e8dce4a111f6e752bdf29a5879c2c5f77ecd1c5f612df3e9edb8b251df803c", + "public": "026c915201c05aac2a8893115fe41615a49ed8d601bbee9867c53c7e3813f95088", "signatures": [ - "4e727595557de4754acfc68276a56809c4c1b8a31ec812bd7132bec87837f40424e8494ccd0db96356f6ef97f4d2975352345f030c68351e67da5855085f78cc01", - "06a92ca441f8972e6b9030deb19da0b4d5cd8236a0891b32fa2f65ab5f68be520d2d9a46a2140fd8c6e7d54875c165e0aa440ca1917e4c1965e40811b30d5b7a00", - "1cce4eaccab14764ac33a680201c8c9cf41b328052c09834e800f77b2daf61e37fb6194879132b0a2a81a8b8dd862596f608fd641f7def7a1991dc191c8a04fe00", - "6f157cd2684fd6e8f507972a41efa27f8f7204a3c3bc218993384971f1298bd7670dadabaf0b5162d02c25f5b78b428873b35a57499aa66f4e4a7e2b324a3d6801", - "a381a456d98529608ffe93c678a6dad21e67c5c67a187e7dda4cff826865ab6640491dd35d717ab10af81fb95f389a5a8ea75059455e07fb704994e61beb58f200", - "67a6a9724436f3161beffeeff917b81bc2f6e3e9778d14a5c9e8310e652e1b332d507e241f79bbe177f3d4d778053d265edfa59ec665e7663c8bdda14c7ebeb700", - "63cd8836d4f60977736c030e5d2273980140ac57dfadb1ed4c44132558f0307619feada69c3a2d8f1f3ff8f552b0cc73952c8d62eb04d3bea1262cebd5cee1bd00", - "587cd7f6ae40c16c5528532615ebf071c792bcbd72147be04d8e5cc369cd1826555fd8b4538db860776bc7a30174d41aca6ba5ae6fcbf2775e276ff50234ff1200", - "236d8162db391de61ce64a5808b43c41092aef164454271b7cd18244a3e99e5e4363e5452b5d43dfef71f6ddd851a47474e3bf6db983a49d0889412b00ed939601", - "399dd3eb57878333053e2b93b1e465941bbc138399b878f5518de6996f5b2b531222b34003e64225f53bf0eaf43bf347d88f2dcff1c7e47bca75305ccfd5215001" + "c723e8e7ac59644eb1a9a59e6b8dc261104e7f89cad7e7e508be71a93a9ecea70c63a10f0d93eb5edfb23b0183e0a654dd042cf2420c6228818e819f8a63a4c000", + "50bf3cd499902e7350d89531941af889a0dd9bb0e0bdea2282313c99b291a6884080095a1eeb55f5a65ebbd209d889dc264bb7da5ddb7e13706a88dc532e3c5401", + "f4a9c141f072faf21151839182d55e841e48ce3d793e14ffc36088ffd76b1d650760bb36721ae64b2792cf2eed0afb0fe1d862d42ba9673348382ff3f1ca245f01", + "37a7ff5a750b8b77fe93cc01f71f4d4a324ac70fd5d1527d5ab41c1775f09087321f3da3198c38bbef0cbb886596804a22006c704f6592652aae8366a1784e9201", + "95fa2b244623e26c29ee4cf050c73cac85f1b49246790f34838d2922e4b3c90d28377d332cd9f9bf122afccc889a84930b5ec196b399c9550b1b83372ad7486e01", + "b391dc7753846b34c00091914219addb98d2c8f843d21c72c8f0b57c9292ee4642599181c94129464cbdd8704b93babe7cc0b76d281555536a93b6a17ccf042001", + "54325c4d401df59c618bc76f16c1684f3cc25aad328f5944d232a9f0a3170d8a393ec2c78c7389be320044f0770bb6c2f9b97a0c8df111425f7683753c783e7600", + "9479da56bd083cd4e8f53e492e651105659ac18682488ccf9019084d14c8fa9560873c07e85f5fc002e573ff7c5465b8167382652d088082ec8584f93db0d5d301", + "a4c4429e46ab80549c155fbf05fd7ff5d1adc497024cff628f751522ce429a825856c0c7f62a1dc92fd95d62bacecc002a6800d41ef6db5d8737dacb9d60e08601", + "fc82184adaf042736fd92e36fc42dc7e0b63125b6014916065bd3858402a4d891c8c206bc05f3a60ed6623b107ee34ea8bfb5182e5d75c33b8b5672ec5c536c100" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "mkx9CqV8vnX8m6wgMiQbW8gLLnHh6vGz4N", + "secret": "ec677f802da9627a8c4a90d385ae68399bfbb69c15dea4cba08573cd81ac5a9a", + "public": "038797d2c1174dbb2e128e165c9d3814cbbebcce024c6fd459043f0dc661c7db24", "signatures": [ - "9fa5c18ba7bb3b62e642186d4039e7883dfdac6639e90829bf21c7155d2b30c32d437dc04ae301619ed59cb1d10b07306fc34eeb9db4053c3adc11ca2002572800", - "718ff65c2b835026a210db5f3df65ef4171b135b4e5cf9b4740ce26e57727c7503273af6d96f4c627f54377951a6d4b06cb36cad9b1be47bac8bcf8c167cf1c001", - "be51bdbcd7fffdbc1b68898aae83e338e75ee7ff166e2708c0962bf9c6dca7f262d49da05ddbd9cc7014dc8330ef29a581f859394e4c8258fc078e92c5bb377d00", - "3e9986b4e0bb554d5857b3edc785be2549c4d99fe33816291c6e4bce5f099a0c17f2149bd7b85dbff0b10df1737783aeec834ed00df96182c7d743c2c041362701", - "7242d0a7f3944c0618598c3d0224cb7bfbdf3aab8c426d1fc8fbaca8c446ea12792989d5063ba1b7e6767dd34aeb01d38d4e82997139cee4ddbffd2dd4202f8600", - "b804ab89fd4e129ee2e2e8c3de46bfeddcb688655604b641dbff0c51529eb35641d200ef1105d46e7c07640d3e978213491d9c40f11352554b86d756110ccb0d00", - "dc5afebcee93bafc45c156d1c3b562a9c376b392da62837ffa6ee8af4a9da09b34b72758af2ce4181a94e9f4dc310e78b477e962c59b5e046a630f8888f7240600", - "4d2b6adb0fda0b55cec556b4a299f7d0120732bd787f9fb3d49365d3bfcd9fea31b40a71b3109c217ca5c13635d9b41293e75783a9ae74f9e59facb99404e9d001", - "4d751aa8ea6a9c86825e8f977092aacf89eef29311aed2acb6e2a9e4ea241da5437cfdad2d94b575fc49a2f98a07d58e96d615863e96da0696465d4e7837a7fa01", - "75ae84f3ea553a8a55befe6c4edbcd36f0f2718354a424aa99ec6a9533de8a8202fed73b8f09d615700c43adcffccec2d5a203be54696c370fa113f814d7f1d101" + "273a38e3d7ba7ac27064fb70420911526994f497976c809803cbf933b95651f570c82ed60b0d5eee3e434754f525716ba85d1fb4f4b6ccd85680f12c178af1fe00", + "e4efd05ec215a0bccf810283ce8397f023cb79cf549e9b84cc9a879da14a1def127b603baf0756698db559d4ce57f12c84a90233eb952857e3864236bfe413f900", + "cd7bdb06aa7c5fe19a365ed29c120edc4936443b074437e048a174525fc8a49678e6e5d34355d771835c176f281341eb621d1c9912db8d04d51ef9e8289b3c6301", + "186363b97aa04417a725771ab2f53219f75bbedcca84a7720c542bcf1b7a7bac1d195cad9b52b23efc8278e0035856d1c405220164b29189ed094dec7618656600", + "c6eec9029162fad395aca44947e6cda7517f10835e5ca801462fe7a868086eef3cf8d712bdda3f4aae38b288c09a3851cf6d8f418721886a0a8e87e9fab6bf2200", + "aefb39fc91f106de7f7349b53ce3e8efa97986ce3503e8ab527af820aaae04a053cf336698cebec7d306cf5c52618ff77aca763ae5393ce8d5f45a580ef9ad8a00", + "7f2ace494c7b7ddc380da34d60ef4152f1cdf8bdfe082603d86a9d52a543e66253635ec64531f6b09d5a546549300d0df2ded35ec25e84f7b0a961f8b392423500", + "1fc025543feb8990d415283e946d3d42593e3f4259ad36de79d3211640b61c2607da58688dc13734c15beb10018238aa22cea4460deb1c0a95626699c0b58f8201", + "a08ecaa36a67fffac7189c82a72ef65a419f8ac513cf87e7d1e2780c25da17e72d21e72755f88d6fad7f5c9b21fcb5d9ff3e1cc0796d46b978e0023663fed85d00", + "58733846895c696b0dc113a50751747fdb0dcf32b43171acc591013c2c6fbd7239f707a1c5820a8b922544d2cbd3f49bdcbba5e7bf28db69035bf30b202da4b601" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "ufRofY1rDAa2QQojenfxsM4X6ibkqCeEb6", + "secret": "661e38c38e3a9a5463be99e2e57d9dd6efd5569545cc0d4eda18be36911408e4", + "public": "025b6f563fdaf60aef899c7ea420397602b1b3ff23ff7a36230cfe55fd88368b8b", "signatures": [ - "e2cc5b328ca1f7afb3027f4bad9d8c8dbc34a5fc9ed80b505eff9acd13f737a6380697a36676727cc248e9e9b675022d37d5529d7b88664e09b7970c6beb7e8a01", - "7b0f177b480d58141effc935388d8378b52070ff292c1dab5f1a93859f7b392b7426106a77f40cf8db3437cb57a3d741546995685f49253876db4e473c7d395301", - "a71cbf44d8bd51977866877ea181c431bc1e8e3b95c8751865aaf79d5bc23e0a5663d89d3f49caeaa94b315bcb409756cdc068b2858f3769f3c42e04831d2a9101", - "ad907110cc6d112316b90a1529c746a5fc61d64e9b029fd5580344e5ef3326615da4cc72a34543b5652e2a1873f914e88914918960dd53abc9939594b12907bc01", - "b34cb69da6b14c28014f797106c508bb9db9c40894524d8feefc31d1d1f8823e100c96e56d06c85e4bb2b43fcdae3eb2170aabb4c4625370c75713d5661bd80200", - "3545a0a1fd40805ee54584cbef82342e6053abd8497632c518a373bd77e489b254115642d300acb6be0db3e77a61cac236cced7a2f98ed1f5ccdc7f07a4cb82000", - "d9d83feaba83ab93c67662b625ec95e9036fb479db22796a2dcf2da70c49b4f14d4984805255268682e21fb8e551306535e342490605532e7c086f92d16d25d801", - "51c6576e1a05037793dc6f3d3a9213e9d78a01b7e6ffbf133f3580c2b49fa62466fa9d4e10513483d50d94c63c92e99719515a8a641d1f5adedb552b1cc7017400", - "f6859244ea7c090db89cea75ce4e56f3bf682dad4f0578cd8d741689b2706040036c3ef2c1ba06e5d719994cc2a96741dd34cf8b421fb16c0401775d61a16f6501", - "d4bb6d0f0510f59c79adf79151ad14fd92a077d61588fb823641867f3c170d4029caadf2cfd7be39b7b332f0ef30bda39745aee9412669f7922a5839fb3b588f01" + "fc478aaf82572939f34775beba8665c9fe1366969dbe69dffc17824447f45192506556092180d7f76d3a317902e33a9706fce4d9dd41cfbc29794e31d00d123501", + "53bf45832787f16e51cb6bb8468a790cd494a3719b4430b84d1d4050a487d7ce347fc6e1cc810583b681447bbbbe0c9b2a98b12552417a4c687ce4de59de5e8400", + "fce73f2e0970d1d02338d808609010351a2c3cfa41f63e7e632b32741978f598158096d5dcc54584b05e288b3522db48d01e6295a1a64750d8c971e734d0597200", + "c44114e4381adc869165fc09554859f1f920e8cb25abbd10bda4f20c34fce4665b4403b43ab653f14354ca43e1cdc78e669b5448e4b9db5424704253141b62c500", + "80f551c54136d983cccb8e656eeba08874318b0fbb1239d2d0306d49a262591e7c44cfba78775ea5153b2bea5e6c108398b17c20fd8e401929c5e36aaa3b692801", + "4c978f3ffb2986d0251e54672cc393e1bbfed047083fd3ada43544bb2beb3f9b14f79550b5251431a4993ade176063589dc0df26ff16355b65b5ad6e06d9892100", + "460dc20c24368bc2793c15df634b3da1ecf55ce3d86507514a03d9b945663cf00887da944dc845fb1ef423e7ab51fe556b7391d697e6a69400e1e676f1ac24fe00", + "c90f01c37871140f69d90b2c5338ee058b0baacf05277bd5d1945fe465cbe0670133edf40c746ac174a5926b102dea63cde0e283e7d7d6b7cbb1faed0f5ffbe101", + "1ead603fecd7f7860eaed98169f33f479e45ca8ee2aa8bd220e9e602123435c84581a5f8603b2a9d16fd5811a3e6ade670fdc5114d7300bb1e12990c5c9eef4000", + "6731612a2c6b5ec693f8c710c9633840f321e572ae0a2a0e641193bd1fa543f55acf916bc16438ab756b365cefa68d749569fc49bd75a993cf193ab3036ea9b900" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "jhRanaAD1Ta8fVFa6jR7u8sMtnABK8i6Fa", + "secret": "1d3da4928ba90d5bf443fd7fb56a6ebfc2a01fcc30ee33eaf8465d82b683850b", + "public": "03f3cfdd8ef2bf64c313f2feb8e9a0124bcd5d633134fd8eed177f46e957a77e96", "signatures": [ - "bb396fed08c88d9c560b685a84442c4883f9d439ab5382f4699d5b7abe0f5c9975bf7c7384290d25d93e65ea78fd93cd474b08fa3bd9b16ef5a73aaaa16ac4de00", - "8da2b3065edc1fb8de8f4d953987b8fea4f8a0199895aeace29a3bd79e10984b37a3b658d7c7bd92e5bc14db272934a6cc0d1b970b05b99b9851a5cf78e030ab00", - "65e9c9a63c81b1b2a7a54f18e77c0920e6d3f5797983b67eb260abc7360467286bf0786fe3180882b3d4fd35bf7c256c20387a34009ce206fc1466fe8dca67d201", - "d68dede154195fb072882c5bbf2a7f8ab6ddc683d98eaddcbade4c0ed961d9633b6bada1525589f14ea559db187016cedb8e24f09d2850aaf023e42e36b7f8c100", - "c48b63f001079fc16e6c2c6c24de01d3589760aed941bec93ad1123043bf475e3e9134af6536d345e9c44545f82beeced0111770cfac98b6b467aaa7ce4c0d2d00", - "fd042b624758a4cf7a40414430fbc3ef5f3412262263bec02bc749256fd234a65c3144b5cb69a3ecf37f08045e8518cb0da0fb5eb58e93c2477c394a6567d76300", - "c8e05cf31626826d7336f6e88cc7d0328a554a4ab662f96a6f7b3d6c6f52aa656b38e3eb076cba43747358b4459e25b8f795d72e06801a4418d330815397655601", - "5e10204765d52e5fcb29b6ed388e21456744e646a84beafdbe1f906b2dbbd262345c28c102c9d056934196e8d81a5b2d5914414ad9cee1207f3b3f3e5a820c6d00", - "9cf611193109c973b21bafee98b2306da95ef147261c3428ea1f3f0692146e094e7c91194a9d6fd97fe1f545b68847c3fdd6947482083ad11d6fec495cb93eeb01", - "84e080ec2d80a749554711f122b3b60205761a3b2604369e534c503b8a867d370d7a93b11a2743b4d3e0d9f5bcbb690b88c0d8e1f7e357c63969ee0342ae438200" + "813cc034cb0a590d2b264178509c874a27978e1590b39536319fba150cf16727759965f1c02ec72d01d2c76b403753460cb569739a2b4193f94184508c5733ad01", + "eb31c1e18718ea401dd5b1bbeda01886a4c40272c8f6d0d56a5ecde09df3085d513be8293fb7e47d37de19849a756ee6fc7ac73f3a8a215b2096c5f7662cf2ba01", + "a8850cdf7936d3f8339029efa5bea9c9422719c52fd31386044c0f7ab8a628622b118d80df8a5972a5e0736de5a2ddb9684fdb8d620f7a68dd72e4a09c10bc7601", + "9d6c8ca1145714afed5a3b6e2ee995375ab6262cccf0d24f22cd7067a4350ed0751dd15bbe7ebac345a4d56d75a3c850f229d3aae44dfb7916c39e07f252d37900", + "84eb2b5c4d183334cfe54dc7601217f81672985a6f2504440ea867cea0eb8446193a6f82d38a1bf7a32c3d8f2bbd3afb57767837986537a1d9b7dfd05e4552e601", + "afb88d11917ae3cc498bf982efa0e5afb1c2d23eccd20dd5494766e763673dfb664aff38e6f6482deb6cb05f38439355ca3ffa395af381cafb8353a105cd321500", + "a4f772b50f0e7ad5bfac148f58bad6bf83a98954d04d51608a9a218b9adc1e5417fb5ca3210a3f04d0dfa2ab09e44f6b667a51f6f005e8366d83032e219706bb01", + "21bcb3564cafda1143937042447b79a89bf128d881a88099654a12c5ebc05f4b6b477da247639e2080f1e0a0c0c5cd5180f902735e634026235c2f3e1a9407db01", + "18259cab8828b0a8b4fdf6b116ea053a82e1ddb71ac3b8868d8f14b4ed3b8d290dbad8a67f9ebe626ecc213db20e3fd90ebda5edb995682be0afa8f35690bebd00", + "41d91535c7fd4a9d7835149d3eec0c72b90a6d1b73a92dc91c35af16f2d35c107bf9e4c2123e09921439e161891becc5a2be9c5ddbc8b1795cc6804ed3eab34901" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "77W85kDVi2ygMY6EjQffPtZQ2A5K1kJeTp", + "secret": "450e7d29bdee2f8a2e15ae2730152483498dd0b31dfc693ec7e4fbc6eac502fc", + "public": "024e94e6e275c8a3c6e409c91b071b70c0c1ca2ddfbfd3d08cc76c1a98ea719eec", "signatures": [ - "b768bdb3fa817e8f9c12ebb663575d4636febbbd3e7ec51ce3d808460e4cbb6308c9ff72196b1f5cb4fe7b4b6684dae924d950a910b33638fe62725b3f9085dc00", - "1111d4d3bba854400b3276620bf2b38e689f74674e24e9ea802f391e15b6a5ce02fa137efaf474362860cfbc5fe9d140e693345608ec923f90e39d6603c148eb00", - "4aef970c9a6cced941ba3b6990263f1194bce353cc13db3abc84b9dc40d585045a8d6f8c8d5cf58d06f31700233619cbc9ec8e580fa1f8c7eb7245fa3a409feb00", - "9cf6c9e2f3358c464065b715ca442b70fa4fc18935b7f2a0f96d853c73b37c557a07dffbfb6cdd156e530483760eb54221aef5e7f8a98d6db9e8113db224770201", - "71584b4db5a1f2b3e873a2cbe749d475d3369b04957c8e4d2b05b1941f2d6e781d201f2696895f3ce67a36c8a833c9e6c4fa7d4cb09726bad1679f37a75d51a001", - "5c7e7daf63f62191f9c86630672a71f8d04acfd5a85b9ca138160bbf3fc2fcb276f57166ae1ad44320940b420daea897811e0f01c28bb25827ffc9a90943616c01", - "7b5094bb98e1a807c31254aba3df116657709300da7d724434a4061935f9bdcd72b75238211f6cf832456fa80495ba89910e66103477617b75b7aa8c93ad789201", - "11018a82609a51efb318aa24fdd0ed05d59caed913671cae56d438c1d3b928035bb778819b5e380eb96ace6180a5d38769cc467386df58f100eea42028e9cd0b01", - "440e49f22c6e203e1fe0bdd84e81dd7278a79978b1ecfce7fe2afb8c15e0437447c05efc89b141bd95c70fd116bcb4f7a538a4fb0ba3665f44e3234e935a8ebc01", - "3bf139ce86f8e786c6a2bdf24d4bcdf6c88d3add74e72742d58bb71f4d2d4b8e5b00223b8c390a5343f7d8c12fc59ddb19ab51ff2806cfb48ce676cb1e71070c01" + "647bbd3dd48454ed1ca0075cc15a39a2be0c91842dfaa57907eabaf9ca6d561219e69cdd04804ac2b83508b779a2acb71cd3bae1f6e9e8352a8b1d9240fe9dc700", + "04e7cf21fbddb4b196ddda4b75bbc92e82f7ec92fae5c824da045e352845b4a127f84d07069132fc1530b425fc64791d556733422ecf6a571425f622b58cdd1f00", + "90545da6f9a0e89c703bea93df3ce2ca7c8cb05d137659a2a3407707164913f928712322ee2067b26ebff4cf052f811e630936f0ce21affcdc7d99f21e25fbe800", + "21ed7cee0e1df586105273b54228c54a21e7621fd97592d6ba5501e2a277ef7b03282b2109dc87c2770d28c3c9b381ad82c7c79b619322a1f797b5c95d95a9ea00", + "0f4fcd6374b0b9aa05a3a702e41afea1173bac9077f8b5d037395097ac5482931775f134d59c55f546ff33211bb1ca83911c1901f2e4aa44358d3e2df97a558000", + "4b3f21d76694fe2f03012f2f4cb506e128f610ea3e8738ac94f22523bf5e1f4830e712d3902342ae2779c49cb8ab05de744540443f69900f1904f5b2e5a767b901", + "e1a91763cc1105ea763e67b9cd1c25f74d41b39f400df22003d779f2c91e4ee20ef444a3c454f8eedfc6b127c8961be3e6b25a75db3ad49451774606d35bfb2c00", + "395b880f1c233c3c12c0a7d9ce08c5e95e35873e7b5659f8a1472f9a197f59d8345bf678724bdc2f83138cff4c3ccc5de81bb074efeeb2105a4aa28e66825e6e00", + "0ea0f9b45f425ea224675d88e24c092e369a2d2a969ac0bc959d4d7b1418c10223aab768d397b7a71967e27e3eef91494260b43a9da4460ed5f973220221c6cd01", + "4142a63fc2be7e70c9da1501360b84662bd02eda9dc2d7d5e6c6217d075d1d683faa45cea9069cc8fff98348c7f2f31ea30ef5da710f27a9203d13a41b89c00601" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "2fDFwpM7P6tK3krFcrhaYY2x93B7D86dCnq", + "secret": "189bd3947f4682e4bbdff3195eb88cc75c023248242fc1a2d3e37d707551e593", + "public": "02ba296ae39678461dc7a1963624b71f8038d6f74785f01d8e884c72f228cf7e88", "signatures": [ - "b21305133aa2695e3efa9c6452a691ad0b4745c622395c055643d94117d557a6547d721e3a6fb7924e35b5cc54d79fae9bcb1d33cff0a3a5a080f0420924712d01", - "15f1591958bc4ce34f9e1ce9155d9555b7ae78dc9f8c88783f73a7289088d8cb009e2ed52909a6f9f52e3ddbd2c4637ccaa34bc320766b882333d0ec1c18007501", - "e188817ed878c98d4eb3f9e59aa965c72b21e83a393f8886d790dec65cec959a008660a9a2efc5cc7d842641b3a997b93fd876a7d3afb4f17d43aa2ebb45b32200", - "60817f8172cfa8b54f8c3d0749d439115f3be1c23feddd5dbb92d942e48de79928727edf25fe8f8398b25722191af89691558cd4f89ff2eef25aa741acb0446701", - "c247b79139d5590461c417c2a25b579cc1f6a88dc14b2ae6ffbc3efce36226470a1cd490bc1132d0de4b5670566b73c8c140f11deef17992cc4f71fd5f202d5c00", - "c677112b77841d4f4a3e62a1f057be2a823527d7f7b02e3c9e30d49aefaa35207f00a714599bb2dbe09bc0c2f9aca0a174812b901ee7874b0f73b6a4ebff183b00", - "ef408051912eaee297a7450af21367d0d1220d90e07500f4330dce7f26254452361b45b273f2e75b72ed6b7b89320b55b706c9815c43bada27dd3e83d085dfdf00", - "e094f10951adf919e4e60fca7fd0421e79a175f4f528b8e39ba3f6e6f6812cba4e12315a4c85e95714d1e2a18b364512bf953bd926dab9f305098802f44b2fe400", - "217d85e3d4c91fd3b7c3ecf39d02f390e089274a205e9a307b8a72fb0b1e6b7d38f9a34aaa899d74db60a4672bd112ff19e31e2a41d766841b9381c5ec5a0b8001", - "ea109ebdeae8aefe8d331c09b0d11d3fbf96423b8048c365d5f823e7bd687c4132f436a718141b4f5283647e5a96876fb876d029cde25b1c16f6517f8310fc3100" + "89fe07b2f3da7f6e1c5de1dc60111033b8976a7e79e7fcf062c0c8ab3d7e9ea0206e68b8b01170fb5d7f491142725573625b3a006df68af15836496f00013b1900", + "62923dcc288cf2e7a118e44a4e087d13c86cc63f1f5157f0199ae98a900eb81d20702990fb9804c7d3ee668ddb80ed1cb36855ce479b54f0971ef7300373e72d01", + "59479f47a39299809c24b8e206f129d204597f2bfb416bbfbd4b8608a1d89fe33d3c1ccc4ac469393b12ef514f5c82d2e2ca780187ba1ab1e376f164649cf62501", + "d3fd138264c4b63d19341ba742456ff50b63bfb62bd7b2d70f18901a1d1478b73f03e45328e587d0f11c16c3dbd43c1ddab6c4ad989975e47093a4362287313200", + "397e578ba4e262ac884394d924650ea6b5065c72ea0ad1e917ba256875afca776055d0cfb36f4720d76f7b276da462fcd09e2f3ff791827660cd3ac139d1deb801", + "9fa423cad02fb69b578d38a059bcbe142ff273a91a042f61da0f73b72c80f8e24ed3a7cd1c8986af7de8ca603b2fd09812d14c098556fcb3879be8fd65fde9a501", + "a35ad7955b416e9db5f0070fcfcd601084ea72d313f1f5f20fe7ddda8f4e8cb0608d0a524ec33c0c7c7b9e22942cc26c13f1b5d986695ad9611aa38490dcd2d900", + "ea661e1459ead9509b69621676e1bc53ab2844c189df802caba4894d22daf93b1711c6ed4095ecf989794c5ff7f6af97f2cdb200fc4185b657a986b75910c90500", + "16064c60d7077e55795adc7c0f34ab0fdaffdedb7a128e99c0af9f1365463ffe62c8e537e4f591b0dcd3a26393f04eaa0651a9fd4f3d9152da2cc96e3b0590af01", + "98ecc21e4cc24e917150352ff2cd1df43a18fd7c81934ab5826763d300848962261ba895d13a8b5d102c1b4897cefcc5ae3bb777dfd882dbcc3a0437b1a7d9d301" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "Ly5LPYccXjDtx3EA1Amb6kwZe4xL2HTCJT", + "secret": "2a00b256c613cf7de4acb7b47efb7b5be2cc328012717f3d585e6eea02df6f53", + "public": "03713f5421167dd1b76aeccb351d4bcf4086edc9c9be95d4f9efc4b27bb41c93b9", "signatures": [ - "e8fec9789d9e86aac08b9c3da92e75e68811880216a98fb8f6e83a51cd39ce5627a1298250bc6a83ab0ec57e4b8dca80087e5b3a7399b28df72cc0f2eb02575d00", - "3fee1e78ba4baae5e7ce90cf77bef8d9361c2f3c8c62e7c4f44d0413f8e54f5e23440f476bde240521092c2ba49b6e8851d76233f385f3685fa52e69f68128e200", - "42302a4a9b08c72f815043b13e3bb12f06c5ba0b4ee7db97e0f433dbb086d34c354d48826c016272fe437e8fc6490129282987967e517b88c9fb6f86369b0fb700", - "bd439e1ed91f5979cc833a5bce28ade16382fcdd2e6d338eac13e0c8573b10844428c94305fb83cf05e9958258406d87487e7e85d3a247d94c16e05a7d80ad0401", - "01c9cc8fafe5825a00398b0152ddd32f00a29da764e29e30697f088e32ca888d675f06aa536c68ee8dd97a4a01713ab5024a5e8f3ef139b2c35e1b549048dfb700", - "2a58e1264a21fc8dc70284079aec17e22fc735feddf383c047b4cb8e310a23940cc84338649ddb1db00ba7d0ffd5d3164232fd18ac090c4c42ed7b4238db293801", - "fae5f8292191f2abac7a5ee53c6127d6c578a15209a68ef72b481d4a8d004de002a152e4a5bd3810bc19d3ce8a508a2a9cd569cc73d5b3e05a01293f6f088d5100", - "cfa7535086fa88644682114dbbfcbd836a9a7ab3a6ee4bd10630b0ee5c765ecf1fa7e272ea0f737dd498025098af8c1c5d5054dc6563e41001934157dbc2f81e00", - "bf2ac1f04bc4e3d8b992746ae5e91676b4a40c8075a1d1a835c78c557cb4dc2d2baabf21a0e47c54b6bc1677f20721bcfc6e3d02a4ac2e4086052e4435830afb00", - "1099141f74ad51b13f6fb216c29eaad87ac97fe9252484b4a19ca82b628fcbdb684479fc912de0fd8e117ef07a90308b03d06fd04681bb3833ff995f161e3a0500" + "e8b8246e1dd328a7fd59d5e5023ae736d14f03f55c71a1e164642f0abd2d46975c27ae7b4ba1cd0acb39cf55fb24e7c6146011e3bb4fa7d425693b0ee8a3fd2901", + "c92fff56058c70c86863c7b703cf245a73ef615f4985c9951b2647be5c4b543f0c840ef819c7bf0583a11627785ab310a21338597fbc8900aa2f0b21fe81f90701", + "4f319b9e8697570ca0acae7423498da1aae0b53497f5feb3752279c7416498eb4b8a0b61f9be697dbe59bf9071c4c507fc0d6f59cfa29003aba8789a2caf5cde01", + "6ca0e05d533fffd7a3514c8d0cf7be303cb901dd19171a07b9dedccdcee28c830231e465c24d2f728dc88e9d9a742923b237f69132fdd45d282bad446e60750501", + "e8a4f6ce818a4a66e9fec715a01d4412d6bc8ec64199764f6864cd1004a6a54919897cc7403ef9106a5dfc76c16d56fbfcfe6f72f762726715148a09322bd5eb01", + "f236ab0ccb778d2cb2f3b1c94ed6e2aca5c2dee17a0fbb5bd560cc463e4fc8602e60c1dba5efab13f452a6b205cc231cf65bd015183855ea00d457a5fa0bd34201", + "d0114bad79c8173035bbbb330ce157fc1c1cee17de0801ac594d2b86931f42c54cb01efe70cc49bbcbffd85f363821efda30357e819d9a71e64f092b53f18cf500", + "6830f56c0c6db89cebe1672b1ad58ab4691e72c8e7ab44430cea79f1df58924504154d1f6109526f57d53f89186c4c631755123274d53365de0fc8c74ea2ff1e00", + "c580993fc7bf98f4d75d64119ae5e3472d2108add0a3ac427470b253433d9f8d36ab1e2e2e60cda7b7701ba0a78387df04ee3679a5fe0011306d8ee29ebd102100", + "a90ad4f18a5292bbf30e6b6a9e8143573524823d3e6b0a066ed78b3e9f30be6c0285e6554e6e9a1c24a01809dc7e0d439fdb57ac054259ec10895a52a5c2873400" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "fVskJWYkJekapAcR3QQvBsegn63BkRCsE", + "secret": "115c197195ed609ebb91e4d81a5fa57f0819ce9e08774a330db4fa52d97417da", + "public": "024a4807e5f3c20b777705cee1a58905355232210e84b72c74e25cffd9fcb110ed", "signatures": [ - "d382ae21f3c896077413190b2d534152e44fb174d592ec64b42f8d31cbb9535771b6d13c617ad3796ef61cdd74f7989ba70e229640ed495a8b36d0ff062c97f801", - "4831cbb4014ed526062982cfdcb6ccb2a75e9fc69f4d3e4f236fb16b701732e4697172a4b5156099ddabd6db3bfc71c8fc5f74618edfd2d2ab0283a5aa785fa301", - "2716745be5eed34eeb47f1ee56bcc34b725cbe5bc118b91b1c298adde98f74d0501494ac8e6032df9ba968851f97cef3ca38309ec9e7dce4e7ae709c1ca33f2001", - "cc1dae545f65527f879ecb0c9a36e1e14a103cde2c1658ed28552b91249ae144024417e1d04054f18dce5ea3f8c4c08177aabae1e319a5a74af7233128d4d3fd01", - "be3a70a5643ad120c182a166d62642174da7d35a54a7da3b004e5c6f2c84817f351c3c5ebfcaeb19e09ddad1ef082a483cee84bfe10c5be8eb2e96968286439f00", - "1e450ded7eab97bc5480eec06b0e2133019a59d89e7c72160c55307c7109af16438bb58fbf9e414ffa4ac5f0be8809f8671cc89c889487d2c1633cfa043861f300", - "b4aaf60db09dc37859d960c4492292b1e4b7248c742206aa970e13c0a9ebcc62282cb6435741411ccef14de0aa50bcafc682d727cf4ade88225fc9d1088f590700", - "85cf6ed31b17217fa37b26e23e86c86b9754534765afbb1084f6b5b97404fa7d3854c562f5bf3112d627dd7ac31a2bff371e2f9e11983b356b670f8f2bab58c900", - "864f39b9d2334970d8bb29d915be77575b9e59f13f33e4aacf0326cbf93078727b29950ac1a877a7ec3953a60b3887b4fe82115dd0f441386127d7fb5f7c10a100", - "2b27dd9222bc6f25d6609368be485aca6dcf6f4f7738e45ef13ea5fae07ff2bd26d5af4b25479d94bc576f3b07be03a0b297c7f729ae9289d6bd69799a4238e400" + "f210a289f3cf7dea3476400432a8a64e7b2c62a3b12e8f3fd9c8c22d4928e5c607894263fcbd23e0538dae2deb979b555d11539034b8ff31f99fc7f51d69a30100", + "f463eb2677fa97af9666a103e110010484197271ef4e710dd792b8fe0964c9b8307c9c40fdf5633d278f3ad3fc1f00b10c42310d11135158851b6b19edbccab901", + "14e222fff75aa114b3145022a34eadc6abb64e69e7f1b905430c38b7e4e4af294c720a884a9c16f44c8386cb91cd53b2af334da27177fb4f1d282ebfeeb80aa401", + "9df1ad76f388829b069d4474c4ecf0d8bf7de01a31e287b10fcc883c4fa714441490fb088d0586402cfdda4202e4f648ef9257be506daadb9803ddb84545eed200", + "9c83abbf506869f684bdec893a5d5d1291929c6b66e9fd35ebe655e1528f2b0d63563a380785345aab85e375132b7257b6b26a066b6a20c9c8ec58adea33122001", + "80b6477e48dbb5ea75eab67eb887fce8229ba9352fdf1175f6e502301be5ff0e370504d8ccf447dc76e58ebf0a8effcd3604b5f3935fefb78e6230fb1aa3df9a00", + "2bb168b7613b165187391ea14889863d43a8d967e63edee1fae608d2cfb7a7ff4939a76a1571e67481065c4e56a72d2bdd55877c474fd62dfaffcc6926a360bb00", + "eff83a7caddce6009dd76d07a5a9a09478e3300dacb39c4aca637d653ec4cdfb380bf7e83aa27fdc632467b4a64834055012601d05306ef3aa7cecc86f50ddd000", + "6f87163870bd241190f9bca7d3df36901d8139892f21a6db2575cc5b7f1cc55a21d85e68bc73fac1e2d29fe01d51fbd55741e7a727ced4947c8d6712f64dcf5801", + "7ecaa15895a85a13a2f8faeaca642e4439187f1899fadc7f954624764b29b64e0e617808ff959e0a584284f65931807817d3ae23255ee8cce74a8b65412507bb00" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0006.golden b/src/cipher/testsuite/testdata/seed-0006.golden index 3c365d40cd..ead326764b 100644 --- a/src/cipher/testsuite/testdata/seed-0006.golden +++ b/src/cipher/testsuite/testdata/seed-0006.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "5MnQdu6vWeP9NddFiehxsGwspc8aff/Fuzs5W3c6L1I=", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "rLjV76Fayt9WU5rk19FnzWeZEbF8nWqGHH", + "secret": "953b69e03457e239449ef051aee7a5fd9ad4f832bc60e8915e0f07b52598206b", + "public": "0296d12f5627840862172af9aa4a22574c427e60bfccdeef22e675b137b439b92b", "signatures": [ - "6c9769afda48e21e2699b891a77e58f93629a4dc7a4a8e6cd53fc7c35b9c1e0e570d84e4497fc43c8eab834c8f7ed15d60f9069a687a48e06d4413d1998a605900", - "65ed818e8ae9fa3ade9dea462f12126d638652f1ca4f944422efb451b5d581430ec9882b320b307de3a2df8721301b616ca6309880ed7a8bfc5fbe8682f0355d00", - "99bc2453fb28e01f03dff6f15d3732ecaa586473c87042df29fbf1cb4a923b60675242c2995f9479452ab00d6520c0b22532ff2841d6eaad4b432e3bf763853f00", - "36896844f549d3095ed3db718b1861a99a716ebcb8f14df1b5f529e0271c9e006097d3b6e0b419cc1e6b3eecaefe4d8f261cd13f1b1f219b995e91ceb20b6fa101", - "f6d2d764d325df30a606a7b13ff37a14ad0b653fd7e443732dbbe0a770a8ade25df52c9c75a159b1673f1d7da59e5502f265dcdd2dba0859748e04d9bb4e9e3c00", - "aa4b05277732047593aecb7b972bc5cd34cfd151972a210d1380dc64b1e870d26216b88d6eb4246733bd2ac45479aa6be2545ddc8dfa4a0e730cc5cd2d7ad0b400", - "18bca003dd6e9f4a6a2606f1c4a06dadaa173030ad7cd2ae08df1f5ffab4f54f6ff883ef66d64c1fab860856ce576371a190ca96b5d80057554b425647b2646301", - "9a0d0f63727cf8af642403c5d703391ff3976f2285abd05a486481c37e8c44d747455b4b974f4eea6bded77074055e756a7e20b3935e244e5e74ad035b0be48401", - "07dd3c4d4877d47bbd0e9c568330cc9ac988e6b41a4c7a5f78c9368771045e08006203a0b7748ad16306813239e5498cd0ac3f0bf04b84401ac6859836e9a60700", - "056f60f342d9b101e9dec13269c08920c5e2cf7a9176b6ce24def8c392a2eaab4d57819dd00f3b53b9a2c2c5f23f2e09e89609fa18ccb77b03cf1dfd90681a5b01" + "4c9836174cf0204d88ec36d6cebf72aaabd1c5085ebba250e12e5fa21e629a9e78d71b3a0faced4cfdf037110b452acca16e2efae3a16efaa84c5132951139f600", + "e27307fdd00c852a4d209fa94502e580d7aa33c64cdf811c743c394430f1b2d361a1108937a57fe35ceba04b96498421f8210fe32cfe1223601565b918e70e9c01", + "d29f5c767b865f6311218d23cccf4dbc728a4cb4a148c7863a4475e4aae268af27e38557216a8290ba01fe1047b7400c6743388f75d999af176e3bbc1957ac2000", + "30d45245cc67ae3ca1bc840d90e3535ede9ce5008796a2c90250f7de86500da86f17b19a343ef2051d3526fd33a5894927b09234b86f58f469a3f1d018094dc401", + "826d791c834ed696f9f961f0a7f971716c66efe58a6ccce16e4b3cf834fc49d95051cc8bea2cf183a1d05b04ba9ed407648329f51224781a27bc01fc1fe75d2101", + "b0fbf1f4e21d32b4f3a6398da88e8d4dec7f20eddc4938d7fc493997254245fe257ab78edf9412fe3cc1d773e3c28b41669504baed686320abdd0edf21f2259d01", + "7515f2946fc8e43199818bb95926934d6a5be0722782ad44fbc67489019564094f378b3c57d1b11bcfe14bf2c0eae08aa9b9186f7b1c072a03ecc03ba416f33801", + "870ce446e34720816170da99f49a843537ff6cf299d7562af82fd9025deafb0b315529625a47049408d081da2b3429f555c74d7657917b8f7ba8fe0fefe0cd0f01", + "94fe3ce87ddc7f386fa597df17d53d9aa33d01a8aa2ab37a18a40128541af8874e1e05cbb6429f40710d945ae493aa033387696884788dd9ef9322030f1c246300", + "1700b3a08d9733e486dbbd26f67b48add3b43d72a952930c786ab44e5f31866f14d20319a6b1a72bdbb091d89ef7bd55ce9078c8c86aa2f0bc30e75f13b8142201" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2d94nXraZtkPD2GiSCfzugewm9cRbCVDNnm", + "secret": "4f8db9121a8fb6bdbc8de701593e953b6022431d9045b914e58c0fbf109cf1cb", + "public": "029cc260c200b5893e55faa5f23baf6268e0f20e77ee1b524b37f6e1e6ca9a1814", "signatures": [ - "07d4c9b5a9d16d29bf1cae0303a8fedb5be2421eb7d4ad8cd3be601d6f7040a82418094628d06c5c5979e62c10ac74fbd2426274ae88faedcfb3de600363bdda01", - "d5e6e4f054f7a1b2c626043845e31efd19f7f1492f3ff26661c0aea068bd20b86329314c1e9f6452801b605821792ead5d72bfc072b14bf3c733bd7af0b8a89901", - "83a5fca6595dae0b0df942bad42f6091bce3dcf82fa0349850ec8d3a0c13189e2d934f5378981b7eb243cdf9788c8f7cd346e3408f00df74074d12aa1f773b9d01", - "d5462e8e3ef41e600169d074d259d330744b2be4c522ca8e1492fc1767c1b5291f676f0f918e4cf8305af4b5e92f095e5155bea6ad9dcaf4764e8a493ee06f9201", - "43d6b5cd6eb87893dc58ae082c0fd1b235e66321c43b608dc917631d48f9d229361fe9a8e8d194c6205fd72209e3331313d2bb61caaa1dee3bb268ad67f843d101", - "a718c42d8c085c298af4a6a8169dc944b5a815ec6b697590d6e7494546d4ee2915cfd7823202921a63bc0914162226c5fc3082db14fb9fec7f0663d5209083e801", - "aebe18904793b3493a60d3e0d5c9c00ccb9ef4856022e5ac95c8b25a4c148e514775cd75c7b283c0b29e4424eb528cfa8836d6eed6416ec3b62a7beb9815b32d00", - "920baf098edf34290baefdb735956fc9dafa3e814d8c6c1f5830b367da2b1baf68db7d33a23ed6aaa514d7b37a2ff7d1dd783d13c2f329a346e6cc66640f0c4100", - "2b22170a0833df91abae334a12be61bad17c55b6b839684acf01a0d43f9892427d7895ccf49809027c5307cf0456db2c5a00cfd3f85945e776fc308be74232f900", - "82562cebe62fc7dcc178e08639ec589f2cad45fabc603f3969f94d236000634675bdb81dc6256786e4af2d53fbc454db37313bcb968b271c188f018234a4b96501" + "96cc1e166e56335bc6f859557ef73c2b7a96e3cbca0f32d901052fa55023a88732b40ce4e45ee236ffc07e0c4d2db6c294cc7f1d3a2f39d5e6e0f11da3c2259b00", + "7478758d8006ecb8103311c394931722a03f3bcdddeada8afd37b9d93b39d67033833444097d3d979bd9913526300f6491107be0d31acad6c28591d8529e24cc01", + "db8a4f5dd1d5cd811cd08f4ac1c4effb55ee93498f7d5f4d1531c315f047ffba605861a92e5d5358a87e7763ac223c6edc2489c9a08ebdbd3d37e7728ade58f300", + "7dd0865d18a574266d0dd3b173e03c2e8cf92ae77af99a8f68b9c7db2837326c769c69968837647d5b763a13f1caa9cef07804cbd814140d66607b0d151014c900", + "7f97f9fa0d45f1eda3e985b3e64b4656ef38480644c355b644e01dd772aa7c374db2e37f819d008d2da57d564fce1c0544e17206f3200dd12161777428c383c401", + "7a1aa12c91e34842ab1b8cdfc3e4d46d2f1a8af0267ff74aeb24a942d78fcd544438341e30c91c161689491514bb1d19e6881758007b25f0e6a87be044ea8c3d00", + "b823e93c1fa6e3391910ca4e461c58e51118e76470dc88506f183f6661f8ff0f03e4e4f1c58c06ff40446dccc0b9a9bb65b7793589e8402860f0d60f368659ca00", + "36751c77d88427b43ef8b68f15a2cdb48225a98e506d40fbb09f442cd513621615fb62d138933d7b88812f054be3c21ce1a626162abcc705bd45d4299c5ed15800", + "0932a2f7eedb5f7b9fc67602c1379254682892da2af0b5b8ac06d417b5136b756b96c281c4ab3735b9e3f8195747128b4cb46a704702b42d54c99e2b79ea98db00", + "9a7b5f8c7a78eaae1fc9c6ec63372297748a3e977a3b06919ececd3859e0ff5973c2fe2effedc1b01888f87d1ebfeb7b96dfb5dd6a9c96f804dfe56e9504c0dd01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "gVpAMGVd271pzHcNZiMzU7FDNqUiP78BwT", + "secret": "1a59b0065001a05a93d72d5939fddb148c5cfb775a0e2a27a99c6d54372939ca", + "public": "036de1827a8524f166854bc7b85510d17ebe0369fe828d8f8c40e930569dce118d", "signatures": [ - "cb941000ae6bb597f1115240667fda04c4b0853a14003cf59e4340c7462c6f8a346671e359158588f1f7df59da594614047773cecd9ae039aa32b4171ab9cc0800", - "481bca8a8af8ccb758d18f3191f7013c256c38e1213c2d8e72f884e7b304e9dc3bbbd6a99004284dbd86e195b8409451cfa695c01013d5f401a9411784e646ce00", - "c7fc7099359d66286fa79dc321ee0c38030d1a73e8c613307c10058bb66b6f701e12956085b7193022237175518cd0eff496bb33689f4790ba495d1181c3fb9101", - "721be91e940ab720ee5bcce7f79c3f485ee3ab6e94dadf029627a532aba0f3af71ec50e0a2edf0ef48e12385208f6c18d72e16a5a162bc1b939457de5ddaa60100", - "a14ecd77dfb6d12e1235af5e2084a414741eb6bb8e42a76149b5289482b136624bb390978e7134afe689801ea6a8de65d7538d6c7221eb8d4199864b3feb75c801", - "c759dafbb104d94114cd0c2c70b858936588d0ac54b370dd468003d4f2dfdc872dc99e455a6b5efcd87ab3d37484d16f7052d9d5a561b9ae0ae913a3890cc3ff01", - "813d72b439da9b46409ec30297c8e98a4c3abfd576c5169a2acb2149e972599a2ff00a0175fe2b012862a0a141aab4633494d58a64d2ee53bddc86c7340f98d601", - "b8c013ba342e679b18d77721f6198d3f6f7e587973ee181a7a4af23926ee6b4e093c89f87e164cda0cf5ec31fbfa590e7e4c741b98eb34aa124a7a55f9add35401", - "4bf6463368fbca11cf4c60b1108a5df0e0f50103331c776a49a82ef924e540090a75b76227ecfc10e014a2144d63e67312243c9adb029697a241f07a7d79e04a01", - "d64322d7389070f0dbcd426a524e325133ce3e01e421a32019b06fb7aae84af450a2a16cdaaee4e407b79d8bcf0f5ef8812cd331d7a636208575556b85dab1bf00" + "0dd770f09abc025ea1f3bc25b8910f85ddc5bd2adbfde66d247607a069405bb10cc60ee15cf03524dd5c15365214401b0d911110ac2ec6d530850c097bd543cd00", + "69b432114a086fb15dc22d85340d605bb73e81dcc48b2d3ac776fc84686e19304850f09c69d54dae0b30704a7693a33956303c5118cde508295927599e13cc6501", + "0f43fcde4a728d8c8a354aaaf12bf7585f52cbef863d99c63c9a0308ea53a5a32af018116c1669667ac5a62acadc0ef198dbac3d72821ea300b5459de615b91e00", + "af29eb64035e6e7282927df51f1506e5b0d12db63fdd567a23bd386e086d1559770b918ae23d51a73cf6059c8475f611c786b81c6b15233a2b707cdffa71af6600", + "7ee7e341312c1c2fbc6179f325a58cb592b740353431679e178213cdfd0cc0726247a34b9379559fa091eaf45e5b4e39e7687eb83729f409c6cdba842bba197601", + "18aa13d884feab6eb0d57fc85500cc714a49b45ca1529f4cc6eb5c6521e0126c027679f19d06d629789480342209ffcec217e0620d632cfb82afdae61c53c14500", + "3256f3bae51169f46403562616cf71988324e86bfdb7e7c24f431fbd4451ed29302dd9762a2a296f9cbb58dc757c2d0757fce4601977547c6a54a30dfe56c9f000", + "3214ce760c0f3dfc8463c85b4c5bf1c81759c3d45e85d8d061af54bae927ebb3297b7e30e9a24341b1a620d81a8cdc7e5bcaca4bae94e910a8dd4111bac8956601", + "bbbac8d56a6c385825c5549fe5efd900331864550d4c56f9930c3eae8e1f34ef7d6fb9c51f731aa4d501b224f37ce6ac73141f2bbfdcb881379d4d019761c59b01", + "f3fb7ea9622f83cba22743363780060afd9c6e5a46971636edccb41c90332caf6340aaf635bea94085b8cefe0533536bcc0076ab305bf0ca30dedf9e8d9ba35e01" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "2TpmTjZqMDwwnmMum5CqDZjyjekoQxctUaZ", + "secret": "df84bb1a455c464ebb1da23257ce7e2998d6a2f92e2864a9e9adddd3f017d784", + "public": "03a9aa938ee9aec021db0717c0737973e68a39b4d0a2b0c168135a98a1a7c64dbe", "signatures": [ - "64f0bb9b8264078a9732a3d8fdc59e1309e18a8c5c982f329419b31cec1a2543358b4399ac71a61343b39c1b7181dcde4581b7332cf7f4419ed0e6506170068c01", - "dec3769190cca7be0bbed8a16eeefacb2adfd8ae97cefc42c0fe4d77976c541e322328bb6576766db77742ab744173567e8288647ffbf27ebcfdd2ed76bac5e501", - "f49493bf0e92f26091be12ec7a731f74c20b74b4c57526b5187612f7e3fbe3f50d587dc89d435ccfed374ca41c7f4da38a0e921d08fab518dbbc6f32c845362901", - "93848f4ac92e3790dcb96dc2911a6c247b5a4b38f7ddd70cb8741cb18aeb529c5ee928c880b302ded0f3b1a6b83b38f3f5ec0e0e49840d2351814c1f9caa4c2801", - "3c044199314aa17764b8fea798bf3befa49b34b3a2010c39a835efe6a5d54cd84ea36944f582f109db8e6378c3b01faa5315396e9c74419384511346fbc0ce9801", - "891d0bda61bb6528d09190c288fc8dab8d94e3883c4382a6f27b16a8bd843ffa10b531409dbec715558d27e81e6ab71be78fc345763e260387838ae950c8a7e801", - "1a0d42c0940b33b41ec0a617ff66420324bc4db620792b0343be0215dc3e6cdf2640897726c7f20bf7949d010ec10ee65d2df3f893d53a7a5c99828f20369df600", - "488c323d44b39b204cc71ab9cc3f21cd14e24aa1a29292227e120f3c4886dce76a4b2c1c8acd9cbc524bf70cc5945b16607fc821d34d1f5fc430a559e103862e01", - "fdc0ca2fb4e4ad978c03466f5ed9c51a83616fa8dc10fccb40212517da51e5d827046bb1edf9b6271bbead1e78848335fafea83d257728bcedc888e6a295295901", - "9a0a5dbe54da836a31e99e152ac0268d534f43353a3f4b6e2867b99f9f5117c93b13b915e0c5898d4f97074be5ed7bf4f41b061162aee44f809f2c1662384d9201" + "2c64c71319bb1650d862f7d7d981947866d3249dd88f18e7955cec62343e6b5d68fa07470cf84d29731989f2c7b5132de1197cc54af7c13b0ac93b09c3779f0801", + "0023899b5ec712d998eed46bdba397be815fe1d0bf17dd1fed798a7d6cebd90e15ef600c2ef755cbfaea7705cf8f9c151b59c652775dcb8a1bf193a0f157844100", + "f291b5461df348d6b63e956b8ceff056c85dc80062fb4109f8ad4b7c92e64b5a3be753846525a0929e10223e6b50d6ab3705f259d515a4e861172171ab40bc4e00", + "3338f44cfaa47203cc6b7f40608a4a7391e3116244e7e3c2926d895bbd42d6841954685b36f65007fd768dd99b54f398de79d57355e5fd1d70f88ad83e27153000", + "a6fa07fdf20f918b7e834c258c759b8c8c701d990e879cbf3031935afc21ef882ef1e5802e4a6203a4e8be329f629185031948f46362ab8b9798990f10ded16c00", + "147ad65314e28af6c3153d74e278777184d4da1daf328f90da98f1f2049254a843d780f7ff795bc5e64960555355ea600897dcc6aeff4ad9e20b98d37702386800", + "8b6a680ec0484a272a0bfe3a22e3d2e764b78e71f0f616ca678d350b46aa8ff90d8d4c1281dea8ed555f90ca721da4960268e3376d752c772c2bf1114fb9b80900", + "a978234a0f34f7acda0716902b32a13738532ffe1f80b7f2194f5f595cc5f0f4083163aa767d6d84d40a0ec8f2ba9cd7a29e7778aadc15387201b6d3418d391500", + "5e4a552f73c260759372db4b6ab76dceab031ee738aae499b0495b214e7664a50fc03a74d2fe5c04e77edba12149b37beff9d4b247d3cacefc09696f7f67e2a801", + "838b75641e209dc77a8b72e7ae3ff0cd00df644abf5889949ccbabce2bccb3e563525b3bfed5ef54785432b87206342ead57e1b404235bc96b32980a570b25e100" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "2fznUrLmmNj3vrq6kqhYTPdEcxsPF3gd2Bc", + "secret": "49db3eb8a8973862917e151d92ad0d159a5a11de20ca3fe299f2fc4ec71a9161", + "public": "03b0f175d8daf4d0b353cd28a6d454a39cedfe58d4d9447b47bf19cdcdc985b2c8", "signatures": [ - "94caf8e8a35758e75e35d7d0471687288ccc1bd1fae6567df3386befa4ad82a219dd31548efda2a2d48b187d7a1f64cfe945c9ae5918716edfdfe3583c4fa85b01", - "15ee99d36c52ea12fa4b887d16cfc252670f5242cd32944b866c242d4973a9a430797e558713e645de02cc551137b4ffabc417ceee846458bed4bd60dd217d4200", - "98d7660696a048ab82e06cbdc23d1be09b0268da60d44d9780ffcf8e0134e483325dbc8ff06eed1213daefecd699eeafd3b4aadc73f9029c58da0798aa8a777300", - "eee3253bfbb83d942adb5892c1118c4b5c6c3d46fd2a5887c91be827e9f11c01192c987fe44576afcd2025cfe0be56e8cca093ef42aae6ac2b6abcd16edd511401", - "7e2a30f8db1a72623b6608dcf5428a39f90fd83184a0d79f7cd36dfec4706d1225561aa50ee01d215dd4df1853fb95bee50dacdc217ee0d69f513c70ec1c772601", - "3f2ab49822192f7bf5ea2b866e180e2120a8f7eea89ac996688f13d1a865096f1c3ff2061635807d72a8e485f182ac93213cb2a68eda12cd3258cf58ada437dc01", - "7c84c41f625cb86342e098904df8699f8fa03506b05e163e68508b00c3ac040b7180445238e70a936e64ccbb8107e4d4d72a4343346ea78a00a383a91a702a2701", - "6a70649a90159ef0963baf794251de49de90b3085cf5b595eea8b1ef63253ad74469c9dcc016cfeb363bb83071849e4e5fe9792bb29bab1b76d52c40c1716fb101", - "8c13dd2216567995c564800a126b54d777cc7f5e716cb53a859beee0a19aa5d1241032f244f2af5b6eceaa50b9b8557bbbb0d55cd8b9a089d353b7937bd5522b01", - "1d4c11a86e4b3749170a672240cb768a7a743d74ed4ae45bec2025a530d325396b8b04e9c3978013ae83538b13848da9e355735f32ec2ac32f1b6d34aadd825c00" + "ca098ae575f90a7cb8a33024977b5511b54be8207ee45e607d0a1b2b01df75053eb358c3d1afc7cd6a14d127f37217def7d617fae164ed865fbb6edcd519bd1d00", + "3a57e71e97f360e0760586b567d9a9cd54aa578348c5ccc5b8105aab532ba4396ff942cfee75b255b39a60bdf8dfdd86218301a233b113da1110de51502f8a1500", + "67b95edd21d74b9348e2f1a9b04459edb63a1f6025f967f3e9bf237b01bc1dff426287145206d285984881a76d353416b0a09092f020389a26dc6ed2083a479101", + "929c014bbc57f925525698c7d382d98b7997a46bd8ef5d6cb195fea87a7c45575c55a8e9d9578f0847fad452b39a32e25968d546cd90bc9ce4adb0d9f9d82fa200", + "763f05ac9198194298c92246ac056bf1b9f92c808260aca82fa976b803d11c8d1e2afaa965baa5ecf38d656e3ca3c2035ba18518765a7aac0bb6d9106fef6fbb00", + "3abe07f94713ca02e09662cc1127822cb7c8a2fd68ecfe859777dc818c67e94331366941b9e3131d3f8173a504982f043d985e00de6291bc48fd2e7a362f9ee601", + "5f2062b454a14402f952b1f82e275c9e94d5a803302b7d960aa8fe739157b7dc6ebc1f8b284e2a1f7b94b7622a1cbd6928a8596cd843f93cb829b919f9d1e50600", + "61803922611692eb0f4776862841583e6e31844c71f12af2e6eb1316350017f731a6be87b0dee2ed0e32ad98f72e1e86ad50a481a2b153226b532e3473020ec201", + "c08e615dc8e024d42e22553de77971c3eb19de95e178528be685c2c9fe3f64aa59541a40158a3ced9a4aa974b0fad13e57d9bc6fe182c78b5a3a9f37dbcace5a01", + "fdef54961fc0756322e658a993f3cc4e982b770483ee763fc40bfff7b37943c771e7a4f44b4bd48dee2c0a722f184f0c8faa22173c3b2f1da0a3d3ac2965f3f901" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "2gQbpB4v3yXRyF6oorigjnUUQaNzM8KuQtD", + "secret": "60961b0cb2ff7ec60965404fed8b5dbf29edbec06bb8325b03957ea5cc191970", + "public": "02c4534d31801b121ff729abc6873ac9ce3fca7f8f87f4b4aa001a9990845bed33", "signatures": [ - "6821397c773e7a6e2b301952708a31020762ce25a8eb699b68fc92e1d327ca9a510ca96ca6c259abc658ff137ad0b9baf3b70a52a93ec5ee61bba945648ddcb400", - "e82ffe9fabaef33ec2d710c04d09f189736f11f6ac7daf26f510814087299ccc16bb6495473a0d9e7a26ae8413d17b63c592c6a0fd1cf0725b6a4f43c633013900", - "27c405d5e81f1388d723261f5c724f90e5962d4b6ff608800455f18b02bf2d761271a36cb5e772e067f996cbfa25fdb26dd4f625b573ab31494c5cf37411738601", - "afba648ec046defff601822143a32f2de5791c46c50db3e436751ec54e7049bc7d99120220daf934df79711c6d66361896d4e7702dd63cb3f39011e75340190e00", - "bf3300dfc36b1ddd7cfae691ed494bfbfaa9706fa8fe50f50e091c7c47389d23134c15ee11332d1c21ac4cd429f13c928978988a199fe0e0910756ee01bb4fd001", - "f15a0d8169bc8aa1ea910416c3a5d42869a35aebf07defd0e41d048f323583e3695d0226bd1a904ca54740eb589f19f086a58d0cf9d78830d5abb99d4c374cdb01", - "709a3fb4d3c082104edca57a81443f72d60e1dc69ae4d7b0cbfa2b7c49e7f0674ad9916b576a390b0c5b7b5749bcbaa7ee9213b214c7d21dffd416f94500fc7401", - "e486339717d0a71fca9dc22217f00169d74ff0ce37623229fe6218570a17cc41665802771961ef071c47d8b0766b4fea84a7ed73f10a14ba5474b80d7aa0ed4001", - "954149498a800e327fc5bef49e17320b9de5c7591ced71fbbf78d9fdf59e04006896073d63b31f5f63ec9ef6f3824454491e3fab18256f7a4d982fb720c3d0a500", - "046fee91f7756488b87eeca99c0a2adef4a7f80d9f1583d51bc8f5d97b2b8e9f5194de568ac7d5b47501da7052d4e3c550c97be906b21a4b1bd4d24cdd1916f001" + "8502a96792de276b98893482baea1d2d1b1cfd7aa6e028662400f3f59212b034270f86e8f98a38a8b3bc0452afe3c51730fe321833d97a6f2af0a75f239a565901", + "f80fbe0a4126504ea331b1eda8c0ba9c33ae9bbe43b80a109a7d4e2dc102a5be7aed8abf4ea85dfc6378f7a090317df37a2bcad54ca4982871aeb0fce5b497a001", + "e8e4ce06507f1aa72def1b965fe4a2eecbf5f3cc9533138be8db41e78768ac8445db94f136d8b373a21f5991679091914c849736fdf842d35e4ce9b66d38ce9e00", + "9d1a1454348343036699d8be3be97912e4b29428e3642344557e24f0ce7be7537e150b9895636e28947b4ee1a42ca037c392fbb9fcc419ce5f250718684d71cb01", + "60fd7de5912ab8b581be9d6c396c838ecdb497c706c38f45a6a2b730b8d1e5ac2562ece612d9debf93f453ae45136d131d08a53e6a1d393914571d1c551b1f2e01", + "ef9f454083f9a2550115585dcf1d45e3c3cafa1460b0730ceb1dae89ad07d07e67499e3ea50ab5798c16923325b7d33b70456425d124d0a7be86ed2efbd4133b00", + "6f8231bf2769af9d12d011798307d7faf9580135df840576dc57addb0d66eec33c343646d92bb2297a8d1085d953be6f96697c88e2f978f4033b7bf4ddafe73400", + "8667448f5154ef26d1e65a6d29f04c2a510fb97d7de90949b3f47a3aede8694d1fbabc3c16f64b698d1fdc2d986bd5e8df0ebe09ecab5399cfbab39a8ac80b9e01", + "4f964bb6101b0126e44e1e71abdb414e937b7668ee97074a69b628c15ac78d524fd45f39a1be141ead32df77a8ad0a62cfb6c05d5eafdf69d6c80932219c856a01", + "660763690925139272e41c09c27885b1c5d8aae87bbe2c02fd83d57f9db9c57a69aa933da8a4a37cb56dcaea20c0f742cfb00294dec4a6c66ce7dddb5669d9f101" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "2FmtRamAEN3Eiw2eqroJt3nhHzgo9VxTvPK", + "secret": "5127d7f0c06d335e1584ddcbf4534c8a5be109ec2e28a2f40aa5491427b7452c", + "public": "03103745843f93a49c945f4fbc0bf4ff479101c22a3ece11220cafa109280b494f", "signatures": [ - "aa22dbae3b41fe99973a8ad198659ea14e8072e23dca8d35593e371633ed00be4513d2e050ce71594b2c833921a9284647b83faed187e8523c702d56c197f54101", - "cd305f43ace165a12660cc72d25fe2112efa06a17b4874ce988a6d55ff91ebca404998145f9e6049ec137286d1a575e1a98554a3852bd685413cfb2c2b6f8fbb01", - "2de889cd06ae84c4d08ee76e48db7c7148baa60547b2c477f242b1dc87042b401899a4b2cab8a3dff8f19005bb4a9191491eac93c63784c399a778248dbe298901", - "7bdffa5e1ef624a3048b5b3a941ed0ddfd2c6f47772497a4629d9f83e37f975e45e164f6496d3e92785534b8d4974f676b5e0609566acf0333d851cffcd0862400", - "64b3df8e9fb7c9e313ff9f300bc79639f8e1917a0aae6d856ca1305b9c38cf866d654b8abfcca7aba0b6454c9f3acf219969f574f3fd655c275ff96043a457a301", - "ddf58760c8026515c7844d684a0f91f8c88c390df4d99a54d1195eda77e034984f577ae32bc2be6720f66e5a00a45d097929b67cf140b7ef52d54b62adc0de8001", - "a7fc1806dee333384f95f0022e6c3613219fdef9bed596e0693039a4130a87a835ea86f90b20b812d668f3f97642df5ac33b7554eebf28b683744ed94d82301101", - "4914f4623faa688a4b79c00dcbc1cb0e317244de9d6d2421a380aba8026e7515535128adbbf65083afa7adfeaf66ec05a81fe9a072818ba2c983f4f4dea9321100", - "d9a9e6f64f218a8772c735fb4fa057316878e1fa1812d563f34011805aa6a6af7876396471556846e21133338675c995eae73c2846d71be9e80f345e42d1d91900", - "97686bce763eef6861b7f2721825da8fe26b41b9670c25004d1529cc583ef2f701386a0d27132d02b7655c2ab15b7b7fc5a514975b24dc0061365aa278fe54a500" + "6f9e4d1d02cca690bf0e2ed204e32b11357588a77f8605280bcb92f148cb4003166a5aef470d4e3170e68f6be369e4444b8b04290ed5a0d564e6e5f86cda0b8701", + "7e5649e2e83de29a9058fa138d253133c7bb8d0594c3cb546ade2a026796050013926bfd1a8a7bc7f92875e2275224037932568b60dfc7bc2ae2ebc6a1b0f82501", + "b5d0be26eff1bcc5ae0d03a115baa82d52cb33c13833351362cfa2bf4c2db3075f7035d08b3ae0f850c63b87358e1bfe557678bbcc7226097c9e45310f9a5e6b00", + "74352b57c8344b32c37420f636892e592842c5e1794d2bf0369d4f4dbb005406152b7725f68726df8274246e7923b2aac6e43314569cd54863158d0f9ffdcd2500", + "366cefeba68f76d1ef460ac310d0654ba8434ea30e79b445cd7481b1356482d107a7148c2495b0d143d800024cde9364aecea0d1457a8fed1a2c1de326c2777701", + "2d0a2fa37cc5e3cb4a882d0632fe2204cc26c4340a13376e7b0805264a77a32313ae46ced96592e9a25a7773b7cdb38ed0a6ed4db445c079b5cadee8202d29b900", + "ec35429af03b64053d09c0e7e1413331e261ec2652c9a5ab268fc48c8a7449d13b4f707aaa5edc48fd78feb5018fb000f53521ed9167841b618a9a27a153567500", + "d8f999ae5e660966147c9faa1acb503ad6750ba1f5fbc14fd1806eaf6667bc3636cb000d5e02f68963b7e6af546d21d0c0f4c97eb13411a03da3870c73a685d801", + "f49df2eb22d660fad6d4f529b0c645023d4c9b37822bc728bb80a28ce5cb2898618f080208f48643efd045c130025f9f3223c568a5a2505a8b2747880af730b201", + "17d9223864ee1764545b1bd74330f3d692052f42b73ae530712ce7b3a02e0336316736ae1e054e80da778e173f9cc6e93bd865e208b41ddd6bb7b8231d0af4e700" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "k46MSCkDYk6ZaHcj2ytwZamLRr5w4QUEwe", + "secret": "2b1ba25cdecc2b0c4b7938c220615929abca0d1df1d673604f8b370f145467fe", + "public": "02771a319f31f4d999adb58b1df0042a525e539d6cb4bc3721efd7ab2cfcd0a3e2", "signatures": [ - "091dfa4a5f8492ac8a932ae90ef5d278cc4afe9211ee9edaa52087b57c31719013d8a8890909b5577e41e613b40e32dbc88aba8890e2d988a441ebc9f110eaae00", - "b6d3f4f178b6e7e518558e4898fd09ae8fe7083304fde662943facb7ca55c90c43be81519becdcd0a819758bff7e32cbbc66fc4270c65e1968638696220e723500", - "cd387ee5b4a51f60db46a46ccc9cbe53d57e8424d5a1214f564dc7c292d32eb36564ddd5044aad684e40db48bf5f4250f2a1cac9ceab43a29a4065c02af4483c00", - "78aeb6ba6984c6adafaf4f89d0b041480a736f22fbd7f43d3ef72c5c9a84ba9762e0ec96878b9c497793f7500545d0b1a15269d4755507c14fdef6fc59ea4b0d01", - "5629c00b57d6ca0d2ea55ace7ee25156c89db9795cb367f5c9aba0b3f1c0cebd5f2c7a833a9d9dc576a9947375eeca2581467dbc7d5edaa1368d6c80e80e47e401", - "70f6994be757ae0b681240d68566f7db73849710cf530e322f17dbd88bbaa4e47c75c64276e273daa07177578f58c0b6fedfb76cccc1e3123d7b06401311678600", - "df190df91e47d90ceeec45eea1b40e43cf470e9647484c9a04405df2e910c449197f91576e34234245b86b420373e895522732746e556d8078ad08f3df0bf3e600", - "2da3c025601c60f57dc13befa0508cb1b88592291ee20b0343947e1390e3e8946bf1b9c5e9a723f882cd910b43d692020c14ee47443c06468440c27605df5e3e01", - "cc1f8497bb2ecc977ef752b7c2f777a9908b7b6b15ab6100739e5ab2225677b645642d28ef849a4ffb4a52e50a1af708908b5999fed859f6411e4316c0fdf1e001", - "e5d97a1ea25306fc8aea775852527b139be7d8203dbb4bfef5b47620825710b54810c99d530a9bb9676e042f2737cd932628606d6c4ffb0be47421b411dea05800" + "59851f4aa542003febf2d39ebadbd07ddd12cd41a665a8fc052ba01b1c484a6d407bdc61b449cdbeadf73f6ba5866685651b7d0249527a82f965d5a2b314c4af00", + "40f631b61815f54e0a12eaac988684f4808462f19f7b76deed56ce3f3dd2bf2827104ee2ab71c3a96773de3bef7a41df960fb98329852a42be09227a1c9ed89b00", + "f539e928d4c68938eb6eddd169a09edb46c056771185968d548b7886f5c1eb9b7895cff1df13be0d70c51bffd0c98f8fee9dafb68d5d8d3bc1b2f6a5e700c9cf00", + "d1b9277ce64f26956d65b15bac44a3ec80bd2024e098be69bfb6ec36a4718aa75fb6e8b353008a20bd4dc994ae9e7bd928c6efacfbca7d2e07861e3fcd74f51301", + "bf919b227af4075ca7864fceca4dad5a21ca9c1f124fce3b8f66f8406322fb021c85aee03128fb1b43fe0ea91ea825932b4dbd468c15ffbc8e5d36f69906f45200", + "36a6c965fbaf282058fb5fefc466d9f4df508598be400eb1f9415533554c59ac18f04007eefce37f5c8e9ef7901e65deb2a2219e2aa7ab638e4370bee9c98d5d01", + "30ea0d7dc2735767bd60d85cbfb39c19d0b4a2d7aa81157a2d647c548c7eb9082b991300b5608d13eb2bae260c4eea723f92a0c1fa82a267fa34498fcec117d000", + "91ac4a1889132a827df3d7dbee5aa95a4c9b111283cc1209c0a7ff77dbe782cf31c8f32320bb3344e06a3c114e18fa0da245f4749b11a27ab918c521637d6c8700", + "8c59fa54d45f81390b67c23659c831786376bd7d730a9af1e936f09dfb0cf11321200469f6ce4c2ebd53f7ef09069c314d9742ac540c3ae90bd4dcd805ea6e3f01", + "1055cbb78a97a410fc3663dfad3bfe21865da1854cf196d1f532ae42d9161783284210305c1abd09f77f0c36131458506d3e84dc19e87a3255e1fe220018169c01" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "2GAWkAhh6ddxLGT38b2XHCuhdbRx9Jvf4pk", + "secret": "e0c84b3bd790f03c58548657cad0a83cc302d1b75d7b6b3d8edfc21d8c2289cd", + "public": "028209201b8152ea8fd7f7711eeb82354f67cf1cf1b4082160f9f04eca421bea2e", "signatures": [ - "f8cb74e03be6342a1fc862dee36880a15ba14c3053d34f81c3f285156f317a9661c898cf22018c1a96f31f403dcef1e54c893df0651de0fa526d68a78f85d4f901", - "d5ad1bb3e03416ea15285e3b0e642f5bfb65d2942e719f9d4fe66e49dc6a79fc70747f38f9e7869cba17768a814bb5162b26e7a9d9db06d0edb0a6401e53ec7b00", - "1cc40046c1b8d3ba3edd7abeed49e12b09eedd82ba79a0cadded0f1eeb5501422443f85ff6f75003931065ae1c5a7f9533d61a73be7e1b90e693e6470dd05f3f00", - "647082ad94f57657a3154367481d31847acb97ab65bd7576cd693f9b3a0f6b433dfe8e851eae3efd9df34b11d509ee216a5c7224a4ee3a7b61f72a3aebcdae0d01", - "de8f8b6898aa5cbd49fa47a8df42b2508a8fe3ac8397bb8d63e65d1586fcb84f25536b95f15579a21b8fe948006bd2200a596bf1437aa14fa90770c80abbd11c00", - "0f37b7fe08edb251bff61578bd30a4a5aa6290fbebf6cff7f5b8a07c2f0027b422a9ee59b574a23a163114862023bf957d5999f1ea3dc5bc77dbe041e934eeba01", - "662349ccc5595b6aa88c15c8fa3f4a5688ec7b008de4751332d06c5f4a6b7312423e24bb4c225df9e09526ab8b077b98cb1697d0a5e32765751350c07d5d682901", - "80baee7e6873baa9ee15cf66410a93a8036fdf8974ead1044218072d56736642373700c886f137bffc2c0d6d06b297f6ad348dd85c18a26a9d0de399084ebe2000", - "b4c42131dcad854ec75be519fd657b52625faa9f4226c30be33fba3e077d375052df7e102e7a7a66bc7d360d93adb57f80d1b662a47de59f61e376a4d0dc973a00", - "d2b91b57a166cde71f24acee593e360c422d88c60515b0efaa41cd29f276f22b4e82f22f608b489f6f209dbd6dc01b03fc6f3578820dbac4583c6679792f087f00" + "2b390a37a9cb797fb637ba4ef700637108629067a6666d5e1ee23bf448fd171e0f7218eeb61ab445ebd7c14ed3998f3dcf0a3aa22b66e7d5a545a31a6829e5f501", + "871b75956dceef0b0edfe032290de7cc86347154cfdda5f589298e6aee850bbc2668a09c61d71f92ca98347c39e33d52193f61cdf125db85d463bd24b3805a4500", + "dcdc972a97aa2c3784a9d48a886d344a1db80a26e0015c54590621ac2fdc9c6e40149a4966a80b4b96a3f92cb40fb48043c359f44e58134c0addedba9257506b00", + "de090ac5cdfdb9082e682534f1486f426343c9aad870ad45291a8343524ddd67379f76bb35f75191ccd45c5286b48e4cf5049b975d07548b97fdb31d86c1fa5100", + "7bf2158c903b09045bedaceaff8f15603c762543d6854e60037529a20f401f766979df98a63a9432f6154b010deed9772ad21a15bc3a162b49bd5f11bd4d96ea01", + "ae300255bfb6443a65ede797bce0944bf7a503d38c4b161935f44ed2f7738e347040bb8309017d5d6c14161aaa0075f301d957c8a761b33284d6d535547bff9100", + "e61371336baabb089fe52ff52751e5e41f34820c4875f0a2cedb2e20cd8c1c2b638f3b0b04b199dcb2699428fbdd1e55ffcee0744d46c503ee125ea533d567d701", + "e22f88a49370f37b078fed65668cbdee44567ef3254693a9fc0aa181739acf2f3ced7c4ff5fc8204304122c3072c2e1dd8a44989cf6bd77ab4709d6fd1e3952400", + "76d6cb79f1529b03762fd3323fd381174568a05f7c799faed8be6a0080d89d9b3c607d378178b6e941e2fdbeaab235f2cdfd37fbfb9922170193d6508081148c01", + "1cc5722eb5e17c21114daba7c19ae25649ee79482ef8b681015f8d708aae2aca4b3abc6b345410f94193d4e9e8de50cda2f5a5e52befdfc9e7c81a42757eec3d01" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "EzfiGbJmK9AtLocAbUUgKt5FbvkptAfLqC", + "secret": "4da01bf2216bb743f5412fcb843d79ed3bc22a03ff7ca0b314255fd622d90874", + "public": "0342b3d108f4f046af97cd92244b841b6ada34f52548d944d3e22344a952e3d173", "signatures": [ - "c4642c3754fb1770d406eef862163578761bb4ef8775cfbfc2b163e8c6ead20d314687629fbb4d752dbeb548ab81fe99674c859ada805722e094a998c427598300", - "e33a2b41ea05981c9c03db5fa93d5dacac517fc1a5d447d3f642e72dc06c2b521e8419d475fec4bc449651415f368f69bbae88b7f0c8f11c195301adaccd0fff01", - "a3cbc503c1fdff502e177f3cf82f9a78b46ad90205e79e4128b8ec36917aec08193b5223c19a3bf5b394a071610c7cbed784f43ba9339bd9c947c02646350a0001", - "a221ede625d037407e7ae9fd8b5e49a3a11a568525bf12e6278c55f5b32a92347b8dd88949c93e69b82079285e29b8454c1c151247c9df018c441e59d2a1d42b00", - "13bf3e6f06c89c9f435373b9fb74b241ea6b2f00792d5c94c44109b2b4d8e5ce5914b59480424e2147a4a4ecefe8c7c58ae3716613b18582e3e597b3da180a8f00", - "ec5103d7250360725ece23a21b0ccd40e086aa883bd2e9d49d51939e2609e1d47ab88f31b0c6ff119ceda612f5d8a3006f639688072c56a4cba05ecc4153994901", - "438df20e13a643d0f96ddff8d013408a9df3b43645790cc2073e59605862676a12e7b1881fbbec6e3bf7b6b76f22d009966a2f36cb88f7b24446bf07014b856101", - "3af4b61036872f3f0ae6b4db497c295f69e4b890afa4b0210d5461857c4b32c11257a1a38bf94c71a3fdecdc4bed8687328f9cdf5940b036a3863f0121a7c5e201", - "c04f629c5b7dc51ea44d9ef444a96027ba392112e91df4b9b47ffa3d06531db70c31a04e727ee46ee9cbb08ce2be6b8b5edcbf24309fe5eb5dd3e1474af2c5ec00", - "33350aac56e28a110104fd15c51d03badef0bdc69ba8aea406de7d3f3c2aa5a43bf277a024b7d42e3620b4be330800f2c53a56c1582b3366e1f68731a4399c9e01" + "d320e4335cad33aee05f4149326c9975464d2b8b0f24fb0ecd68d57c19f6df3f3dd0df782322bfab34be399762e3c43c91e8e61fb2d52d9d41b63663ced9e71c01", + "ac536af52e3f49f392a5612bb227c25c3ab58c60b6d2646ca43b465d409620230a52304d22c942f28d5a6f7d2e69093e828027dd6dd5ba4af5e91a6fa423cb1000", + "922a0df5d51a5a7f64b42a2a3491842350cb37f3d3331e14cc2458e449f384f158b9d6814017cf2b8dbba0962315808163af33dc85f73339aea0db2f1249e4c901", + "19ab17f648411a76c8011199a3f648bf4678ec8086ee97bdfd09a6abac3703190d75dd1444404a97505401e5c5465cff9c73f8281ab300ea2bb473647265cf3301", + "df43f4d301309340903b862f6002d8746b622c7f8aebbbe6a3b9fac0d17e8e933a32313dc3faec39590c414d5d9dac92705e72c45be95a1e53c9476c96b35f8400", + "91af75028b21573abc40d3b7a652850202898b2692e5fc77223ea7c8bcac75f002d42a0968e9bd12cddd0f5dfe8372f441dec2108650d8892ec133428099951601", + "4ea9d6a9cd5a4298b9649a83837a1492339c53fc2db3e120003f5e3f33e13984739b7f2fdebc10ba7b465e000c2167e8b215f250379d7c864f98d16e6d9e130901", + "61ba9794787249f40c9d49e451f7605d7e7df411db3e6833f3ec6b436139583615644f11da4e650dd170c501e6f4011691c9dd1eb8371f7e06b5de59cb4767b800", + "8e3ce6420e9e3ffb84d87f4b62738114f93afc76650c184445e5e625b7470fd01f1052b3c85f629053fad8bc8e2b356885f1cb82e647254d4e5f79d86cc94f4d01", + "2966a1e0262bb90144cbcbce45fbe477f9ff135ec4aa59f8fed4225ad88c8acb4eb639cf1dfffd7f702b7c9695b427dd91274904394597bb83209f00b7403a8900" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0007.golden b/src/cipher/testsuite/testdata/seed-0007.golden index af5c05d028..a62353f3de 100644 --- a/src/cipher/testsuite/testdata/seed-0007.golden +++ b/src/cipher/testsuite/testdata/seed-0007.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "cGlsbCBnZW5yZSBwYW50aGVyIGZhY3VsdHkgZ3JhY2UgZ29zcGVsIHJpYiBpY2UgcmVmbGVjdCBzbGFiIHRoZXkgamF6eg==", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "mPSsNuUTsMdvc6afNScJGAYWLTK6zjpaXr", + "secret": "b4635dce2ea621928c61bbfb2132090c674e99b9ca6017a6c7ab33dfdbefdee8", + "public": "028e6507a815ed048711b7bc74214addda37b5197d3128419fe2cf1f46aa6f4da6", "signatures": [ - "ff6b95d4eae8bc32ef880b3a74892ccc950ee27828f32f4fee7fdd54eb3324f57bf75242f16fa42bbd70a233756abd6eef75e90f060f1f1a73ed6c27aef22a3800", - "48a97a961da900ef608a4aacf28d254cfedfe5a5cd3ff074ad5c6845555dcbf570b93816dde869a1e5a55062fb70c919712035ae4c739e6fc289b17e86004b7d00", - "8a5423e457dd297a31ee11d4e040c4a4ee094c6d52589d8bef6fdbe81c66375902ff97cdaa8eb98a294fc69f93afce1bcc62951a6769e8207afdeaeec41cc0ef00", - "fefba88a0c4aa54dea419d49ac7539947480a0119234c46880ea4a4cdcc22658678c7d308156635b97ad7763c10e7ccadf297bad5744cce90c336792640b080901", - "869bdf132209f84f0ee3b07e46e98c65c50fff0e3e4e942c56cc5519b2eb10e43ea548a35d4ca9840590e2e2f47a8a659cb12965553328d2b9dce32b33452fa500", - "1ff31e27f4f3273dd763da586ab1cc50215433f6107c0eb292932b549eeb775a152dc814564b110525e956b49db29f02a902a192715f7a6b13715d3e4bb23b3400", - "1647fb106ec4a6d36da3502c7a949566b3cfdbdc007d3aebd70482a8abf659883fd0fc38bc67903790fe62429cc4139e31916adbb9fa4952e19e28cc97874f9a00", - "535f2254f7738c18b54dd80887fc1d20be7c0af52fd9d8410f9b0b3734e0da031a3369cb57651d69bb4dd9bbf14c0799468069a8c7655a42d215b0f3c6e622f800", - "8f5156b9fc9bfc90aad8654e574bea8f8f8f1875449636c8420e1fce5e731a85080002154d035ec16eccae396aa1fee9d37043d393dc1b4fb6a49e64d5c9949d00", - "dac4683fcfc2f1a51f3f4c036b48a44cf84bef27eef07644d762227735669e042e96580046408bba7f7b43c978cfea9db1d9af60572697593847fb1f22c0775800" + "8669aca771dc0437ff8e12b65ad4458b4e38c1bcb1b1ff29f8182780057942b82f5877933306f93753d76c5e74d0915bbc8ab62c6a641b2bd7ccea69797f5ac700", + "97ea4fdd2fec0593c93c8d37f2e938057fb570f023e73b8b441d5eeabfc2a72764a3f851f7da5c5f3af3d969d87f86fa905cc9f1bf6472e2a749f60d6891b2d901", + "4ef65b166932549734074a92f77266c70696f2ec5d64aee324f6cc68cc6dc20b0fbdfac4d871c47bfe97f11070ef74900f9da818bd5a0f44bab01b35cd47fb7501", + "da6383da7ae60f724056a120280e8fa24abcf08c0ee32024165090edc7e472b14c81d41c9d52b637efc1c7114ab65f53890251caede1dfed2ad2beda0bb57b6c00", + "ca7d081115500cb95a9b8e4990429f2d1df284ee6088503721c100d8132c54ac1298e9b79b1546a09877e658735192292283d8396734607a90905c98c7f5b1d301", + "50906532962f9b50c8db4a9836669fd0d62f7a33d3d58b33e95cdad4ddc99f207c9f75fb0fedcda2f87ced5fc9d48e2eaef274a7395d68f31749282ca96f729100", + "e316c729311f1cb873bb245e128775948f4782f9e36e9112bea1d4c1ac8644ce2b3c4c914b1ac36c102fcef8e99391ecdd5bcfae3bafcbb002c5b0f6eba25b5c01", + "af312200f509edd20bec70328b8f88ba71a57b299b46799d15d9a8afbc7ff2a173d7f67a70b7a527e7bdca3ca0d0980cf84efbee41d2eebcea8d81d79da6843c00", + "04c2cd593c4cba96a0fe54fc119b3fd00efb82bb20bd71aed1fbbaca05a588a239f4975d39351bc085a2b8c0043a08ee09351e3594554a23b357fb5223f7769801", + "792267a2445428980b35e0d59f3f656bd4c71f0e6c4b8fd1f89930060d90ad8b26dfe4e4aeae7df72b42e7d4b5a5781c402cbeed51a23302f65c321a2d847d6801" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2Necqw9k3NCEtj9FY28Kx7NV5nSCGQ1joHi", + "secret": "7655913737a47a580d2c388440d9236a0283050aadc7b167f2584e9878b066b2", + "public": "02bd478e24155889b48977d6ac97fc7bdedd146fb2c983960e28d63a20a1adb6c5", "signatures": [ - "faa99b352fa519feaabfda7cc6a8540132f4bc5ee13670a180829894092894544fb7386a332992ff2a9b0def06509bfef6f11eed67801cdf6c9174627ea0930900", - "e6f0f43f9fb009871568e0610c70f81b0a936c6796c9b52e48c34107569b2cff6d7b3d134d094fd759b02e13eeed7604a6017bb33da88163be858dae09bba6be01", - "fdb0eb7f82d1e1fa1e3bbb038ceb80314019b562eafb2037a89c579fb1128d876fcf01f383443dd777d170eec06d1e58a4c7af671b54fb1bd628f23c84b2f3e101", - "0b6ea61455ff7007df320c800ba6d7f7c447daaf48e36c034c40e4dae7032ba55dda53ecad71a90ce7176b65bcd50a58e7bfdf6bb8f24327f382602f7f43f6b600", - "a613d490e62c334bbcb516502205187fd42d860b410048a814aa2aeae61b0c8d5f31b7981c5ffe995b87eea25872e9e6dfcd867b1726fecf180d607170036f7001", - "1d6538667417fb1406915e67c42cbd596a722c682eee04d47e369aa2a4d1c64806bcd9973758e3ad23ea4595c00d55b094ae62d0bb9cdffb7c3ca46b647c349f01", - "3d458223edccf077b41a8ea91f164706a19fa3342b894b698b8623195451742a126f57077bdabb6f3081004cdd0f4ef1987ed8d6cc293a30034ee5b0fb16f5c700", - "8efaedec8ac07fc038759044d22d086522abc2797435769a891dc8a8be34030959373a2145c07cfef3a5ff59939954f8287456b6c64a543539514a59d48341fb00", - "c43e0ae05ec4b94f447d6ae86f2c1eabbf021adf617d3f55c142a81c4cf82c4a000a98c8ae975a3ec56a44cae089c148ea093bdb2817a4f9599b386a801a68b400", - "4d86f4f55eab1ac25365720fbaab9b433733a0fc5af69e365ef7092c36b624617bb9fbe12bcab754a3734f159fc5a864603ad69a8dee6bae46dfde00352b20c900" + "aee5eee74330efeb184999e59b5b26516a124f6c320d9df6167cad45ff297c4f43525905e5fdf73f07f6925cb4084fca43fbfeffaff5eee81d52f53ca08d2c3e00", + "d97bdbc541dd80006dcc5e4c6001f044e20ebfae2f6410a2af7e44acb9ff4c0f68e0debc89784258f6f8d04e0d58e4342ddf0ea52dfbfcd693dfd00b6cae60a401", + "726eb4a9402228f925da2aa936b635bf1d3b587e7566620f0d5e359a0596c35d62a786f1d604d5109420e3449232622c3ea440341715119821c8392908e0db3601", + "b591beb1c89636c14a82694323df81508bfd6f209ffa768d0f2f74b27b2572aa65719c48732ea457e628ffd68fe3125801336f147968da55f8165ec020f480bc01", + "9f5ea12b545d1ca7f4ede6515e4f88e92aeb075e470d69a4a5df5b8516eafcdf762be8995c70fc788f886a7440781c95c384f7a8a4cd5e9a7e228366374ece3b01", + "f8e7277a042429076ceddc5b896f6ed69864776dc904572cb499be4672b16d0613e046fc3626a953343046c60e86114f59a24e46ef96f5b7032b8b204d18f4ad01", + "2c4b74070467fc30c8f902cffd43cfb21e7d5dce587fd1ebb07ad4374df020e240c0191cd5e68f4913d1b99a87f9c68cb59bb877296aa6a531e6bad860c0ab5300", + "00a0d16272360c4f47de24be8962cd3f3cdc13fbc8ea64aa57f138f12b9de5082ce3ee1e50906b74552dd5f99cb10d517e4aeffd308b43f680443a223363b9cd00", + "3aa6aa35b15eda95eee58a82e8a2e54780b77248e6020149407e3981a721129401319fe05da2a9e768baf195547c5180c52bd2b862af445b5b0ad50f8557aaf900", + "863ad24a59dcfd63da8c41af9334137277cbfedaed35c0c85d1424751c3cd871191ae55d8227dafbbf9596966a759c77fea4da7a2eaabf126aa47e9608cc000400" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "ajzwXmj91ZKMnHeJ8LasEEzjd43fGJo2P9", + "secret": "b1410fe8b4705b209bdbce08b800017e52d34ebb5cbf62f84bfba61c146312c6", + "public": "033c8dcfced958c25c2e522a854c102da4901ab2985474183e3563b5540b4c7b00", "signatures": [ - "80d617611bab1489d77a1d562c914a38d240bdf7a7e9c55f177d67c13158d0cc4834193f02c8a576edc9901a7a4617325683b694446b5d3c928a86f6f805a4ea01", - "9619e9ad6bfee79b3f0f3d3b326e1c2a72bea423c8776980317c8f6d032ab27442388fb8570a6c768991db70c83a03a4f812e261a0687550ac52f1744860304f01", - "580bd09616110575b76e1ca670c74a893650cfb2e46c5a0d4707b9cce57f016b251efa79131d4663d7a20c3b55aa8f7fe1d5aca237c69a81285e8197f4d6d96001", - "4eaa6b3fa57cdf0a5bb6cbbad195163042db2d7496645c8bc8fb81d77f5a46f251edb9c7daa036888ebe23c722249f5cea08b759e6b43387d35e8885b47dab1601", - "bdf656123d05e98c1cbf60a31448175883d0031ac7aa319f70cf5c5b84594da13926d2f5490bc8b722efab792ba2b2531191221fd88cb51fde1a6ce610dba42100", - "dd1f40daf2454d9592811621b4893fbda8e44dc19b20509aca1fc08d7b81728a452e802cfab5dbe8a6a6f667b83d26dbab114de7f03909f270ba7249026a685d01", - "78f260fd032b6739132f01bedba2e82ce33dda4566043972d1b45b4191441e6f4f4f68618983f0fb1ab49d56817a7bdc5e0b6a5f4efddee81c8cffb3aed10b1401", - "226c05166b064f2ad5c7f635d0b744135923a0a3eb134e9808bf06a5ccc8fe866eed21ca05d05ff8d8a3d0028d010962dbf0a3d818c19ca1f638282831e7aa5e01", - "4af1e87c9d2d5da2588b22dd5aa8a7b20fb5aae6719da53cb88f3f5c527204a372c6ff91c917672b53717581b33e4a3b08ea5fea31a3491f155e59247886925800", - "74a2f016627609ff263e9ab25cae0891a88ee0ba1fd7dc303e9c3e9019fb44815f54aa401fb4eef5c0fcb42f0ee9429dc911efb85a5e071a974b8f9a61d4c38300" + "24643acd511ef7d7310f30d42c6e627cd7fe33681b5a6e3752f3a29176b44c7a547dd22d421019223d0575478cd20ce96931afd3ce50bab7ec7814b07f5690a701", + "20300a8466aa41d9ca854c4cd18291d6aafb8be050db7553573493387ea56808494e4bfe7bd40670813ead46f6dceb0bc147faa7804eed7738de4588466f800300", + "8d47354f77889b8b6e5c91af0771b6c6a1f8cdc704184a635fe06ed839f054ae264189d96c05444c3412a352e5141e08adfdb9f71a6694f98b029d43dd47251101", + "a13d77d2f566e73cdf93b915f24ca8408716400261ae15997dd6ce6a7ea0372e03def52420d5951645211c59057f911215ef25f8534867da690ff90fd9f7247f00", + "0980bb01721d53f0498801b77ac4d916a89f17c243f8e6323fa0988245dfd6c74d2919c4dccf3732567349349fe83be40c0dd068e9b49517cf15d0700ab1811501", + "d8f02afe36134fa6b42a649fc5c779a2c22edf4ab828da68c5f891d99823a3a72345a4e0a0770404f890fb385bd306a4d25e92a6dd5e6d1fdaebac427c10c3c600", + "706d0784c82536a5f2b79622a8c6c73bcccf8384dd22c4b0d2a8bee0918e1492240ff03af79937797292475464e04cd0976bf3a9ce3602405f6808c9af98bfd800", + "cc27141a61bcafeb90ff4a55c25b2f80f5a4a8bf1d9b23dc56990b06ea523a91650b356d9a24b9624fe74541a117542d2f20992bf047114680c8d2169dd6404b01", + "052427033c268b9b576a93fa05513f07f5fe090aa1040d94ed116db202e064af58e2f05f9ebee6f405448ec70e41173ad39e29f8462e6a4a82c6e76e2790b94700", + "215d08a564e5fef911b8fa1b7dfb84d9d7013501efc3ab92a7ea2bce8282dd8c31db5c2bbfb44df63b8b93e6bd2099cab367ed1d9584b432c85018f816b7302a01" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "KAcJer4yML3KndgxtHGs2SoGLmRTxJCynf", + "secret": "4a5e44f0036c42fde00ec8dc633969474fabda864e45f5035b18f4d15c8321aa", + "public": "03f7d1f72c91c5e6878c76cd1e5b84996a0c0a8ef36efb550d01f7af459606b48b", "signatures": [ - "998d5f79352fd0cb28f376bc0e2a4d40e1f6ca66ba23d5b931b75a22381cbb9c0d3dd77f49e80a6182f2ed2c0cb1b51330950efdd1525c21dc3f02cbbaad8ce401", - "ad53a2dfd23a5a4accd39713aeadef42b54932f1b07bdbcc0cccb71a8a6bd6ae15c06ea2fa5a4afcf9126747a99cacbd30318abd4ff167c541f733081435866600", - "a2d328d2b16ab899d7dd4755e83da90fa031442edef056fa664f305769ee79bc52d8e368be02329d1cdb1a1e895c8c7b9f594b2e770753f6ee3b7afa729c769300", - "bb40e6d2063c500b5a1a41512e52705528405363822aa961daa1d371d83ff239012d838169ae198538c806ca7d811b6e9da38c68c4879c864a2c62cba9c6dee701", - "6253ef0b5d217d1ba84205ef86ecc6b8566d47fbcd9bea71ea464fb9ab89e6797d923c743c198ba6824c4796fc3c88b645a1c3156db9f4d3c934ed4c61204cc001", - "379adbada8183370994b10194f66fa01a64ba5f9c32d8da191402c0014d4b57c3be24e9bd9b2e4c34a31970557417c34fe6299dbbefa54e7c69948c29b1e47fd00", - "9b3ae005e1307b615a3726d01df9b316a28504bd61aac5fd68d72e40389246b60420525e72ce87d09d03ed2f9841ec5eeb43bdd609f9f5b72174ebb71071dcdc00", - "61441ded426bc1cf2755f38361924d2d7cf5264d59783bf67d498c6c14aff682774779c7a34d1023fd9bfc7f11555ce51bc14871a4860ade2fb983daaa50982f01", - "f13c3f0a48a4ce4a6fb1657205c2e22be9eaa0ea6b8b6d1c88920c647be9edc622ee835bc7fb5fba976eb91c427945015dae000c714fde0a816669523362680d00", - "7f8f219bb7da2ca07e5e9638e401a7d5394a1b031e325cb22f501fe2350d6d7425b1d426f081d8d3b93ddeb157f20ee2fbb2fa2ee17bebf088419f3fae45bed900" + "3a5ff4fe01d7cb3739f2976746d396eb18f1f181bd5948395d4c41e7326ade1215da758964d42ba65158bf7e03ff8c7eb7c0dfbc914eb365e1fc0ea6c02b24eb01", + "3c391bba2682abef47fdff47022a590859abb9e95fb7dbe7317f6094901189160b114cdf44b240851c939f22e1540ff3086f91340b3c3b842fea5fffcadeab6100", + "c2be33d40825d186a950a653b61cad1b16ec0429689867a82b0f44f1a6cd633d03a6e6272e0cb886f1bff6a014516cf181a2cf6e12658d6ff32d6b32d69eedc300", + "4cce6a1330e0e838aae3747ca45f35b9df835f8744fc4ea10aecc7aa0f14946c3a780554f6fb2de15ba38c067b5e13d7d88c31c9e77bf622339cdbbc3be985fe01", + "7513352f17bf50544d3b808f9be00b9263f4328ce98db10f3f8e6e601145673c0bb2ac0dbe4784a370434d45f209dbd6afe1c4c26e0e7f8eb2427b94293f91c500", + "3f3bc0a9d2979a813bc0e1d9f6f755fa0f542796c3a2db18c04c39aeeb1822842c4d1373bd524c45aa8b537b71e5848ffefc65871b3b91e753e54ea1dc66acb501", + "1ebfd245fb5b3654ccd95be0e7f4a644896c5e5ba758778d77de878f860e4d8a3a4c33f7407db1fc5734672fb046a5c02776e13c0d56eb8ff8105ba68d52cda901", + "49e5a8fbad3e381488d6ef1ff2a8d58167cd1d17edb597c8e88a24b6e5e17e8c442d4eaca8e1bc7050bbfd439a86e857a9cdf1b704d5aa2addb016eb5af77a1e00", + "36a9f46810244e5eb23e823965a83224cf2783c140f6042fb35568ce9abb33242616c0ef0b619d9034205f01b4b7155a8237c9745fe905078dc4bd2c8fb8599001", + "e016afc5f089018881eb7516cbd07e37e044565aa826d7e37c9aea005be336f158eda455c30e03eb7cfd56bb79c5895dab15ae575b18d4b1b2de8a8645529a5601" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "X8yAtMRCVageKAgRixGESP5vRJoe1evT9w", + "secret": "e2107eba690b1df6e0d3a08373921d0a19ac491bb10380e40dc6717ed11bdd16", + "public": "036a17b121be33dce4f868d591c82268cc86d765db3b86a447ea50b7d1915db8be", "signatures": [ - "5aade6a67bfcfa5f387ff4ca8837ffd86ee46d09826b5d98fc3163b32aff6735494ef38f5d249c6acc112fd527627e9fba699585647beeea0435b7f05c2927c300", - "618689f80fa84b48f5b15a41e0913b76b3b635c4a2f027077088c6ab00c303876139afc099734598c98af3be340619b34cad392ff78ab47775662bacf21c013f00", - "ca72840abcbf4f1574de4cd7ecb749c4654a1f4082f8e61a95b19c88fca65edf39c2f199d4d364099a0ceebcd2a9410396890448f7b165e3e48149c579444caa01", - "40d2231d5db73c36f2493956ab12a5f46d2b4968e575f93983530a7a0734ab0b308fab06fac0ee347a8a925992dedde09015c219a0954f459a8162d5c7d97e0601", - "84ef9af1fec3ef2129b13ba3742789c23d236be4f6df532806cb55844f3b9b8e51a83654e42836940b8dac222d768a0fcbd2dd1f1ff5e240027f93543969e87f00", - "7a6af20efbca85f7da87d2220ad022225a220e48c374977ff6fa12ea997ef28067a57f90a4341fa33ba96cdf299ace939bb308be9943d6e1b2c8e7a390d2408c01", - "6b8da89ccca464559d53057b6f02d6824a5554aac7c86865d1ba7dfef76704be0a1e81a60c1eceeebbd024a32ff26d31f7a0437912414f65eb85f92bc494069400", - "7bd4a8bdac40a103d859e78151935eb244eb7394e89fd3b513d704cf2cb2a1ab7d49d8a7f1e2b0a86acb51dea8a59285e3b55a6e26255e3f763e55bddab63bb201", - "a3ef134b2c0efe008d255432afffcb101ab45be3653133165cca5e035890bc274667e3285f8916aace5135bb6b875904c9e838db65b5b851ddfc4aa40ea11fd301", - "ce2027bb58ccdaf7cdaa602d2b83aabca3f75d663be6aa1831b7fe54bb40a3a3730f4c9c6eafd907223f55866f17d04c20e66e2bda011f06af30c143fd9a853801" + "90fdd824c80b4d683ad26e8950aaa9c9459891374e6d519154e16833d9c6ee801c5d7d202c204e85530ae4ee0a38e9b115528bb3446364c945d529f9dd1d185601", + "b51a66267ef5c3373cd2d19e569d65349acbd3e1bf2e4422f5ef9fefbfbefc4c18fbd07ab1d008c887cb52c179dd15c7ad1f6a348a5bac45071b62ad4f9690a900", + "629bdb73080d5a2148d3a6d68e46c29509285edca81d9ec602a6eae1ee1fc31b4cc421a925e5c1a55f77ececbe201146afcc93ebb1376bcdc8a0950f61a3010c00", + "e392a4bde506161eac5473a3f646d3a153efb718405bc3ca96ae4d6d302c25964ac38e211ecb52564f459098f865f3b7000e58f30afc444a6b9fd6837a61b90500", + "7ac54bbdaa5a2b800904fc79cee2b55a6a2953b31292824bdfe2796228b2c97c06a0d1032adf26570c139ca5ceb7ea17d677be5e32f3d73edb61b49dd21e312a00", + "7f4e56604ebece2f589ba9cc8bdd3ceed3cae3bc7c737946c69637613a497b0a22d7bf916b70cd40fa7532cf91bff9d48c9cedc0e8fcc24c2a1d5a70ecbc51f200", + "74b00a4928e33bc6121e6eb622707487fad27282c736620892c0015b7b7db96a1e94f3a19f0da4096c8034456185107911c25a01248afdfd4a49f98f38bce89001", + "8a880ee824069f49a1f4e7d5cd76d70b44990cb8902379ae64713921bd8c0ebb4e6f63f4c3849e3fcce331f77c080120cf2409aded25bf48000c64a2515cd28401", + "4121056c8a3696b6158d8e3301e23c514a5863ecc1926db3c6ca313583098fc409d61ec72f9d3bcd0c215defe6cd5a07c4b2aa062e55c9c4e631ac3db237443e01", + "264e63e3df6bf4495d12d1df6db295b61ce99b9e477c1a3e6ac9fa413a11410455f173038160aaea178bcc71a3da7deefb70fac5f1f7fdc9dcfcf8d5d2f74ce901" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "2XKCgWpkUHdPxBhzgN6RNFDQSFDpbfjTM97", + "secret": "bd04dd38b12d99d5d99da868871ce4c8ec3005e615043e7f6ef766bbfa041d88", + "public": "02037e40467e07e07528f1076e64429ce8efc955ac73b741f2775df7ab7c83e9dc", "signatures": [ - "cecdb291753fa4a6741656efbae864fdea1f6b3768d096884505c1eacf14db6205649fc612664ff72acba618d8f336d640ec3d0e7d6eb2e1ef29a78c277fd8e601", - "fe60b94fb2e8ab85ced1e56dbba23b1ef209561e664d51b8ca10be74e11a2db57a6a20f4065626a58dccdeb5ee0165ca5710e99cf61e0b9675daceae43faed0a00", - "4449d01a348e95e8cf8761eb9bdc88f04dcbde9dd6e7ef26339e77bcc6035f262b8f3b8ba4515df1cd1591e5bb9ab792f312101021e67e6b7f8c5c9ed2cecbdb01", - "6ae07808d44197943b65a377bfbcbdd8f2fb8552edac78a88f2cfe5933efa147257f00a249f7cd4dc5ccf44cba29bab56f149cc01fef6ccdb6e976e55762ca2201", - "7acd40f8e49b6a256a24fd4a27e1034360574f3f3f295ea035fb21add4705d48306798393c5d6099dc3eb4e7befd41ef16dca456b2e57ffaf3e50ff43bdfed5e01", - "72705ea819f25b819bb72af50c4dfec005a6c2abeea7a17f499ab5a8abd7d2251dc2c3f7dce9e84440741a8838c4d4c6eb46576d1c8babf85e7eaf3de7055bfb01", - "c1e65048d6b1e7b42c34b8723852e8b704baf0ea56815da9fd1a0e06a4374a4807143e3a5c3aa6bfcdb4a53b903ade8ca1dc75895d1c0b79e72eb8f43b3f75d201", - "ba6a6f45f9020f443a6de0b90179881e90ccbd176ebb711aad6ddd78463ae1690a500c542b4963877e566d7ea5d7665705dd6940642a1a776e0eb232b5e9e40c00", - "c07e8fc53f4e69ec41cca8c726b3ce276e9d4e79e81857329c73ee07b844943e179778b8586c1deefa4491febd54d2f42b422f7389487690c7744d5c179ad5fc00", - "0f4fb41f1bd1f57f14a2dbbf969edb414d5938290b328955340497b070d7ad2f11e9e66b694007037cd252aef7bebee8164d24e9a4206c20a1b3649411578cc501" + "25a7ebaeaa0eba12d350cd2e022fffa3ee7d73b60bcfb1b7dc6ea3a930ab16e065a23d7caf1f79bdb390e3de2b1c09371ff22369a1b51a0ebfbee5a11d20883a01", + "d3d06e33fd3597af973851f1ef82278083f8a8a6bd58c6d33ce59264cbcd26a13daf8906cf2699c3846e64a2fd7e7dfbb092f2e4e3925157cfaea7788b8efd0900", + "e97b9b1349bd9b38912270f20c664b1f52c1ccf2dc6122c089fb6bba1c9a1864430ba63af58748de4f3c2d97172577a0b7bc659a31be9e492af81a612d3ca66601", + "5b69a9fef8e54fc5e262b62a5de331a9a7f16dcbe41f61799d367c0a4d965e8b1bbef4bce114397dba8d01b8a86a87f1ebb03ed8f3b3250d95c72963acbb7f8400", + "c34181e4a138f719197db757f12063cf844e5ce384594122b7ea668063a2dea318b00fd391471fa4a6b951f9d3cfac173ff2f4204e912f4a762f6f3eed2ee30c01", + "585ed7c1228fd22d7d481cb6e3c484c8749572050aad297aa9e406b948ec42d67430f39a4a7c46b65e876eecd8d4383aa89ce4eaff4268802cf1369663be9c4000", + "a3ba44c0e700bb0cf95efc6b0c215af840d929522d6f46efd6bd2f4b3d03bbd822139ae82e476b0d8419db6b106418286800d420fa6017ad460980e499ff547600", + "23d1eb4d7379ebdb764e6c99949a8ddd76306f351559db3e6b20aa44b5cd2b201ae1656f92dff367ef9b1608e98206fa97a61291ac28b1894d06a8267751dce000", + "9b61d09bdfca7e6c22fc89e1e60a85b94641fb2496d9259d9a277a48403551351505f6c412a67cfa2870fd43cffadb11d83c46b3abc9e2d7e335db819d775a8201", + "8da42dbeb2e06fc69ecafeb7bf9cb06f1f7c18ff16fcd0e1a3260dfe9302293e68d0408cdb6d2264a979a1eb855d503af18248beadb95ad14ced7fd4b65c516500" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "WmcZyCWxhWWBXhcW1KuBf9ft1j8wzTw9EU", + "secret": "47cdecfb4697492b71ea68c871fbffcd3d7ab6df36f5cb744c7530c88a775703", + "public": "0393d74aaf73d8bda3199efcc619d7bb3f26cfc95800e3a0ab5ea029182669a0e6", "signatures": [ - "dcade791e415b22283e0f257f4836d51c72c6d4726f6d9bfddb15045c05fb0893c0829df32a9e749bf524158db401b60c2894e789540dce6d99c5bd647055ea700", - "5755a337b2f0ac5b2405afd118ff7c061b020ac2d1b593e5c85276611c879ac12cc44c8bd8428909fa4ffabe042db1ede5857fa5ff3c0a569a6e8782b0f2ef4501", - "81b9c2c358f34db002b75b0c05660905b8f3fe4b5b05ea18f1b8dc08d3b26bc3458740078ac8924dd46dc07bcad7a28902fdc0e49fcf78cdc6dd32848867d53f01", - "fe2cc5d72d2be4dfbc0009acfc0b1308691fa891b966f26d44f58b37a25fd0435acd3a73aecb913cda7372a2e6cec7b3953ac768a8831c34a579a5b3000b56b901", - "7326861d76a3568522d9fca2d0f13389dab5decac8855a8241196d44c4a73f274d6b67bdff6db86d46c5b45505c4f72a92181129006ee7890c260df26ab06fae00", - "7a288040c6e1a80c1a72edc39986ce0ab5a12b9f7a3f5b4241abc8363097efa165317365527d10a95e6ff106787a6f4d442eaad62adda8915953e9e4cb85b04000", - "4cd637e62468006517330da6119e38a8a8fb79b1ef46075874a8aa6836d17bb03cd6749ab548e2b02b1cdd509049aa3f1ca768ac919fe6ad9d279627b1ff066101", - "5be2cd75aafbd16e6cd9701f965a1c573c3860c6d91e4cdcd1c0f5f52b68623c3f02e28c69877c42f69bae6a1ce26db2784201fdc23880ddb4f0e3ab21a362c900", - "295d19fac34da01207135ca9aac645f0a0117d8fd3c126cf41982ccb34b2da6620c3c3b958b793069ec43bcdd426e4ac717e1803c2460959efbc7d9c3692d54c00", - "81b61846535798545e25c0cfa2ad4062f19f4a27a4338d5f84471e042e6b3ddc2c5724aac9513b98218a5c960090258bd415faebabcb1e203e27d04177405d7901" + "0cd5e03900cb1f6b9217a68b5456595a5e8693e247d06b59ff1df287b4c8d3bf7a39ae9e794c3ccca84fed36b447b6256df5b6886b73d1f15a47efab6ed7abd101", + "1ee6a768810935fb72d74ca1fb946786c944cb335b1cd95c33d10e1a5ac16e0e18f6a0e4102e99ddb6cfcda7faf4ab49e1a93e1133d488aa6c23ce1a5fe251f201", + "001e7e58de32386c7e5d3b64a967ab804fb147cea16b184c2644a8685922fada0f648c9223baadbde6e637be0ce26bf477d1b2922decd993e1d97bf968b7972100", + "2bc7c3a115f6fe9fabe9a0ac3729d665621e0a1ef5026c41fb65f328914b84a6228cc3491dc07a5cd5f0b6c6a9373b1aa6f4a51f1bd370b74a2827f1773fe31501", + "bd114507fae6943f5adc330ce600b1bb8f67f72bb57f2975348f91e85a5e333440bb6cfbe0b692f63e6aa1e14ddbf62078adf5f6a620dad5b88659ac89485c5600", + "4a147ee3c96cb3563c1b06b251eb947f18ebd45c13d5121745cb0c2676a1dac47e41569699501664495527228cb5d5227e77262a6fee592c2e39d4d076ba736600", + "869de9726a35885a2e1542d059e38637f07a1f7a748f85e248b10a21321fb7a90c895931eedb897d99608115cb3e95e5f3464402099b451b14ccda964585abec00", + "e04d0d2574924c2e42c0402a8586463c68f0c9817c2eab2b0ae12d7614602e5f51a1e3ca41dbed052456c8efe96101c6176af9ef79b785351623b53c8028b2e401", + "d8b3678390136043eb595c3440e891d217024abbe8bcbf8fe359bef38282298b7b3250ca4fd74036386a480529d24bd23facf4b109bc565c61c47ad3515c3d5901", + "77e465dcfb285aee33e2c07ffd22e0cbe66123fdb6d83139f26b2eb5a151e6cc3df0614f9a4687207877f573c9a776bbe8e8582ec76264e68cba2e23db6f866300" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "sQsVTtmRVSBQvXB66Li2HmZFqxjJNt174d", + "secret": "dda8c4aed2d9dd515df72e4a31c3fd05815f7ed3b2f2b2e203d12f7fc48f90ef", + "public": "020dedd0243219fec27920385309b31ea68d3418df5cba597bbba0dc794fff11f8", "signatures": [ - "1d536d28da0315c8b68c165e5c337774fddc1cfdeef29fed374f353fe89c3c593e65f8ef97be9cfd1d42f638933e540c7dfe68e5be352765589dacbe683683ae01", - "9719c8dd1d042bfccb3447219fd58496c5d0d81659264f31d4617bb170fcc5e85c1bf71587fd23d73f224c95cba829630f2971d744a023532018a843dcd5655401", - "787361e14c60ad546ebd4a8ea4bc94edc8c94a059983e6f43c1eb2213a0bbcfe5bade6ab165f4428bd0c50ff61f01d2ea147deb9f35d165c97bc3de2886adf9200", - "f13e4aa85d39687d008ba89ed809607331a4ea087a3cbb7299f1c1ac5cdead6b01ebb746d3792c4162619cff5cce3812c65ebf11c5d945454bc0eea2b1002aec00", - "6c400b60a77de737032a56449fa4f097dcd260cf23b670e6282b1a73302e521d1623ea4fdc37356b6521f4054ed5b12bc1af7f528612fa5be385626889976d2f00", - "7c31ea32bc708999c47f5499def208b333e4d33ca32b91228daab6b2c42b33a70a18a36fbf6f0fe7d6c706083650e28131787730b2b5696ef09dbaa39ae60bcf00", - "98621ad289fc2ac7353943b2f83e90dd6de73d3661d9a8236ef49d0e3fa2c04543ba4cead1650b2f9ef5a8bc3ce191fc38b562929265c2ae41cd7cf7e0a48a6401", - "8f2d1ebf865269cf8d3eb92615995874dadda0e684d314cc2b7a146dc763a1c425365430f6e20cba0b8ae73f6ab81736b77ff9fa7640ebd05e9b02fe8c19f7c301", - "e11c2dd7e43a5d70d13174409302b3be8bfafb38bb5ef7c30852d4cbe42b9a493287856caf91e2a5af197b6fd2ce1f4b699431a03003792e64b1415f96f3930e01", - "dd2652690c50deea1529fdefaf60c852fd72f8ac34beb2f1ae51ba678d052e481afc4e02acb873d97d2559dd9a0e74a8e94d2e01eb101328fe0f2b24a38b0df101" + "9e6b99596d5fa55c07c9daaa893ff65cd713aeb723337996c51e3a42b13bf76e04090eaa3365a5d6297065e229e21315b60e14411ad660d8a74a4c1e2ff4dc9901", + "320954de1ac17b54446863320f55e18ecbf4dd65bab9288d18f25ec163762b42132ff562af17f2b8f2c759f96b2dbe0f4642376c8e8b64164f3ee323dc26bcaf00", + "00e678398b522707f33435ad16714372447cc0dfb0857f744d86fe3cdae1f375235dd78bf6d07eb559b844971754f8199999105b76b0994501fa34c96333c4a400", + "8b8d6c37c63458744011eb7f181e9221029081910565fdb34e4e4ee70ae992df04f005ef1da8920bb820b124571093ae59b2b75e87c6de069c109c308d61314b00", + "45acf679d22c6727f187a2e2516599d1597e8ba0ec268918e2b0ccada99c85136cdecba2d94cf31137b612e87819fa2fd0efcca7aa85771c9ac9f13b00c74afa01", + "1f3b2ae803fb5605cc4d698c1787777d448eefe2deb2571975886c62bf1f83881543913b7182358d7457842be6937a3fbf142ae776180ee2a0488e568898240a00", + "19902fc27e1b56e81e2f98fb4f89b8f15a716c96dca83407917ed615674b77bf0cbf8f7de42fb19da7d40d7de49e8eed4d24d0e260c3421184688b1bdc07cca200", + "c40fb53834a3198829961133e3543d786ba2719b89a059022affd7f3820a38727523fa0dccbf645b492780af141c0ddbdb421fff18f8f97a15e2d7d18114d66c01", + "5c65768f4ccbce98584a050c845264a6a19233260e7d711c48ace814d0820c43681f2d175722518df44cd135c759f54082c9eb866c967892df43875156a9420701", + "5c91737f504558b000539d368aba1c5ea62d4b5346ecac64ffcd2b5ef820b01675a58703e39a55889d1128f678f0ee13ba0170b11fdd6a02eeab87f5485eb79901" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "HAZJiBg33BdkdW3RLqg6CmUe9rTyjobvfM", + "secret": "2d046d99674e756338789b24c04cbbd0c022c06482f7592a19dab3d8da473135", + "public": "03c5784476d10e4110236c60af26f085d3f7bebcfae0a2cc06ddc95e8dfe01da4c", "signatures": [ - "4028c02659da4948cc1aedb2df50250a56a962efc9d65c2f66d2384714b444440c6a1ad707b280371b6847869901153f7d3dfcde97992a917456e063e28b929301", - "b64364bd3396b948780adfe14df9231fbbe9a0a2e944e692410509d424ad287b7ac5ed5400bf3986d6c7a37025ea0be436f11b83016b5e59254d5069021c4eca01", - "3096e655cc8ccda0e9e81aa4625f5f2cad81e00383f2396f28e324c43eb4b97932722f77694ab41f60bd0513f2f18fb58a0fe20cc87e130184fda7c36098cafc00", - "93f6072a256d7376630ba3cfe20cf3c402394e4d4fcd11f6a5f29e738051bde24df6a6e85eb4251890785eb275573ddb8867bb22e608fea7cd0e8ee77c6c48d200", - "d7d518e35e8ea5f0ce40b9dcb47de3df6c92036b0c0544a1596a4386906994c33e4706c88dd2c07231cc493fdba1804ce16b88a68a52b0c31dae1cbf340d16cd00", - "9302e5d7f5decc95d10e877c34779f6be97bd5eac6a04aa22627a21dcf9c7c3a4026387be9afd514f9f196040a5d3df0ae202819bdf76377dbe5ac8136ea53d300", - "436aa10f2822d62f69dd8a2b5e6ad68d9dc0ee0d5c87a5033620d061a18365e722f15536adb38c2fe1930a19cf4d857b82294d4e9363baefc6171cac27e7803600", - "11f95e29475cc533078c7f22d5878ec7f232247c208501a8d71043ef0fa6375268c4b65668e1440d1b77a93c51dca8c4d7b13d1bc6c961b168091b60681b068b00", - "c433d82ce5f58e4d809fec53db9f0017e48478fca22dccc7fcd4f7fad85dd69836e6e7385bccaac46f18af9dbf8aff4e5ab9f117a39af42372fea1845856569e01", - "6dbb069e4f1ca772017225984a1897b58f7b0af4be58905731cf67fda3951e6732a631d48ace0bc655b44ea17a3e92da4c586e5337242901cc4b2235a9c6859300" + "7ac208a7d530b1b5777b6416ca89d52e3fd4047d488cfc043dbf655cdbf535c55ae6234531e652376dc034ed3620b64fc7182a4e712569d07f4bfffda421cdff01", + "c8c0f9e69ff25a3a79fcd78efacdba7255fe22e69907fbb23164c6dacf74f0da013213ab8b072dcb11429e4de0d8a5080063b09a613fdd5ecad1028374c3a0e100", + "519ec555c35fd5669e00aab7c8a6d244361f11934b154e026194485d456c019e69eba81ccd983a62ca529ca3203e3a1e8d98e09c5b38044f1e47628f8e6deed000", + "ee211016b58172b2b28cbf34e501484126ac1f49ee1b89d8c2d4f03bdce628382e07f7f7f1fce3ea0b24e413452660a061377f8df4161fba404c48c07f96529a01", + "333d5e802b0b72c72c6bd615521cb3b557cd4ee15a58134e18c7305bb9f909223c4ef26dc3fc26c63a064f88cd1ed77c2a7bcf9a9f530fe7080ce102032b680d00", + "c251824690e71e8766f8896aa79b37054be3e0c981836a664066adde3cee3e482c240364fdcd5cb1398c7af02671f4a999a6ae5313db94f7c13a97b3b4a1b72100", + "2e674b3e7a2988f2d1cd6ea8440a13f78bc9a0dd948c1cb6b2ebc89b766af4531b31de154016462426d7b3594ac2283214d6f5f7cffdeab426fb83ac9f91882f01", + "0d923ce2a834ec22daa222c5997d439406be1e41b1ce8e10110568fceea3b64a2f8b4ca395d2b7be1d1eea8c47845e683ad9c5d26e1f58fb639c07ed8476e60600", + "ced0ca11d628b4f1eeda80ae34c312aa5140c65b781cb7848952bebf3a66c926424f8fa8b605c1542261a088290ca4e2854567be62620fc6920fea5b3d8a1d2501", + "0a83eccbd0c8df9b0f8ad166d892b84d85b2861d945539b124f657400d52c8261db09b5eea6d03e181d38af344c49e3f6356444bc7bb2a93c7662666daf0c2ff01" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "KAU6CLysbrc41MdFKHNioXsJNcFQTLZSWV", + "secret": "fd2de4b3e1284eee8ec5884d92ae5841bef651fa324b001bbf99b7a96a4ee232", + "public": "032548366a5a732e4b389f8fa5d8c0e5debe5be166de2b557fd58dc78d1693de2d", "signatures": [ - "67adb3e7d73ef25702e925ae1a23b710dca7f7a2b36af453c479a6665eb86f8e3a6e53c51bbb27b7a3325d2cb1531f519806c8e7446eb8de0294d29186f5d4ec00", - "b5f3baa00b657cc4c865e513183faaabbba5faeb073d0df9c1235fb19f88ab0a2a55b223b0ced314fe8b09833cef8894acf711b14fe7f5e3deea2ddb3f5d207400", - "832e897d9a1cc311460fd589cf4350863afac7605a5acf08d213ef4352e054ce34d6eaf1e23f03c12199596e514b285bd4754df0931ecd78d45b5662c8df069e01", - "3ba7cf1c9d472e7793cc85d9eb4177099d54da052d6479e5fbdd0de01f340fa83ad2e2824f3038ba8c2b1a844c0c57e5e6d4639fbad098e9de6006da9e3926ef01", - "4eb5fb154306d0c5a2cd3f2c78d43e8d3345a8a61b2dc8635a77b52de7f35c8b5a61448bd396bc1ded4984710dbd3f4b1d8abcf0b4d8bfe1ef83cb93284e59c500", - "02b5f233a4fd0f63a9286e79a81771f878824e434a999113c28dc63cb66d652003fdc0498ae7fb6025e779e851d84d51a9042a845144f3e50787a8639682d80e00", - "a348a10c9cdc849ace1b46f60cc56548f599dc630427ec6ded7b8320567cf301582192ded4f902e601a70538722d8dddc6ec773ab7796af15968b7520eb2c80101", - "6d472aaabc6d1408f62be3cb4c3cabcbb2c4c328290ce486dbc79b43508c41eb35480ba291c92620c45555a3c81fd581bf254bf8662dd107ce9ff3a3b76e2ad700", - "376b5ea40cd8b8e29f9766f6a5669db3f146d40cf6842c738d1883ac1b056c780e6681e14931da1cd843fc5ca03a3bbf39cd60c7f435c1ab7b2bc9877b67530f00", - "d892c0ae1750017b17cc2d34138663531b1b0b1e13ed41df570c2c2c9b02f2b06e7750c42d875de35bcc1e80b8b1113aba83d8a5d0f88a00d07c7b32fb1472f900" + "fd3b22598a78353042190783d3410bf0bccab1331a4e167a2f60057a5511a4425953fe8b7d7099b96f711eec98078ab44c14c4638a8055f750f79384cd5c9e2b00", + "7b6157888227e72af6d22f2964ae61a8d3dc12fc72396b5302e65d2bdfa0e54e13128e531490afe48a7b75e31461587f67f741fd78cb6b15b4da8d8b12fd44e000", + "41b4944313bbb5414956049204dc8cccb782c664cc990e31447904ee317ae75655df2780d60aee06d80a99d6cde3731024d364238cf48ece1129b9f6d9e5e6cd01", + "aa892a1e3becba91b7d2ae3aeb04309e6be4221bc972100fce3f275e6982b8b2124e21016d5edcf8d533b5dc25ccab9656927fa03d6428c4ae8c8fc01be830ef01", + "b7757db90ae36a75c0730786e121567715dfef02f0fde002c56fce4282fae3f1386007b9d6889550e26d756cdf9b22e29614e9ca8325f285e9d19737a8fd768601", + "12a0c556c743f4e10cf60d8e25cf19520b2c83ff10aa508000f9153c38c7b00f4a13bc9c453d6037ad048e3cd4484fbba37ed072698dce7dbdf8a6a153bd1b7801", + "7eba52f7fa4a007f022cefde6a293ba46166420552b06855b34419392a8e906b10005884da94e87f677183f622c0de3066a5e73e1e512107892c967fc71094de00", + "602b4fdd642fbe5630e36c80409db56bf49c672080dfacca681933d086cac6184fec501ffec1e53a0695e06fda2781e33c44f601b2047c2c9392a16f195ff3c701", + "4f09c6bfb9a839e67c39ea1b44ddb21fb4c25808b9d72e8eb2a0667c9b79464d4f2b74908d3c0307eac43bc648467cc5ff3efbb3b500d5f2d110dbac977a18b601", + "f7635143e6d3dc5ffc4918944a4dbd783c7fffced7b8db8c243677af745750b72101ba863d037c27c862a02acabcd897850f34f3b4e7c649de784c937391332c01" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0008.golden b/src/cipher/testsuite/testdata/seed-0008.golden index f612c4388d..0feb035d8f 100644 --- a/src/cipher/testsuite/testdata/seed-0008.golden +++ b/src/cipher/testsuite/testdata/seed-0008.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "c2xpY2UgZGVtYW5kIGR1dHkgZm9sZCBob25leSByb3lhbCBvcHRpb24gZnVlbCBmb2FtIGdob3N0IHRvb2wgd2VsY29tZQ==", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "2hBixkyUneVyeWK8HXr9S5wTuHPPjLQfVNk", + "secret": "a4196da38de61394985555f95c8cb063b055f11a654806d1bc9000ca65fd48b8", + "public": "026a7c59d51fd0412c7964e85d428e8e7f462596bf55b6e92fb42dda47523fda13", "signatures": [ - "605cf908d76697354f8ba95f0287a749c6eaa3d56bcaa219b3b47d9fa98129b34e56167547a173cb74bc850893c35f6fb6a8abb50d114589e3db905f43db749400", - "be5466645823e550cb48dbdb79840c62df6a1c72bf2fef0a0a455ce035ad6cd76bfab6f1eefd4eb1ea087a4ba59866ba4e57c89012a5420acc63c1bf8333e95101", - "8ca919b4d138b9b131fe06dbd8a570e981523e2928684b6b0ba49b8ba7132828058fd3eba11770d71a89aa3f0af4bc62558ee77bc91f05f232cebc9f014b11ce00", - "f0528cf1bc3987549b21eeed8c164305fed1dae33ad8cd582df549c7206186b94cb603e8f317c821509eb8e8bb3dba6cd13fdfa5a6f23f98a31871e6cea2ca8301", - "8a03f6965fbe22645e204f49f5a040a72da93870be94921cdfbeed713ac8eab821c03effb8f5fe3aa56420580e2b08f304832e299f47e8e1ea9b17761d8adf9901", - "81390ebfff2ee3c626575443c0bf7ca397764f9806bf35ef2c7b6132de60be6574ec864c4c233d4d864e8d52172cc71dfb68511b16110d696681fb77b0c10b5301", - "73c2a3ff45963aaeaf30c3d451f79ac94ce721cf68a63f6be203b60d6f2f94ee251ae39dbd657aa53b377b957f16c3555bd5fbd1ce15f4132f6432b6605647cc01", - "0a37b40375c012a167c87b71fc1d45decd282fa3e68c38e066b4deeba47eb2c403ebc8cec8afe2ee5b00e2bfa677b331c5957cf9deb78ac31087de31da09ddb001", - "798cfbf45a4b1330f5a7e28bbe821848b91c50e3a742a16156d5a2e04b303ff92e4416087ceed3d0e02c4f820f9f6d0aa041f7a9283e4a8510ff915f895f9aab00", - "a1e65c242dc31da10a54e1d2658aa485cda7d6aa18917447ad2dfbbc666bf156162bd81470e03e5c34a478acd95545ff42984d7bbfde77457e5d0f0cbe61aa1301" + "2d324fb86d84dce6babbab85615e3fa8fcf40db5265eb12c7d2177463d414f4074f46bfea5af54d9a1e4718d6a3854ad3dd0c07218f7b337b0451677ea1f553a00", + "6eb90b199fb3777ea55a938d99eb0aa5660000bc12945cd7500bc3e465e00fee5eb0779fe7f83d04858928376bbe74faef7b10477fdb78247f5e5f45318d5d4000", + "32e36ef19c712fdd1080090d5231e8c1a756161b26da3d55c8fd86994d66d8c07ce4f774fd2e05d75ffcf9ba6a38396ea58774e6db1d8858232cb1be6a394d8901", + "9cd97b11b5fefde1a0418d6b52436c6cac206e79ebe124053bf365e5d9ed9db042a9b0fe513c3cfaf790af1bc5711b45ccc5ed0724c44e33eec62ab3bc460e4800", + "00b53304db9b47062c92c91a392e104e51cb91ece9426434f32fff31ea1fbddb5324cd9906564c603c8a36ae54f19748a281474ecc8ec788677dc15f3c5ddc1b01", + "41d8e48ebc1a724a242024ef1a2121077cff8f2bd78f27893ebbc14442854f3036094b99ab8f8c7c662005cb32b3bad03858a9d47a8d8eec0c0829d06f37d31b00", + "eaa1f2b114c70d7a04c9eda7892c615ff33b4f0f05e2e9b8b28bc0f5672c04d95f84f284912bf8222b80ce237294c163ee2ee928f0400b1602979de890b8330d01", + "3b4586cc527ab41c6c65383dee57a12000a2f3df181cfbad65511a6203666640681286b23cf890e72405023ed282d67c060433b93a0601e2c0014e7deaa1b92100", + "05ddb5df8ad91c32b933a1fe8c0ae217287f51494635f5dc46f3b8c0c58ed8e54b0f1a522ebef697d41bb7a776702fd7f81710db217346f372acf2140a0a0b7200", + "9fa9c7e922a89fe3f9beb528fc030b9ef53284144e92b95a13cfd19bce14dd9f19d5407a8c4273b6c17fd61c73178b7af32c8c217f00a131f3625cd145c08acf00" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "2X1uf2u1LK2S8CC8e3VWGVLjiVhHGkPyB51", + "secret": "46d449a4e9edcfd54dc0d21d75797421a3f0aaf6363b4fa489e3889a8dcb34d5", + "public": "03c164e6e935c29b4a93ba87cbcdabc49b8639bdc69f1e89dcffc026dfac7393c8", "signatures": [ - "2721434ba26793a429a0f291393b7139cedb32c9c63b035e35f3b80348fcf1076bffe43c3f9050ab645b6d9aa1d90148047d130a88805c69f5d67359c331a9ae01", - "2556656be80b65be690b6919228595e526ac5449fdf29aeea128093372cadc7a2da222be974471eaac34780dd3713c61b2e9a662f5f9981ff5e5b82e60c0a3d401", - "0b6563dcf8c25ea8042d4a2a68d53198329983dbf8016ef4dfa2ce9bbf8c5c2e6b55a63ab8dc830240b77722fc25bc0c6b4f497c7de5b8736cddfff67059c95700", - "7e2dac2f703542a5a20ad8b1a7dfedee469fb95b909a0e8c087f90a924cf5066529c9fdf5e2d1a90837748e3cf58e1f5c58085323ec4eae579be70bd6a8ebef400", - "9cbf1f8366ac59c9a7397c6e221ee78763675dd4520ab505ab2b2dda63837e8a12af376216112a080647e1496f7e8f8e1fb2403370e74cc16841c36cfaa1454c01", - "ff879b5484d04f405b2c5f41dde07a52b6c46651a00fdb1cf7506c5ba2368475501058c5b8673a8af864ff1b3e97c767cd2ba1fd799f19d0ccf2f25e75e7790a01", - "37a73a8cced3dc2b48b6973b9b94e23d485896ec4f8adb945469677d23b83acd0d6fb567714b3b03a74d892e7d07a8c97aa9d174a33135f5bfe2fddb38afc3cb00", - "b9430175d0146bb45f0a1852f8a16c744951a866bc3e6fa42bca709a5f47076c5d589617499db467957b15a40acda252293b0f081be0e3f970703928d5a8b08001", - "5e17c63fa4455f1a9d238a061ac0d422f8c1f4f917120572fd23d91757046cec0dc415049bea34e21deecc19fb8a246a93c22826306a4379a225480f0819762900", - "ba4c45312f47a6119aa21a2854ec66461812a44f085360afb66bfe6003d8000a61fcfd0bca9fdcddef4401684c8163104b375dff558007150c4ca03c3ecd8a6b01" + "2bb7fae7a294a511468194fcbe2000cc7d4e3da84dba19226f89f446c9cd67853a1d6b9519354c9de307f10d9a375aa4f2af3601de56312b087a15317f40938001", + "b84ecbc6f15a0e377bc74efa502029ac87b55bc3d3ffc79867c41c909d34b7112ea1353b9da4024eb3f083bbbc04214f5332cb2d4d25bfb4b47ae0f95515ef9c01", + "1c9a32563e107c5d225dad141db80175d92997dd44ac7b1d0f6c2b0c5fba018373276221bf930f508ffe429ab0efd1a88cf54449d26992cb392983f0f7785dd800", + "df150b6b76ce86e688e3817fc10d16aac4da2e5723ce75181254269175e491a613e7d69f892d718d10fd5a8abc54fc266c731b33f77599c0a30b9186d6cf8dbd00", + "e869020afcdbcc8c07ee6dd356f83daa1aa5522aa3c2d9a0627c76e4745f0d0f4e3593a69a6a22ad3e5ddf7759b6d9ffa36f0c081f5462cb1cc76765da12e50600", + "3ab42e19889ca8527bc75dd3a320ffc7602371ae754c28cc61d2ad986268ab62790a940a0f9a9e7a9c1b32c0f98fd2c52c55171fb7de8f5b4f339997df46e76800", + "20a89d2aa6ebc277ad374e1ba8a8cb54bba5da83f4b0b786d71f7118c87bc73e680641af294c70a4bd5c6d837a8ae373a272e56e1ef6879ef2868c0d40f67a3e01", + "7a12400e7ba39600a1b2dfd9da749b34eff25246c83ecdea065cdf5f1df5046937cfeeab9c9096c678ad27b96ceaeca81e6cd20c00d23b7aabcaa13143649fdf00", + "389b8fab74bd3c02c51029543663f8930e3b37aba3ae08264761ec8cd77fbcbc24fa5bf47482ff4db62ece7ce5c9f8554b685379256228e208f7d65a8e33c37c00", + "351ff96e4913784381de11fda7b52abb87d4b786add98e534d215236100f44922435e0f8e8a264d720a8b49b88307be2a098c0614610a216dbe8862f5e51d4cb01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "nTsFenEp3j6vda1f5uRe4d8H7ZEXQkHEZ3", + "secret": "c7bee90a73f6cffb9abcb920ee497fe7522fff3ec46b35cae5f07bf3fb0490a2", + "public": "037d3dfc78dfa302b464ef903a085fddf94251587290d965754d8530be02322743", "signatures": [ - "efeaab3e89242a45330e1fa370b4f9b10372c7a0d2b63ad14f28e4ca5469716520dcca49d60456a6ec72d63d65c0e20e793b3c742bd973621d094f4f015f56be01", - "20a2e470b51f02ac3181fbd4a84bbfb3f462a73abb39af9a34afec81803627681b3c68f34e0d9e5070661a970070b960a4cbeedf98c6a039f0a601d93ce208c201", - "eda98e1cce3f9eb6277b9df3d07827cca1300ef035ace56705472a2fbf0bbb194041b4f41338b29dfbe55c2289e73127eaac4485ab41030e98d7fb9071ee778400", - "b9edcfa9273f47131afd90802d09b5270110ad093554ef7c56c753984430daf46cf8b11437c192576f1a01ce456a4318e22f467c39b0ef421f383f8980590cbe01", - "71517c2259e03e88f12433b871261722a4f274da85505db1c277b7053c81c4084b3027e9389f0fedb46f503942ee0f02fdc2cd075df06068d4f8306e1960ef8d01", - "9744352b20e655e990a0524d6e13f88b60711128d9ded3562222dee3b7267e9648a398fbc98bdf28e83a23a98c8e40e18cc02211007360e6d716110e8af10a8400", - "d6e1d04c704641b309ea89902e432bf6355c09cc28d401de26e458fbd284523174f301ad74e23bd18481e5177ee13ad86f38502d4bf4bc9f3b5ba0d26c0e7a7f00", - "0a386e2e5eae9716ec6394673ae9126aed43f8e2aae67075396be413b4044ee97e35ee27cc71684e392322ca955ba463beff444f7ffd3069e66096e00c45a87f01", - "b6e55981a73b41835d33dd1172ae739cd22a9eec440ebf0fb311272612fe817b34f6a287f814b909a5543317fd82dc5dae734b4a4bedce324e5abf184b9b78ee01", - "338e0feac4cbfc47c8104e1db99fc30cf57bddf09f9262c0d0dbfc0edac125ce6720080a720924f6c80f2f98a0a9e4a1bf1ebbf2b4161e7398a9fa4018bb799e01" + "8869ee2ff57bb97475d007f70279f9e3b81193259e64e2bed77957e8f6cdfcbb4ab2501d617c5ca2d1dc89233817a0b91f5a8a2d23aae07354d5ebbe97a3dd9c00", + "10af988a9c826232bafc857dbdde32c76cd6532d0213f101d4afa3994da15a261210b9ae7b69273b538fb6c3deb17cd53113f3b1cb01ac9e8604d209cc78cab900", + "6e858a10f3ddf96b2fd8d49806dca2dcb0745979e288c8a4a913e7bf6c722a531d285d2f081164d414af64bfa8ef6c8c9928ed7d25cce9bb28a698582802fa0d00", + "3b1ae90d38869d522cc70e6d4a51063bab5eceaef100cba3190c15dd63681067700cf336565409075b825e4031112e1eb0bcd209a7a0f5a99eae804b9599104601", + "4bd286c40792b96bf0d1588be470b96d2fd2e4ad7ec3d48e81fc129a95274b9b5ac15138902cab4112730ab83767dbd9845fb3157dfc89131a5e4f36fa63fc0f01", + "1270a0b3f00f41e1f10eb53fdcb5de369585bd95a0900231c7e7f03c2b0cec942adae9e17a043774bec2e40d36fa15e4c9adfb9133cb8ede06d07f840137c57601", + "8a12e03ae27a954c4f8e865fa6428ef4806c40391015962d9ed151a9cfe3a87274a3b1095b76e47aa72e01512bf5d412caca5e336c198f82db668bea7abc452f01", + "1ee1f0fcac14db2ce6203065e58f80fd7e518a56904dba875928baac48abf454513225dd572c9d3c28c11580a7b480dd8c34c24baa2a895ee5b61b0613ba507300", + "d0bd8fbb858f52de5f38029c5251941a0a2cfdf3cfaf8da684db747b4470f6943fe545e9c31a8666546d5d1b67399fa013394418f638de3fdb54d93d68347d2c00", + "cc8842288635cecfcf885db9863a870674d37285a795a326ea11ce93aff2aef0372e06054831dd776cf0d986e7e01a05070a2572bb7926635fe153a464e64e3400" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "2Zj9ehnjn7c2P9AcoxbvQPBiX72yjHEJaPb", + "secret": "8727e233f4165d2cf3805052e9df916b81a19d2e859c48e15576fba347d4123b", + "public": "03ec84a0cebc8c690f106fde7df91b86f7b7dd2bd6bbc15d19b6813d11bf523113", "signatures": [ - "152cc95aad4f439d48b33adc67fac1a79df0947d401d61bbc64d8865d9d6de0577d8d86c8a99e182b1701b0dcfffaa1dbd81bfd8aceecac53606c2f2e6ff9d4501", - "2ad53708375d6ca4f3070c8fa7cd0b79473016b2c44889cead7b9d3d723eac561e7d9886ecdd8e5e224b077d96c72d440ab96bee4c013eac6c3a879c8365b84e01", - "2975a59f6c15f02a4548a322c28b055a1c18380b0c6f92f54c2b490ac02aa9803d80fc85ab82d1fe48f2a80a0f67c99399ab46d3663c7793596ddfcb661f3f1e01", - "2b5831e7c93bf83b0750313e418f74bd739cdb5b7dcc616761ff31e82b230bc26f8a58798d1915508d1dd789476fd211a34a473e38a02dedcb7e5ab5e26429a200", - "026d80d851ff4990b758fa0c4f63919f6b08d97d70e20180d4d30098b8be96de47a649cee34686043e534ddd2bdf91bcb457482863d52ee8874e178b769075dc00", - "e0c4f92a28295d2ad82f881704caf38cf3d9302295bcbf1940117ccefccc662d7f1e65fa8886abca280665960fcc7bd3071691806784a844b620603901d896f700", - "d3bf5ca8c924a0e3bd6b6e18bba283683718e9f84a0251f6fdffe37b385aec71482c2575ad88f900050171434d4225b7a70b9cc4fcdc0abb93802cfa52123da300", - "68ac1dd3498e5d30811546704882f5c4f851bd10c369eae3f7b5fd9e6b8ea68022b69ceb7fe5979c105f1ac302fffb8028072c6d9d7a051af0ac671bf88501e101", - "03b4fb1fd652273fafab985e9c238ee56927bfb396258310a81882f35905f9b156127696477e72a809aeb1126a02f9c7c346fc34218966556d1f652d7a66007e01", - "7d8a40488b9e5491a3ca1a67dc8732e562ad19715f52cba0eaf72764790227b85aa750ed56d827a70863ee38298da4fd2aa3c7c78e5a816e2b1ff6e8bd93a1e001" + "d878d051562f5872f20cf27067b54b677a7ed2ab44e4b88791933369e632993244d88b54060d3253e60afaffc30d8f89b6de5fedba6c90dad01ab9680ad2796a00", + "fb2f87e024946cbdeb11fca226d0efcbdb7d5c27e24b260bb1f6184bdb6446881917d5ab8e0f780fffa13b9459c6e751de391b3d7f1c61938736f8df5550534401", + "3d6b8527fb2b455a6d8565bef090728d3e0ba88b5f1a0599d296d21f268763120ab02a9f3521a96c4e93ad369080db860f6c00da586e91664e5cc410d9b6e99b00", + "baf8d8164e225bcef8a8ded4d54980af405fb6ff28281a16f64586f78a1a0d82670cdf6195f9ae7bc2a7ae9d9f5e32f81e5e6623e239005f4db8cf84ba85c10200", + "90f5ed24882e6e7dfd4eea059e3ac3d2414fb9d1cf7f58156be9e194c1d35e1b44b063a7c81c595d7e818ac6b28aa4aabfc9d8dab2d9c34310d6432dbbc5907101", + "cac8341488306402682b33e723ace25e45f599520753b65f0744cdaa64b14069255126d9d7ad18e219794165f6b723c500e72195ac535a554092444b0c9ebe6000", + "e8e3a8a6937abe48b730de30c5f486f9dc583f7054315c8c96c51e54be8a76772b476fea0543d6f825aa02fb8fb6b7b4c9350bb33889b16eb968fcfc3a64678500", + "cfd8a7cda65e598602bb91d522bb328a3a273b803b6e0e209019987487b1de7a52a87fbce1a87df47756a94ce97e3c51d6f4e66703f2c4893ab11304c407e56001", + "206e31703569b50ac2b2fe0d7d128dc53200a7f84ae74c0cd5153271e9d9d4367a9ad4d7c6b19236b836394ac40a1723468f96a35f4e813d4dc499f50feec2d300", + "7235cdbf150eaf66951644d4fc07226997c313c33eeb171f0bffc5548223317a2c6d933f970656babddba290e044a03d880eb5cb2d77d3036c3f925dd9b7a46201" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "4DueLL7QCMVrwsbR5ydfJ9pnR8vahYytBz", + "secret": "ae81bed68945bf50c190e743deb49273168569001e452be70725e1d4844594b4", + "public": "0295546a4287fb64ae8077ac4b8ea13768122654901492f3920541d76bd2b7acc4", "signatures": [ - "e0886d396926017b945192c84567950b865320dc287c154db102028957d3db924dab6ce72417860cf3c8e47b864e2d5cb7ec8869fef14661adba7497f906503b01", - "680d006dd0b6b6a76ad0a85014cb4654741196e50ca0c0d7b87cfe8b36d00c6126452176b6cf4ff41e1dbd61a393f761d1a0aa2a44b58785d7327db2d15f966400", - "cb3edb8a592ea4aa060c78a885b48fd38f2262956e67540beb175930cee6fe68697d3b819c3c60f2f84b13fe1f65c56200a3a038088fe928bd9e6818fff2b34501", - "0c71ece2affd0aedf2b9573c6e3ff9236fc901134d013038a044f393214e892c0c8333092f60d9af62151153605c0256040304d610c1b355310f999cbb4fbe6101", - "9986604fea3d8b019e538405e0939554915bc8186b95854ad840c00b5790596510df85a02cf1e491650b9ed45110f1b7b0c4116ba4a034d30ed149b97d4d418a01", - "7e2a2a8050f9a9bdf4b5ffb96d1bd24bfaa5e4a47c1d18124dc7777ec62b0dcc3242e7e829ecb18adc6d2168e55ad77991fc392e69a7bae0dd8b7bacc00443a801", - "4c3e64898c2ccf9592add15f665e7f8380c2048e92b519ed32ff2ec5d984628c2c948cdf47949ca71fa9df8bd913ecd36a558c8e07c256c98689411dbf17784f00", - "26e3f0436cd4e329341de681dfc4695ab17e20eb3ca398eb5d14b2f7cf050ec63d4bd32d399fc57d0089248e4a022c81dce1ec8c1d23d3b692f538ed03bd577001", - "a0a877473dd2788dbfb81cfa6b2b473187e79664a8b5d49e073253373d4ba2411703929c2a037b3b99c89e8bacb4c40c50b8d5ed83168fd7a9aec391931ae1b101", - "6975d1cfd42165d6cd94eb48103ef0b571b6ce79c326977906cd8288b2be05f16b4714e761af6a3bec15126164615c57ec2b838bab2aadb7accda1238cf886f100" + "bdbb583965e1281daa47dc4010c30251dfd30473e44348dd9111d517117f5d4b56c6ed8d137e0eb0e68634e196266c0c8de51d5250549a760c46d1198ca7795a00", + "be84724248bfbe549ec32ba7c06ab7d40f0671248b349e9b4587a248a2459cc31f0fcceb2da8a5d5715dbcd9ac92082029bec9ebef4c00a59f18a5fbecd81ab000", + "c215694fddc95dbf210c4e6291ffec12c2dc431583159efbb0ea0edec08549cd27ba5a682b07fb1cc97e6ad92cc8c41fb6755ec2fda6edae10c575f93a0b761901", + "b23e9e76c81ee93e6a27e984bff91cd9546282cc55c8c8bc06502715484fe0610692f71015579110c1f96609550e7d4b0c30ea8fe291c80c73e65915b97644ea01", + "d0e910ee5328f38fb8283e87e7e64c38a99b2cf0e3ec5da096b032d77ec7be814a110c66b1e13632ff373b56c5a307d013d636aaceefa92f9683f71ce4c7478901", + "021a0670aabb167b9e7f184501247b031cc34492e2f22565b3173aa7091ac49f64c8f2535cfa4855ebf8e4ee1e522cfc6242ee87cb75cca29623269a954f465701", + "aa9c6f5a2ade42fe2f520115508c9182fa9652880511027190d26ee56ef088134d7689ceb3dd7a1c6350b8a49817759ec15b9d3ab7f0514ad51446902b41fc2e00", + "14182c66e730a7a8c22746abbb683d2f65a4492ed644e835aa376d81d848edcb229b813c89ce41bed07b4114b7d8b558a7b53132065bdd9769c228d195a204fd00", + "4036bd33c3b8e0aeded4275d0d5928c71e808350ef1c6926987c5377cc48395870169fb2987db63a5641080a2037e9fe5881b8e38e493063727d31327d04952d00", + "8434cec2a8c8ec3daa591a4b2cfe87426b4b71d0ae5397225ff39ad01c5fe15e209ca7e4de4056a64f043b73b622ccf4d2b3d27f362cf7d7fe932c5f110d986a01" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "2XUMdVGXbHaBmFBiYcfwssY5vXnQTav3BP5", + "secret": "312483999efe5e2a416a5300c9ada328cd422b8eb81d348aef76b1ab254ffa31", + "public": "028992d0ba3ec0cd066223a35fc6221c89433e373836e42ab820909dae2a7649c1", "signatures": [ - "5f936b5629f50fe28be24f71655fd89238c1bba1f203e7c90bbe1522667f44da13a6d7afeaabdd14537f3a9d31d6c66080fb815080e729b030283bfd33d2397800", - "027922f71eec7a5edffefeea2372cf879aea5806294329fae970fa82f7e82d8e13095623ffc1bd26b058432041146e423bb6ef9ad89fe49dd058c51657a0485501", - "a12079c58970c29c20f8f7154f560d3f93479dde4196cb0401fe94a984730e9160792b66e5163cb64a58f29245ee46f8e2cbb05183a13f33a5563e26eb71942f00", - "3f19f960922d6c61255f074fc39cf62ec765f609e8cc5e3e3e0a19384e037aa4245cbe03b4cfb9d5de229d0d768ef2ad67b8207908eff19eb4f9aae878e037b501", - "08f7a5988264e56a910c6c6f88f9c3e886081c39165760828dd68ba05f24a9175a64bf9ba9fa1bbb3fce81a70473d4dfc37fe5ad5f92a3fef629ca26bdbed6c201", - "9f1e662e0f249f65f8252c87b6ca606dc8623de7b442fd98b0f41e8e9771aebd023eee06e118a11e5844d7c20b9d66d2e9569a03233ee159ea4e13625ba9334a00", - "228454e0db2c5e77a716a6486163c570e9d43a62efcf103b7eb6d7431cb0ae6f4c7378960d911fa4ad7ed3e4d1e22d7cb2edbbfdeb84d4c43fa42de83b613d9800", - "6250ab376cd76b4909aa89866f8450195edb50eb6429bebcc8b12028ec263b995c582c771f63f16a4d8cb7653e79d89f4f68905b14663ab4c70e2a6a4dd46f7d01", - "d0db65f2e0986808efef08b8453ec9e26283746077a0a1d82378d8cd4d579fac3bdb450960e262d88c0a0dbb063f372b106265b9fb04e787725fc1ea2f533f0700", - "bf457cab0d1e8aad7eaddeba56997e380b9d5074301c72d915f056e95160079668164791158b397e193e338af1cbfbc8cddb674f8118b60a44e9f8aefa56f60c00" + "da51c05e697d2eca9f130713c958e0517d17a8ff829f6e6e7df581c74954b1b75d475bcbe3e96fa64048fd89cd4f5abb418efdc780ae1fd44553f9980ded225800", + "d77d1bb5711b9f08dfcf7f5cc69aa3883c34b5a38dfe428aa705ee2190c2ef6c4a1572e07348616f57f1a6133161136278c39a16a421039c1ccf6de16a02431500", + "6cef8f2474eb973aedcd8e86fbf82de5245db429408e8161343d681440c08a0730fb6f80fd42ba3f10a74a784b18e3cf7c36a2cf89bae3446f0348904527d55400", + "296ca1df8fa846a321f4ca49b76e06e2b8712bd4a7276f0651c38ef1aab9af265c411d0a76dc499073e7be7b60033db5cf2dd85858311c17dd9fb7582a954a7f01", + "3528f0101c5dc155c9d68580ab804e424a6bf81ea85bdd3864ae6eb347960aab33b20a3d4ac2763a2bb50de1b5cf11362086a5659e5859c7d6aa2d64d6a489e501", + "3c18a53e7f1a1d627435f685d3dfd4b7ae2c40ab4b43de1c559b5f8dea6c44a358fa73f0fe004fc42c1f660b711215e477a3752dcebad0af01a4d86b7b3cc91800", + "7a5d1227d136933f935dcac3198ffd462d00fa9e91d76d071d69331cdeaa98a33ca61def907610fc121daaa9d552f872090adb31d25f60023c9dba8d422c335c00", + "a3738eec0537aba0fcbc71627f588452b7401e5892939aba2119e1b063902da55fd912777e1d2bcc61944f77236efd2d7a84f3817b1a996a320f71fbbc7dc0c000", + "3afed1e7749b9bd23a97a55bf9e6aa9f9533151ffb731afa52455a00ec9f1aa9575369c0ce426d64830a6bfa708218ebd337728b914297002db298f10cba9b3e00", + "b0886b57153458794497fff860c70955b7ea80146ef30e413300527f547798e3775bd769893bec65c7cea503d4fd8703e08b6aef736027ba2feb06315f9b2b4000" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "2f1gvQUSUucGZ1xtNcqDb2QqT8mR2YtJF2r", + "secret": "435d065f46be884edaf18ef9371ae6b9723e0931a45551447826368b3b1472be", + "public": "03dc267f778651a06be4b14f2a47063aacca922a218a1f984f224a8ec55f6b8da9", "signatures": [ - "1e371180a747d250c1053a0b6470e8dc379b6fe768e196ee430a268f8cf271fb0dbbd860c45a2d53ef2b92d7138691662d995951a947ed93036f77f93a78ce9800", - "3cae8fa654b4705a758740f28d6e28c553a1e57893d3084fce24e146c93fa6e2540c5b0fcb43d2e702ae227c352d16c70a3145a9a709c8f990e1a681bedb65de00", - "664a871b3a22c7359cbe8a745c48bc488ecc1b5f28d5c1dc50a383fb57c4acc95bfca493e040bb388f2b37bd6939337bf1b7eb0658e27d317036d1df0a4d80a501", - "96198378ebc85a37c4e157c4ef19410b076317a996737a23df2db390e03f7d1d424b5354a68fde7cae45fb294d2da07a2dc261da5196ffde375cb0f3113b5f7a01", - "0f929c4fcef2d230baf25972fcf98a5734c2ecb4b71594407d7f8fa91da849276a984e07a9ffdf20f58352384320b091ba23d614ba45230e6f2fe0f7efe0bd5701", - "b2b4b1fee34e0aa350d13792c61cbf12a28f138003c900425acea26bb4e214b53e0762b06795b8ff6da951a31242a791d281f46023c8cc69e963896a4f19a1c501", - "ec821630d8220e2b7d2778bf38fe1efce46f1a1869ff5c0b5d76618d00a8ebad3dc067ee3a74ef2c40dacfe71c453fb22a0809100807eb57f5822e64671079ac00", - "2bc4cffed750e30c0d4f60210861c3d35088e9c86541d25ec47fd10de4522a376d6c5ef7288a8933549ec35b3a3d3a8ce8870e8d8a5f5b0af40c583532570a6501", - "b262172aa9ba2d5a09be2a375b4f66e62dd220049076025a4ff795e77cabab23364a57df06f28de84f70cc124ebe653001d0c1a0387f1d716b24290fcef9269e00", - "c104911e8c1a8d2618394028c049a810ff675984e6276fd6d4addff56a1bd406243fe7be80b9c82ae1ae66b138b19e4b3333d010404438df299dee9b610837d200" + "2c7ab60525daea6fd2bd2a2944d3f7ac62443f2c5f3ca4dea2252a7bc6d7a7520cf8e0e0e29167cdca142e1c6106b0f723d9caeaf181bb7ba7be3d3dd049053000", + "49dee8cb5efabb28ab2bd248482d913a7de2bce830637728e6926ca6f9607a8436eecb06aadbec7eb8fc49064a73d48de1215d2541e196f450a870565dd8562100", + "1ababc8f886af10ae76d167a93c6a6d5049c7d2b72257c6d51fb0242fb2d13a027b92c76463e3981489e665b7bff2707c577d960cadd5b392aad117f13e1218500", + "8461a17909adf7e7ba21ba08f9a351e3f059cce7b81458121e432a1b07c2353e46c874dce95d02adfa1cbdd723785eecabe93c3a65ac732e497a6a0adfc0350c00", + "3e458d37cd58a426d176f2e3acf123880f44607db8805f5cefd4c438c4eb1ed779eb69fd65dbba39d91cbefc9f54eebe9322aff7c8989f506cd1bd74a05fd66700", + "6658d5242d1fb860d4de1d54cbb6290893990a84bb139a9b79c50c20fa8f5add37af3552601645ac8fe35ad5790ebfd8fcf8b371b9f862e67e48b929bbba3f1800", + "71b2930f5e1b703e90d328f65164673a26558a3126ead81d61807354d59cf91e622d19725c201ec16fbc621feb5679957bf710fb5d54935673e8cadc4e25be1001", + "cc4c1e0fdd2301539ec0ace1eff47807af38c26c20c0b7304abfa75346472ccb38dedab61733895911e37591b35eae5be7daa554f22e75baec3f5b9b158d758900", + "5cac030ff5bb66bb091a86693a2d972540cfb61bd79869a866124dffb515f50907f7c90e99e09c04c3bdf18b7aeb5a82d5d9d983e2993c01a75571a335c8852101", + "9758a5917b51e9989f476eb9fa051a32d2ecf19ad6ddbc2aefb81ba95c16e52d3dc528db27b34ea150344458490d58868e5ca493b8ad4cf21dc356e776d0d54c01" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "2QnMSr9PedSgf84NreugQJaxnaGJLHY9axQ", + "secret": "9e3b1370323a9aeb7ef6872489f3e33a0349235854464d656ce4b0dc00ea56be", + "public": "0255538dfa3b6c02635b667704512bfc4c3d33c48dc878d8576076e530382f34e8", "signatures": [ - "4ebd641e2c9f2e89222ace8e88b799de0b404447dc61dcb70812451516feaef728c03c3b0d65b457741a372925b59bef21aaa720af08b241373660202180c15d01", - "f4144079492424e2937c92e4136ae08f74dfa72d9c830ba47b363757baf9ebae33b4a49ce08a3309e5e787c45911268def1e39a5ffab5c9243763c6bd9565b2101", - "8ec633b2c3d537458dfaa61afa9e2b83551dba4e742c67ec2c742e579ac0bdcc1b6a1556e8defa25a328a0d0e668724935b4f750ea299a0cba23eabee94d40c901", - "f353874dd71ce86534fa984f6f88a10704463c9e5801f2aefc2c9bf4ef94aaf50d3fb4a2164a5c272db116ec7b13cccd3793766c5f8cc35a45f06be7e195c7af01", - "77f2de16d1b5fb4846ded9d9228fadd0ce648d544e8e166e047b410a4049b4316187c0c44ee01ff4854804784e1d27dd10754494de39678f2ba600c635d87c1d00", - "1b0ee1bdf14cac621a2dfa7171e57578b011c7996ca11bce6ce7dd551e2a275c484d942230ed7139229b447c0f2a10f15d426d491b78d9c11a83d437760220e700", - "3480f7ab3672af1c81d0ea8625b3c89824eafec30c98b4a4a36ecee87a1a1cbb305d3a8007a02ab4d2bd8d1260a2246da0b47086a1c49174d97ea8dee2ec6f3001", - "a3d89f957b3c0ebc752fe71c472bbec067f3cb30d4155253f80ed12791fc9a3b3d88120fd28b739ca62b222581fab18e6a0a06350485dbdd05bd93c5d146c5c700", - "a3a073cbfb511ddc5bc5acc2064d1e5fea9c0d84059141048da80526b17b67055b4c67c6bd2c1b8d44cc5a4a0e79f14929a55382284e89d7e1ae3d63a861074100", - "5bbc95586433a3e39a02ffe7c9be12a7c58b3e3090219a6f3d7c6bd2b7be64265cf4b466ee7cd339150b10a0eba7d90272d82bc28027ad90b7e56636a77ab11f00" + "9e40e30eb9ad0d99b592a148ba1066542651e04e90bfc30bdd98c258754ef77d500d11f51ec5eefa4a1be570d12cfc580bc55793fe430e75e31676f9b2c1bef901", + "0f19610905349de8673a6c9ed78158a899f6fd25a37efd22b9657af5b51026246669112914c6d203364456d8c1ae06d5767bc12ee51e91608bbf8b54ebf2ae2300", + "14dd6d4ebad35dff18c60df85ceefa17a03a9e0c5e2c004cc0ecd29ca8096e716333d8e24a32d0ab3cd74ac7fe917e4ebad00828c27093b6dd26eea20f0def4801", + "ca337390ff73808c302904675b4f954b6d4be500ed1cbbe1536693f3ed185edc5973e64764773763408d366d7dc80c209fb3cb323300bed542c359686548046a01", + "5bd597d9019853d5d13f89d55fdffe6a12e1f1969e786ce52aef28df44da1b04595b497136dda48e5eeca2b19741d3851c08d51b18a994f55e1c45bbadfe9d8a01", + "90d711499247f36f3280b09bb6fb9d1a9e89ac3b055bb59bead4c08945d2f9de59f0d6840314ca4641d39a80d9ebdcfc6cabc603db53cef6fd12240c576c7f0400", + "9f742e202407c4fc7462278dc4b8382ed34161faca80f3015861b8cc9cf9b1256d7017777e2fc68eeaf913725dfea2af2cdcdac76f88415dbcd2f6e65b9ef98001", + "20fd3fb2c83a63f69a7fc021d8cad22bbf9516f4b1f4053d4e032d5089d644c638eab2fdd8cbd9a7e5e2d797cfcfe6426aee8bb570c6799eef48a84fb333e24a01", + "0f4135937cde24fb32c92be875d39022920e04d76f0a99e60328556570b2250b69df184f9ea803c9cb720d441139d3369e29a4ce53252d7b71b015303d6cf22b00", + "2cea41e7728facd686876fc173ec9f3b82e243db23d284394b46ac929c254e564a58772ffc1cd1ff1940d0dc5ad7969f134471ab408acea0116c1bf2346befcc01" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "Zi6vjiuB86UidJSxPnRnLuoQKNqbhKDTQX", + "secret": "a7d72f9c41978b79e61dcb6de20d05d31850bbbd5defe2e594262157292eba49", + "public": "02f947801d035fb531c1859be4045d3d6f54d4df41927277a42040c25ace724972", "signatures": [ - "48adc13825e8081a7d90bf926027df0a7b220ef9893fcfbfe4403b7b2f9bc2a031366083fc3c12ef5df9ce62ad7495991c5b7844d32cad0438b1fff15992df8901", - "0d317d692d43483c2fbc2ee0154e6f89ef7969c306866df8e53b108fe761666b3f3dd5afdb5b985e3facc525399dea73a48fe68d9224ba42e157bae5af67fc7100", - "d87b508617216eb3fed3472efff6fa51bebd4ffa623a348d48a04d7d96fd9c183554481a4f922bd945b1bff72f6f7edbd64d8c9aa436b633e582b6864442559601", - "40cdcfce7fb14bea4e100f35101e4fb26c291112de16b43557c522c0976122ff14df7d1fb5c390b95ef0e1e0df4bf10724c2a077d2e0fb439929987e77bf247101", - "cc980cf8fcf1ad3d91e8885f1a0fa4adf5b183ce9b13be92b6809f586e7dacb9008e85bc800f34cd61854ce11750a39b29edef368e84de4fc294d3f467b080a701", - "68567b560205423f29ba641d868da95bacdfd3b28747684c70fc5904faeca897768a445dd17a112242fb4ade4a4fa4fb7989c968aee30f59e783f7a144eb3a3500", - "3f889278d20aa937c743bdb0144855bc8e680adeb750d94d4a72e5e3766b515d766ef00fac0aff013042feeee57c221441252196d6fcdea85bc4a32b1a37799f00", - "aef94b827f276d9146d70e5f514a1764c44693c4b34f4649e9c6c8d1781c38c00f79b42479e59b32db7db445574174392e6a96cb887ea3bb300baf93b1dc6af800", - "5dda52311a7e86b01234a636935926515c7078c5640c88a3cc4aca12fa740c0945a3842edd3ee871a89b5237a5800b06a62466759447ae8316d398ff162d9a7601", - "dd792a9916a9ca194552d5b84a9b4496e55d8e16a3eac7ac5166ad2ec675512e65e693e05a5408852ee0ee14eca52aa16609e32a1b731ae98ea4eafcf2f775d900" + "34e7d96043aaedc7b18d19a44934e9a59695bf5cb2b8ce04e845b6d5547103f046150acb03a3d08dceee0648a96d0877b7747d07d609b5bc2738eed78406571101", + "9eec6edabe7cc6c38a3c8f731aa310683f5b1b5b7f18ff597ce1cc85b69316226bdb6a853054bd0e0b07f7b6e95a14c1b331ceb47c42c7de0f64978e23c3f89401", + "024c006a48beefc070dbda72b0335726bc875143330cd5a5063b5d36bf81bfa971cf8b5bd8b0a097f9ce85b5e1e32d3516b9dc7fc18b2d07f967d2a0a85404e800", + "fae32316c3926889b4a6c351e32865c5f619e84678db65eeb9a8b97b2aa60859246e416af3844a9a8d036fc95cd583ff6d194424fdaab1a75d6302bec4d5fe2101", + "c8e1782059a35a98d0dc23ddc45a29e6ee37855e7ffc3a2db02ba548be82943d4c01190bcb22d8bde6a18545428022a5cae17efe9b1b59bcb054190016be55f800", + "67437425c618bc99fc2b111ac534a8337db17b07f05c2dc0c8699809de0c69ac5201bd0ce83d4af61df6597f0aa819c66c859b3fdf07e12739494e942dcac83901", + "7df6c5bda9dcef9a81ea470d1cf0a6c465220ff8cdc9a549021e02fa1dfbf2aa16f2434d181db5ac44ef949b0447bb56ce0ab2cf43e0ee6c7f4835267c12d48401", + "a55b5663ec5c53f034f45c199ca720198e272d25012444d6ed1e2c8dc312223a084126d0b7b0cb0dd9753fc68d3a1c3daf625203756c6c92a924aeed718680e600", + "c3a346976e04f54d750dd830fdea864495e3ae80e1a3995e5b7852db907cac1f454d95532fb7c536daf11003987065fc835414b1a19cfdd9d08f4332ae1e691901", + "53022befceb0a4f6de14ee1a6f287e75413614f4df77b0ce4c1a1e8d85f8947e7ecc9ede42ba82ee06f06b4a6dc70a25cc12fe9ecc6f1c4e31350980140144f701" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "2EVQ1xmJ6A4iHeZXRtD7DawoBoxX1vRmBxq", + "secret": "04ccdc4fb9e5d77140a5ab7710b4993f9accbca372d142e358301f1bf096e05c", + "public": "03fc5a8249345fbf2b876f4d0234efec9e88b6a9b3a6ea3fdaede839f0520cd2bf", "signatures": [ - "1f6a275c785efe6570c74c040bceb95d38b521c801be7d76082bc243f2a3f597288e0525d7e00dd61a205b411171e96cd78e71e4e5f61f9aabadf445876247ba00", - "9d9c1f403982948c869390564e78c7becdac058765d56caaba771319f9bb3b7a3e0e341f5c5bbdf6aea61a4a724b25db9c57315da18cfd2847e724825c92ab4e01", - "f56fe6e85afc09858256b8b2492b59e5241b4e938d118f2e520ad626224769e43517043d94648f391f8c72d1fa423d1eafbd0ec48c9fbe67726e96e371513db100", - "810ab9173601ee3b9e0ec79920658d5107751d6fbde8992c197eaaf5d8658d5352862cb56d42557abdd364ecd5b4ee733dc0fc78407a0059d0f02ec193ab70d000", - "17e5c80ad0d580c14ff59f614958c1fd024ab1988a6a921bcde327df400d0b886b986a52147ba4fbfd818c5ada45545a2f387ccfeed885914924f2914a2b28da00", - "6e45948905464b11ff3934bc291926a37f6d9c36ab85b39bb3906ce8439504994a7171b7d397f12d15c3e46d0390b71a90181fceb74e6c65ffb860adfc92f24500", - "4ee5197cbe7e1416a49add4270f1d2a85f73efbe78f68a0debc1865ecc846f48284b9c6b73e3728b99fee7eb300eaeb8e6e8739c97d6dd3fd601aa4fe668a04d01", - "a24aace3684b8c10895ab7864f9044a648b8bb2330f32e6c7763878d204d93c56b030035ab5e056a9b03c5e785f069ccc7e6dbb5f81f25cf164c91b97c54f2a300", - "f40d98f9a995d667034b3fd90f994a0dd305793d7f904f88bccc115144b991d5019ca1cddf93b942b38b2b390415521d44f0393ef4e953dbb52e0b25eca6371601", - "64ea69878fdc4aab73285bd470233cb6370cf54c97dda09947e4dc9c49c248495120bc7e03395204269da02fde39a81154dbe4698d438ed187622c875324bb3401" + "a47efd9e820c974dd9107bbed207f6324c042a21ff0d41e323f799974ea963282fe800b1f1067d8c7753b3e666dfff01f2bb6516121fd1cc3afdb5ed2d45ffa701", + "39b2a9098ed07c55e1492ac28673dfde7a9fb683bbc5c9ce62079c7abae343764dfe618112bbcd5805226e9a45a98f8efac840d38ae4db420fdc13e6dc9f05a800", + "a7934bb9e039f1ebda681cc87c833c7158666a9cabcfde5ed95aad53f1fb529733daa506e7f65845e4a5c7891ae059d62a52885010a4113d844df2d03acd17ed01", + "d8dd518bbf0d921954a840ca9326f9eef5b17eb00e4c158c03b298426f682a55077685305337e06a1d5b0ed3d48be76e6a404eda1bbf4a0f58bd84ea0920a28b01", + "3787c025ec0a21ef202b340770fb21d9c5204d969feceaa7639316b0875f0a6875db7554b4cf67c476f32292d7415ff07eaf73d9922e2639890d15dac3fd2e0200", + "89dd0b2bef097e4a7da14f90bca131005084ed954434627ba3c9e904515120d309a0fe9ae64c5191eb483d07a294ac37be0d53153d511dcfe8a339b79db1572b00", + "b559569007407a5cca128d0a3153a8572d8e8d1c765913b23ea27036955962470abf538464d519fcfaa4caadf9322c3f0a1a432ca5d3f45bd993c6965f4e63d000", + "15ebb160d7813b01269fd09e07d62b27b1665d243ee1c1be913595bccc6fe3377b46e2f1ce0fe485a810bb98c988d70b9dcf3a377d99ebe664b88a2239ceeef800", + "1ec59aa97c2e40a0766bc470b0a2079c58f337a6c8eca1372696785446f77b1b42704bec74c429eb2a084a00e676d084b175323dd43022f99fe513c17625d0db00", + "ed37c8d62f87802a0cc8e2feaa56c9ce46681d07f31da88c958317e5616b1278043e6abb646407909ab2d7f8ea880a7d89e696052a9b01da573a967fb91f141301" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0009.golden b/src/cipher/testsuite/testdata/seed-0009.golden index 8a4d0b9962..f619411569 100644 --- a/src/cipher/testsuite/testdata/seed-0009.golden +++ b/src/cipher/testsuite/testdata/seed-0009.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "vWqzW+tavumliuNymgNb1scvd3DxS3kEU9EznZRyjys=", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "dxJmhYz5CYqbxaurBDKndour8bKsX2BCg2", + "secret": "103bc41600c537a83751efc3b3375224ab5e50f062d5f679ba39a69676ddf4af", + "public": "028628228b9fa099df41f59a84685964e7b5b9aa2c2517027bc97163932d3f44e1", "signatures": [ - "32aa32ec24d3b36afcaf696f5dc322859c3c5e5312da1d4bbae4d1997c7016451b1d88d611ef6c167e5035e0c397fc2b1b6ca5670f26df6618ae755ab67341da00", - "12e94556328f77a47686ba122ba229f57de403dae3ff2a412722aa5346e66db2656dd14205fbe49148541a38c46f1b0bc1c1a401f2729757937558a9af2f86bc00", - "c8529395d05326dc06819fe399463165b865be77af00a02e82e642a14f9ab94e60e8bd90e17485e43fd7cdbcb08d3a4ccbc22feb450b6bbefd91959bb78bdcbf01", - "933bb10c6a9844d61b9ede2fb589cafb40a4539f140403ae981fcb42ab6c6b9005e43a7724167bf3341355aa5b6ab56344c75200f0ba8f782fbcfeee317f3ab401", - "26c6a1e7b30e377e0e7d56e131c85a5833a6350b8d1fff3dd6086211d683e3cb6f0188634a4b7b3d506fbef965800e3b11d29c7b469f43c85f6c4c99749495ab00", - "905e299bfb01ad38083b5c408c178ef68a069e44c28334afdc861cc0a92f6b9c600a6bf9a21084556f5368c85a35f2e292dcb17dc7e73599de5e7d8ac902a92201", - "f99a64a7c96b7098bb7039cfabbdc6ad3caef29ee2e29ed75bd1e4dd99730f067969e6197820485355c0c3ea46efc1ee303ddd56ba55693efae19b137682954e00", - "6677c31672d6059bad48e16ecd430298f20ab47383afbe7bacdde095af96547130aa609a370a07791f20296c8b1ae67aa14ffb32b6286711b63ceadc99907f0200", - "ce3d9b72d5c7ef8cfe5abb38ded52febbb8373b946a449eb89f51cf8dbfaa6320093384d2a441a7fde4e1ac66aa77decb821eae59a487d8529490856bc24ad3c00", - "d3e9b596baf93281b9087b9f17a6c74d94548f308ede783e5cf31b3fae1b8249050bf8b57cb26247995628aa4cfbcc1d7067977e26043b2356abc4d8992284a700" + "673112ab3fc33c8611b71baf4f5859b11f15775c619435285c076c77406ddd5b355ec1dc1091481ecea3ec23b05857fa5756842b19433cbd16edb98b276b4f3300", + "b884b685184fd7b18465d266e5c0aa3f715ef1ebdd2c510fd1d93985ed73700e07cd8967fb4bb41baac5dfb1b5acd43542368843571a8c2328c04ecd99480fc700", + "74ab28ea8eaa8abc10a60900da86209415f9c2da7c40c4dcae9c24f4a7577607264c1fa8abc18afbdf618726c5fa4088d074b22281419fa72042204da4d101f700", + "42e5c576f3c946efdf7433f68bf8bb08bdb9a4cd96b1df6ae21c1f977452565b144a0a3431d1fd01964c016a545f70581508ada70ed2d2e2471f61adb9fae9e200", + "d94e96c42e8206c754363103c1dab199ba324ca4a84382800cf95be2bb2fec4a641352aac50919a636cf60e21f6124b0898096b2537737e132b3a591a73631de01", + "462dcbfca20d8db7933e5ce611bbeaf3445be562df729e7110fb262651efb8512186b6b19902894c2ee0dd2749612c839976b6ba56b42d091357b9f63f40400800", + "1a7f718160e4ebc415679c176b4266582cdb59d0d3cc6d5844375604313513356663f148e0813fe02a6b4e657c76cb2fd5095a78048c639e431def9a0ea1f36e01", + "0c94e5e5dfe0ce864cfbf722ebe2e567f7b3b0303eae438f1a8fae2c232b8f95344ff2b43c1c5473942eda7e2c292b11c99bba70281964ff03105a1b916155f601", + "ee890cc57362d5adfb7e664671a4073c5d126b5da52835089916e45f5ee71cb227bae34bfa070ad0920bd9106fd0bad517bd7346cd85d7042a2ba88c029eef2e00", + "0199f28e2f9497c17c59e31c863984d7d4848720c9c151b6334e2c56dee15fcf2d642e073bfb728498342d9f19ea1dc6f9a4e8af31056e850405a5009be6f6c701" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "wWfAkC5DRKmBesD3ycyZPLA9WUC5hKBY8J", + "secret": "ec68100218702342e62a0138e49fecf0281e97214f224f3ab2591be5094764e9", + "public": "020c1e5d0e449141cd10910c9ae064d878537bcf7a617e6f694a9f377a6528b96b", "signatures": [ - "4388f063e936f3e848c02abda5b1648c00f7d52f7e23063ae7b0f84a9c7d235b5ce8cd8c86c6de98aa03d5fc27f1657dd9bbbe270f0f66dd303b41b26175cf6b01", - "7359b82a407fd3b5bf14ec0ea733658329ef473b72b43a5a7b6c66b29e35a0e37c324f8fb4e0e8d3ceac0d4857c23761a4a5ba03b704c342326e0cba9ecb47ff00", - "55c904af649c93df2cc2525043a3ae29f6c997c3fa53a225e3c70753ecdf007a5ba1cd8fded940b4915336aab90bd9d58f2d9319d4e2e22cc5f0a38e7bbf6e4c01", - "796a4bb0656868f240d053ff3c658e7e9ac7ec2671284187804f56d714569b04704d3c56510dbbe9fa0ace8f4d38100012262b6e8561f4915f417cd2b3467f5f00", - "981f32d11edef54dc755d02319ed461a32998d622966207c0c0b1dbec749f66728b9e5b9d12d32636f383dbc42654597affb23ba6517bd68bfeb22e0bf91d26e00", - "a709eb29ad5b5822fdf8135b748358b9453a2d9e2dcad976297fb0a80bac9cec0be4e37732f245c3b0587a17128f865bef834729f7b175ce90e9770f9372f45700", - "c675e5bcdceeb06226fbb780dcc79ba1cbea8bc593f3fcb43ac3410ea6b06053341e65194dcb44119259f101042636e340008ad48fb355bc3edd479b81ee17d001", - "67787f261d0367b9631f6b5bcefe80b184951b1fa5bb3f5651aa596418161d89436de2e3cd827b281c096105817ba7275c440d5ae967908c3034bd11bdcc165200", - "38c888332c6f40e074647ffdd92de4174162ec96c5babd6097843e7aa34dd2d453e02df748510269daceeaa2cd9d8e111842717e07ce581344e43700d85bed9300", - "b6352e1322d11ba62580d5fd126ae15327f5a5fa813ae5c70d9a27d206c161256f63393ffe8e6b810db37bd1666358b39653be06bb0acd804bfa3e6ccf23fa1901" + "74dd33ff9586150eb0a6566e31da608be6cd9519c0a373a10794a3f2b0415ffa2f0b4304e895b4d9c7a6a1bbcbd0e4557800732ecf39239c193e27738f432fdf01", + "d23c6e62b777c96c1e21091fea380733c223bd68811c7bad12fcbf9a159b84992c7b011e4152d0339bbdc4ead5de4aa1a288997ef3a5ad0bdaaf79653077df7900", + "237df8d524e32e90b2e2e009b0defe40769fb341147191b2ba45aa277aadf81068fe8f206ef713e674ebaea775385b053c85be37dc2490c0c4f736a7a1feaa8301", + "83157989273570d30d0221ccff0497c8e9837d728fee2adf2b3142e8f04cef2943410fff868ec9c7e68602e083420b29706d3926c2d397e1e1587c31a60c9a3501", + "34212857e85e5dd71748f02f77941550164b4702dc55cfc835a22cb99e30ece054c53f43a3bddf4ce800bb2aecb2ecc87137acd3ca8a269af9763bc3abfed62e00", + "5348dd18e2bbc319860ddbe3b5ef9627447718252a189ea5957982acf54f0c3d4d6bc9d191cc6cf454281cb74fbdc9e05971b712119bd39332d94a4d03340d2d00", + "14f7d8da4fd890f6bdeb978a389a65d954a82037f1a59a3c22a952d1a6071a5601c460f31a6cdd5b9749412d44b8399068c9605b18c9677ab89ee3d92fb74a1200", + "4cbbb3a086dbae9049670ee8b55e31ab36fc012ab22674b4f036091bb511011a5ab11e3500a47f09b0187a407cbbbcaa3b8addd885b6b0639278903bd2d64a7b01", + "c8db912171497d49570aa43ccb6a5984f25fef8f44dcfe6edf4fae6e737082ec03d531e0f77057b47dbc5e50af5b67b74fb8915fa802f21e63c1db9125ce579300", + "d13cfe83aa0faffd130cede0acd5c6066c333474e7f2a059be3e3c27c081620d6f5fb985f4f595377332abdad3de0e27db9ccff7dbb24211b7375682c46f3d4601" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "2NpdyMGSis7pKksyJdw2Lw9CkLxRXQ4mXfQ", + "secret": "e08ae8786cf4f17a7b6024143f7e99261b0f30f240b4a4eef241051f4b051c57", + "public": "03185a63e2d55ae868e815e5ccec398ad955f5ddf8f7f5878843810d22a95d8749", "signatures": [ - "9821c9f2efced5da0245976e771a87a08e4d54b5a9744b3cf4623c54ef4f69ae4e51ff0c3397563f5748afd6ff202c770ee44ffcf02e38495fa725dec88b27c100", - "48ab3b93851a75e9e7f74e80352f0d48afbf84fed4fa5bbb558c6bac78b0c1455c5067ede1c6a6108cc96440a02337bd9a73a885aeb2a35f15b126b755ad353301", - "45d484c93980505db71e8a2f85df34c0a04d92e65aa2042e5eba621ae1f7e55641385d05e7b315b3f3d7b2570991cd7a6862fd671e7ddd68686b2ed41abae22a00", - "a793339e0d4c5c8712e95adf43470be3dbd62954360c9326d45234c56deae38509accb038a3d9cd516f1a7c533eef30dd96241b559438717b75bb3905c5946ac01", - "b1a9444616d506882de64868077fe81c9e24ddb0671c5abb8c21a147fc05f9a90a2dd2e89e3aae37939b855f92969e09f0675d1e45128f960830f095b9585e1901", - "34fb919bba641985b68e6a06cfd01837b5cc64e735a3263a8dfe713301da13de7bd4b9f879478694183d6e2c8d36dc4cbee390afd6c60bb6b9fd08dd7b4cdad201", - "8074d4c1810d66f7482f45442b83f17c80bd075a71a2be0f2818309a4dcedbe856e1d4a47c7889e907715f390448a79ebe42e6e42dae91ea642046c485d908f201", - "d152399d5622956b4d4a6b388d9012473209de28b64ba002cd96b8631016b226162d26291d1ca776fe6134dfc445fa6dc52a7e0928baa4ec5d37092adb94df9d00", - "151aa9382543454890d0af786bc8ae2101f7f4179536f47c350cddf15694ca565cf497dbcd02272bc5c7002ae0d2bbdf0ca24bba42f9fa7d45167a268ca5f1d601", - "54668d4190399fed5f0c8ef7bef976f7c09d40b139b45d2b888bb80d966e1a1e0a6da1d6f1ff688250dc9f89fc42f28941136f77d3667f2f6408e01a35fdd21a01" + "5d97d0bb03d8eff8cd742665a59e6cc7bee75c809f46396b607613e5e6bca6a84aa089f7cd8f53b18d6bc3068493ac1077da6f818bd65e18457d5b457549b9a501", + "66db0f30c1e6ede54bb6f70fff659935ac180bf41d62b2f3a649d8821d90e9f9452393d0ef245a4b9070a3e7a93b05fe3933ec5bfd3042ea3a644e77816e57a900", + "4dcd8b7df6aa6fddb60c9ae6781426d09f43b3f72bbc8c6e2f80e2f052bb29fb68d0541edf0bd7fc58b468850110fb3209742c3a1e4cbd0fa385adc55d76bf2301", + "b64aa7147d42e3e67617f21b5f49d0ce03dd5ff677efe922a57d783f438facb43d35df5d3f5bc6bf4418b12189bda65e791e837fab789f5765c58a4f3362758701", + "a61449bbae701565ec8b9101ffcb1e5cf8ccaf0148cc074649322d2ab07df14329b60562740b410dd042996d17f9fcf9bcf48eef01cf14439cfb7679ce49ace200", + "9ec3b65bd966d8d29037a74ecb0da1425a8bff15b82fb5aaa5ce85dfdc26a0c869d43b8073dc98d9871907908b13ed80997a11bf61724646d94525d0ca33185401", + "5764aa6b439d5eaa4ea629cc0bcd0d0bdfae933da8a4aa1beaf7ed8d6c751446784fbc57f0182c6f7bb13c33641dacfad3ca0065c1bad8c49690ba42abaf00ab01", + "1a48518590d1ad8fd92863486c10078b3c1703037cbea02e81ab17c41f52e8120b394db294c7ea4a4d8c9e5e735bd30c3a1574125e8005b80b2d429c4baa764b00", + "12e8b5c303a9d348bfbbfc7ccf5a74e9c1701482f95d818f51aefeff982e18ad0e25b86221553e6282be68cfe384ef7729cd716b3b66e48863fdebee137d2d8801", + "d9abcdf0970a1b8fd7721fd8bb7a6f2712cf331d04e300b7cb0a12caef919d2b335bef5436cb624cba1aa669df168840eb80e0f9f40c6ed180ac58fad922a4d601" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "2YsC7EayfSJEMpH5tkFABZ7NxksBxUcRKFM", + "secret": "d609d3e43e182e23c9414e10427b1c8437d5de881836ae882819b4ccfd39ea03", + "public": "028158909c3c9e59135b6019738c31acba380d2d42cd07b3bc0e302fbfae9c3ed0", "signatures": [ - "36e74cf5aab12f2dbd3e87203ae55fcb2f94f19eb9271cfb15f05adafd271eeb43ec119febe70dfbf8bfd6f9c19b661b8f18f81995f176bb1afae4b3adf2f17301", - "a0bf3e8e2dadfc2f77f130510297e13aedf7ac55061775aebd836dad219f8e63425ce947c0e9fa17ccfd161149ef314553c83fd26ebc0209c049567561c99aa200", - "8a35497706e1b437c9a50fb3b71c683dca069eb68d0cad65161af1384709c59e3890ecad673a46b0f87b9dab333eeb53c46936bd94559d106a771448ede114cf01", - "6e936e59d6b1ecde7c49dc09e9bcda7a5bb78800c37d2f37c4790475a57d148477becff065b1c8e371d44128fb17ee84da62eb46167121214e478e840038500b00", - "4bb65e7ad83aa35ef73bbaf4b9e9ab54991238dbff24f5b21c932f2538e9c6973811ca7dbb383327ec64f52c1fd9b8c0d38635a888abc0c7613e4fd33ccd290701", - "9ffa5ba1a44f33185e174a4c8f8b9e849f971a566259794a47bb3d15ae8a35714a50c60156c7106b315f6e7e6186fe7b8066db4dc46d2066a6e2e6465db8a3a700", - "c6152ba18975ec161e54a0169a306a524d766e6a868cdeaba245e8159757d2d211d427d4413ff3f0586f04b1db56c87a6775d0164fec32647fcc04878b16d5eb00", - "e956a82f380337c7c5c8ba642a6586d0cd82169a9a47ab7afcc26f2b183a24ab35bea547932d1e6c8e3052b82ad25cda59b4df1c0db37f3b6a340aa43d03ad9f00", - "9cb65c8c08c9a813129dab5d034995e9195dbb7a3ac9740c936b51f5b5538fc42b5fef0061da1632c4792ca1be2a7da5adcf9c19dad0a49ddcc92966a5bb32f600", - "afb7cab38021a0d5e4dbea9c588f26e3b53abf078aa5bb853794f5c205ed2a5767f2aa15e228ec8a2a05d5f4179cd0e0201f8bcfdbf2421a6f2e2e38ba963ef901" + "5de888e7d8889d800935e92430ef045b4b61896ff9b400edea6a9f184e56be5954ba6dd40388a43332cb2515553e227e936c3f39a40ae7fa254a37dfd478a89a00", + "9534f206b47c69377a9134a5a372817e68893181d5489f411a90ab47748e7fb621b840c0d2a857b7555f266611960c47814d3c9460c6f0ee33b688a7a95e0d8d01", + "fdb21218173ee37a35a864e6ee685b66ca3b3a62275499b5050ba9563203634f7f4ea6988aef0cd05b504e0a4f090a341d3cade4fc72876171a41d4a8e7900a001", + "c444d5d828e5d9551e6c85a0744655d75fdb35c90174557c442f6866130489a07f8d3e72ab8f1c4937b5b56174e83f1f0099fe8a90a2034a30ff33a58cd95b0a01", + "7b105ce2133aa4f330c7bcef90473b0433ffb8f15eff07533f31083d816a05c86e18e972ba8200db9c173eaccd57658d29e541805c467642b7c71fa3dcfa9e6d00", + "6c83b4cfaad9fe84e9fb6221c96f3e3f7a8a570d912df042c17f01877fcbc5755b52aacf432a0655461446c25ebb6668828f2c93930dc0c25cd0625204fc6f7401", + "a524aef799f60bda7106f53f7be4f6dfa23c650f0183fb6c8c7945f7a1091db10b569cf203541516404853c6f84b0c903015bc1ea4b84689f76503af90819fc801", + "64e06be4685c5f44276114ee82eadd0ac0fd2dc32e06695aea6b9bb1c4f539bf13a1dbcef6083d764d8fa1246ce72888fb242e5e2e2fd40708a1101f078f568400", + "0405169edaf9044e0730ebfadf22bdba6d29433227626eb1183b4e1fad384bee129c911097fd5b5996a045a39b75fae33f20d6610f3c160ba6c9f7fa61afddad01", + "3a4d6eac4ae0c420a2b07539deea5b9703816b8f1c63ee015e9300a89192035e4a6bfdc1c0764268b36f545ba40dc69b0de024fb89b367f74f0582c49991f1bc00" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "VWBgiD8Bm82C5scBT7ouJXUdCt5WYBmwid", + "secret": "cd6cac0f13566084bff6d1415a6cf5b481d1180dff8041f4b0cbbc3ad9c45575", + "public": "02db0ddcb741d0ea2e05d2e299a09d063456dc3370cb8ba32adbcbd5f2de195d55", "signatures": [ - "3e558c955f9826fe8721c076c24fdfbd3a410c20ddbee3277203eb41a02f93355adb108034d966f364f4f3f8e5305180b8ece1df3a795279803ab20806688cca01", - "9a5bf6a08fd02bf724879351da1c4018dd984c05942211c7303e606dbe634f1c18163646863878c6a4d5642831192eec018bdc49606a2b7a415fe12ee952f54101", - "ccf102996eda46795e60d1f26e478bb8a890a992a6a17966db33e1ada2872adf2a89a41651ff728df1230c961061092d3cf05c311b21a925b6d1c92d2d46610600", - "30fa1d0f678d06bb2ed84d01dd9f14f19e252d8b85132b2029ea120ba7d0b8213a0efafc5473269cca402069ebc6b7fc5b5eba34fca394afe7b49914e7393f4000", - "792190db51480dbf58182260c78b79397863af8b80594b57e3a9007afbd9791c09d7f93f40d7fc7d705d9aa5cf2e08f31195a18fde100a68bec8ddc1723e6a8501", - "570a0936b0874925b7c7abc65b9d4681808c7b88dd0e5439065d4736ba13c1b669aec131e8718bfb1ba14a8a6bf33d83e9a554b0311901c1a347fd646f1e585201", - "b6a074f08b8e65157510370bdfa3019a14e097b2fe3ddc7f978e0df3996d601317612c097e256dce4b779995b59f8835b3f3fef98aa35dc2aff97d3f75cbb00601", - "688ccd68666480334c394815829704ac829f0bc0c0342c9d6f735da0ffa721385758008f56b74ce94a8d449518d9c900eb0bd30538678271b3a63476838b75ca01", - "9e314909cc24cd02aa9d00f78cb5bd2442af7f6a299ee53d87a67cd1222a4b7c7a4ba96fdbb321b571fb9f6f2fe4122c5ff96af2c8289c8a00044b5fe1337f6300", - "fa935f6cd144b6583abd0e4d6d87786ccb3e79a6505914dc326bcfab2b8049ff348d728f6dd66dde05928daf00f0a8aefa2c311bb8211634b997c20d679768b900" + "01b8d8773c41c67426921f5668f6327f3a678119f207fbbb3ea88031fbc3928a3b516ef61495997234e59ed5548b5ed94f59f988e3de4d12f57bbfdecf2ba00000", + "1832e3ef1aa54595cfce5706271449f00f634ddf07a124673027e65bedfa3751377dc647490148c8a753c8458824edeeb7a6a1dce149a49cd57f04d26cf775bd01", + "a32e7217378671d22ee640ad993cefe1cd7d35dcb8ec8c4946a202246b8ddc837e0933dc6246bf061115e7adf77b1ea7cee2e570da6afd263c4bee68061c7a2601", + "ea42d95fdb6dab4c5df0cbb87fa8f893724d26b1784b7e19eb799f1f8a5facc34eef7b929acb300c953864ff36dfebab0e4c069174217c8ef3cfef6587f5644600", + "a281a7e62930e0ac659ef9c372ad192cf86db5f35d71c656b72b03b9b439fc8d551bbcd58b8904f8653dc4fb3698774cebca153ea664040ce0184be627d31ab001", + "83c70b8c70db7fcb8da6887a6c0d575383ceae53c28f904a31ee69ce6106317a23e6c764a23b55118cc8d52bb621ee3f9782165580d98bf4b74f10ccdac5f2a700", + "42ded223b124824f156a96ec2a3b39a98daa76eb845e365c1238a38f7b49e663286b94e55dc245221d85345497f223d1dd81aecbdec5613efe4c4ca901a3c9ee01", + "c07eed52f2b0a550e57cba0175ec37fcb71aca4ed0fc37c4528a01117c6a52665196310f3b56b8439a156c33ee67a6108cca46b7b6081c5fad30be432f2f0e8701", + "04faaea1a63d8c3fb7174d21785afdae0e8520a4bfa9e5a82f4915be48cd4180158490d079fa2b7633d4082c8f1ab2a25a9ce4e99690b08cfe95ee60a92eff8d00", + "12826d3405affe5552bbe42b5e9f1ffcbdbfe3b88b537ca1c6d52a53fce068f5482f9c9026b8e72858506d9b8d1bec3b1cda36878ce979916382e880af7715e901" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "6d9MoeBRrPUSW7C88QFe8T83GKxKfd2CY2", + "secret": "e7cba671232e76a905770b9dcfc280a0f47db8e37fd2e5cd32cf67d3d7e44c4f", + "public": "02ab3080b4ea8a74789ca7ba75577609de2961e01e583d8432f50e112ae1c6a7dc", "signatures": [ - "05465d1224f4ddaa860c4ef9d5ff88b4aa769d794395ad7abb01e823d7632b1a46a5c72358f79c932b681029b5ca84d285ae7d85d302fa116c1f73577f0a2fd800", - "6891462eab210c9597e2a8ce93a45c6f041d7d6ef9960697c79411a326292a2d58a96035dc88d5eba815046d2a3491aa030a5905daf6521e8f1155e42dd3770100", - "80ec356094c66bf65036a2dc2aa5921dcbeb39b489d2c3954c7163f4e09c5d113c96bff3a35f94fb2d4975b5216e099f49cc27e97f0feed04134833fd1a8629400", - "e7de008d9a8fecc930a1b2c8ef274af1997611b07025d92ef28bb008141a16d60f4a47c5be9fcac74b1d4df62409f9b112028f33a3c83d5d2c0b298b442ae98300", - "98fafaef70891e51dcfc6faf0e3b0a0bbcf2ec6760d2418ad40d2e4d631398ee0daedfd971e3eefb9404cd32150bd9f9d05482fab5ff09c2bcc3df7f4dffb92600", - "6aa4b9536ae6e4dfecb3623fbc2495bd8efe18d2437999fd14070e3ec53ae59f60e95c0aeab8a0755e907907fd98cb2e960042fdcf95ae999c92756fe87c2d5a00", - "012dd083bdda78d9f92a431ac08002881240f7f81c8a313be515e0dc61d3a9c421c25b6460f7f9a7b2ddea28c233c6712d92868e975754f3825355fd9ec46fe401", - "2009d9315ce15f1611e0ea8e67637569b98e0cd1cc8d918a65f773f9fa261c54043cc89066ff5892353672e777a7367863f22c99c7202a8fed918fa0d3cd586a00", - "dc38db213fe636d269f056ca6dfdb292731a311b14d1df97241c25d02a5fa85b0e34dc788623bb9792c5642a6cbc1dc4c4e09efcffdab8bc9387d2900cb5cf7800", - "af26cc4eabf9d7656dd488f028428896aa23fb0ce8ab1d2b18dda20eea8134df525faf4ad0033836a5982eb0febb07e4442d320a2d02b9b7a392a4b6406b902b01" + "0f15c8684f255ae234760053b193e2e3e799e0972f11aa7cd6ab62e29a4fba093d66356b08a0fc544a6c62c37b419e65982dacac87c445570a76cdfb3e981e2101", + "84e597668750e6c582ac72925d5f51c1ac43913f15472a13f45470d8e35ea6da6134b2d0fb356a6386a0d7bc95b4d35deeb8381d61e73ad852975e0c188364ec00", + "f2be4f437fb1a7f8e6ae876833d02a1b2407e29c393565f43cf28a6416cdc839593188c29d402479321d4cbfe92f0c70664bf19f550eba0c72c2e064727b93fc01", + "e8ea5937f15a16c93b56b60e527f14b343453a689b2fbbf98141775e7419f030190a32e8a831c4148f703f1861da656e93365cf6bb59aee628270bde6b6310a701", + "122ebc51724839413d8760e5b7e6317e7348e3c06690083baa2b5dda38cb103d3d6fbd0b924cbcdb4803a7c13de1b3a3794b464a6e2cf7ad9cc33305cb3e704401", + "e68851a6bbde68b5645eac304e0be24f3e8b51c763b0a5b3cc3b7d58b9ce1b4a3ff54a30199ad276a41015781f951f058eb20e513dbbe0097da5840821afa8eb01", + "23555eb3dcfcb3757f0ab11f822822da366baa4148448e76f4123ce944f0b4c80e1998aaf3e00b38e8efd33d8cecfab46901cce7655f37958d67d92b280e687401", + "46e956e8a6c12707ed890079afdecae1c94c5e39d3d04c312bd5477e6770e3274fb763ca342857e80358a2101e628e7d1a653f227307337cb292a005ce2f03db00", + "d3c7b3ebebd0fc24f378f1ac9a2f60bf9c96d9d88d64369f33fdb97893585b303d6cf556dbc12e991c336ac7df9e48cda650f4e5219696108f295af769cea5f601", + "9f8ba0642998c5da0c4691eae7a51a64120ab74ebce32d58fe8f0c11683ad06f232dd3f3b0b9aec0b1c53687298be5584b259bc7738ef54b247c6e436929e01200" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "UBGqCZrRCWLNVUTejLUTmWs3ZjcdnanAEa", + "secret": "cefc013f3eef428213011a542db07a220e85b2ea978caec5c47170e2fbc52a61", + "public": "0316f70fba8d65a0f9f3e49b1cbbc3fd3ce83b62725a59ed85bc1693c98e9c0f24", "signatures": [ - "f35397c22f09529ad3f01f84a87d44cb588aa54eb04b048287f8e8f3ff4d98575dd30cdd254d9749e51309f21b09cc25c527e744cb3f72e73e57ec6a8cfe473201", - "90383eebafc301792a58cb9354c528b7af99f31c3cfee8aa9ac23776281cda8804d31f78538995ceefecf4d3a5afd2f1de1645783c0208abf32f20afc5aad81801", - "5233585f3c8d64c789dd754a916648ab1120407911c7fb11a0029c197cdc8e440ac9e7e048587b1801d9d4d7c207a654f338447b8ff3a8144e346f02cb43e9c800", - "e85759cf0cad8cb184f94cfdfa64881aca3bc0a97c61a20bb95a95f037942ead5e50b3bb37f36d0c8d88b3b1d141ca2c571913b7d3a9ac0b75d7dbc022ab098701", - "ab415ba30f3fb35c172b3c51aef56b26775ab893bf157d0530059dc8545380c5555308786bc5b473e37e638ce674c535f916e11481b63f69f1f20213f04f4f6601", - "794b7ce02a0d8467d1296e5bcf1916df3f51027dc3a386fb372cd937de5a1c18745c7a48c08f7135bb31c65594337744589e290a628ccadfbe110ecf5299901e00", - "04e37093bd09349241ee5225a7c7772b95a2d8a91ef4d5ee3f3a7e276afd2b0e25beef17844e3f24e37a08f904f2b428e7b2c8aab68966bc820c5a9ad8f6b83500", - "737f852ed21e7531cd7e69ef46f8662945cc7ba7fa613950bfc5c279d0390d067261ca1275c4e55aab64dc8bf5fc6bee9efd50ef2c00ff9e889da32e9685f56201", - "84420de713cebebe3718162659e610605fa7e4a552f02f73bf7234f0f1d39cd55578149e5efae1d3b18ac03fa4b566943bd132aa0506523b8d620619717e8c7401", - "b727864e1e988f8dad7454c1f2421477f26bb744982a0a74d711e4be5e87f6f16b3790097b076f63fcf1bc6cfbd922d9411fb0dd7e571d21b8729220f7f39bac00" + "e15da877661402d0c6c8440d05c3780591c61c5f46094258363b5ced7a3c23e565468cd9cda0a34be02efd37e49239d3b9d6f3fe64f53f359dd1dc52275f6c6900", + "b5dd04df253eab7c671b4414e1dc706f703016f9f545e4d765160fa8511e4e553ce7ffae05b9a527b84ffeca7ea531a7f8bd51add548305d3bff5273b3db6b3601", + "c3135db42f34ab5443ba8ce3e6833c24ca84100d3247fcbb71b8615dc958ee917edb1deb12bc9eb3c259d43958ee10a53e22e966ffeff4116a04714a88ee285c01", + "9183ca8eb77e2bed8c9a788fb13c0f2c834619edc7013f58ae7c7444016012ff033bfbb32494cef26f0e308aa69d4c10cc92b0a8dc3da23d883319808496dff301", + "7ccf91f8222c834c99d28f79d7f858c028150bd0f234fafbaf55a39bc1d9f1c30c39672373d94b2c66658c91f770a280882909717eb4e6020650cac801c7aa5401", + "6f7bd016f7130ce5f33f46da12046b1bc9a8fc03e5fed7165ed16b1eb96012b12ce6166c43af598e24d8eaa8e08c60923de15e55088148993cab843f7fac758001", + "1b62fdbcd1b0eeb42a2ea162ac8332607007d3e94c40d3f329fc5f06abcab57b493cbd3f4b490c5635390500c66d45f51bbd340899922aff54204a2cbbb1ac9d00", + "bba47fe6febf896cc1f9f02a34d77710a050adaa8fbbd9ef2b51bbffca08cb9a22146c0eb84099cf48b499715675417a486abe4de28f99a24a75e9bccc1e91c301", + "ec16b3721e1f05d368969b88a9cb476e8aa7c0177691bc080d5f698decf5969f5d7910d95360cd49700f191cf0f7745d01c09468a1061d28630f8b4f923fad1800", + "76a0ca994efc4714a3d1bf10c7ad81825500a2492ab5df87682acd145bfc6c1e234c1e6238254bc451ae957353531bf2bdfa7899e99c3f7eeedfcc0d3d35a9bc01" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "28mhRTjG2P2fah7AJuUrBygpxhmheYy4qwi", + "secret": "a5bf25ae3ac443489d23aa9fa45810a36deb19fc56fb67d09ca920868ee81933", + "public": "02e2a845979adc6147886e594728f975b3121fbeae3bb5e026a2b2738c104175cf", "signatures": [ - "c0505b28c8f81f603b274fda2958bb7f80f49a381fb7790cfd39182c5375caca3060bb1fca04a6873ee913e18e8176e72d02eacc2c70dce05883115789c866ba00", - "eccc26a0e9b06d5643e7fee33929be134ebc1a4da98807fca14c7155c88f42a459949d4271f37e12b61553267219d2a4b00fd6482cf8eb8808c01efa6cd1d3df00", - "80a6d84144169b78c657219db07044dd7a555782328a46156db868fc172a76417e4c926c7ae2efa8fae5626347a783298cae7daed43517fc62de51d6fa50634a00", - "67eab917b3f9984f888d935623f43177d18404d5b414dd887e9ab14136468f5d67fb44a7c221078be8ba0f4a5076982131b487de8f0e56061c9892dc6fd05c3600", - "bcfddd04bbc37ced7a4718a9ce74ba17a0a4cc0505b3ac50301a76b85eae1907565c703a1c868ce008479955cbc3164244f5090e7562acfa9922f07820d53cb601", - "a51f3267de19e16a51aa20ba502a2ed97dd2b8f14ca65dc6b8ec8f10ae6fb7893bc89ae8a08155548fc0dff516a4fc9cd71bb6255d20ab362d7d72f56e33db2d00", - "5f6aa1c2b6b758057317bd5288958e0f9536661296ee07645debd254bf36165237ce6425019ff930ec25ddf7fa40f798349a86d738b3aabbc228f8c7253e874701", - "bc7da5e18211565c9222edb6004bea3a30cfc6896ece632da5dedd2147bcc2c2331003340b5e91e0dd94352e45017a5c81a7855af5c94489fbe515c3fe9c765600", - "9dd6beb715ceab720838c86e0111d644ad102ca80cfd1b2ceac73a307fa4520c3957bd9dbe4e35d62d74af6ed1bb60132e4926ba150d20159c2a99c4cefdb86f01", - "f4f33251b849494d6b6708ce0ada139f604eb78d9ce9d55d0e3eb5f605eb67496c5533b959de79769cc1014b4c9d678cd7dee90fa4ea8c7a38306966da6c3e1901" + "459509346729140b8534d06867f7c3885a59b38ca9264ae6243e83fd71ff023631aa62a9926ebc21b164717e227813c0a84b222cf7881038d7692c208f1911d300", + "36dd71d7c43b438be226dc6bb3d1695162da774d4aa9d73621ce40f17e71d59c47129046201b7f7ff42128af0df2b8b1075d3c96135fef755cd50d78f443965800", + "e3dbb279b2df949cccd238fd7c9682024a7e86ef4be62c46c21d1a5add6d5bd75ece28373bf65ef0ef01e35873510e1bd6d632390c1d0043af57ee6fcb8e423100", + "21bb5e11f34214dd7472ddccf0e156ae8c2a3b2519022246ba77f2ba804593ee21fe5b20dde87ac0e60948400187cbef45b70ac20f44add46cfd045d87b839ba00", + "f8ae837a61c9a083e366417f0e4be2d43d490add9d34ff4c513d6222194c16232a01b51b9205946f4cd66a5ba69f1ccb6dd4ba3906ec17711547378545d1be7e01", + "0393357ff49e2de374492fdea60319320c37ccbc03e7e6b9ac42ee3422303cfe0648c75c57d3062b5c33634ab0916baa88a998505281287e99ebbb000cd2e42301", + "2900df4afc8b3a123c0ebca53ed6f6398e5172f5f9676b76efd6dd2d5c4fda68568b72fe2cfeefdeed89fa2604d7bd6b3bc9ec9cddb307832a2d4368d863bafa00", + "f10ed20af67fd8a37f4100885e08195460728c89dd5651047e658cc679237c445377114888c7f4402140f2886492038be603087cc921d1baa2ce5ba62e9e40ad00", + "8e00142a82c8259adbb209104373e52d7b3986fda2a29af86e4915706675a35b3af0b4a31002d263355d47e6072a7959d4eacacafdffc5279f6e90bab4e6a84e01", + "87f22431354dcb7f1484d18a1207365d69b69341bcbdd49dbb76ad9ce53cdd3f7c806f14e71b3f05fc1b43726b3be409cb4b06f2738553c61e2ee7713898157300" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "o8KcCaEq7rUzk9jU3ej9NXz8ySGoAsM9wq", + "secret": "a774d84ad42813d48f293e77fd9d872d4bc5dcf94a968fbac437811a37e0273f", + "public": "028084b66fe7cd20247fe319bbd62116732e22219ce6ac0c38b10ee7df6a5e84ef", "signatures": [ - "37fa3e4b17a1f71005e969ef547711cdbf17ccfd73e0b6ca63f1e0311758efd27761c636e3a073d135a4ec9042da6a3712e8a90b3f59404f9506484640249df701", - "77a5ea4431d9d7cf03061c9be344dba0fce3007905076e2e456879f2cd0e21d44524da5364911e35a7340090c6d3006dc9bd7b47cb40cbbcb3c5b56c7809244301", - "55a0b815b2227f48512cbca87075db66b51532f4f8650f7ffc4c827a7bf40d311295185a989673e1366f0c58a36bd4ec3dffdd9286d25e04b388b01ef30de31a00", - "8deede045d816ea34fc90311a978bb6e33277b7d89a883fcf809aba4bbccc1b27cbf056f3f20b3ad34307e32385e6dda6ff867e241afe013d3ad3b47b9b3b49c01", - "75236de3d16a31a088bb58a664b13ef968eac76c6e5b03191e24ed74b8d9f4717af06f003c18ce552bc1ab6408aa9d6ea0cfd55605d4f46e871b9aa77878622a00", - "284c40b7deb3d23f3e2fc7a5cec270b4b87e6bd6017c666db2bf6b40b78337f01042d4f2ad621617d6ffb6d83ec2fa6faf61b8ea1bb11276050493473d17837f01", - "1d9bf7537c1a141853af6c0c38bc052a04245bb093f5de9db41caec9ce3e15ca44fd02974b31175ba30077895bfc98d8779297ffaa49f93297d60523a06a7f6700", - "81377112fe14bb32f199599fe2d9f68b4bbcd1f01d611db6157b2b6dc796c6ea436e86b4a6e47b9bf41e34533973d4ced871d367a0d0415af2005025d8fbbb5801", - "39655acae74ade1ddd5b5d42459733f406e53bc3369a8f249416cea0613bbc8604b63f22fcfc8049e40d865f8065bc8613b5b51c3339b18d66c08f416bbb949500", - "4fc5ddee0dd6e03e9b14c35e1ec146c545232a9dea490c1d06e79c4e40692ad5399c43b3ef56c92ee6a056045081138ccb282c489df9075b7f98f795fdba965d01" + "1f173b3cbdf6157b181cb88ba8fde5490288b1c994eb3d15dd64109207aa330a1eb99b8061555b30addf7e5a1410b22c1791ec979e9f1e359fe67bdf1bc331b000", + "e44ee5d90f91ac62a4b08ca7adabb3f4fbf242fda2c60db76730788a1746012517b7e656078c36e6d2aed28bfb65cded94d4f776c7f3e339829668e2d24fbb8701", + "684052ce6947cf8ef9c661c317136f087f8ccdfaf8b9e9b309c6e61ea43ae09808fd5a912a45e6ac71e4833d7089e1b610dfa1a67e2e3826722a145efe7ced6501", + "673ce36127a13f491044262e8d238aaaf5dc806bed61d7999a262ab215aff64747c2440e532d8bdc6b04b889aa856e0e53f2fd1bb2bc514854e46cda7fac379f00", + "2ac98375228432233fb3d2d3e3e985bef2e46b65a906300f759f6c5588f30d21656385d9a48412387199a44eb21ec2a9da4434e981c5b6e1dc2740565a381eb601", + "acba6f64c54168e9d0a3dfc01b52326a2c2f18d3af10ca6ebbac6bfca02064147887a6cec9613dcbbcb909de55dd5870561c4d6a98683cd1bd34db16c93f6b4a01", + "9b0b680d306e8f196fb882c8ad3fe3591486b19487c5ff7c5ede4a9c86809da6586d28e62bcdafe4bf6d1f48b0714e8f876fdc9bee9c5a946db34d095fb66a3501", + "5c1a56d3fcd09a8d749ff6e69eab86c3a850d9ac4cd4aad1e650c7cf83545cf22192288535eed8d67b1bcd49ca0c4d3ec950b1eac2d1ebf52d052ad46323f76401", + "4ff012ec8b1e136eda5d7638e407985ec6ac20932a60cc9f6387cfbd07e5eb8c6b9e991876f1230008e76b9881425a10f74f731bd67b95c44fecb7239cc215df01", + "15f1b3110921e7113a3e2c0153699c4932189a9f11e08e5e780b171eb6b3dfff5ef5c2b283ef0883ce128c32323efe8ae4aa240d70113ca0103870842e65482701" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "F5b64tWsytrtoTB7Gka3Y8gL8bcozi9ZwC", + "secret": "c9da0f4e53c8299fc289eea70a8204053f8e2d357496bf37673b7a2a09606239", + "public": "0249ea059bbf219d4e5fa61b68009dcf568a4c3b8838281066098c9c70e6302e14", "signatures": [ - "66d247271d65f9a950de0a6929efbe7dceda803e8e70af920647c74362c5612473b2e817a40afec189dbd6f617312b50f819b7f55833c8233287a6b62185af7f01", - "ba29d1f28ca42c8c7dae60c48a9819a5b62a461012c9397b00356465e37acb890b1ed54a94933c77948a2ebfc799c9e1536497189629dcc5bce77e3b3e70dc2101", - "fec5db52a2ad06d6440fd9676aedb5a34fe07d98865a30ca2ab52f3b26cf8a18465a0d1218eb4feb4b3ac23493a04466435bc5e51baee648c010916c02b39d8f00", - "569b774840ff04deefcee01c5b58792d82280523243b6203bc885daba04fc66c25d51029619a8f3e5269978aec6a1c703f3656081d67c0752c71fb4084844b5b01", - "f8f423216f3a4c8f1fda5278aaed460be8563a8bd2628e5f25e91724209654b71585bbd12afb6cf8a4611b58476fb5a81054b056a840194295beeb0f9342fb7d00", - "9f3be0689ca5bcc684f88b0ed2b42aa9bde31c2feae15d6c05d5554ddcf1ab3c258c2bdd7c1931b8f8ef52b7e934bfef6d2e12e8420faba6503b791e6c4f16cf00", - "3264e76c8d3e4ca3a6b5b8dca93152017c6fa9c0dcb395dfb229258271dfaf04095232bfe9869ad9139f6e57b6dab658d0567b2372b46f0008c31be17aed9d1501", - "0cf6701a0b2666473357ff40157ef8a5b7fc12d4f29127d105cc508ad3c9d54944402d75479c8e927e80ce4bdf296de4b5a7d84cc2a46c9dc675bd638660b77a00", - "f5d8208b78a471106b7f6ebee66c8f9cc299503e6d676b6fcfb0f317df27da772eae3fa83bef7a1377a33c0a1649858c0c5a9b321110461a999e18d682a8cc7400", - "052cd27bfe86e9b85942d8a088a0b3d94da1c7fa8f452144fb598aa5adbbf0da4f25047f121eb16a239a3f87e0ba7597eaed5c7ae9b65adca5326e38acd8b77301" + "2b6a68e36f23bb4e70e325b74df03af03507c617e1a3f2f3d9ae9de51684e69502a1d4b9d4576a58851c3c30dda5098fb5e483c387a6791d220ae360fa46db1101", + "9bf76435655fd5517083d56112a85d6390f2cdb29ef0083b72f05fc80513553d3855fd859c062c615197f85fa6ea2f64df0a08c05f6fde543aae1e5b06fb070001", + "b4b3d577b3f634171ff462e6ea1a5d7847095c9be3afe56e1ffb5910bdaf5993776a79fb0a11d31af5b8ad03fb82dd60852da5db60812fcb66c430b76e6590c900", + "aea6e04924a561febd89188d0735fccbc342d23afa7d4874a3fb7deec80e38902c85c386e2319bf165b28e07f8f2e5bc65d53124a2e18f3664f14f3156916cf000", + "de5a68867d648b90fb090b366800a458eae988401778295d6737161bc2cb403b7a6c65054ab8a63de5da6b78017dba1fb5225c6d49fa02b0a884c8139e00b6c601", + "b00a6f1b743f2ad3efd370c33bd763924615e06d9640d7473183822f8aa6be792dfca685286084a2d88027079a4eb510c49192da0355217685900c644c37a29300", + "e2c318045aefc3099a25545c35bad5c8b34a9566b5a5e3813a3ca0b9c82698e27209aa93d369b788d8567a9f77c47796060895a566c961652b606f40e73735ca01", + "707e73c79f3212dd48e2d14a807f59a4ce2cbab2d60f9bfd213f3253b4b37c962f66e7b22e16633bae7c6fd4cd25489f731b99f6a68062532f509214ca7593ef00", + "acaf82b616b71700291f97934baf5693a018f685594af570ff51e6b19bb93238174b5d5bd4fb70e7ca1c7a247b795817269e4a93c399d2e55065f9851e0c6d2501", + "7a6afd718dd5126b7a238933f0ab66a93f68bd83b0e233698706662eed4d61486eeb68af6bc69c63f30a6107584a302dd2f3d404feb35868f155b83939541e0800" ] } ] diff --git a/src/cipher/testsuite/testdata/seed-0010.golden b/src/cipher/testsuite/testdata/seed-0010.golden index ce595e0778..136b7f246b 100644 --- a/src/cipher/testsuite/testdata/seed-0010.golden +++ b/src/cipher/testsuite/testdata/seed-0010.golden @@ -1,174 +1,174 @@ { - "seed": "jhd+nsFhAJ5Sq/wSStR2mkBnwNra9miXQ2sWcbOuItI=", + "seed": "58OY1/IoLeJIrfYkiwmSc3IbtSF/XwYHExUdRFPL0G4=", "keys": [ { - "address": "XZ9S3QKN5tSRVswDNE6GLCtTfm8DqRthyA", - "secret": "697c7cfba3c6d13dc6bd3f063c60ef4d25de903e50fe8c5e123e5efb08e21e29", - "public": "037c4cff096a7219b17f8502b9ed643c947d5d4929c1a141b3240f70b60a15a7b8", + "address": "2SrJiwmXj5RmsN9DzCVzNFuQDA2ps8FToiE", + "secret": "646ffabadff7a510e36d37a6559b98c24956a62275bc6ac80fb2597985c1557f", + "public": "022b32f9b0f70ed57f356a49faa999f5bfc25f6f1863db2ee5fd2aa1cac0592877", "signatures": [ - "86f89d90b22fbc87aae9a9f24e41fd797ef3b2b3a57a58eda2f732832f7b19a2516e00581f0865233335efbf20ff9d1d2ad23682d981375a3fbefc77b49d5b6d00", - "d97b475324ffe9d65291fb8aef96d3917a36838d477c2e7d00069e5dea1ded46464510ce136acdb0515b2622d6601aaab8357c0a77e7265dd8ef0b6cc1a0e99500", - "9020130e3c63ca27c6d6d672cb3f4a3cfcdbffff06586d015363bc4355be94260a2edfe53c8eed57ddaf250a161c6e6206b8cbe6dbe26713b1358f1f89b1a00401", - "b07b108ed1b5ca1bd68921278d75f1aa88195ead0129c04ec686ed2fd10d0d6f5718f662d973ef09585a4249783fe73b9fe6f21723cc2a8737dcbdd06023cf7201", - "ff62ee8f2dace84cc7e455ea7bb3fe36a85b1e6f7c75b5e5c701b174cbcbb7c4496d47b87be6a011d169fd8bb2f66d70a2d61d8510aacf6f41d30855e79a75e601", - "7434a911e0364c923db494b57dd25ff6b68bc11b67da073c4880554a4a31185c1622a8c7820c8e75aaa1890cfd18cc14e87c2781bf7778100842f75497b75a7d00", - "6196ffe2e84b4e79d6560970364c7c34e43b203e514088758650e04e88c2793e09b3a755ee45e0f4e875e097e581724d962e52710e1bcbcdb4d3e2dbfcf5a57801", - "9d87c993b4884b20acb5c1aa1f8bdb3242f63663470df76c2ed4b6d0ecb15b1933f9e3c2f7f30be4f7849709012a9814347c8c296591824bca30158a9e12d5ef00", - "15bc1770837a7d4601e9021681fd8712189ce0f9d2adee51634b145e52ab154953ad66e5dbaba2a9e4722a77c2e335852f8971b56b6d66c1ee6e99358e1ed27001", - "1fe2b50dd02c975fde9012daf661fe27fdca825cac66cc242e57dea20f030a7c6dbe1067db7950333d9cda89e374c07195c6c15848112131e86a3c1bdaf58d7c00" + "6ca2305b555ad4757be898041a936b5ba013a0213c24b37abe5dd6586c1dd3e3718f1e38c72481c39d4733994ef2db85528d4307162923427b2cd3fdf67103de00", + "c33f4665e035ca0534798d866857da38b37fc7aa24ce2828d9639bd0cb88ee6e14fe150b016e1cd842a6056d2093629eb272b13b86afb71771dd8064f65a8bb800", + "fc2377a4be18e2c53fd277b136117468b7c8fd12d3abbe6561c210d6c29c56ae3afb4508d5e74ae75c697d51d578458e7b7310a6bebe4c97fbd51e9ab84f7fe000", + "40637de52a5d28d87db456c85b3854a4b73865fa3dacead32bf5d3d24349aef0680735f2083b1c4c0dc10d2f5ff8b84189ecf3c196ebe09d479587334a56145601", + "1265e4ecaea5ba5e80f7125e28fcd6a228e0899e53fce3fe5fc1087a1c931f28710662c01c1986775761f0ed677c5dd663c43b8a3db4e7c34414ccb61fc9daa801", + "02e14ddc2c85600f466297b5938bea2fce271dee37cc4e54c812c4040364e7bd3a57b5ce9839877b7742695c55c85de569aef2faeeac234cfda4246a0d21c0a801", + "614aee033e979afe8cccfbb568dc4f3b1fdb368e249f913ac12a3cd26d4746a52e87252b156dd3c572e1eec02bde554c0d5afb0ee37648aef342d8a401f3332901", + "79e3de5d0b0996e66cb2edc8a683a7ac8aff4a79ec4afab42fa4ccb4bbb0df4439c9e0ec9acc390c9b0c639f6be1d61b7ab9942113f9adeb1642724515cebe0b01", + "8c6ab61c14112eb77e0e3dc0550aa47a14c88bf51b9f3b7bdf40ee666330ab313787b54300c2f405bcca00f7f8a157426cb8b87984e091ba30c095704fdc27e700", + "c30dc8967b5c2fd418e7cebb7dc5cbacc2694da4b80e3fec197b8a8b54a9c517383a2cea7a07bbbc166f53e171d58e3a971e618c62e43a86bd8c529fea53376d00" ] }, { - "address": "2SjsWTHp1xovzm2Uu417KycJqJJXMnUY3Hj", - "secret": "ac4841fc0fb045d60b3166dd5270a8fabcca7114bb6c8f6484dee37276dd8ef5", - "public": "03b03eab6974b951039ad0f9ad588678d5fc55639b00d860095ef8b4fb49fc490b", + "address": "28EpfFX9Syr1E1DTtufp4rt6KHDKWJLUCzw", + "secret": "8597cc7736e6a039267fa3ccba8eb73360ab492282026ab8b73328da061d3256", + "public": "0276f2290c48973bd92552fbad3a9ac4ff433a8da13e13beaeaab95f164edb8ef8", "signatures": [ - "f95acad132ab5c62e8fa284e11d7da47c9dbd049c73a4824f76919dd9f05579412e636bef7dc4dc8ad3e76d9b95c79b268f02c9d389c03cbb931881b90800d1501", - "1dbba810d0bd2e1a9bcf8edc1df63a8479b3a3b7f24ae77c68643ad87ac16a313cf58e0add627e9d09093208f7658ea1eb6dac23634ab1b2a10410aa99f25b6601", - "5af69787db67ddf50c903c2bb9e9857695d7a0d4fb51e11a89cbe86e4be73f5315f48899ed57f8deb91d3d03b16d6832e8da6fc5477c92e0d25828b6a50814cd01", - "50600f007935776f8cee7d2d68123c8a299143d0f075d6ad229fb30575de5e32130a911696db235b1dc480aa87a404c097138322ab308267d21614a7f991735601", - "8463f7c4e64045e68406844369631ecc0ea07ceb190335f9fc3d764a399808ce524cefbcb4d584348ebd7f04d073c461f74c869b74dbe541ae02fa79e816e75c01", - "4410d606bf2b2683e3b50404012330609776d9d67fff79941d1b824d92c4b9b572e20f53f9ca488a1cbfcf3660df1bfea9aab460117c67c55c4e5637ac57691d00", - "f2fc085dd3a7cc63fb829d707915bced86407cf0727875d0509083dc92e7b52c40c2f75c944bf74d47249143a05634c912d33668a4addcc1f9f6733331aab1de00", - "b8c5fc6a749e753b64f3e832bec79e26ea21fcf6c7e0310e59ce52694e5af59f4a506f55454c01e3fc5959c02296d0b9a1e0fccbc184b2315f7ccce4e693131501", - "ea5d5e2a36ca36afe720f981c34346480df5bf581298a684f6406ae447d61c0852281b3f97c641b0f351b5a94184f12eae9fbbdc4d272a8a0775c07dceac97f901", - "ed2b238464f50e3e17ab4b88008ecc5199ddb701003dc2bb2bafee2811a8736c5d7499d5d8ee32aa294459c75af6d1fe1c9c418bee15fdf7f1e419fc8ca70b1601" + "403e2bf565bd10642a72ac10ecb868dd54f22413f1983c5dd8352ea3f5af2e3f660f790c200fc38d135f61c97169c7a6a51d77d00975e95598d47c19b7eab0c001", + "4d9011b95d86cdfcb867ee695d40417b96a1030afef22682874879a9a55b6cb108afb8963d5f89344e396b60e17ef758813a6ec4c669786184031e814c417e0801", + "7505f810db7cf603f5f370f0442cfb15211395fbcaa1876eab3015aa96e11c3d52b681d3b8758b878cd577c984bff55492ffdefd8979d28e355950fa7aa4aa3300", + "9b969732d7672397c3b85b9279a8c7e633f3d59446824ba3c77360c0a1f2d6f315d548aa2576b61285388d6fb1d6f33815cd746b85ab4baec28d3aee3ef06e6c00", + "57c1c7d20cabbf967a68356f806115a1e900211159a2a40dc6fa3420432523977443cb3bdca94911c04f9a15dbe87cae661a085aec6044e9c561df654449f36f01", + "54189224c9c02dc272dfb4474a802083e1ac372350ded7539db03bf60ab918187a2b63a8041e79e0b8bbfd2af09417f71f553972c914df8f956cab8cc4eed2a801", + "a5987f6d62982652f06f5cebfe4a83fe8918566100f9b28b65478a5100164ecc2b366f92ed006321e1300931dca8fa5661a906145fb769ea6351dee3b5215d2900", + "ead667dc0d71e3e6877da08dfa17720e80e372bddf067a6783ff723a37f004ac675d15229369aac75bdcf1875cd548b7b068a41d04b50cfd8bc5b07ddbb13d9e00", + "3dc279ce62d0ea023e13007c737635f752787ca6f5268d12e6347331eb0edb274d702d485599954ec99cea8556aca04d538c87695c2c1c9c1551288b047486f500", + "d5c31767dea1490d951cadc4bf1472ec341b83b3edcb397eb3281af60b48ad4d68ec1d3a192d05af7883a19eb955e2ce4c30db6a7387a708bb41f33d9300ac5f01" ] }, { - "address": "89bLkVdXd4ErS7iCVUZUqcCYss1cajdJiF", - "secret": "9dee21aa7d7d5de4936cf6a719e902162eea3207e633b7f9c7fd7db532d28486", - "public": "021fdad43caaab82bce85fb90261540726a0c08f3f91a0e3e389588f7d13ce33ad", + "address": "2j5u9ieaqLQjoEru9V9sMqLPL4cncKJfpoU", + "secret": "720a01fccd31cc08832df230316cb89e619113d951475c97b9dc350122036cd8", + "public": "03ad8eec89298721e6f6da1ad420fe178e4e37ba6c5fbeb707375380454eda84b6", "signatures": [ - "944793ec86dba1704856c721dfa070cbdfca4e64b6a8421ae9310f755a33f0017256293fc1e596bbef1e4731bf524131843f992a075b014b0306a77d73db44df00", - "b410fce2d5ae784851c4a910184891dd885170c3fdfccf6d0dd5d83543abb0926709033e6b04c377ea16af5933270cd89d701303679b80a76935279d08e1fe2400", - "7adf554c1b273cf1b353c5e8e5129cd8e91bca756751aba44f4700a2ed1482a32b34ef9fc7ab006e7f6ce2f67ed8c671ab44cb5fe8121351bf0c21feec69357000", - "1c2eb8ff3ec1168c1c552722d1ab0b2381d25a7d0cca025d861db457860dee6878c0e148179a0d8fea3bde7dc7c3f8ee431f4296ffeef7a2904b38a411e8344e00", - "9e7ecddebfa2cc1574318bc4aaae0c2f112553a27e0c8169c99ac7853050ccfd52a9abaae14609b1df48691d6460a06280f596d397019b9296f62c2bce8a0baa00", - "ae6893c7c7cf6a8b8979b52b743ac3c88635e396e9a32a201d05168fdb3588e173f36f0d3916ca84ccacdd153956cb0e8cf3eb0275fe8bdde9d469972665ab3e01", - "26dc33a1b18b20b4ca59029907f2de319496477c86681e5b7414ee4f9886cfd5405b595a653d7845777af929ca1eacedf29f1d42eb3a32ad7c7714fe253f6bf800", - "6c1327c4d53834e53de8574de716c7d9d7808c3875575fb4b6ae22c49afcee4426b8e2af84beedba358eb0363c8799705a41a7578cda13e0476869dff4551dd100", - "62ca9d31d37db86ce5bf21a077c70a9225bbc17f81f4ee2b847adc0db2e8948b5b6173c73d75ee0df69e2e1e922e46e6b80c361ae4b859cce1da4590eafc7b5001", - "bf98c8a1b8a29661b45fa62745f7ff97f9414a3bb2d3b61dec875ea4ccb16151388b4d150789a52d502cb02171e8775ea920ca8aa29cf9badec24fc1a5c99f4200" + "89272a6545cd40117f89c7e18594e5794a72445fb45752d64f9a1d606f7e69604992268952b136b192c0dafab15b9bb322401b967f18536f0f5b78c7ff75f38800", + "06b3fcef37e36255613a3805d31ca5753c1e11ed1c554d6c8c4676c78fd9c53b2a1b0d19ef37b7e8062a65d5e982fec61fd5097d49fb5198c376e914571623dd00", + "82359df3355f1823d03c0aefa5fe9f04f208cd7105f9ea310c615bc6a857f2c153f68e8b1e2ea4fc952c1dbeed02ca31a5f425aa23234ef31a1b052ab177ea1301", + "72ed2078e5bec03162cf64aca6eae363aaae0b402324dd74e7ff630f0d48c67d6e781d0f2612fae060577d827fd7987e4a0d6b6254babc3744c08a98ad85ee9c01", + "fd6d6acb517bf4b27cf1e6b03bb1f2b4213e883c4174c56b14c2ff429aace102214df6bee50df0b5707cb59e215eef0a2138fdf3d94ae01537b03ad4f20d279d00", + "491360c4d4937e2a1e9523051909639a8262bbdbc77becfdf82dedff9fb9c7710b7ac8b9b97aee6267fde5635d247e1c16a1a26a82c9727778c6eaa5b7e3d50e01", + "dc6468ceb3dd16c717549a68ce0d03cc3394891e9118663aabe2de125fea621c16de79f0864fd44b5e23c2058ed8f8e65156abd27e89bea63627afb4487e7af501", + "22ecb0f1e4b39838cb386ff2c705c22b35ee0a84d95ee5cf739a97d3a6bf51be245ae7392a89d05def89a5075b3590d2ebccbc1458371e5cf5a4aae932904d8201", + "806050af0d6b5d2b806f06927438981c648ec6ee3469fae4cfd4d64a31fdfbc57ea6347828cc15ad8092cefb59a738a61bdda7e823282472a688ec288da08e4c01", + "c7e31a146353e1273a1c0f5ba4205e743ed67da7515f1cc052d2c0c24e86445905ada83acf5ddf68b9124c8edb149cf96851f01d41b8a8515d22f0ffb8a86a9101" ] }, { - "address": "22bgAh966no7Zr4QcqJAS5YJVss9PtEak5i", - "secret": "060780023ee83eb8b9fc091ed9ce1e1924a0cd04de39e6b249b37672518c7cc9", - "public": "026cadeded0b2c6677d28acf49196aa14217551c5a65e2df20ae18a96a49c936b9", + "address": "2KoZQBUD99gg5jKrZLLycqJvjMvKFf2APLA", + "secret": "5a04368aefae7f463f31da6955d7c08249460e3c90da76936b641f25f7c6ea91", + "public": "03ee8074e5474b0712267b0f66ffc17f42d130523ff4c3f78217532540c89f4609", "signatures": [ - "4c05f3f7dcaf78665b0b59820f191a25b1f9fc1adcbf40cdf8a786abb0173d6522273440b199efc0b4c5e331648ec146fa258924e4727201d3e61a161f71184800", - "3ba6bd06e9aae607676ee5d2b94426de65ed97e2932bd7cbcdff345d1b81ff8e427055d0d97561c2a299cf80c6b9a5f4d98c6c4ddd7a612993c2d8b94aa6d0cb00", - "bc27d14230c0bc20065447f67d708be466f07585894b4ea5077d8b3c3fe9276d1d919df90ffa41230732c3df8ed59a80c4a1d61b9ff5062a3d94e4c6cf880ef001", - "8bdd824fb06f68e186ac8174c7452d4f0042e698686a89633dadd48009ba93176006d95e50f2ba0f7c9a7d71b8b5d4425debc9a773a041faca4084e413f2b22001", - "9e852869d0b91bf4500fe241e1f6324e621966811b4e7b615fc5cbc09aa1f98b3d3dee3ec7a83977b44d24309a99c34bd06cb7f091d9106bf818f76d881b862000", - "774269ae7e76ab839f843dabc55faa6a9601a65436fe85c7f0d4aaaf757d5ddf08ab84d0168abafb7a6250457657a50e40497d6791386c72e573a5d95aeda96001", - "8663763aea5b9269c494395bdb8e0fc85762a3c296527ca4d5db8e2a49d259a06388a3141d00493bc35336a3dcb0d9750694398b640bede66dce139ea736f7b701", - "f1583d172ef41227ade3660da5b4c7930f56ac0d7e0193a07ea134d73507b4c6022aa717240ce9f9aedee6b905e6a33cf11a13c97c4d125bb10b348191b1c98600", - "e11799534f37f92bfd625e69fd821ec7bb423128d98d2d1a027bb382a415357e1501d074766792112e2bd4dd4b6d815576efc27b0e72ee5c541a8f0009c5b06f00", - "3c5191ca06cdb3e13db558902d239b4859e37061a0ea046abea6aed0ef9563f57a58136a4320464652555152c04c90dbf3c3e7b31b0571a99d22d0581093d7ee01" + "aef0feb04a3a4e4318282c0b8d2bcc1f658470be785aa4a3639117035f7b5f357562f1167230ca14aee019f8c32e9c072299a8918f5a76fed3c3f54a40661f1501", + "ffea567262851e00794d58ff9bff182a19fd97862a4e0dba414ae8681ac8f03d5396550c2a867def5be17f5e38296c40c8b6a994870604ccccc2326c5709062d01", + "3d88280db03a3ba9b15929f0f9d6339c835218e60e82780b9a1becfdf674550852149d4e068f2527ae425d280bbdf70bd37ef98ce2dde4d5d3feddcd87497c7a00", + "d53f2a4c346b8c007530beb4c1a28904b0cfa876325cf9790489959f82d4ad74035d957cbbf335177912ea7278f45bf86fa8d47ed9929d78d43da6a9637bd1ea00", + "b02fc80ec2869131159c562df839971b3285ea9dbf3b1279835ade6ec0fc2110228eb443d743bfd1bca24f20308d6034f1a5654f2dc81df537f761aef1234a7701", + "bba9e94d716a041fccdd03498047d9ffaf55a28b1ba905915464255af0b883d03a109c7afde2fbcca2ec9bc2f9bccaab9e07898017d40882fd6be9d12423825b00", + "9b557e95d53b22903526cca3e17468ab029bcb478708ad88c3581f0aff4fbaf4328bb3839134933f3a252432f01573e3f8111f0bbac6c61528de302abf286ff600", + "fec6d86d9efaf625b18c0f48ac7856f1825dfe82495c167a0f44511e9cb52b5c1ac4bd6a5015feb5cabfd39a62f48da6d267da23e5a49d6a1d66c34cd9588ad201", + "1a3ad7d2f56ed736cfe7db24673bfd917bc582b3a63132828372da1def7ae91f5cf322f8d35aba104eb71004658ded222f6411e36079a17a1c7d99473bf2a8b001", + "e3faf295d743fe5e38c1517b1437bea083c4908004dacec1177e410dce94278a4477cbdc751cfb1497a5cfc9c6707ee47bd1e34fc35e0bd27411c3fe69e8186f00" ] }, { - "address": "HszFg1N3YQ1AMDe1VgqJCeX29qV1PiAFHF", - "secret": "aa6ae225421c12634b38b405b41fea441640f8eff8fd8684bfa72a83de82b4f9", - "public": "027709330a7a5b4850a64e095ceec3d62b48b34358f8322bdc01d4e17088425ca6", + "address": "2YUgePgEgTrbACq7vrna1NXVGUzrBERj4dw", + "secret": "5674c557050ac9dd67cebf9629b9af676024f126e3a52e856fead1ff51521c06", + "public": "025358627a6f01a52f446cc7b643b813482ae3077cd3760385b6700d83def6cf39", "signatures": [ - "dedf0ecee798f6bbe78d34b2a8408a60eec615ba0af68fcb65349834736cdc165e06a417182beb75b4679583d27600411461b241d451b749fbd63d490bd4e8ca01", - "8499a4071c7bded8e03cb5041fd8015ff10fa755d5116e52cce4c7f248f30bb524f3d4a9f9671ec7005c2f88d020a5e55fec683fccc3fa5c77bb340da263da8001", - "1c48da10a18b1d3835f0b80706da9664896c29b19123b412b5de810b9780323b626d04345f4bc70ac38fc5830479601dfaa0459a83403c7f82760e620cb37bf601", - "85af950d9aa6f19f2c270631cc6a1e21ab24e8e429d35ab0dd9dd24da149129e7014d491704432f56de8478882b4f7e693c1df8f8e277883a55b0774e4f585b500", - "0ac34f63233d7e16bf6018142d8d282890865d2c1671937e918ccc37df2d121e5336b2697a92549a1ba15cee2f2eddde783e4ab1776d428cfbf4f545aa3aa4b900", - "12471af9e27aa52a73951d1d34731b43f3f4ea7bcf3c8df7204510881fc90b0c6f275816557db46f52ceba052d6b48b1c90ecd37592bea9a79710e36ab4ebb6001", - "d518e45a1149eff534487a6c6e024862bb55cdc34c79f1bc44a1495d6b3d22a6027268a944735887c4189bf46d867c5ebde07c04210afb48690bcfc108d650d701", - "a0c15d0bcfba0ae0959a061f20d5c8e517e4b0ccf7f4c8242b9a0d00f6a6854f4d27af848931be583f666162adda3c69cc5933858ea7cf7878200f76db4b6a2500", - "f71b2699a612da1de2bf02a27a8c856b2598e8b6c2c045658d57eb3402f5fdbc0710fd14d1a11f20484acf4bfda8801ffd25a23da22944038609339718872d8300", - "59bc713b9430469c729acb9302eba7bd507160403286396b321bbdda6e0623012ffe3702f1bfc2fd9c5ff938cc6c10f52550f3ec370f229f1e0084eb63ad97cc00" + "d807b670e83a1dd3424f916a7226d44bf3c9c8cea11f6fb37fe8e96b031f95d52fe48d0a3649e7777cb003a03890c127020bb698dea5e4eba0dd4c3beaf289fd00", + "0437e62986f35dc27782a1697e282da1a7ed39032ae01bf66ed61fdca42e87821a8939036ee91a16ab7bc917d2aa74fb059a6961d8265f98fbcf209e73c3f4db00", + "54d9401e1d6e12f7ce81223ab450134e1a39c7a2077de5ce121156fd56f345f3240cf8b9803df2bf7f105d1db73d8aa1e275dc5926e9340d9c4398f9b8af929800", + "8f052c5c4b6093a88bd24c80d1bc783945ad34b71b00ddc3f5bd6c948419308954e20d8ad22636c082ea536a431c96473531899f2566b57de9d038749e71fd9f01", + "8ecf28f58913914851d5fe5a1181ae665a7d536acd8e3cffd55e1e37e1bc1b8946b1dfbd091b0945dfe944123ba3df27d596dd7866169f4878614cca58b0f4eb01", + "b2c4e3e9bd832da27a0766914652b48a3b93e66cdf558343a4fac554844b99da27d9091693cc8fc5c89f769b870f29cf56b855f29a2f7ee1130b1f51a4d11f4b00", + "2bb5c25e4cd8ad7353d64f5e3ad8c23aa213c71c60c14a207805dc03562b8b1928a1f285fba00eecaf2fe00825574c7cee09cc3eb06a510a87fe3327a2ed808100", + "b00bd2eb6cdc38d9de63fb3ac5f249cc1b65d0aaea101a096d3434563a930a837aa7bf3cc91d7a28c4fe2a0cbacb20e9cf16ddd0e2fd305053c69d0962ad434200", + "1443132e898aef931e53552c74e87a0226227a443dea6d656d02e41e2d03a27749c6f2dc39e0f1de5441d2a828f66b60c598c197bc6a32e0e670143e57802cf200", + "ee030515f8444a3f9abd4cf883fe0d56ac35e44e4a17f3a91619bcd9892649f31ecf607475aaea87b69bfb25fdc6f785aeba8c3f64eb20624ddb18020fcb8d1f00" ] }, { - "address": "2ikfAfVzEpaU3NUSBXVVtm5rxAvpYxiLZbd", - "secret": "bd7a859124214a0cb4db1bfc0950b465499df0d218cc2e35631f0030f71887a7", - "public": "035625eee011d9f2f54814663e42e86aef5af9424827ce85b9082bf4a9bf4c478f", + "address": "dVMg6FSsHo191yyMzvKAu8jNempZbKnkRS", + "secret": "d5c59918edbc439fdc9237ea652127f3f83722895e07b82e5a5094fb628d21fd", + "public": "02697d387c359d57c492f24403a10e2ee47e54866ee381cdacbb5b7cf8ab6e1b80", "signatures": [ - "9a8f70022744cf1d09eebb467559377a08598139dd857bd69b5fd6cf5b7bc54019e39c1e2c845950a8fab44ee780a37a1981a284050b389232a44938d896117301", - "c1fffa892f0ebdd6742662b67c831cfa795bed5555dccc19c6aafd880300898e4bcfc91c8924f9071cbf2cb3d787ee12ba9d5bbddab73bec1771cc1442dd5be201", - "43beda9994b8d2d033a971fa94d4a58c57a43c48bcd35c131db00d245cb2498b2e745522d273b46b5a0698a50b6699232111c40b545b36df552ca1944bc6775a00", - "042270d091816052192c1e746f03609a42c94fab06523c0eb96600c9fb96c48e5748a0c33111de55ff1475f7cf12b711ea9ebfc180e176289e019ccc4af5861e00", - "d2876c4b69c56f3f9f943adc09671c2118c264155a3aa22fb62371f1ee3a9bbb6a5eefdbaa26152dddad1a6b3cf1c2f02d551f062a1589c0e74ec12383b8f88e00", - "0280da62b39496bb8395debe4fa792d602c0d544f021df224ffe7c4373c5a97a33445632ec2d81a93ceada9634be4f6810ccb4726414f3294d62144c09a8384501", - "beebcd18bf6ed9036135a8f780076af91ccd88570f3bd653e48f871527a58df37b0bbd1b19b9bee8df530d93ee5c7b2faf2f7d85a990bacd30d8bb23f941e1b200", - "53c4e05a5c9a85c91c5a0c0b842d40b3279d7339d3028c7c3e3aca35e06a496a086e53c9253d129ee5658e7ad8ab353758376b6a04696fa50e29b18fb3641cb601", - "e5136dce7f716e133d21466cb5827360c687f0749e316027b6236f2331ef77f34a8ea011990f2b6160ba221b50f7d5ba43806d6797df3dc089b5865e917ff8e600", - "962ca8e92906362c96259543f45ce05ab80b690ce990f5d796485feb6654e64341bc1cee15e258b324fafb58e8f818eb35c61f27bcf2962d175f28589c28fe4301" + "a7e7bc206006583d3c9fcf9380c3cc9d3c405eacca2f65f8fdf1ebded73695824cb75bd9cbcd7446c19a45e907e3c3ce2bfc84d4dbe890280d9a41640a1fde7100", + "0e68259177452e77fe363f86c8dfa8f4eda29cb75400f05d1353cc5d7cfc64a36aa54a266635ba55110141a66a63c19429650d72a17f57ad18ccdfded25a264400", + "331e14a445fb114fe7960de531de1612aca3d6701dabcafddc155065e1f9322247a19bf3ff1e9804d4169e6f295215bf41642ac095a6e540e4161b44d660ea1b01", + "69bc7a31bda0c4600e66c7ac02dcfd49bf8ea99cd6f8aec851882204076b2eaa1457b47038230bbd6dca6ae72c404b73e3e2ed4fbe642b5ac9a22c214788363900", + "951cb4a095b98c49470fd3ad7befda82093ce231623ff346947e6eb078f3114020fa56918d334fc29ff724b794a7fe3698eb473efa95c053cc43b1a75c069a9201", + "48fad2b7d86a9b8b7ed87c506d7957bc32c1df1a56af9f2f2f44a382f182a6277766c39ef39fdb580a488393b90937ee0217708c3266f680b62cc980575957c701", + "40ba88d401efc157039d9b305a0ba136d7aaddf9fa97e3e8b11012532eeb8c2f72b910e96029e6a40ae73f15949c692770f95bddbbaebcbae1df67d6002f5a2a01", + "9e5889ba9f34e0dbd4e9dfa354533bf005ead72f170c00b562bb08fe40c7f6e0323b94e84d55637e5dc9b6f007240fc4fbc3bea7c8632aef1b6d10fa9c68d32400", + "7acffdee6552639aa7a1960a0c80366e72f28e74826d17cc4eb2804d516c57f67d2c015df16f5ec84b46963925b53cb3b9e8538360c66a334adba487b4a065ea01", + "11131aa556119bce1540e2820bf21925e5ee2ad16057a6ed3aca1ccb600697ae449bdd0b266838edfc8b02c82b01158035b041c3c844fc7995cc86ff5372749701" ] }, { - "address": "2msjbxGFo7PtTLpJifpee7fzR2tbxgVQ6s4", - "secret": "797843228be8f6ae3ed5436285e5559990b5abc265b11960ba6f26f281b20c41", - "public": "0240d53d4c20406753ac6237559fd5919e25c914350112edb3e1a08bc54895fe29", + "address": "25NJpLNrTci5BtBtLGzGzeU2ABvT9Nw4d3f", + "secret": "0d3ac7f674c3177de5555a6a0e7d97eca63651f686942111ecedbd00c586d03c", + "public": "02c18d3e9b15c91247a2c71ce8c2e27e1b008de4d17ffa388d34b35fb27f3ba1a7", "signatures": [ - "f9389ec97abee7e78737cefeb0c0a7a4d307c02efb4d8a6ac541e08bccf73ad211104196fdbd987ac8e918f7e549dd35861e0c1d1d1f44b2a0e71ec885955a0701", - "6fd2cc0d4992f3f363f53149fd44be984c926e5f5ebcbdf03bfdc79ac044ef3a38d3846a0a9d009eee4644c68263838788f505a6e79ac28b5458aa9983a5809400", - "b77391c16d122dc86a40bebd78ac7919a1e17da07de58cdd453336a487579a47043e96a132809407053c8973a94b7154175c3b0110285fb3edeac5eaa8a84f7901", - "27a4542c1bd4693731e16091fbb33f5b7db47193474da5acdaadf3361487cf3d78e224dd4e156933e9af2510a87d0529f615c0f94a2e1561b9e390373db2272100", - "e045a17098663e156e14b9fc80e8dd1dea0648dedc99334a83700e1a878f9207293087966f7a854001f91635208cdba711daf766b9f173d711e2d5c300b7911901", - "f46f6cc92c19892a718a20bf18166301641d5fd2eec3c8228b056e9c70c57b583f3d93778303bd3f36265046512bcca4d30a2123c6a514b72b55d2d4eecc4b1400", - "5bd207641775d1eaba267402ff5d4c42bb4b5d0c867ea0e50b3cbe456337e6ad6f4fc59bd00ff171458340f48f182124bbe9a7c39294114a73e900f0f421981300", - "392ba1fd0b0f3acb40aa48c634fef706e7f3360a91aabaed98983102f650c84013dd479b6d8bce0fb16c6273f9fc3e9956e139aab0742d479d7fab53743053da00", - "53683788db9667788a8b8feb968a3edb1ae53f3a688cb83146da311ea09a23473dda7cad3411e88a0bc77d6cbbf5723866d1b4f955a5992fb7067ec391e987a501", - "70e7145d11a1617a1c1403db669c4d0620592972cf1490e58c3e2b8c7a3e656604394d1fa41236dbd3b5497aced72968f6a0cf8fd0b328e8966628890ee352a901" + "459d02374af7e0547df8d3ac93bbbf477d9b13add08cea4a2c4a9d55e04bb9501ea2f10c8fc68cde1ad2539df321032fd2f2fe56b010a8afac91f65d63c1ab0900", + "da1e742628e40682df13b888c7b166220638af152120a18fbc3e41cfbc4a2b8c0fffda7514e1c84c0f9211e0efff55ef7699560e64bba76adee30f341f5edd5301", + "da1893f530c4fe952d2da3a56d7b5f40e29e24368c00bea9c6d1317287f646fa08d251e69052b97f7c1d4033936b00ade787de33e6fa8ef939ea4412fe96bfdb01", + "0b782c5ad45598c6678b11254821637c3aaee8c4677dcb38285793337df838924160101e905f89502d30ad3761b4894dad68b7d2601f949301ed5ae4079cbcb400", + "3355727fd4fc2342737c86fc1c01bff49cf1afe258a927064edfc48c2445582d1415b3c74fea1ad22c5d9df4bcb0a65f6e633b729dfe088b29041a013e67db6c01", + "c493605d78ca352ae5758c7b56e9d6b338411e2c78e3cf244df3f5182d55f8de32c3a8464e00de450320d6f62cbbf00719d34d9bd6262cae586befc2bcc0601300", + "833b50000dd4564746e3dd0a90023f5fc74eb443795d2f986a568196fd849fc41751145da01b8a6753867184e02da5e023b12b1638a06bc5e2821afce12c6ee200", + "fb702b3cfb5c4225e14a9f9c56e9959d6f73ad6b8cd17b127187127665e9ca035718e5c139fb2c495425bea29c9c65b2be97f4c642b0da60a37bd10d717ac9f900", + "2dedc42424ffa658049e251c9d0a690a31637f5353e5d1a0d423c1efa3c361fa47c54f642f1876b5089f7c059796579f4a556821f3aa2810678face35c8fe22401", + "6ab859b8b4cf7e047e1e0f8134655aec58c04d0ed86b909d4290c8c335fc9816591fa8236258144b5c4b44c8ce746a11b4e1cfb1b5a259c2ff3e3beeafa26c0c00" ] }, { - "address": "49iXrCpJMzkjCn4iLFFCnQ89q6HTquUb6y", - "secret": "d1d029299edd1cd977f5e99c1d532ce0672f4ade0c5432df5811f74fce3f2a3b", - "public": "026e03bc8d06421c86c1c651b205ae4584df5b32309feaef46e7f7492704d7211a", + "address": "21ryRMcQ4jvpDLv947JhNYFGhkBdPfTa7Ft", + "secret": "cce2107186b602a42f83bdd37870457404daf2d327c83f02422a381628d2350b", + "public": "0240ae55709e29278c3c5df3eba50d14caf9ef73cce3329c05c56595384e801a81", "signatures": [ - "5f0b8c42f84c57cf68469a31af9013a954132b4e9ae87ebb84cae3a52f5a08631c6791021b8a7c6be10321c0f86423325955eced554feb3ac7d6decb1864369001", - "820888903f388a82224d8082d60be02910382e10e4a87de53d0a37fa874c225479acac96e7d6455a73a9af38a6a33f405bb72e1a9d70eead3ab1f519e7cc572e01", - "d32343367540eca2270018b09b293e67546d61397ca4454bdb75430debc76fda77aea55c446444dcb86354591a8ca2acff7d24439ab508982fe59b9d2aaaf8aa00", - "241d3be0de0e2813c669f54085849b98b195329347e04e77f26538bdbf2c9d683dc94e6b5146d9b7748b6f38291df631eb1eb2dde9baadc18273bfb2a5229cf100", - "5e0a6fa58e277a0658b55d9634491e59aa981ea84c0e39c704dea418c8047f68616358458975d337a0cc62e9e48498534e19fada2645a20d5a3251513b0a3b8400", - "c2fbcfde34f51f1a609f0ce07e8d636e6cc3b3a1e47455b8beea8fec14e5de454e8af63e09dd5aa8269e961c9157773c677216d94c779f9d4a2e0425ddee762800", - "d75a38407b21c891e58ae8c1da6ca3d927e75ad782b3ed4d776fcbef4a63ec544ee53b80f59eda88b0d193b066e060b4354c6c616bdd134dc7470c7b37da42e600", - "07e0d11341c7f42cbe118e7512303f137c12d9fb7fad087a7386c2471562124019f5a9b24c206f98e4a41a1ff76abd0a2019d03b9c14430123afc6f461be45fb01", - "fcabbed28bd2e40119d6d3ecb0f166b96beec498085aeff4d328b452a41d35b637d0fa5d07898be5f9f43dfb2e656eaad04b6130cca2b1ce70a60871ad6b197b01", - "606fc7634282004e22a8f5aff77f2034ac6724068ea36e21a6986c71903fbd2216c3e596563b8f6836169771b8e40f11ebd61e95bd31a016e51d3f4e5c3a8d5301" + "f59f660e8a14a0ce2b5c866a077ba83529b466658293067c6d16bc3ca1bb512c1cb4923fd4011e23ab572714b7dae244cbbec5518570ca3978a04902adcc183f00", + "e4ac4e486160881d9ba88c70a3aec2c5b0df4e56b1dfaa8212be1e5ed52a2ac36495d35e71791418948689e551886704fd669b2981edb13a8b4b2f385ad301ed01", + "517f2f1532c4986176854141b4a1fd4da24f1a7824a534e1dfa7430d6c6bcff66808f8bd72223a4a8caaf636f4408744372bfe2bdab86eb7c86f862dca40a53200", + "9d597dac44c1dae6b8d940ff6fc61474f6109b07cd4cf036f1c04702c5de5c613b09c0610da9a80f386d2dab714d72b804b0f4404a59d03f8fa63dd9738ed1d301", + "67b3708f680fc77279d0c1e7e65ee6b009223f83d63be3cf3bd2f050110222ac7b069b8fa6fe51bcd18f8332e3696e89ed759eb6d3b01f6a47de09cf1f929a3801", + "c6ba13f4754a3378272eb6ef0bb8543c1c821cbac252cdb23ea3a5687e4672ab6e9f9ebba8f77c2d0805f4c72f81455ae5e91d5669c48cedef9ecc0eb7fce1fc00", + "9db0cf266b02ffc7715d53796c871f0b6cbd221d1d8e6da6dada54198348c4c446b8c2a77ae8f2734ef4209caba8173c86fbe7ea4393cc53021e1e0ff7b5940d01", + "2eaa229d2fddd9dcad651f375202e71168be4b350a1e897b1fe2f27f8660e60131129a497d90254832045c830971578e0f7c1c963b75ada05e7589679fa23c9901", + "36a806424d934f5200b94d16a531d8375bd75183e72b9fc060b3868610930b411e298110ce7d0fd6a3325d83b896cd224c9cb293054553b7a7b3035aaadc39c901", + "5d660629134419b57f48ffea9756105649061067178059caab7c4d285e6a4ba572565e9b7aa7fc8700536e25d7c0dc04ebbe6d50647af58c04e7347d9b3557c601" ] }, { - "address": "Yj4Q9d9tN813tg6HnnA3d5Lm4y5nhuVNdX", - "secret": "2d06cf8416a4c54ebd313579673ffc7683490666e4f13b0d6a532329f02b9d8a", - "public": "02bf626a5fca30181df82e291a4ea66f670361b78b49388ab44e62c7f1239d1306", + "address": "2UpJ9CTUUzbSjSfByhiYG7TDuHpyuRCXmjN", + "secret": "01776da713f58690c4ba654afa403ee43527a3697b32c898164b1739b1a8307e", + "public": "03b8f7b20aa8cbdb7b40de6426fcb4a5eb2517dbfbc6e532ec1612341b51a234e8", "signatures": [ - "0a95e58a6d973fd2c90e4ea884b8eca09c45f9f8a4c00e9ae6365e4c36611c125b3e0651f39d1400c1d759764a774b6d35a3e6b716ebe346cf84b993d29c087000", - "0048af236d9ea0112a9c6c26ae6bb36e69cf243ae65d3ec23a92d11e082442635e28a1bee2ddaa043c876efaed676585d37c8e7f2349bda2d0967e182255e5d201", - "8491a7d0d0e4f7b3949cf8461125492a2f4116b808c914a7fbba3e12a53e61e529fe901f443d1c4733f1e79deff85cba0b1f27b273769503966609899fc57d1a01", - "5093d4dfe2886f2107c6482fbcf4d5c6d8b35f8c645a149ce833decba55718b24c9e84192a01bb10c0f46d294ab05b9cebcef60f15cc98f47007609fd077006201", - "6acddf6ad7bb85e1737125367a965bad8c2fa1dd103f0f36560311da4a1aed2d53369ce516402a1d0af93af0c3c44e4af501f37994683a025c8b1508a852961501", - "802a7e248440d40031bd721439db1b37c5babf144fafab44cb7fdaa337ea22043d88add11e1a7fb66f812b5ecd12432f4ab34d4ab166bfe019ece403270153b401", - "c377962aa91f34af8cc69876d275d272c7e34827ff0b9cda68dd5a0ec5ec94ee7f6cd9a797989df22328c879a618bbb786d0c6e233a1ac8bd586751ecebed41500", - "1abeb311d0ed5b2b6fff596909d5eda550672b6055149d8afa447ca8b6db9a9b1223b5654acccef97e81e1b940072493f8f7e31b94457ae252ea41cbe011b28100", - "12363a14975902af213a7681a998b21632a9ce04e841af5f2c0c91dcb4e9254503b4aefa1dd537c48447da3852357f5ac09e13817130922a66cce57f834d3a9500", - "ef178847041446498c99575728c890d4e520928796f61c95efee1f0eeb73f6ff7a3678a9fdd96fd1c030822994d1cd26c1d88ceaec2d85e94d4d11f82567de0a00" + "7fc7d6a44b4368ee439be43108306c1b78c90f401b7bf5806dea4793ed5941fe67c3fc8700751e21841c16b37f1a22d7ef354b85b39e73dbd38dac6c1d76dd8a01", + "5e634789d9dd8748ce83b5a173ec580a2e2483170f10e391b37e71fa1a0513d7407089d0e3ff410d122518b7ccaad7f39d3e6d87fc731259ab162e2e65eb2e3e00", + "15ba0d2d44d9ba95ff5477275b646d6fd129454a364feccc96eadda27666c2a9419453e2e9fe6890037dbc14d347813ba3cac14bdf11b33dc388466eeacacaa801", + "de5a67850d94ad5183c032b75255de8d125acb9ab613c3a678aa4b0bef2205fb0067b51ba705b25038619a4d99be5f9b6144beb0e758a070e0a5781d1f3d793501", + "60f137a5017662523950c544b23334d98f4ddd044d9ed1d9ae529394431f00883bb79088b7fa127a679a2998dd1bbec57aaa1e9abcb803540e520414ce69760b01", + "273cad4820707e6af38d07e847a579f297200cb567fae62c69ca68cdc0d32c5d7b365b2e8c74d74d802874fa98ba3d1d342246989d56eed0d876e4373cd82a5900", + "7ccf9b45d6368690c145d62acb788b8e1d0c555e8a8e3e3d396ba7f3cdf9fe7b3bad3bdbbc3bf26f5f07a9d7cffedd5f54fff4d06f7354fe60baae6498f0325801", + "c38ea111a10d599bee668edef517315c5a3a960fd38258578033ff9b8a92b9c2443e5dab03a7fa5596280b5aa8fda6c6cc0feb5c921d8cba90ba897d0e61c3b800", + "1268fee5962b4b33fe144373ecbbcf5a4524adec330e46144de4d5de7d7f45f64f26531869aea55eff07b8ab76a6b4c27e7e0582bc5bf2d0e31cca5c82bd60f500", + "7bcf7fd288b4f734ff16fe8c49682997126350fbd5df9537c009995a0859f8ce30c4748c4965c144c415af1f8434e4e2ec1023ca00cc793c55505c7fb4e4f94800" ] }, { - "address": "2QoDVDwqzEkMRhCSEdc31jDBXJHpeKiq1NU", - "secret": "6c7cc328e2622a27234af289516a263e1888d443bd8c5a89e4fce2294b633f8b", - "public": "02834299653a6542c23ab24042738b3142dcfca35ac7036914e6c3d514aa4d3569", + "address": "kwyudpCciG9nTC98vz8b3qrQM9DP2pn9wx", + "secret": "3bfecb42d2aa5f86043bf61ebb1ffcc52c3355e0cb5866cc6d4db80d467b5387", + "public": "021d7c5180dffb1d3e65a341525fe952d65627bb1e4d881777b278665b138419d1", "signatures": [ - "0f11216d8b87acd27ba06f15d23b68390012fec4ff9c8b04df08c1310b1d1db519dac7d3361bc2f81704a23eb2833351f9a14b10b8d27fdacbc81a75dcb8107300", - "7f025e3745c1b82b8ef1d28ce4738dbbe322fa580f7cf00a31f8c3b773ae3fc8391dc59060ae3c42e1e74131c73b159c811614a592e67905440de449a09d844500", - "78bad7cfec7eef89b6c31ce4b0c786e63fa4115f1a04998a1962b42c8fa6d5de717bb43338b520d4d0e99af832317547ae721e401faa29547b99972de218568500", - "9184e48397500e3ac01a67e5f6bb077a972ec54739e8256a8b19666fdea0baa7489a470f6935558b3c7643f0acbf1265e5e54b21e9c61225c6ad43887b11280d01", - "951f89d7d94ec77eec4a0d2852d53feef1366410446bd6f85dd5e01ca30547410669244594095ab7a7e8749ad73f1c92f808bb93f9798ba0d50028a49b1665a601", - "1760ee3f92b9a0e5047230c5bb0ef47ab2a930c45032c0e80e55162c188a2fb500253a1c75bd2fe9b8120c40b40a53eb896d6ccb66a872c74de12d2b6f7805b401", - "13ba19705bcb672f94495059b4deafd03748748a0717cff047434fe035607f511747e83234df69306210a7f375870d91beb6eccf9f0abb14046a686d0a9c88a900", - "b82b3bb252fa2f90d57c2f6036896573bb062c6bd7b9570a6f02796ed4b687b939eced4bbf72849a74af5472c9a380814565695d18819fab14797aef755327b400", - "71a71d4dce787b5d0948467471a123bcebb16424a58767257406cd883ad7a7652600e712a77c64b9887a3740a43ed47811764491f62e5156d3d55ca825294adb01", - "fe873610021d5def7ca0a71d144a89527db826aeb2cb07a64b3fa40e01f9020918a4c87d321b30da5ae8dd1d57d43e9ab609e8854004809e13fc43e2108e223d01" + "d8fd20b09ef6f55bf0d668e9d70c42906c54551357122c363d1c8dfd427cb1fd157a47ba228f011e4654b94ac08239ffc955174c0b3123cd445c964ee81e3d3f01", + "40b439422c0be6b652784484e3f760dbe243d2e0639cc2d0b26405615142a3625c1bdd3b088e1444b6f350a01c3ea58439938d01dd0e5b7c840c81f47722b6c601", + "b79308cd0df36560badef6f66fc137a98d0ec27bd5be97b5b83ad94b7d26d94471c3b1d8814008c41524a204aadf208bef1deec1b4019720d2a751455b9d1eea01", + "5a286c751257180a33677d22ea8c66cb457436dd54babe3cdebdf932f6da769b24f99f6cbddfcdffb2d4b5a810431f412737d5bfb9f0de42808d926561b557f301", + "bd066317a372c59468c72f9aae202fe7a5f2f954058ced864b31523961068e0a1bc7e10fcee9ec16cf44580e4d3e7f6194b74dbd6bcf4cd1c5a35640b56293f601", + "cd6fef0e0329f7c11a1785c9b0788ba8be92a5d063486872ab8e85bedd9749995166dde4562ceab241e97f9441e9bb73c54eae7dc3eebea7cac286955ad9016300", + "a5656209f4e0d02c32c38322296de87bdd9688d560dd1d46025929f9a8adc3dc7cbd5127f06c58caf405c8e4c8add84e7e9319aef965e85f7c658173001b8c2f01", + "f3f53b4e7def065704eaf65ff500d33b0522524eb240ecd68d149902334d653a25ec6be35ff944478a852fbc74657d4c6e1c3caef0a525161dbc1b124920cd5000", + "14315ad0efe67c42a7c78da6b84709b22ed187d9417fd2639c88a8f5badf411b0c9ff5ff0420c05d63eb55ce98c743b8e74f73d100cf236cc30b4b397e25a13a01", + "8cd16c423b8ddb65d690651975404a6ead1c8bec450e24181e6c1f1ff914313f2744980e4a3f37977b91133c0c87430156073ef8f523a160e3f266eaa9d4e39100" ] } ] diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index cb9b9cac12..7e785394f8 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -53,6 +53,11 @@ var ( ErrDisconnectMaxDefaultConnectionReached = errors.New("Maximum number of default connections was reached") // ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed ErrDisconnectMaxOutgoingConnectionsReached gnet.DisconnectReason = errors.New("Maximum outgoing connections was reached") + // ErrDisconnectBlockchainPubkeyNotMatched is returned when the blockchain pubkey in introduction does not match + ErrDisconnectBlockchainPubkeyNotMatched gnet.DisconnectReason = errors.New("Blockchain pubkey in Introduction message is not matched ") + // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. + // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey + ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") logger = logging.MustGetLogger("daemon") ) @@ -126,6 +131,8 @@ type DaemonConfig struct { // nolint: golint Version int32 // IP Address to serve on. Leave empty for automatic assignment Address string + // BlockchainPubkey blockchain pubkey string + BlockchainPubkey cipher.PubKey // TCP/UDP port for connections Port int // Directory where application data is stored @@ -202,6 +209,41 @@ func NewDaemonConfig() DaemonConfig { } } +//go:generate go install +//go:generate goautomock -template=testify Daemoner + +// Daemoner Daemon interface +type Daemoner interface { + SendMessage(addr string, msg gnet.Message) error + BroadcastMessage(msg gnet.Message) error + Disconnect(addr string, r gnet.DisconnectReason) error + IsDefaultConnection(addr string) bool + IsMaxDefaultConnectionsReached() (bool, error) + PexConfig() pex.Config + RandomExchangeable(n int) pex.Peers + AddPeer(addr string) error + AddPeers(addrs []string) int + SetHasIncomingPort(addr string) error + IncreaseRetryTimes(addr string) + ResetRetryTimes(addr string) + RecordPeerHeight(addr string, height uint64) + GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) + HeadBkSeq() (uint64, bool, error) + ExecuteSignedBlock(b coin.SignedBlock) error + GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) + GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) + InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) + Mirror() uint32 + DaemonConfig() DaemonConfig + BlockchainPubkey() cipher.PubKey + RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error + RecordConnectionMirror(addr string, mirror uint32) error + GetMirrorPort(addr string, mirror uint32) (uint16, bool) + RemoveFromExpectingIntroductions(addr string) + RequestBlocksFromAddr(addr string) error + AnnounceAllTxns() error +} + // Daemon stateful properties of the daemon type Daemon struct { // Daemon configuration @@ -209,10 +251,10 @@ type Daemon struct { // Components Messages *Messages - Pool *Pool - Pex *pex.Pex + pool *Pool + pex *pex.Pex Gateway *Gateway - Visor *visor.Visor + visor *visor.Visor DefaultConnections []string @@ -272,8 +314,8 @@ func NewDaemon(config Config, db *dbutil.DB, defaultConns []string) (*Daemon, er d := &Daemon{ Config: config.Daemon, Messages: NewMessages(config.Messages), - Pex: pex, - Visor: vs, + pex: pex, + visor: vs, DefaultConnections: defaultConns, @@ -299,7 +341,7 @@ func NewDaemon(config Config, db *dbutil.DB, defaultConns []string) (*Daemon, er d.Gateway = NewGateway(config.Gateway, d) d.Messages.Config.Register() - d.Pool = NewPool(config.Pool, d) + d.pool = NewPool(config.Pool, d) return d, nil } @@ -340,13 +382,13 @@ func (dm *Daemon) Shutdown() { close(dm.quit) logger.Info("Shutting down Pool") - dm.Pool.Shutdown() + dm.pool.Shutdown() logger.Info("Shutting down Gateway") dm.Gateway.Shutdown() logger.Info("Shutting down Pex") - dm.Pex.Shutdown() + dm.pex.Shutdown() <-dm.done } @@ -357,7 +399,7 @@ func (dm *Daemon) Run() error { defer logger.Info("Daemon closed") defer close(dm.done) - if err := dm.Visor.Init(); err != nil { + if err := dm.visor.Init(); err != nil { logger.WithError(err).Error("visor.Visor.Init failed") return err } @@ -368,7 +410,7 @@ func (dm *Daemon) Run() error { wg.Add(1) go func() { defer wg.Done() - if err := dm.Pex.Run(); err != nil { + if err := dm.pex.Run(); err != nil { logger.WithError(err).Error("daemon.Pex.Run failed") errC <- err } @@ -378,12 +420,12 @@ func (dm *Daemon) Run() error { go func() { defer wg.Done() if dm.Config.DisableIncomingConnections { - if err := dm.Pool.RunOffline(); err != nil { + if err := dm.pool.RunOffline(); err != nil { logger.WithError(err).Error("daemon.Pool.RunOffline failed") errC <- err } } else { - if err := dm.Pool.Run(); err != nil { + if err := dm.pool.Run(); err != nil { logger.WithError(err).Error("daemon.Pool.Run failed") errC <- err } @@ -392,7 +434,7 @@ func (dm *Daemon) Run() error { blockInterval := time.Duration(dm.Config.BlockCreationInterval) blockCreationTicker := time.NewTicker(time.Second * blockInterval) - if !dm.Visor.Config.IsMaster { + if !dm.visor.Config.IsMaster { blockCreationTicker.Stop() } @@ -404,9 +446,9 @@ func (dm *Daemon) Run() error { privateConnectionsTicker := time.Tick(dm.Config.PrivateRate) cullInvalidTicker := time.Tick(dm.Config.CullInvalidRate) outgoingConnectionsTicker := time.Tick(dm.Config.OutgoingRate) - requestPeersTicker := time.Tick(dm.Pex.Config.RequestRate) - clearStaleConnectionsTicker := time.Tick(dm.Pool.Config.ClearStaleRate) - idleCheckTicker := time.Tick(dm.Pool.Config.IdleCheckRate) + requestPeersTicker := time.Tick(dm.pex.Config.RequestRate) + clearStaleConnectionsTicker := time.Tick(dm.pool.Config.ClearStaleRate) + idleCheckTicker := time.Tick(dm.pool.Config.IdleCheckRate) flushAnnouncedTxnsTicker := time.Tick(dm.Config.FlushAnnouncedTxnsRate) @@ -437,7 +479,7 @@ func (dm *Daemon) Run() error { case <-dm.quit: break loop - case r := <-dm.Pool.Pool.SendResults: + case r := <-dm.pool.Pool.SendResults: // Process message sending results elapser.Register("dm.Pool.Pool.SendResults") if dm.Config.DisableNetworking { @@ -466,16 +508,16 @@ loop: case <-requestPeersTicker: // Request peers via PEX elapser.Register("requestPeersTicker") - if dm.Pex.Config.Disabled { + if dm.pex.Config.Disabled { continue } - if dm.Pex.IsFull() { + if dm.pex.IsFull() { continue } m := NewGetPeersMessage() - if err := dm.Pool.Pool.BroadcastMessage(m); err != nil { + if err := dm.pool.Pool.BroadcastMessage(m); err != nil { logger.Error(err) } @@ -483,20 +525,20 @@ loop: // Remove connections that haven't said anything in a while elapser.Register("clearStaleConnectionsTicker") if !dm.Config.DisableNetworking { - dm.Pool.clearStaleConnections() + dm.pool.clearStaleConnections() } case <-idleCheckTicker: // Sends pings as needed elapser.Register("idleCheckTicker") if !dm.Config.DisableNetworking { - dm.Pool.sendPings() + dm.pool.sendPings() } case <-outgoingConnectionsTicker: // Fill up our outgoing connections elapser.Register("outgoingConnectionsTicker") - trustPeerNum := len(dm.Pex.Trusted()) + trustPeerNum := len(dm.pex.Trusted()) if !dm.Config.DisableOutgoingConnections && dm.outgoingConnections.Len() < (dm.Config.OutgoingMax+trustPeerNum) && dm.pendingConnections.Len() < dm.Config.PendingMax { @@ -543,7 +585,7 @@ loop: elapser.Register("flushAnnouncedTxnsTicker") txns := dm.announcedTxns.flush() - if err := dm.Visor.SetTxnsAnnounced(txns); err != nil { + if err := dm.visor.SetTxnsAnnounced(txns); err != nil { logger.WithError(err).Error("Failed to set unconfirmed txn announce time") return err } @@ -565,7 +607,7 @@ loop: case <-blockCreationTicker.C: // Create blocks, if master chain elapser.Register("blockCreationTicker.C") - if dm.Visor.Config.IsMaster { + if dm.visor.Config.IsMaster { sb, err := dm.CreateAndPublishBlock() if err != nil { logger.Errorf("Failed to create and publish block: %v", err) @@ -580,7 +622,7 @@ loop: case <-unconfirmedRefreshTicker: elapser.Register("unconfirmedRefreshTicker") // Get the transactions that turn to valid - validTxns, err := dm.Visor.RefreshUnconfirmed() + validTxns, err := dm.visor.RefreshUnconfirmed() if err != nil { logger.Errorf("dm.Visor.RefreshUnconfirmed failed: %v", err) continue @@ -591,7 +633,7 @@ loop: case <-unconfirmedRemoveInvalidTicker: elapser.Register("unconfirmedRemoveInvalidTicker") // Remove transactions that become invalid (violating hard constraints) - removedTxns, err := dm.Visor.RemoveInvalidUnconfirmed() + removedTxns, err := dm.visor.RemoveInvalidUnconfirmed() if err != nil { logger.Errorf("dm.Visor.RemoveInvalidUnconfirmed failed: %v", err) continue @@ -656,7 +698,7 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { return errors.New("Not localhost") } - conned, err := dm.Pool.Pool.IsConnExist(p.Addr) + conned, err := dm.pool.Pool.IsConnExist(p.Addr) if err != nil { return err } @@ -676,7 +718,7 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { logger.Debugf("Trying to connect to %s", p.Addr) dm.pendingConnections.Add(p.Addr, p) go func() { - if err := dm.Pool.Pool.Connect(p.Addr); err != nil { + if err := dm.pool.Pool.Connect(p.Addr); err != nil { dm.connectionErrors <- ConnectionError{p.Addr, err} } }() @@ -689,7 +731,7 @@ func (dm *Daemon) makePrivateConnections() { return } - peers := dm.Pex.Private() + peers := dm.pex.Private() for _, p := range peers { logger.Infof("Private peer attempt: %s", p.Addr) if err := dm.connectToPeer(p); err != nil { @@ -705,7 +747,7 @@ func (dm *Daemon) connectToTrustPeer() { logger.Info("Connect to trusted peers") // Make connections to all trusted peers - peers := dm.Pex.TrustedPublic() + peers := dm.pex.TrustedPublic() for _, p := range peers { dm.connectToPeer(p) } @@ -718,12 +760,12 @@ func (dm *Daemon) connectToRandomPeer() { } // Make a connection to a random (public) peer - peers := dm.Pex.RandomPublic(dm.Config.OutgoingMax) + peers := dm.pex.RandomPublic(dm.Config.OutgoingMax) for _, p := range peers { // Check if the peer has public port if p.HasIncomingPort { // Try to connect the peer if it's ip:mirror does not exist - if _, exist := dm.getMirrorPort(p.Addr, dm.Messages.Mirror); !exist { + if _, exist := dm.GetMirrorPort(p.Addr, dm.Messages.Mirror); !exist { dm.connectToPeer(p) continue } @@ -735,7 +777,7 @@ func (dm *Daemon) connectToRandomPeer() { if len(peers) == 0 { // Reset the retry times of all peers, - dm.Pex.ResetAllRetryTimes() + dm.pex.ResetAllRetryTimes() } } @@ -745,7 +787,7 @@ func (dm *Daemon) handleConnectionError(c ConnectionError) { logger.Debugf("Failed to connect to %s with error: %v", c.Addr, c.Error) dm.pendingConnections.Remove(c.Addr) - dm.Pex.IncreaseRetryTimes(c.Addr) + dm.pex.IncreaseRetryTimes(c.Addr) } // Removes unsolicited connections who haven't sent a version @@ -755,7 +797,7 @@ func (dm *Daemon) cullInvalidConnections() { now := utc.Now() addrs, err := dm.expectingIntroductions.CullInvalidConns( func(addr string, t time.Time) (bool, error) { - conned, err := dm.Pool.Pool.IsConnExist(addr) + conned, err := dm.pool.Pool.IsConnExist(addr) if err != nil { return false, err } @@ -781,7 +823,7 @@ func (dm *Daemon) cullInvalidConnections() { } for _, a := range addrs { - exist, err := dm.Pool.Pool.IsConnExist(a) + exist, err := dm.pool.Pool.IsConnExist(a) if err != nil { logger.Error(err) return @@ -789,17 +831,17 @@ func (dm *Daemon) cullInvalidConnections() { if exist { logger.Infof("Removing %s for not sending a version", a) - if err := dm.Pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { + if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { logger.Error(err) return } - dm.Pex.RemovePeer(a) + dm.pex.RemovePeer(a) } } } func (dm *Daemon) isTrustedPeer(addr string) bool { - peer, ok := dm.Pex.GetPeerByAddr(addr) + peer, ok := dm.pex.GetPeerByAddr(addr) if !ok { return false } @@ -807,9 +849,9 @@ func (dm *Daemon) isTrustedPeer(addr string) bool { return peer.Trusted } -// Records an AsyncMessage to the messageEvent chan. Do not access +// RecordMessageEvent records an AsyncMessage to the messageEvent chan. Do not access // messageEvent directly. -func (dm *Daemon) recordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error { +func (dm *Daemon) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error { dm.messageEvents <- MessageEvent{m, c} return nil } @@ -831,7 +873,7 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { if dm.needsIntro(e.Context.Addr) { _, isIntro := e.Message.(*IntroductionMessage) if !isIntro { - dm.Pool.Pool.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction) + dm.pool.Pool.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction) } } e.Message.Process(dm) @@ -849,7 +891,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.pendingConnections.Remove(a) - exist, err := dm.Pool.Pool.IsConnExist(a) + exist, err := dm.pool.Pool.IsConnExist(a) if err != nil { logger.Error(err) return @@ -862,7 +904,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { if dm.ipCountMaxed(a) { logger.Infof("Max connections for %s reached, disconnecting", a) - dm.Pool.Pool.Disconnect(a, ErrDisconnectIPLimitReached) + dm.pool.Pool.Disconnect(a, ErrDisconnectIPLimitReached) return } @@ -870,7 +912,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { if e.Solicited { // Disconnect if the max outgoing connections is reached - n, err := dm.Pool.Pool.OutgoingConnectionsNum() + n, err := dm.pool.Pool.OutgoingConnectionsNum() if err != nil { logger.WithError(err).Error("get outgoing connections number failed") return @@ -878,7 +920,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { if n > dm.Config.OutgoingMax { logger.Warningf("max outgoing connections is reached, disconnecting %v", a) - dm.Pool.Pool.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached) + dm.pool.Pool.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached) return } @@ -887,8 +929,9 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.expectingIntroductions.Add(a, utc.Now()) logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.Version, dm.Pool.Pool.Config.Port) - if err := dm.Pool.Pool.SendMessage(a, m); err != nil { + // TODO: replace the last paramenter of nil with dm.Config.BlockchainPubkey in v25 + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.Version, dm.pool.Pool.Config.Port, nil) + if err := dm.pool.Pool.SendMessage(a, m); err != nil { logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) } } @@ -955,11 +998,11 @@ func (dm *Daemon) removeIPCount(addr string) { dm.ipCounts.Decrease(ip) } -// Adds addr + mirror to the connectionMirror mappings -func (dm *Daemon) recordConnectionMirror(addr string, mirror uint32) error { +// RecordConnectionMirror adds addr + mirror to the connectionMirror mappings +func (dm *Daemon) RecordConnectionMirror(addr string, mirror uint32) error { ip, port, err := iputil.SplitAddr(addr) if err != nil { - logger.Warningf("recordConnectionMirror called with invalid addr: %v", err) + logger.Warningf("RecordConnectionMirror called with invalid addr: %v", err) return err } dm.connectionMirrors.Add(addr, mirror) @@ -985,8 +1028,8 @@ func (dm *Daemon) removeConnectionMirror(addr string) { dm.connectionMirrors.Remove(addr) } -// Returns whether an addr+mirror's port and whether the port exists -func (dm *Daemon) getMirrorPort(addr string, mirror uint32) (uint16, bool) { +// GetMirrorPort returns whether an addr+mirror's port and whether the port exists +func (dm *Daemon) GetMirrorPort(addr string, mirror uint32) (uint16, bool) { ip, _, err := iputil.SplitAddr(addr) if err != nil { logger.Warningf("getMirrorPort called with invalid addr: %v", err) @@ -1016,7 +1059,7 @@ func (dm *Daemon) RequestBlocks() error { return nil } - headSeq, ok, err := dm.Visor.HeadBkSeq() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { return err } @@ -1026,7 +1069,7 @@ func (dm *Daemon) RequestBlocks() error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - err = dm.Pool.Pool.BroadcastMessage(m) + err = dm.pool.Pool.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast GetBlocksMessage failed: %v", err) } @@ -1040,7 +1083,7 @@ func (dm *Daemon) AnnounceBlocks() error { return nil } - headSeq, ok, err := dm.Visor.HeadBkSeq() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { return err } @@ -1050,7 +1093,7 @@ func (dm *Daemon) AnnounceBlocks() error { m := NewAnnounceBlocksMessage(headSeq) - err = dm.Pool.Pool.BroadcastMessage(m) + err = dm.pool.Pool.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast AnnounceBlocksMessage failed: %v", err) } @@ -1065,7 +1108,7 @@ func (dm *Daemon) AnnounceAllTxns() error { } // Get local unconfirmed transaction hashes. - hashes, err := dm.Visor.GetAllValidUnconfirmedTxHashes() + hashes, err := dm.visor.GetAllValidUnconfirmedTxHashes() if err != nil { return err } @@ -1075,7 +1118,7 @@ func (dm *Daemon) AnnounceAllTxns() error { for _, hs := range hashesSet { m := NewAnnounceTxnsMessage(hs) - if err = dm.Pool.Pool.BroadcastMessage(m); err != nil { + if err = dm.pool.Pool.BroadcastMessage(m); err != nil { break } } @@ -1124,7 +1167,7 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { m := NewAnnounceTxnsMessage(txns) - err := dm.Pool.Pool.BroadcastMessage(m) + err := dm.pool.Pool.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast AnnounceTxnsMessage failed: %v", err) } @@ -1138,7 +1181,7 @@ func (dm *Daemon) RequestBlocksFromAddr(addr string) error { return errors.New("Outgoing connections disabled") } - headSeq, ok, err := dm.Visor.HeadBkSeq() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { return err } @@ -1148,7 +1191,7 @@ func (dm *Daemon) RequestBlocksFromAddr(addr string) error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - return dm.Pool.Pool.SendMessage(addr, m) + return dm.pool.Pool.SendMessage(addr, m) } // InjectBroadcastTransaction injects transaction to the unconfirmed pool and broadcasts it. @@ -1157,7 +1200,7 @@ func (dm *Daemon) RequestBlocksFromAddr(addr string) error { // For transactions received over the network, use InjectTransaction and check the result to // decide on repropagation. func (dm *Daemon) InjectBroadcastTransaction(txn coin.Transaction) error { - if _, err := dm.Visor.InjectTransactionStrict(txn); err != nil { + if _, err := dm.visor.InjectTransactionStrict(txn); err != nil { return err } @@ -1170,7 +1213,7 @@ func (dm *Daemon) ResendUnconfirmedTxns() ([]cipher.SHA256, error) { return nil, nil } - txns, err := dm.Visor.GetAllUnconfirmedTxns() + txns, err := dm.visor.GetAllUnconfirmedTxns() if err != nil { return nil, err } @@ -1193,14 +1236,14 @@ func (dm *Daemon) broadcastTransaction(t coin.Transaction) error { } m := NewGiveTxnsMessage(coin.Transactions{t}) - l, err := dm.Pool.Pool.Size() + l, err := dm.pool.Pool.Size() if err != nil { return err } logger.Debugf("Broadcasting GiveTxnsMessage to %d conns", l) - err = dm.Pool.Pool.BroadcastMessage(m) + err = dm.pool.Pool.BroadcastMessage(m) if err != nil { logger.Errorf("Broadcast GivenTxnsMessage failed: %v", err) } @@ -1220,7 +1263,7 @@ func (dm *Daemon) CreateAndPublishBlock() (*coin.SignedBlock, error) { return nil, errors.New("Outgoing connections disabled") } - sb, err := dm.Visor.CreateAndExecuteBlock() + sb, err := dm.visor.CreateAndExecuteBlock() if err != nil { return nil, err } @@ -1237,5 +1280,136 @@ func (dm *Daemon) broadcastBlock(sb coin.SignedBlock) error { } m := NewGiveBlocksMessage([]coin.SignedBlock{sb}) - return dm.Pool.Pool.BroadcastMessage(m) + return dm.pool.Pool.BroadcastMessage(m) +} + +// Mirror returns the message mirror +func (dm *Daemon) Mirror() uint32 { + return dm.Messages.Mirror +} + +// DaemonConfig returns the daemon config +func (dm *Daemon) DaemonConfig() DaemonConfig { + return dm.Config +} + +// BlockchainPubkey returns the blockchain pubkey +func (dm *Daemon) BlockchainPubkey() cipher.PubKey { + return dm.Config.BlockchainPubkey +} + +// RemoveFromExpectingIntroductions removes the peer from expect introduction pool +func (dm *Daemon) RemoveFromExpectingIntroductions(addr string) { + dm.expectingIntroductions.Remove(addr) +} + +// Implements pooler interface + +// SendMessage sends a Message to a Connection and pushes the result onto the +// SendResults channel. +func (dm *Daemon) SendMessage(addr string, msg gnet.Message) error { + return dm.pool.Pool.SendMessage(addr, msg) +} + +// BroadcastMessage sends a Message to all connections in the Pool. +func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { + return dm.pool.Pool.BroadcastMessage(msg) +} + +// Disconnect removes a connection from the pool by address, and passes a Disconnection to +// the DisconnectCallback +func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { + return dm.pool.Pool.Disconnect(addr, r) +} + +// IsDefaultConnection returns if the addr is a default connection +func (dm *Daemon) IsDefaultConnection(addr string) bool { + return dm.pool.Pool.IsDefaultConnection(addr) +} + +// IsMaxDefaultConnectionsReached returns whether the max default connection number was reached. +func (dm *Daemon) IsMaxDefaultConnectionsReached() (bool, error) { + return dm.pool.Pool.IsMaxDefaultConnReached() +} + +// Implements pexer interface + +// RandomExchangeable returns N random exchangeable peers +func (dm *Daemon) RandomExchangeable(n int) pex.Peers { + return dm.pex.RandomExchangeable(n) +} + +// PexConfig returns the pex config +func (dm *Daemon) PexConfig() pex.Config { + return dm.pex.Config +} + +// AddPeer adds peer to the pex +func (dm *Daemon) AddPeer(addr string) error { + return dm.pex.AddPeer(addr) +} + +// AddPeers adds peers to the pex +func (dm *Daemon) AddPeers(addrs []string) int { + return dm.pex.AddPeers(addrs) +} + +// SetHasIncomingPort sets the peer public peer +func (dm *Daemon) SetHasIncomingPort(addr string) error { + return dm.pex.SetHasIncomingPort(addr, true) +} + +// IncreaseRetryTimes increases the retry times of given peer +func (dm *Daemon) IncreaseRetryTimes(addr string) { + dm.pex.IncreaseRetryTimes(addr) +} + +// ResetRetryTimes reset the retry times of given peer +func (dm *Daemon) ResetRetryTimes(addr string) { + dm.pex.ResetRetryTimes(addr) +} + +// Implements chain height store + +// Record(addr string, height uint64) + +// RecordPeerHeight records the height of specific peer +func (dm *Daemon) RecordPeerHeight(addr string, height uint64) { + dm.Heights.Record(addr, height) +} + +// Implements visorer interface + +// GetSignedBlocksSince returns N signed blocks since given seq +func (dm *Daemon) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) { + return dm.visor.GetSignedBlocksSince(seq, count) +} + +// HeadBkSeq returns the head block sequence +func (dm *Daemon) HeadBkSeq() (uint64, bool, error) { + return dm.visor.HeadBkSeq() +} + +// ExecuteSignedBlock executes the signed block +func (dm *Daemon) ExecuteSignedBlock(b coin.SignedBlock) error { + return dm.visor.ExecuteSignedBlock(b) +} + +// GetUnconfirmedUnknown returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { + return dm.visor.GetUnconfirmedUnknown(txns) +} + +// GetUnconfirmedKnown returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { + return dm.visor.GetUnconfirmedKnown(txns) +} + +// InjectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not +// already in the blockchain. +// The bool return value is whether or not the transaction was already in the pool. +// If the transaction violates hard constraints, it is rejected, and error will not be nil. +// If the transaction only violates soft constraints, it is still injected, and the soft constraint violation is returned. +func (dm *Daemon) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { + return dm.visor.InjectTransaction(txn) } diff --git a/src/daemon/daemoner_mock_test.go b/src/daemon/daemoner_mock_test.go new file mode 100644 index 0000000000..756c7b5f4c --- /dev/null +++ b/src/daemon/daemoner_mock_test.go @@ -0,0 +1,568 @@ +/* +* CODE GENERATED AUTOMATICALLY WITH github.com/ernesto-jimenez/goautomock +* THIS FILE MUST NEVER BE EDITED MANUALLY + */ + +package daemon + +import ( + "fmt" + + mock "github.com/stretchr/testify/mock" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" + gnet "github.com/skycoin/skycoin/src/daemon/gnet" + pex "github.com/skycoin/skycoin/src/daemon/pex" + visor "github.com/skycoin/skycoin/src/visor" +) + +// DaemonerMock mock +type DaemonerMock struct { + mock.Mock +} + +func NewDaemonerMock() *DaemonerMock { + return &DaemonerMock{} +} + +// AddPeer mocked method +func (m *DaemonerMock) AddPeer(p0 string) error { + + ret := m.Called(p0) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// AddPeers mocked method +func (m *DaemonerMock) AddPeers(p0 []string) int { + + ret := m.Called(p0) + + var r0 int + switch res := ret.Get(0).(type) { + case nil: + case int: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// AnnounceAllTxns mocked method +func (m *DaemonerMock) AnnounceAllTxns() error { + + ret := m.Called() + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// BlockchainPubkey mocked method +func (m *DaemonerMock) BlockchainPubkey() cipher.PubKey { + + ret := m.Called() + + var r0 cipher.PubKey + switch res := ret.Get(0).(type) { + case nil: + case cipher.PubKey: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// BroadcastMessage mocked method +func (m *DaemonerMock) BroadcastMessage(p0 gnet.Message) error { + + ret := m.Called(p0) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// DaemonConfig mocked method +func (m *DaemonerMock) DaemonConfig() DaemonConfig { + + ret := m.Called() + + var r0 DaemonConfig + switch res := ret.Get(0).(type) { + case nil: + case DaemonConfig: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// Disconnect mocked method +func (m *DaemonerMock) Disconnect(p0 string, p1 gnet.DisconnectReason) error { + + ret := m.Called(p0, p1) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// ExecuteSignedBlock mocked method +func (m *DaemonerMock) ExecuteSignedBlock(p0 coin.SignedBlock) error { + + ret := m.Called(p0) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// GetMirrorPort mocked method +func (m *DaemonerMock) GetMirrorPort(p0 string, p1 uint32) (uint16, bool) { + + ret := m.Called(p0, p1) + + var r0 uint16 + switch res := ret.Get(0).(type) { + case nil: + case uint16: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 bool + switch res := ret.Get(1).(type) { + case nil: + case bool: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1 + +} + +// GetSignedBlocksSince mocked method +func (m *DaemonerMock) GetSignedBlocksSince(p0 uint64, p1 uint64) ([]coin.SignedBlock, error) { + + ret := m.Called(p0, p1) + + var r0 []coin.SignedBlock + switch res := ret.Get(0).(type) { + case nil: + case []coin.SignedBlock: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 error + switch res := ret.Get(1).(type) { + case nil: + case error: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1 + +} + +// GetUnconfirmedKnown mocked method +func (m *DaemonerMock) GetUnconfirmedKnown(p0 []cipher.SHA256) (coin.Transactions, error) { + + ret := m.Called(p0) + + var r0 coin.Transactions + switch res := ret.Get(0).(type) { + case nil: + case coin.Transactions: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 error + switch res := ret.Get(1).(type) { + case nil: + case error: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1 + +} + +// GetUnconfirmedUnknown mocked method +func (m *DaemonerMock) GetUnconfirmedUnknown(p0 []cipher.SHA256) ([]cipher.SHA256, error) { + + ret := m.Called(p0) + + var r0 []cipher.SHA256 + switch res := ret.Get(0).(type) { + case nil: + case []cipher.SHA256: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 error + switch res := ret.Get(1).(type) { + case nil: + case error: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1 + +} + +// HeadBkSeq mocked method +func (m *DaemonerMock) HeadBkSeq() (uint64, bool, error) { + + ret := m.Called() + + var r0 uint64 + switch res := ret.Get(0).(type) { + case nil: + case uint64: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 bool + switch res := ret.Get(1).(type) { + case nil: + case bool: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r2 error + switch res := ret.Get(2).(type) { + case nil: + case error: + r2 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1, r2 + +} + +// IncreaseRetryTimes mocked method +func (m *DaemonerMock) IncreaseRetryTimes(p0 string) { + + m.Called(p0) + +} + +// InjectTransaction mocked method +func (m *DaemonerMock) InjectTransaction(p0 coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { + + ret := m.Called(p0) + + var r0 bool + switch res := ret.Get(0).(type) { + case nil: + case bool: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 *visor.ErrTxnViolatesSoftConstraint + switch res := ret.Get(1).(type) { + case nil: + case *visor.ErrTxnViolatesSoftConstraint: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r2 error + switch res := ret.Get(2).(type) { + case nil: + case error: + r2 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1, r2 + +} + +// IsDefaultConnection mocked method +func (m *DaemonerMock) IsDefaultConnection(p0 string) bool { + + ret := m.Called(p0) + + var r0 bool + switch res := ret.Get(0).(type) { + case nil: + case bool: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// IsMaxDefaultConnectionsReached mocked method +func (m *DaemonerMock) IsMaxDefaultConnectionsReached() (bool, error) { + + ret := m.Called() + + var r0 bool + switch res := ret.Get(0).(type) { + case nil: + case bool: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + var r1 error + switch res := ret.Get(1).(type) { + case nil: + case error: + r1 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0, r1 + +} + +// Mirror mocked method +func (m *DaemonerMock) Mirror() uint32 { + + ret := m.Called() + + var r0 uint32 + switch res := ret.Get(0).(type) { + case nil: + case uint32: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// PexConfig mocked method +func (m *DaemonerMock) PexConfig() pex.Config { + + ret := m.Called() + + var r0 pex.Config + switch res := ret.Get(0).(type) { + case nil: + case pex.Config: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// RandomExchangeable mocked method +func (m *DaemonerMock) RandomExchangeable(p0 int) pex.Peers { + + ret := m.Called(p0) + + var r0 pex.Peers + switch res := ret.Get(0).(type) { + case nil: + case pex.Peers: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// RecordConnectionMirror mocked method +func (m *DaemonerMock) RecordConnectionMirror(p0 string, p1 uint32) error { + + ret := m.Called(p0, p1) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// RecordMessageEvent mocked method +func (m *DaemonerMock) RecordMessageEvent(p0 AsyncMessage, p1 *gnet.MessageContext) error { + + ret := m.Called(p0, p1) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// RecordPeerHeight mocked method +func (m *DaemonerMock) RecordPeerHeight(p0 string, p1 uint64) { + + m.Called(p0, p1) + +} + +// RemoveFromExpectingIntroductions mocked method +func (m *DaemonerMock) RemoveFromExpectingIntroductions(p0 string) { + + m.Called(p0) + +} + +// RequestBlocksFromAddr mocked method +func (m *DaemonerMock) RequestBlocksFromAddr(p0 string) error { + + ret := m.Called(p0) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// ResetRetryTimes mocked method +func (m *DaemonerMock) ResetRetryTimes(p0 string) { + + m.Called(p0) + +} + +// SendMessage mocked method +func (m *DaemonerMock) SendMessage(p0 string, p1 gnet.Message) error { + + ret := m.Called(p0, p1) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} + +// SetHasIncomingPort mocked method +func (m *DaemonerMock) SetHasIncomingPort(p0 string) error { + + ret := m.Called(p0) + + var r0 error + switch res := ret.Get(0).(type) { + case nil: + case error: + r0 = res + default: + panic(fmt.Sprintf("unexpected type: %v", res)) + } + + return r0 + +} diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 2fe414e1b1..7328ba9589 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -51,7 +51,7 @@ func NewGateway(c GatewayConfig, d *Daemon) *Gateway { return &Gateway{ Config: c, d: d, - v: d.Visor, + v: d.visor, requests: make(chan strand.Request, c.BufferSize), quit: make(chan struct{}), } @@ -103,18 +103,18 @@ func (gw *Gateway) GetConnections() *Connections { } func (gw *Gateway) getConnections() *Connections { - if gw.d.Pool.Pool == nil { + if gw.d.pool.Pool == nil { return nil } - n, err := gw.d.Pool.Pool.Size() + n, err := gw.d.pool.Pool.Size() if err != nil { logger.Error(err) return nil } conns := make([]*Connection, 0, n) - cs, err := gw.d.Pool.Pool.GetConnections() + cs, err := gw.d.pool.Pool.GetConnections() if err != nil { logger.Error(err) return nil @@ -158,11 +158,11 @@ func (gw *Gateway) GetConnection(addr string) *Connection { } func (gw *Gateway) getConnection(addr string) *Connection { - if gw.d.Pool.Pool == nil { + if gw.d.pool.Pool == nil { return nil } - c, err := gw.d.Pool.Pool.GetConnection(addr) + c, err := gw.d.pool.Pool.GetConnection(addr) if err != nil { logger.Error(err) return nil @@ -194,7 +194,7 @@ func (gw *Gateway) getConnection(addr string) *Connection { func (gw *Gateway) GetTrustConnections() []string { var conn []string gw.strand("GetTrustConnections", func() { - conn = gw.d.Pex.Trusted().ToAddrs() + conn = gw.d.pex.Trusted().ToAddrs() }) return conn } @@ -204,7 +204,7 @@ func (gw *Gateway) GetTrustConnections() []string { func (gw *Gateway) GetExchgConnection() []string { var conn []string gw.strand("GetExchgConnection", func() { - conn = gw.d.Pex.RandomExchangeable(0).ToAddrs() + conn = gw.d.pex.RandomExchangeable(0).ToAddrs() }) return conn } @@ -226,7 +226,7 @@ func (gw *Gateway) GetBlockchainProgress() (*BlockchainProgress, error) { var err error gw.strand("GetBlockchainProgress", func() { var headSeq uint64 - headSeq, _, err = gw.d.Visor.HeadBkSeq() + headSeq, _, err = gw.d.visor.HeadBkSeq() if err != nil { return } diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index 7656f8583a..e6fbd12399 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -56,13 +56,8 @@ func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { return nil, err } - if debugPrint { - mlen := len(msg) - if used > mlen { - logger.Warn("Receive data with extra fields") - } else if used < mlen { - logger.Warn("Receive data with fields removed") - } + if used != len(msg) { + return nil, errors.New("Data buffer was not completely decoded") } m, succ = (v.Interface()).(Message) diff --git a/src/daemon/gnet/dispatcher_test.go b/src/daemon/gnet/dispatcher_test.go index e3f5dbc152..d97e40d7a1 100644 --- a/src/daemon/gnet/dispatcher_test.go +++ b/src/daemon/gnet/dispatcher_test.go @@ -70,8 +70,8 @@ func TestConvertToMessageBadDeserialize(t *testing.T) { // Test with too many bytes b := append(DummyPrefix[:], []byte{0, 1, 1, 1}...) m, err := convertToMessage(c.ID, b, testing.Verbose()) - assert.Nil(t, err) - assert.NotNil(t, m) + assert.NotNil(t, err) + assert.Nil(t, m) // Test with not enough bytes b = append([]byte{}, BytePrefix[:]...) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 4be57a2609..3faed76535 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -132,7 +132,7 @@ func (ipa IPAddr) String() string { // Messages should place themselves on the messageEvent channel in their // Handle() method required by gnet. type AsyncMessage interface { - Process(d *Daemon) + Process(d Daemoner) } // GetPeersMessage sent to request peers @@ -151,23 +151,23 @@ func NewGetPeersMessage() *GetPeersMessage { func (gpm *GetPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { // self.connID = mc.ConnID gpm.addr = mc.Addr - return daemon.(*Daemon).recordMessageEvent(gpm, mc) + return daemon.(Daemoner).RecordMessageEvent(gpm, mc) } // Process Notifies the Pex instance that peers were requested -func (gpm *GetPeersMessage) Process(d *Daemon) { - if d.Pex.Config.Disabled { +func (gpm *GetPeersMessage) Process(d Daemoner) { + if d.PexConfig().Disabled { return } - peers := d.Pex.RandomExchangeable(d.Pex.Config.ReplyCount) + peers := d.RandomExchangeable(d.PexConfig().ReplyCount) if len(peers) == 0 { logger.Debug("We have no peers to send in reply") return } m := NewGivePeersMessage(peers) - if err := d.Pool.Pool.SendMessage(gpm.addr, m); err != nil { + if err := d.SendMessage(gpm.addr, m); err != nil { logger.Errorf("Send GivePeersMessage to %s failed: %v", gpm.addr, err) } } @@ -207,18 +207,18 @@ func (gpm *GivePeersMessage) GetPeers() []string { // Handle handle message func (gpm *GivePeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gpm.c = mc - return daemon.(*Daemon).recordMessageEvent(gpm, mc) + return daemon.(Daemoner).RecordMessageEvent(gpm, mc) } // Process Notifies the Pex instance that peers were received -func (gpm *GivePeersMessage) Process(d *Daemon) { - if d.Pex.Config.Disabled { +func (gpm *GivePeersMessage) Process(d Daemoner) { + if d.PexConfig().Disabled { return } peers := gpm.GetPeers() logger.Debugf("Got these peers via PEX: %s", strings.Join(peers, ", ")) - d.Pex.AddPeers(peers) + d.AddPeers(peers) } // IntroductionMessage jan IntroductionMessage is sent on first connect by both parties @@ -230,18 +230,20 @@ type IntroductionMessage struct { Port uint16 // Our client version Version int32 - - c *gnet.MessageContext `enc:"-"` + c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() valid bool `enc:"-"` // skip it during encoding + // Extra would be parsed as blockchain pubkey if it's not empty + Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message -func NewIntroductionMessage(mirror uint32, version int32, port uint16) *IntroductionMessage { +func NewIntroductionMessage(mirror uint32, version int32, port uint16, extra []byte) *IntroductionMessage { return &IntroductionMessage{ Mirror: mirror, Version: version, Port: port, + Extra: extra, } } @@ -249,27 +251,44 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16) *Introduc // need to control the DisconnectReason sent back to gnet. We still implement // Process(), where we do modifications that are not threadsafe func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - d := daemon.(*Daemon) + d := daemon.(Daemoner) err := func() error { // Disconnect if this is a self connection (we have the same mirror value) - if intro.Mirror == d.Messages.Mirror { + if intro.Mirror == d.Mirror() { logger.Infof("Remote mirror value %v matches ours", intro.Mirror) - d.Pool.Pool.Disconnect(mc.Addr, ErrDisconnectSelf) + d.Disconnect(mc.Addr, ErrDisconnectSelf) return ErrDisconnectSelf } // Disconnect if not running the same version - if intro.Version != d.Config.Version { + if intro.Version != d.DaemonConfig().Version { logger.Infof("%s has different version %d. Disconnecting.", mc.Addr, intro.Version) - d.Pool.Pool.Disconnect(mc.Addr, ErrDisconnectInvalidVersion) + d.Disconnect(mc.Addr, ErrDisconnectInvalidVersion) return ErrDisconnectInvalidVersion } logger.Infof("%s verified for version %d", mc.Addr, intro.Version) + // Checks the genesis hash if not empty + if len(intro.Extra) > 0 { + var bcPubKey cipher.PubKey + if len(intro.Extra) < len(bcPubKey) { + logger.Infof("Extra data length does not meet the minimum requirement") + d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData) + return ErrDisconnectInvalidExtraData + } + copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) + + if d.BlockchainPubkey() != bcPubKey { + logger.Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) + d.Disconnect(mc.Addr, ErrDisconnectBlockchainPubkeyNotMatched) + return ErrDisconnectBlockchainPubkeyNotMatched + } + } + // only solicited connection can be added to exchange peer list, cause accepted // connection may not have incomming port. ip, port, err := iputil.SplitAddr(mc.Addr) @@ -277,7 +296,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // This should never happen, but the program should still work if it // does. logger.Errorf("Invalid Addr() for connection: %s", mc.Addr) - d.Pool.Pool.Disconnect(mc.Addr, ErrDisconnectOtherError) + d.Disconnect(mc.Addr, ErrDisconnectOtherError) return ErrDisconnectOtherError } @@ -286,8 +305,8 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // connection's port is a random port, it's different from the port // in introduction message. if port == intro.Port { - if d.Pool.Pool.IsDefaultConnection(mc.Addr) { - reached, err := d.Pool.Pool.IsMaxDefaultConnReached() + if d.IsDefaultConnection(mc.Addr) { + reached, err := d.IsMaxDefaultConnectionsReached() if err != nil { logger.Errorf("Check IsMaxDefaultConnReached failed: %v", err) return err @@ -295,25 +314,25 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa if reached { logger.Debugf("Disconnect %s: maximum default connections reached ", mc.Addr) - d.Pool.Pool.Disconnect(mc.Addr, ErrDisconnectMaxDefaultConnectionReached) + d.Disconnect(mc.Addr, ErrDisconnectMaxDefaultConnectionReached) return ErrDisconnectMaxDefaultConnectionReached } } - if err := d.Pex.SetHasIncomingPort(mc.Addr, true); err != nil { + if err := d.SetHasIncomingPort(mc.Addr); err != nil { logger.Errorf("Failed to set peer has incoming port status, %v", err) } } else { - if err := d.Pex.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { + if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { logger.Errorf("Failed to add peer: %v", err) } } // Disconnect if connected twice to the same peer (judging by ip:mirror) - knownPort, exists := d.getMirrorPort(mc.Addr, intro.Mirror) + knownPort, exists := d.GetMirrorPort(mc.Addr, intro.Mirror) if exists { logger.Infof("%s is already connected on port %d", mc.Addr, knownPort) - d.Pool.Pool.Disconnect(mc.Addr, ErrDisconnectConnectedTwice) + d.Disconnect(mc.Addr, ErrDisconnectConnectedTwice) return ErrDisconnectConnectedTwice } return nil @@ -323,19 +342,19 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa intro.c = mc if err != nil { - d.Pex.IncreaseRetryTimes(mc.Addr) - d.expectingIntroductions.Remove(mc.Addr) + d.IncreaseRetryTimes(mc.Addr) + d.RemoveFromExpectingIntroductions(mc.Addr) return err } - err = d.recordMessageEvent(intro, mc) - d.Pex.ResetRetryTimes(mc.Addr) + err = d.RecordMessageEvent(intro, mc) + d.ResetRetryTimes(mc.Addr) return err } // Process an event queued by Handle() -func (intro *IntroductionMessage) Process(d *Daemon) { - d.expectingIntroductions.Remove(intro.c.Addr) +func (intro *IntroductionMessage) Process(d Daemoner) { + d.RemoveFromExpectingIntroductions(intro.c.Addr) if !intro.valid { return } @@ -343,12 +362,12 @@ func (intro *IntroductionMessage) Process(d *Daemon) { a := intro.c.Addr // Record their listener, to avoid double connections - err := d.recordConnectionMirror(a, intro.Mirror) + err := d.RecordConnectionMirror(a, intro.Mirror) if err != nil { // This should never happen, but the program should not allow itself // to be corrupted in case it does logger.Errorf("Invalid port for connection %s", a) - d.Pool.Pool.Disconnect(intro.c.Addr, ErrDisconnectOtherError) + d.Disconnect(intro.c.Addr, ErrDisconnectOtherError) return } @@ -372,15 +391,15 @@ type PingMessage struct { // Handle implements the Messager interface func (ping *PingMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { ping.c = mc - return daemon.(*Daemon).recordMessageEvent(ping, mc) + return daemon.(Daemoner).RecordMessageEvent(ping, mc) } // Process Sends a PongMessage to the sender of PingMessage -func (ping *PingMessage) Process(d *Daemon) { - if d.Config.LogPings { +func (ping *PingMessage) Process(d Daemoner) { + if d.DaemonConfig().LogPings { logger.Debugf("Reply to ping from %s", ping.c.Addr) } - if err := d.Pool.Pool.SendMessage(ping.c.Addr, &PongMessage{}); err != nil { + if err := d.SendMessage(ping.c.Addr, &PongMessage{}); err != nil { logger.Errorf("Send PongMessage to %s failed: %v", ping.c.Addr, err) } } @@ -418,20 +437,20 @@ func NewGetBlocksMessage(lastBlock uint64, requestedBlocks uint64) *GetBlocksMes func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gbm.c = mc - return daemon.(*Daemon).recordMessageEvent(gbm, mc) + return daemon.(Daemoner).RecordMessageEvent(gbm, mc) } // Process should send number to be requested, with request -func (gbm *GetBlocksMessage) Process(d *Daemon) { +func (gbm *GetBlocksMessage) Process(d Daemoner) { // TODO -- we need the sig to be sent with the block, but only the master // can sign blocks. Thus the sig needs to be stored with the block. - if d.Config.DisableNetworking { + if d.DaemonConfig().DisableNetworking { return } // Record this as this peer's highest block - d.Heights.Record(gbm.c.Addr, gbm.LastBlock) + d.RecordPeerHeight(gbm.c.Addr, gbm.LastBlock) // Fetch and return signed blocks since LastBlock - blocks, err := d.Visor.GetSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) + blocks, err := d.GetSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) if err != nil { logger.Infof("Get signed blocks failed: %v", err) return @@ -444,7 +463,7 @@ func (gbm *GetBlocksMessage) Process(d *Daemon) { logger.Debugf("Got %d blocks since %d", len(blocks), gbm.LastBlock) m := NewGiveBlocksMessage(blocks) - if err := d.Pool.Pool.SendMessage(gbm.c.Addr, m); err != nil { + if err := d.SendMessage(gbm.c.Addr, m); err != nil { logger.Errorf("Send GiveBlocksMessage to %s failed: %v", gbm.c.Addr, err) } } @@ -465,12 +484,12 @@ func NewGiveBlocksMessage(blocks []coin.SignedBlock) *GiveBlocksMessage { // Handle handle message func (gbm *GiveBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gbm.c = mc - return daemon.(*Daemon).recordMessageEvent(gbm, mc) + return daemon.(Daemoner).RecordMessageEvent(gbm, mc) } // Process process message -func (gbm *GiveBlocksMessage) Process(d *Daemon) { - if d.Config.DisableNetworking { +func (gbm *GiveBlocksMessage) Process(d Daemoner) { + if d.DaemonConfig().DisableNetworking { logger.Critical().Info("Visor disabled, ignoring GiveBlocksMessage") return } @@ -479,7 +498,7 @@ func (gbm *GiveBlocksMessage) Process(d *Daemon) { // It is not necessary that the blocks be executed together in a single transaction. processed := 0 - maxSeq, ok, err := d.Visor.HeadBkSeq() + maxSeq, ok, err := d.HeadBkSeq() if err != nil { logger.WithError(err).Error("visor.HeadBkSeq failed") return @@ -500,7 +519,7 @@ func (gbm *GiveBlocksMessage) Process(d *Daemon) { continue } - err := d.Visor.ExecuteSignedBlock(b) + err := d.ExecuteSignedBlock(b) if err == nil { logger.Critical().Infof("Added new block %d", b.Block.Head.BkSeq) processed++ @@ -515,7 +534,7 @@ func (gbm *GiveBlocksMessage) Process(d *Daemon) { return } - headBkSeq, ok, err := d.Visor.HeadBkSeq() + headBkSeq, ok, err := d.HeadBkSeq() if err != nil { logger.WithError(err).Error("visor.HeadBkSeq failed") return @@ -533,10 +552,10 @@ func (gbm *GiveBlocksMessage) Process(d *Daemon) { // Announce our new blocks to peers m1 := NewAnnounceBlocksMessage(headBkSeq) - d.Pool.Pool.BroadcastMessage(m1) + d.BroadcastMessage(m1) //request more blocks. - m2 := NewGetBlocksMessage(headBkSeq, d.Config.BlocksResponseCount) - d.Pool.Pool.BroadcastMessage(m2) + m2 := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) + d.BroadcastMessage(m2) } // AnnounceBlocksMessage tells a peer our highest known BkSeq. The receiving peer can choose @@ -556,16 +575,16 @@ func NewAnnounceBlocksMessage(seq uint64) *AnnounceBlocksMessage { // Handle handles message func (abm *AnnounceBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { abm.c = mc - return daemon.(*Daemon).recordMessageEvent(abm, mc) + return daemon.(Daemoner).RecordMessageEvent(abm, mc) } // Process process message -func (abm *AnnounceBlocksMessage) Process(d *Daemon) { - if d.Config.DisableNetworking { +func (abm *AnnounceBlocksMessage) Process(d Daemoner) { + if d.DaemonConfig().DisableNetworking { return } - headBkSeq, ok, err := d.Visor.HeadBkSeq() + headBkSeq, ok, err := d.HeadBkSeq() if err != nil { logger.WithError(err).Error("AnnounceBlocksMessage Visor.HeadBkSeq failed") return @@ -581,8 +600,8 @@ func (abm *AnnounceBlocksMessage) Process(d *Daemon) { // TODO: Should this be block get request for current sequence? // If client is not caught up, won't attempt to get block - m := NewGetBlocksMessage(headBkSeq, d.Config.BlocksResponseCount) - if err := d.Pool.Pool.SendMessage(abm.c.Addr, m); err != nil { + m := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) + if err := d.SendMessage(abm.c.Addr, m); err != nil { logger.Errorf("Send GetBlocksMessage to %s failed: %v", abm.c.Addr, err) } } @@ -613,16 +632,16 @@ func (atm *AnnounceTxnsMessage) GetTxns() []cipher.SHA256 { // Handle handle message func (atm *AnnounceTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { atm.c = mc - return daemon.(*Daemon).recordMessageEvent(atm, mc) + return daemon.(Daemoner).RecordMessageEvent(atm, mc) } // Process process message -func (atm *AnnounceTxnsMessage) Process(d *Daemon) { - if d.Config.DisableNetworking { +func (atm *AnnounceTxnsMessage) Process(d Daemoner) { + if d.DaemonConfig().DisableNetworking { return } - unknown, err := d.Visor.GetUnconfirmedUnknown(atm.Txns) + unknown, err := d.GetUnconfirmedUnknown(atm.Txns) if err != nil { logger.WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") return @@ -633,7 +652,7 @@ func (atm *AnnounceTxnsMessage) Process(d *Daemon) { } m := NewGetTxnsMessage(unknown) - if err := d.Pool.Pool.SendMessage(atm.c.Addr, m); err != nil { + if err := d.SendMessage(atm.c.Addr, m); err != nil { logger.Errorf("Send GetTxnsMessage to %s failed: %v", atm.c.Addr, err) } } @@ -654,17 +673,17 @@ func NewGetTxnsMessage(txns []cipher.SHA256) *GetTxnsMessage { // Handle handle message func (gtm *GetTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gtm.c = mc - return daemon.(*Daemon).recordMessageEvent(gtm, mc) + return daemon.(Daemoner).RecordMessageEvent(gtm, mc) } // Process process message -func (gtm *GetTxnsMessage) Process(d *Daemon) { - if d.Config.DisableNetworking { +func (gtm *GetTxnsMessage) Process(d Daemoner) { + if d.DaemonConfig().DisableNetworking { return } // Locate all txns from the unconfirmed pool - known, err := d.Visor.GetUnconfirmedKnown(gtm.Txns) + known, err := d.GetUnconfirmedKnown(gtm.Txns) if err != nil { logger.WithError(err).Error("GetTxnsMessage Visor.GetUnconfirmedKnown failed") return @@ -675,7 +694,7 @@ func (gtm *GetTxnsMessage) Process(d *Daemon) { // Reply to sender with GiveTxnsMessage m := NewGiveTxnsMessage(known) - if err := d.Pool.Pool.SendMessage(gtm.c.Addr, m); err != nil { + if err := d.SendMessage(gtm.c.Addr, m); err != nil { logger.Errorf("Send GiveTxnsMessage to %s failed: %v", gtm.c.Addr, err) } } @@ -701,12 +720,12 @@ func (gtm *GiveTxnsMessage) GetTxns() []cipher.SHA256 { // Handle handle message func (gtm *GiveTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gtm.c = mc - return daemon.(*Daemon).recordMessageEvent(gtm, mc) + return daemon.(Daemoner).RecordMessageEvent(gtm, mc) } // Process process message -func (gtm *GiveTxnsMessage) Process(d *Daemon) { - if d.Config.DisableNetworking { +func (gtm *GiveTxnsMessage) Process(d Daemoner) { + if d.DaemonConfig().DisableNetworking { return } @@ -714,7 +733,7 @@ func (gtm *GiveTxnsMessage) Process(d *Daemon) { // Update unconfirmed pool with these transactions for _, txn := range gtm.Txns { // Only announce transactions that are new to us, so that peers can't spam relays - known, softErr, err := d.Visor.InjectTransaction(txn) + known, softErr, err := d.InjectTransaction(txn) if err != nil { logger.Warningf("Failed to record transaction %s: %v", txn.Hash().Hex(), err) continue @@ -733,6 +752,6 @@ func (gtm *GiveTxnsMessage) Process(d *Daemon) { if len(hashes) != 0 { logger.Debugf("Announce %d transactions", len(hashes)) m := NewAnnounceTxnsMessage(hashes) - d.Pool.Pool.BroadcastMessage(m) + d.BroadcastMessage(m) } } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 1241910138..f2593c716d 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -6,6 +6,7 @@ import ( "os" "reflect" "strconv" + "testing" "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/encoder" @@ -13,6 +14,7 @@ import ( "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/util" + "github.com/stretchr/testify/require" ) func setupMsgEncoding() { @@ -243,7 +245,7 @@ func ExampleOmitEmptySliceTestStruct() { func ExampleIntroductionMessage() { defer gnet.EraseMessages() setupMsgEncoding() - var message = NewIntroductionMessage(1234, 5, 7890) + var message = NewIntroductionMessage(1234, 5, 7890, nil) fmt.Println("IntroductionMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) @@ -538,3 +540,292 @@ func ExampleAnnounceTxnsMessage() { // 0x003c | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... Txns[1] // 0x004c | } + +func TestIntroductionMessage(t *testing.T) { + defer gnet.EraseMessages() + setupMsgEncoding() + + pubkey, _ := cipher.GenerateKeyPair() + pubkey2, _ := cipher.GenerateKeyPair() + + type mirrorPortResult struct { + port uint16 + exist bool + } + + type daemonMockValue struct { + version uint32 + mirror uint32 + isDefaultConnection bool + isMaxConnectionsReached bool + isMaxConnectionsReachedErr error + setHasIncomingPortErr error + getMirrorPortResult mirrorPortResult + recordMessageEventErr error + pubkey cipher.PubKey + disconnectReason gnet.DisconnectReason + disconnectErr error + addPeerArg string + addPeerErr error + } + + tt := []struct { + name string + addr string + mockValue daemonMockValue + intro *IntroductionMessage + err error + }{ + { + name: "INTR message without extra bytes", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + }, + err: nil, + }, + { + name: "INTR message with pubkey", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + Extra: pubkey[:], + }, + err: nil, + }, + { + name: "INTR message with pubkey", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + Extra: pubkey[:], + }, + err: nil, + }, + { + name: "INTR message with pubkey and additional data", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + Extra: append(pubkey[:], []byte("additional data")...), + }, + err: nil, + }, + { + name: "INTR message with different pubkey", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + disconnectReason: ErrDisconnectBlockchainPubkeyNotMatched, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + Extra: pubkey2[:], + }, + err: ErrDisconnectBlockchainPubkeyNotMatched, + }, + { + name: "INTR message with invalid pubkey", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + disconnectReason: ErrDisconnectInvalidExtraData, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: true, + Extra: []byte("invalid extra data"), + }, + err: ErrDisconnectInvalidExtraData, + }, + { + name: "Disconnect self connection", + mockValue: daemonMockValue{ + mirror: 10000, + disconnectReason: ErrDisconnectSelf, + }, + intro: &IntroductionMessage{ + Mirror: 10000, + }, + err: ErrDisconnectSelf, + }, + { + name: "Invalid version", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + disconnectReason: ErrDisconnectInvalidVersion, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Version: 0, + }, + err: ErrDisconnectInvalidVersion, + }, + { + name: "Invalid address", + addr: "121.121.121.121", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + disconnectReason: ErrDisconnectOtherError, + pubkey: pubkey, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Version: 1, + Port: 6000, + }, + err: ErrDisconnectOtherError, + }, + { + name: "Max default connections reached", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + disconnectReason: ErrDisconnectMaxDefaultConnectionReached, + isDefaultConnection: true, + isMaxConnectionsReached: true, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Version: 1, + Port: 6000, + }, + err: ErrDisconnectMaxDefaultConnectionReached, + }, + { + name: "incomming connection", + addr: "121.121.121.121:12345", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + isDefaultConnection: true, + isMaxConnectionsReached: true, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: nil, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Version: 1, + Port: 6000, + valid: true, + }, + }, + { + name: "Connect twice", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + version: 1, + isDefaultConnection: true, + getMirrorPortResult: mirrorPortResult{ + exist: true, + }, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: nil, + disconnectReason: ErrDisconnectConnectedTwice, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Version: 1, + Port: 6000, + }, + err: ErrDisconnectConnectedTwice, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + mc := &gnet.MessageContext{Addr: tc.addr} + tc.intro.c = mc + + d := NewDaemonerMock() + d.On("DaemonConfig").Return(DaemonConfig{Version: int32(tc.mockValue.version)}) + d.On("Mirror").Return(tc.mockValue.mirror) + d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) + d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) + d.On("GetMirrorPort", tc.addr, tc.intro.Mirror).Return(tc.mockValue.getMirrorPortResult.port, tc.mockValue.getMirrorPortResult.exist) + d.On("RecordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) + d.On("ResetRetryTimes", tc.addr) + d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) + d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) + d.On("IncreaseRetryTimes", tc.addr) + d.On("RemoveFromExpectingIntroductions", tc.addr) + d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) + d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) + + err := tc.intro.Handle(mc, d) + require.Equal(t, tc.err, err) + }) + } + +} diff --git a/src/gui/static/e2e/app.e2e-spec.ts b/src/gui/static/e2e/app.e2e-spec.ts deleted file mode 100644 index 724835ac70..0000000000 --- a/src/gui/static/e2e/app.e2e-spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { DesktopwalletPage } from './app.po'; - -describe('desktopwallet App', () => { - let page: DesktopwalletPage; - - beforeEach(() => { - page = new DesktopwalletPage(); - page.dontWait(); - }); - - it('should show wallets page', () => { - page.navigateTo(); - expect(page.getParagraphText()).toEqual('Create Wallet'); - }); -}); diff --git a/src/gui/static/e2e/app.po.ts b/src/gui/static/e2e/app.po.ts deleted file mode 100644 index 028e54e913..0000000000 --- a/src/gui/static/e2e/app.po.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { browser, by, element } from 'protractor'; -import { Page } from './page'; - -export class DesktopwalletPage extends Page { - navigateTo() { - return browser.get('/'); - } - - getParagraphText() { - return element(by.css('.-header')).getText(); - } -} diff --git a/src/gui/static/e2e/onboarding.e2e-spec.ts b/src/gui/static/e2e/onboarding.e2e-spec.ts new file mode 100644 index 0000000000..672aaaed8f --- /dev/null +++ b/src/gui/static/e2e/onboarding.e2e-spec.ts @@ -0,0 +1,44 @@ +import { OnboardingCreatePage } from './onboarding.po'; + +describe('Onboarding', () => { + const page = new OnboardingCreatePage(); + + it('should display title', () => { + page.navigateTo(); + expect(page.getHeaderText()).toEqual('Create Wallet'); + }); + + it('should load wallet', () => { + expect(page.loadWallet()).toEqual(true); + }); + + it('should create wallet', () => { + expect(page.createWallet()).toEqual(true); + }); + + it('should show safeguard', () => { + expect(page.getSafeguardIsShown()).toEqual(true); + }); + + it('should hide accepted safeguard', () => { + expect(page.acceptSafeguard()).toEqual(false); + }); + + it('should be able to go back from wallet encryption', () => { + expect(page.goBack()).toEqual('Create Wallet'); + page.createWallet(); + page.acceptSafeguard(); + }); + + it('should encrypt wallet by default', () => { + expect(page.getEncryptWalletCheckbox().isSelected()).toBeTruthy(); + }); + + it('should be able to continue without encryption', () => { + expect(page.canContinueWithoutEncryption()).toEqual(true); + }); + + it('should encrypt wallet', () => { + expect(page.encryptWallet()).toEqual(true); + }); +}); diff --git a/src/gui/static/e2e/onboarding.po.ts b/src/gui/static/e2e/onboarding.po.ts new file mode 100644 index 0000000000..dadf6cc580 --- /dev/null +++ b/src/gui/static/e2e/onboarding.po.ts @@ -0,0 +1,93 @@ +import { browser, by, element } from 'protractor'; + +export class OnboardingCreatePage { + navigateTo() { + return browser.get('/#/wizard'); + } + + getHeaderText() { + return element(by.css('.-header span')).getText(); + } + + getSafeguardIsShown() { + return element(by.css('app-onboarding-safeguard')).isPresent(); + } + + acceptSafeguard() { + return element.all(by.css('.mat-checkbox-label')).first().click().then(() => { + return element(by.buttonText('Continue')).click().then(() => { + return this.getSafeguardIsShown(); + }); + }); + } + + createWallet() { + element(by.buttonText('New')).click(); + + const label = element(by.css('[formcontrolname="label"]')); + const seed = element(by.css('[formcontrolname="seed"]')); + const confirm = element(by.css('[formcontrolname="confirm_seed"]')); + const btnCreate = element(by.buttonText('Create')); + + label.clear(); + label.sendKeys('Test onboarding wallet'); + seed.clear(); + seed.sendKeys('test test'); + confirm.clear(); + confirm.sendKeys('test test'); + + return btnCreate.isEnabled().then(status => { + if (status) { + btnCreate.click(); + } + + return status; + }); + } + + loadWallet() { + element(by.buttonText('Load')).click(); + + const label = element(by.css('[formcontrolname="label"]')); + const seed = element(by.css('[formcontrolname="seed"]')); + const btnLoad = element(by.buttonText('Create')); + + label.clear(); + label.sendKeys('Test wallet'); + seed.clear(); + seed.sendKeys('test test'); + + return btnLoad.isEnabled(); + } + + goBack() { + return element(by.buttonText('Back')).click().then(() => { + return this.getHeaderText(); + }); + } + + getEncryptWalletCheckbox() { + return element(by.css('.mat-checkbox-input')); + } + + canContinueWithoutEncryption() { + return element(by.css('.mat-checkbox-label')).click().then(() => { + return element(by.buttonText('Finish')).isEnabled(); + }); + } + + encryptWallet() { + const password = element(by.css('[formcontrolname="password"]')); + const confirm = element(by.css('[formcontrolname="confirm"]')); + const button = element(by.buttonText('Finish')); + + return element(by.css('.mat-checkbox-label')).click().then(() => { + password.clear(); + password.sendKeys('password'); + confirm.clear(); + confirm.sendKeys('password'); + + return button.isEnabled(); + }); + } +} diff --git a/src/gui/static/e2e/page.ts b/src/gui/static/e2e/page.ts deleted file mode 100644 index 25399753e9..0000000000 --- a/src/gui/static/e2e/page.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { browser } from 'protractor'; - -export class Page { - dontWait() { - browser.waitForAngularEnabled(false); - } -} diff --git a/src/gui/static/e2e/send.e2e-spec.ts b/src/gui/static/e2e/send.e2e-spec.ts new file mode 100644 index 0000000000..63f70282db --- /dev/null +++ b/src/gui/static/e2e/send.e2e-spec.ts @@ -0,0 +1,38 @@ +import { SendPage } from './send.po'; + +describe('Send', () => { + const page = new SendPage(); + + it('should display title', () => { + page.navigateTo(); + expect(page.getHeaderText()).toEqual('Wallets'); + }); + + it('should have wallets', () => { + expect(page.getWalletsCount()).toBeGreaterThan(0); + }); + + it('should have coins in wallets', () => { + expect(page.getWalletsWithCoins().then(w => w.length)).toBeGreaterThan(0); + }); + + it('should have wallets enabled', () => { + expect(page.getValidWallets().then(w => w.length)).toBeGreaterThan(0); + }); + + it('should select valid wallet', () => { + expect(page.selectValidWallet()).toBeTruthy(); + }); + + it('should not be able to send with wrong amount', () => { + expect(page.fillFormWithCoins('615701')).toBeFalsy(); + expect(page.fillFormWithCoins('0')).toBeFalsy(); + expect(page.fillFormWithCoins('-1')).toBeFalsy(); + expect(page.fillFormWithCoins('a')).toBeFalsy(); + }); + + it('should be able to send with correct amount', () => { + expect(page.fillFormWithCoins('615700')).toBeTruthy(); + expect(page.fillFormWithCoins('1')).toBeTruthy(); + }); +}); diff --git a/src/gui/static/e2e/send.po.ts b/src/gui/static/e2e/send.po.ts new file mode 100644 index 0000000000..e1b136dfed --- /dev/null +++ b/src/gui/static/e2e/send.po.ts @@ -0,0 +1,68 @@ +import { browser, by, element } from 'protractor'; + +export class SendPage { + navigateTo() { + return browser.get('/#/send'); + } + + getHeaderText() { + return element(by.css('.title')).getText(); + } + + getWalletsCount() { + return element.all(by.css('#wallet option')).count(); + } + + getWalletsWithCoins() { + return element.all(by.tagName('#wallet option')) + .filter((opt) => { + return opt.getText().then((v) => { + return this.getCoinsFromOptionString(v) > 0; + }); + }); + } + + getValidWallets() { + return element.all(by.tagName('#wallet option')) + .filter((opt) => { + return opt.getText().then((v) => { + return opt.getAttribute('disabled').then(status => { + return status === null && this.getCoinsFromOptionString(v) > 0; + }); + }); + }); + } + + selectValidWallet() { + return this.getValidWallets().then(wallets => { + return wallets[0].click().then(() => { + return true; + }); + }); + } + + fillFormWithCoins(coins: string) { + const dest = element(by.css('[formcontrolname="address"]')); + const amount = element(by.css('[formcontrolname="amount"]')); + const btnSend = element(by.buttonText('Send')); + + dest.clear(); + amount.clear(); + + return dest.sendKeys('2e1erPpaxNVC37PkEv3n8PESNw2DNr5aJNy').then(() => { + return this.getValidWallets().then(wallets => { + return wallets[0].click().then(() => { + return amount.sendKeys(coins).then(() => { + return btnSend.isEnabled(); + }); + }); + }); + }); + } + + private getCoinsFromOptionString(option: string) { + const value = option.slice(option.indexOf('-') + 1, option.indexOf(' SKY')); + + return parseFloat(value); + } +} diff --git a/src/gui/static/e2e/transactions.e2e-spec.ts b/src/gui/static/e2e/transactions.e2e-spec.ts new file mode 100644 index 0000000000..0d146955f0 --- /dev/null +++ b/src/gui/static/e2e/transactions.e2e-spec.ts @@ -0,0 +1,22 @@ +import { TransactionsPage } from './transactions.po'; + +describe('Transactions', () => { + const page = new TransactionsPage(); + + it('should display title', () => { + page.navigateTo(); + expect(page.getHeaderText()).toEqual('Transactions'); + }); + + it('should contain transactions', () => { + expect(page.getTransactionsCount()).toBeGreaterThan(0); + }); + + it('should show transaction detail modal', () => { + expect(page.showTransactionsModal()).toBeTruthy(); + }); + + it('should hide transaction detail modal', () => { + expect(page.hideTransactionModal()).toBeFalsy(); + }); +}); diff --git a/src/gui/static/e2e/transactions.po.ts b/src/gui/static/e2e/transactions.po.ts new file mode 100644 index 0000000000..c0faa277ab --- /dev/null +++ b/src/gui/static/e2e/transactions.po.ts @@ -0,0 +1,37 @@ +import { browser, by, element, protractor } from 'protractor'; + +export class TransactionsPage { + navigateTo() { + return browser.get('/#/transactions'); + } + + getHeaderText() { + return element(by.css('.title')).getText(); + } + + getTransactions() { + return element.all(by.css('.-transaction')); + } + + getTransactionsCount() { + return this.getTransactions().count(); + } + + getTransactionDetailIsShow() { + return element(by.css('app-transaction-detail')).isPresent(); + } + + showTransactionsModal() { + return this.getTransactions().first().click().then(() => { + return this.getTransactionDetailIsShow(); + }); + } + + hideTransactionModal() { + const el = element(by.css('app-transaction-detail .-header img')); + + return browser.wait(protractor.ExpectedConditions.visibilityOf(el), 5000).then(() => el.click().then(() => { + return this.getTransactionDetailIsShow(); + })); + } +} diff --git a/src/gui/static/e2e/wallets.e2e-spec.ts b/src/gui/static/e2e/wallets.e2e-spec.ts new file mode 100644 index 0000000000..82384d5440 --- /dev/null +++ b/src/gui/static/e2e/wallets.e2e-spec.ts @@ -0,0 +1,90 @@ +import { WalletsPage } from './wallets.po'; + +describe('Wallets', () => { + const page = new WalletsPage(); + + it('should display title', () => { + page.navigateTo(); + expect(page.getHeaderText()).toEqual('Wallets'); + }); + + it('should show create wallet', () => { + expect(page.showAddWallet()).toEqual(true); + expect(page.getWalletModalTitle()).toEqual('Create Wallet'); + }); + + it('should validate create wallet, seed mismatch', () => { + expect(page.fillWalletForm('Test', 'seed', 'seed2')).toEqual(false); + }); + + it('should validate create wallet, empty label', () => { + expect(page.fillWalletForm('', 'seed', 'seed')).toEqual(false); + }); + + it('should create wallet', () => { + expect(page.fillWalletForm('Test create wallet', 'test create wallet', 'test create wallet')).toEqual(true); + page.waitForWalletToBeCreated(); + }); + + it('should show load wallet', () => { + expect(page.showLoadWallet()).toEqual(true); + expect(page.getWalletModalTitle()).toEqual('Load Wallet'); + }); + + it('should validate load wallet, seed', () => { + expect(page.fillWalletForm('Test', '', null)).toEqual(false); + }); + + it('should validate load wallet, empty label', () => { + expect(page.fillWalletForm('', 'seed', null)).toEqual(false); + }); + + it('should load wallet', () => { + expect(page.fillWalletForm('Test load wallet', 'test load wallet', null)).toEqual(true); + page.waitForWalletToBeCreated(); + }); + + it('should expand wallet', () => { + expect(page.expandWallet()).toEqual(true); + }); + + it('should show wallet QR modal', () => { + expect(page.showQrDialog()).toEqual(true); + }); + + it('should hide wallet QR modal', () => { + expect(page.hideQrDialog()).toEqual(false); + }); + + it('should add address to wallet', () => { + expect(page.addAddress()).toEqual(true); + }); + + it('should hide empty address', () => { + expect(page.getCountOfEmptyAddresses('.-hide-empty')).toEqual(0); + }); + + it('should show empty address', () => { + expect(page.getCountOfEmptyAddresses('.-show-empty')).toBeGreaterThan(0); + }); + + it('should show change wallet name modal', () => { + expect(page.showChangeWalletName()).toEqual(true); + }); + + it('should change wallet name', () => { + expect(page.changeWalletName()).toEqual(true); + }); + + it('should encrypt wallet', () => { + expect(page.canEncrypt()).toEqual(true); + }); + + it('should decrypt wallet', () => { + expect(page.canDecrypt()).toEqual(true); + }); + + it('should display price information', () => { + expect(page.showPriceInformation()).toEqual(true); + }); +}); diff --git a/src/gui/static/e2e/wallets.po.ts b/src/gui/static/e2e/wallets.po.ts new file mode 100644 index 0000000000..969b8b26e6 --- /dev/null +++ b/src/gui/static/e2e/wallets.po.ts @@ -0,0 +1,186 @@ +import { browser, by, element, protractor } from 'protractor'; + +export class WalletsPage { + navigateTo() { + return browser.get('/#/wallets'); + } + + getHeaderText() { + return element(by.css('.title')).getText(); + } + + showAddWallet() { + const btnAdd = element(by.buttonText('Add Wallet')); + + return btnAdd.click().then(() => { + return element(by.css('app-create-wallet')).isPresent(); + }); + } + + showLoadWallet() { + const btnLoad = element(by.buttonText('Load Wallet')); + + return btnLoad.click().then(() => { + return element(by.css('app-create-wallet')).isPresent(); + }); + } + + getWalletModalTitle() { + return element(by.css('app-create-wallet .-header')).getText(); + } + + fillWalletForm(label: string, seed: string, confirm: string|null) { + const labelEl = element(by.css('[formcontrolname="label"]')); + const seedEl = element(by.css('[formcontrolname="seed"]')); + const btn = element(by.buttonText(confirm ? 'Create' : 'Load')); + const encrypt = element(by.css('.mat-checkbox-label')); + + encrypt.click(); + labelEl.clear(); + seedEl.clear(); + labelEl.sendKeys(label); + seedEl.sendKeys(seed); + + if (confirm) { + const confirmEl = element(by.css('[formcontrolname="confirm_seed"]')); + confirmEl.clear(); + confirmEl.sendKeys(confirm); + } + + return btn.isEnabled().then(status => { + if (status) { + btn.click(); + } + + return status; + }); + } + + expandWallet() { + return this.getWalletWithName('Test create wallet').click().then(() => { + return element(by.css('app-wallet-detail')).isPresent(); + }); + } + + showQrDialog() { + return browser.sleep(1000).then(() => element(by.css('.qr-code-button')).click().then(() => { + return element(by.css('app-qr-code')).isPresent(); + })); + } + + hideQrDialog() { + return browser.sleep(1000).then(() => element(by.css('app-modal .-header img')).click().then(() => { + return element(by.css('app-qr-code')).isPresent(); + })); + } + + addAddress() { + return element.all(by.css('.-detail')).count().then(originalCount => { + return element(by.css('.-new-address')).click().then(() => { + return browser.sleep(2000).then(() => { + return element.all(by.css('.-detail')).count().then(newCount => { + return newCount > originalCount; + }); + }); + }); + }); + } + + getCountOfEmptyAddresses(clickSelector: string) { + return element(by.css(clickSelector)).click().then(() => { + return element.all(by.css('.-detail > div:nth-child(3)')).filter((address) => { + return address.getText().then(value => { + return value === '0'; + }); + }).count(); + }); + } + + showChangeWalletName() { + return element(by.css('.-edit-wallet')).click().then(() => { + return element(by.css('app-change-name')).isPresent(); + }); + } + + changeWalletName() { + const label = element(by.css('[formcontrolname="label"]')); + const btn = element(by.buttonText('Rename')); + + return label.clear().then(() => { + return label.sendKeys('New Wallet Name').then(() => { + return btn.click().then(() => { + return browser.sleep(1000).then(() => { + return this.getWalletWithName('New Wallet Name').isPresent(); + }); + }); + }); + }); + } + + canEncrypt() { + return element(by.css('.-enable-encryption')).click().then(() => { + const p1 = element(by.css('[formcontrolname="password"]')); + const p2 = element(by.css('[formcontrolname="confirm_password"]')); + const btn = element(by.buttonText('Proceed')); + + p1.sendKeys('password'); + p2.sendKeys('password'); + + return btn.click().then(() => { + return browser.wait( + protractor.ExpectedConditions.stalenessOf(element(by.css('app-password-dialog'))), + 30000, + 'Can not encrypt wallet', + ).then(() => { + return element(by.css('.-disable-encryption')).isPresent(); + }); + }); + }); + } + + canDecrypt() { + return element(by.css('.-disable-encryption')).click().then(() => { + const p1 = element(by.css('[formcontrolname="password"]')); + const btn = element(by.buttonText('Proceed')); + + p1.clear(); + p1.sendKeys('password'); + + return btn.click().then(() => { + return browser.wait( + protractor.ExpectedConditions.stalenessOf(element(by.css('app-password-dialog'))), + 30000, + 'Can not decrypt wallet', + ).then(() => { + return element(by.css('.-enable-encryption')).isPresent(); + }); + }); + }); + } + + showPriceInformation() { + return element(by.css('.balance p.dollars')).getText().then(text => { + return this.checkHeaderPriceFormat(text); + }); + } + + waitForWalletToBeCreated() { + browser.wait( + protractor.ExpectedConditions.stalenessOf(element(by.css('app-create-wallet'))), + 10000, + 'Wallet was not created', + ); + } + + private getWalletWithName(name: string) { + return element.all(by.css('.-table.ng-star-inserted')) + .filter(wallet => wallet.element(by.css('.-label')).getText().then(text => text === name)) + .first(); + } + + private checkHeaderPriceFormat(price: string) { + const reg = /^\$[0-9,]+.[0-9]{2}\s\(\$[0-9,]+.[0-9]{2}\)$/; + + return !!price.match(reg); + } +} diff --git a/src/gui/static/protractor.conf.js b/src/gui/static/protractor.conf.js index 7ee3b5ee86..98b715235d 100644 --- a/src/gui/static/protractor.conf.js +++ b/src/gui/static/protractor.conf.js @@ -4,19 +4,22 @@ const { SpecReporter } = require('jasmine-spec-reporter'); exports.config = { - allScriptsTimeout: 11000, + allScriptsTimeout: 60000, specs: [ './e2e/**/*.e2e-spec.ts' ], capabilities: { - 'browserName': 'chrome' + 'browserName': 'chrome', + chromeOptions: { + args: ['--no-sandbox', '--headless', '--disable-gpu', 'window-size=1920,1080'] + } }, directConnect: true, baseUrl: 'http://localhost:4200/', framework: 'jasmine', jasmineNodeOpts: { showColors: true, - defaultTimeoutInterval: 30000, + defaultTimeoutInterval: 60000, print: function() {} }, onPrepare() { diff --git a/src/gui/static/src/app/components/pages/transaction-list/transaction-list.component.scss b/src/gui/static/src/app/components/pages/transaction-list/transaction-list.component.scss index 9f7d72a89b..4e24007511 100644 --- a/src/gui/static/src/app/components/pages/transaction-list/transaction-list.component.scss +++ b/src/gui/static/src/app/components/pages/transaction-list/transaction-list.component.scss @@ -99,7 +99,8 @@ } .-balance { - width: 100px; + width: 200px; + text-align: right; h4 { color: #1e2227; diff --git a/src/gui/static/src/app/services/app.service.ts b/src/gui/static/src/app/services/app.service.ts index a23e48fcd0..d97a667d81 100644 --- a/src/gui/static/src/app/services/app.service.ts +++ b/src/gui/static/src/app/services/app.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, NgZone } from '@angular/core'; import { ApiService } from './api.service'; import { Observable } from 'rxjs/Observable'; import { IntervalObservable } from 'rxjs/observable/IntervalObservable'; @@ -11,6 +11,7 @@ export class AppService { constructor( private apiService: ApiService, + private ngZone: NgZone, ) { this.monitorConnections(); } @@ -27,10 +28,14 @@ export class AppService { private monitorConnections() { this.retrieveConnections().subscribe(connections => this.setConnectionError(connections)); - IntervalObservable - .create(1500) - .flatMap(() => this.retrieveConnections()) - .subscribe(connections => this.setConnectionError(connections)); + this.ngZone.runOutsideAngular(() => { + IntervalObservable + .create(1500) + .flatMap(() => this.retrieveConnections()) + .subscribe(connections => this.ngZone.run(() => { + this.setConnectionError(connections); + })); + }); } private retrieveConnections(): Observable { @@ -38,10 +43,10 @@ export class AppService { } private setConnectionError(response: any) { - if (response.connections.length === 0) { + if (response.connections === null || response.connections.length === 0) { this.error = 1; } - if (response.connections.length > 0 && this.error === 1) { + if (response.connections !== null && response.connections.length > 0 && this.error === 1) { this.error = null; } } diff --git a/src/gui/static/src/app/services/blockchain.service.ts b/src/gui/static/src/app/services/blockchain.service.ts index ef40a411bc..64a239afb6 100644 --- a/src/gui/static/src/app/services/blockchain.service.ts +++ b/src/gui/static/src/app/services/blockchain.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, NgZone } from '@angular/core'; import { ApiService } from './api.service'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; @@ -18,22 +18,25 @@ export class BlockchainService { constructor( private apiService: ApiService, private walletService: WalletService, + private ngZone: NgZone, ) { - Observable.timer(0, 2000) - .flatMap(() => this.getBlockchainProgress()) - .takeWhile((response: any) => !response.current || response.current !== response.highest) - .subscribe( - response => { - this.progressSubject.next(response); + this.ngZone.runOutsideAngular(() => { + Observable.timer(0, 2000) + .flatMap(() => this.getBlockchainProgress()) + .takeWhile((response: any) => !response.current || response.current !== response.highest) + .subscribe( + response => this.ngZone.run(() => { + this.progressSubject.next(response); - if (! this.refreshedBalance) { - this.walletService.refreshBalances(); - this.refreshedBalance = true; - } - }, - error => console.log(error), - () => this.completeLoading(), - ); + if (!this.refreshedBalance) { + this.walletService.refreshBalances(); + this.refreshedBalance = true; + } + }), + error => console.log(error), + () => this.ngZone.run(() => this.completeLoading()), + ); + }); } block(id): Observable { diff --git a/src/gui/static/src/app/services/price.service.ts b/src/gui/static/src/app/services/price.service.ts index a7e5367bbf..61e36b488c 100644 --- a/src/gui/static/src/app/services/price.service.ts +++ b/src/gui/static/src/app/services/price.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, NgZone } from '@angular/core'; import { Http } from '@angular/http'; import { Subject } from 'rxjs/Subject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @@ -12,11 +12,16 @@ export class PriceService { constructor( private http: Http, + private ngZone: NgZone, ) { - Observable.timer(0, 10 * 60 * 1000).subscribe(() => { - this.http.get(`https://api.coinmarketcap.com/v2/ticker/${this.CMC_TICKER_ID}/`) - .map(response => response.json()) - .subscribe(response => this.price.next(response.data.quotes.USD.price)); + this.ngZone.runOutsideAngular(() => { + Observable.timer(0, 10 * 60 * 1000).subscribe(() => { + this.http.get(`https://api.coinmarketcap.com/v2/ticker/${this.CMC_TICKER_ID}/`) + .map(response => response.json()) + .subscribe(response => this.ngZone.run(() => { + this.price.next(response.data.quotes.USD.price); + })); + }); }); } } diff --git a/src/gui/static/src/app/services/wallet.service.ts b/src/gui/static/src/app/services/wallet.service.ts index c7673b20be..3d47f08a59 100644 --- a/src/gui/static/src/app/services/wallet.service.ts +++ b/src/gui/static/src/app/services/wallet.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, NgZone } from '@angular/core'; import { ApiService } from './api.service'; import { Subject } from 'rxjs/Subject'; import { Observable } from 'rxjs/Observable'; @@ -23,6 +23,7 @@ export class WalletService { constructor( private apiService: ApiService, + private ngZone: NgZone, ) { this.loadData(); this.startDataRefreshSubscription(); @@ -214,11 +215,13 @@ export class WalletService { this.dataRefreshSubscription.unsubscribe(); } - this.dataRefreshSubscription = Observable.timer(0, 10000) - .subscribe(() => { - this.refreshBalances(); - this.refreshPendingTransactions(); - }); + this.ngZone.runOutsideAngular(() => { + this.dataRefreshSubscription = Observable.timer(0, 10000) + .subscribe(() => this.ngZone.run(() => { + this.refreshBalances(); + this.refreshPendingTransactions(); + })); + }); } private loadData(): void { diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 3fd8a52b14..5d8daccfba 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -315,6 +315,7 @@ func (c *Coin) configureDaemon() daemon.Config { dc.Daemon.OutgoingMax = c.config.Node.MaxOutgoingConnections dc.Daemon.DataDirectory = c.config.Node.DataDirectory dc.Daemon.LogPings = !c.config.Node.DisablePingPong + dc.Daemon.BlockchainPubkey = c.config.Node.blockchainPubkey if c.config.Node.OutgoingConnectionsRate == 0 { c.config.Node.OutgoingConnectionsRate = time.Millisecond diff --git a/src/visor/historydb/history_meta.go b/src/visor/historydb/history_meta.go index 22c55d3595..e6e3b3978c 100644 --- a/src/visor/historydb/history_meta.go +++ b/src/visor/historydb/history_meta.go @@ -13,8 +13,8 @@ var ( // historyMeta bucket for storing block history meta info type historyMeta struct{} -// Height returns history parsed height -func (hm *historyMeta) ParsedHeight(tx *dbutil.Tx) (uint64, bool, error) { +// Height returns history parsed block seq +func (hm *historyMeta) ParsedBlockSeq(tx *dbutil.Tx) (uint64, bool, error) { v, err := dbutil.GetBucketValue(tx, HistoryMetaBkt, parsedHeightKey) if err != nil { return 0, false, err @@ -25,8 +25,8 @@ func (hm *historyMeta) ParsedHeight(tx *dbutil.Tx) (uint64, bool, error) { return dbutil.Btoi(v), true, nil } -// SetParsedHeight updates history parsed height -func (hm *historyMeta) SetParsedHeight(tx *dbutil.Tx, h uint64) error { +// SetParsedHeight updates history parsed block seq +func (hm *historyMeta) SetParsedBlockSeq(tx *dbutil.Tx, h uint64) error { return dbutil.PutBucketValue(tx, HistoryMetaBkt, parsedHeightKey, dbutil.Itob(h)) } diff --git a/src/visor/historydb/history_meta_test.go b/src/visor/historydb/history_meta_test.go index b6b63c42f2..3f42c85b5f 100644 --- a/src/visor/historydb/history_meta_test.go +++ b/src/visor/historydb/history_meta_test.go @@ -15,7 +15,7 @@ func TestHistoryMetaGetSetParsedHeight(t *testing.T) { hm := &historyMeta{} err := db.View("", func(tx *dbutil.Tx) error { - height, ok, err := hm.ParsedHeight(tx) + height, ok, err := hm.ParsedBlockSeq(tx) require.NoError(t, err) require.False(t, ok) require.Equal(t, uint64(0), height) @@ -24,14 +24,14 @@ func TestHistoryMetaGetSetParsedHeight(t *testing.T) { require.NoError(t, err) err = db.Update("", func(tx *dbutil.Tx) error { - err := hm.SetParsedHeight(tx, 10) + err := hm.SetParsedBlockSeq(tx, 10) require.NoError(t, err) return err }) require.NoError(t, err) err = db.View("", func(tx *dbutil.Tx) error { - height, ok, err := hm.ParsedHeight(tx) + height, ok, err := hm.ParsedBlockSeq(tx) require.NoError(t, err) require.True(t, ok) require.Equal(t, uint64(10), height) @@ -40,14 +40,14 @@ func TestHistoryMetaGetSetParsedHeight(t *testing.T) { require.NoError(t, err) err = db.Update("", func(tx *dbutil.Tx) error { - err := hm.SetParsedHeight(tx, 0) + err := hm.SetParsedBlockSeq(tx, 0) require.NoError(t, err) return err }) require.NoError(t, err) err = db.View("", func(tx *dbutil.Tx) error { - height, ok, err := hm.ParsedHeight(tx) + height, ok, err := hm.ParsedBlockSeq(tx) require.NoError(t, err) require.True(t, ok) require.Equal(t, uint64(0), height) diff --git a/src/visor/historydb/historydb.go b/src/visor/historydb/historydb.go index 065143a206..c3061c64a1 100644 --- a/src/visor/historydb/historydb.go +++ b/src/visor/historydb/historydb.go @@ -49,9 +49,10 @@ func New() *HistoryDB { // If we have a new added bucket, we need to reset to parse // blockchain again to get the new bucket filled. func (hd *HistoryDB) NeedsReset(tx *dbutil.Tx) (bool, error) { - if height, ok, err := hd.historyMeta.ParsedHeight(tx); err != nil { + _, ok, err := hd.historyMeta.ParsedBlockSeq(tx) + if err != nil { return false, err - } else if !ok || height == 0 { + } else if !ok { return true, nil } @@ -164,7 +165,7 @@ func (hd *HistoryDB) ParseBlock(tx *dbutil.Tx, b coin.Block) error { } } - return hd.SetParsedHeight(tx, b.Seq()) + return hd.SetParsedBlockSeq(tx, b.Seq()) } // GetTransaction get transaction by hash. diff --git a/src/visor/historyer_mock_test.go b/src/visor/historyer_mock_test.go index e280bef3f8..6ecfaa8b63 100644 --- a/src/visor/historyer_mock_test.go +++ b/src/visor/historyer_mock_test.go @@ -214,8 +214,8 @@ func (m *HistoryerMock) ParseBlock(p0 *dbutil.Tx, p1 coin.Block) error { } -// ParsedHeight mocked method -func (m *HistoryerMock) ParsedHeight(p0 *dbutil.Tx) (uint64, bool, error) { +// ParsedBlockSeq mocked method +func (m *HistoryerMock) ParsedBlockSeq(p0 *dbutil.Tx) (uint64, bool, error) { ret := m.Called(p0) diff --git a/src/visor/visor.go b/src/visor/visor.go index 25164f0630..423a5d1e31 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -173,7 +173,7 @@ type Historyer interface { GetAddressTxns(tx *dbutil.Tx, address cipher.Address) ([]historydb.Transaction, error) NeedsReset(tx *dbutil.Tx) (bool, error) Erase(tx *dbutil.Tx) error - ParsedHeight(tx *dbutil.Tx) (uint64, bool, error) + ParsedBlockSeq(tx *dbutil.Tx) (uint64, bool, error) ForEachTxn(tx *dbutil.Tx, f func(cipher.SHA256, *historydb.Transaction) error) error } @@ -365,19 +365,19 @@ func initHistory(tx *dbutil.Tx, bc *Blockchain, history *historydb.HistoryDB) er func parseHistoryTo(tx *dbutil.Tx, history *historydb.HistoryDB, bc *Blockchain, height uint64) error { logger.Info("Visor parseHistoryTo") - parsedHeight, _, err := history.ParsedHeight(tx) + parsedBlockSeq, _, err := history.ParsedBlockSeq(tx) if err != nil { return err } - for i := uint64(0); i < height-parsedHeight; i++ { - b, err := bc.GetSignedBlockBySeq(tx, parsedHeight+i+1) + for i := uint64(0); i < height-parsedBlockSeq; i++ { + b, err := bc.GetSignedBlockBySeq(tx, parsedBlockSeq+i+1) if err != nil { return err } if b == nil { - return fmt.Errorf("no block exists in depth: %d", parsedHeight+i+1) + return fmt.Errorf("no block exists in depth: %d", parsedBlockSeq+i+1) } if err := history.ParseBlock(tx, b.Block); err != nil { From 712eae4c111a1a80712502da3d7772b3e804a68d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 16 Jul 2018 10:40:00 +0000 Subject: [PATCH 138/399] [swig] refs #1568. Added BuildInfo_Handle typemap. --- lib/swig/skycoin.mem.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index cdc248b90e..6eddd4f19c 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -95,7 +95,7 @@ GoStringMap, PasswordReader__Handle_, Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle + Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle } %apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, @@ -103,5 +103,5 @@ App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle* + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle* } From 714758ee7cde3c57bc9e4f75c2097f1a6f2fe924 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 16 Jul 2018 17:12:09 +0000 Subject: [PATCH 139/399] [libc] refs #1191. Removed empty structure in C. [====] Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0. --- include/cipher.encrypt.sha256xor.go.h | 2 -- include/cli.cli.go.h | 2 -- include/skytypes.gen.h | 1 - lib/cgo/cipher.encrypt.sha256xor.go | 8 ++++---- lib/cgo/cli.cli.go | 4 ++-- lib/cgo/tests/check_cipher.encrypt.sha256xor.c | 15 +++++---------- 6 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 include/cipher.encrypt.sha256xor.go.h diff --git a/include/cipher.encrypt.sha256xor.go.h b/include/cipher.encrypt.sha256xor.go.h deleted file mode 100644 index b306cba549..0000000000 --- a/include/cipher.encrypt.sha256xor.go.h +++ /dev/null @@ -1,2 +0,0 @@ -typedef struct{ -} encrypt__Sha256Xor; diff --git a/include/cli.cli.go.h b/include/cli.cli.go.h index aa1ffe590d..126a0e3c8c 100644 --- a/include/cli.cli.go.h +++ b/include/cli.cli.go.h @@ -1,3 +1 @@ typedef GoSlice_ cli__PasswordFromBytes; -typedef struct{ -} cli__PasswordFromTerm; diff --git a/include/skytypes.gen.h b/include/skytypes.gen.h index 367e08f86f..d2e7706c94 100644 --- a/include/skytypes.gen.h +++ b/include/skytypes.gen.h @@ -3,7 +3,6 @@ #include "cipher.crypto.go.h" #include "cipher.encoder.field.go.h" #include "cipher.encrypt.scrypt_chacha20poly1305.go.h" -#include "cipher.encrypt.sha256xor.go.h" #include "cipher.secp256k1-go.secp256k1-go2.field.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go index 41ab7c4648..aa4f1bc6a6 100644 --- a/lib/cgo/cipher.encrypt.sha256xor.go +++ b/lib/cgo/cipher.encrypt.sha256xor.go @@ -17,12 +17,12 @@ import ( import "C" //export SKY_encrypt_Sha256Xor_Encrypt -func SKY_encrypt_Sha256Xor_Encrypt(_s *C.encrypt__Sha256Xor, _data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { +func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - s := *(*encrypt.Sha256Xor)(unsafe.Pointer(_s)) + s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) __arg2, ____return_err := s.Encrypt(data, password) @@ -34,12 +34,12 @@ func SKY_encrypt_Sha256Xor_Encrypt(_s *C.encrypt__Sha256Xor, _data []byte, _pass } //export SKY_encrypt_Sha256Xor_Decrypt -func SKY_encrypt_Sha256Xor_Decrypt(_s *C.encrypt__Sha256Xor, _data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { +func SKY_encrypt_Sha256Xor_Decrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - s := *(*encrypt.Sha256Xor)(unsafe.Pointer(_s)) + s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) __arg2, ____return_err := s.Decrypt(data, password) diff --git a/lib/cgo/cli.cli.go b/lib/cgo/cli.cli.go index e58495d293..454ff07efe 100644 --- a/lib/cgo/cli.cli.go +++ b/lib/cgo/cli.cli.go @@ -139,12 +139,12 @@ func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.G } //export SKY_cli_PasswordFromTerm_Password -func SKY_cli_PasswordFromTerm_Password(_p *C.cli__PasswordFromTerm, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_cli_PasswordFromTerm_Password(_arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - p := *(*cli.PasswordFromTerm)(unsafe.Pointer(_p)) + p := cli.PasswordFromTerm{} __arg0, ____return_err := p.Password() ____error_code = libErrorCode(____return_err) if ____return_err == nil { diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 4ebe4ecfba..907758d3f6 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -163,11 +163,9 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ {65, &pwd3, &nullPwd, 1, 0}, }; - encrypt__Sha256Xor encryptSettings = {}; - for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ randBytes(&data, test_data[i].dataLength); - errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, *(test_data[i].pwd), &encrypted); + errcode = SKY_encrypt_Sha256Xor_Encrypt(data, *(test_data[i].pwd), &encrypted); if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); } else { @@ -212,7 +210,7 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ for(int i = 33; i <= 64; i++){ randBytes(&data, i); - errcode = SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd1, &encrypted); + errcode = SKY_encrypt_Sha256Xor_Encrypt(data, pwd1, &encrypted); cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); @@ -270,7 +268,6 @@ Test(cipher_encrypt_sha256xor, TestDecrypt){ {32, &pwd, &nullPwd, 0, 0}, //Null password {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password }; - encrypt__Sha256Xor encryptSettings = {}; for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ randBytes(&data, 32); makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); @@ -279,8 +276,7 @@ Test(cipher_encrypt_sha256xor, TestDecrypt){ if( test_data[i].tampered ){ ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; } - errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, - *(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); + errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); } else { @@ -291,10 +287,9 @@ Test(cipher_encrypt_sha256xor, TestDecrypt){ for(int i = 0; i <= 64; i++){ randBytes(&data, i); //makeEncryptedData(data, i, pwd, &encrypted); - SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + SKY_encrypt_Sha256Xor_Encrypt(data, pwd, &encrypted); cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - errcode = SKY_encrypt_Sha256Xor_Decrypt(&encryptSettings, - *(GoSlice*)&encrypted, pwd, &decrypted); + errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, pwd, &decrypted); cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); int equal = 1; From b1c5ccadd3454b5d9675363ab889b20a8b073fd3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 17 Jul 2018 14:18:36 +0000 Subject: [PATCH 140/399] [swig] refs #1568. Update structs.i with skytypes.gen.h --- lib/swig/structs.i | 101 +-------------------------------------------- 1 file changed, 2 insertions(+), 99 deletions(-) diff --git a/lib/swig/structs.i b/lib/swig/structs.i index 0374e9b010..0d163495e0 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -1,124 +1,27 @@ %include "cipher.hash.go.h" %include "cipher.address.go.h" -%include "cipher.base58.base58.go.h" -%include "cipher.chacha20poly1305.chacha20poly1305.go.h" -%include "cipher.chacha20poly1305.chacha20poly1305_amd64.go.h" -%include "cipher.chacha20poly1305.chacha20poly1305_generic.go.h" -%include "cipher.chacha20poly1305.chacha20poly1305_noasm.go.h" -%include "cipher.chacha20poly1305.internal.chacha20.chacha_generic.go.h" %include "cipher.crypto.go.h" -%include "cipher.encoder.encoder.go.h" %include "cipher.encoder.field.go.h" %include "cipher.encrypt.scrypt_chacha20poly1305.go.h" %include "cipher.encrypt.sha256xor.go.h" -%include "cipher.go-bip39.bip39.go.h" -%include "cipher.go-bip39.wordlist.go.h" -%include "cipher.pbkdf2.pbkdf2.go.h" -%include "cipher.poly1305.poly1305.go.h" -%include "cipher.poly1305.sum_amd64.go.h" -%include "cipher.poly1305.sum_arm.go.h" -%include "cipher.poly1305.sum_ref.go.h" -%include "cipher.ripemd160.ripemd160block.go.h" -%include "cipher.ripemd160.ripmd_160.go.h" -%include "cipher.scrypt.scrypt.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.ec.go.h" %include "cipher.secp256k1-go.secp256k1-go2.field.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.num.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.secp256k1.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.sig.go.h" %include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" %include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.z_consts.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.z_init.go.h" -%include "cipher.secp256k1-go.secp256k1.go.h" -%include "cipher.secp256k1-go.secp256_rand.go.h" %include "coin.transactions.go.h" %include "coin.block.go.h" %include "coin.outputs.go.h" -%include "consensus.blockstat.go.h" -%include "consensus.connection_manager.go.h" -%include "consensus.consensus.go.h" -%include "consensus.participant.go.h" -%include "consensus.public_broadcast_channel.public_broadcast_channel.go.h" - -%include "testutil.assert.assertions.go.h" -%include "testutil.require.require.go.h" -%include "util.browser.browser.go.h" -%include "util.cert.cert.go.h" -%include "util.droplet.droplet.go.h" -%include "util.elapse.elapser.go.h" -%include "util.fee.fee.go.h" -%include "util.file.file.go.h" -%include "util.http.error.go.h" -%include "util.http.handler.go.h" -%include "util.http.json.go.h" -%include "util.http.log.go.h" -%include "util.iputil.iputil.go.h" -%include "util.logging.formatter.go.h" -%include "util.logging.hooks.go.h" -%include "util.logging.logger.go.h" -%include "util.logging.logging.go.h" -%include "util.utc.utc.go.h" -%include "visor.blockchain.go.h" -%include "visor.visor.go.h" -%include "visor.blockdb.blockchain.go.h" -%include "visor.blockdb.blocksigs.go.h" -%include "visor.blockdb.block_tree.go.h" -%include "visor.blockdb.unspent.go.h" -%include "visor.db.go.h" -%include "visor.distribution.go.h" -%include "visor.historydb.address_txn.go.h" -%include "visor.historydb.address_uxout.go.h" -%include "visor.historydb.historydb.go.h" -%include "visor.historydb.history_meta.go.h" -%include "visor.historydb.output.go.h" -%include "visor.historydb.transaction.go.h" %include "visor.readable.go.h" -%include "visor.richlist.go.h" -%include "visor.unconfirmed.go.h" -%include "visor.verify.go.h" -%include "daemon.gnet.pool.go.h" -%include "daemon.gnet.message.go.h" -%include "daemon.messages.go.h" -%include "daemon.daemon.go.h" -%include "daemon.gateway.go.h" -%include "daemon.gnet.dispatcher.go.h" -%include "daemon.pex.peerlist.go.h" -%include "daemon.pex.pex.go.h" -%include "daemon.pool.go.h" -%include "daemon.rpc.go.h" -%include "daemon.storage.go.h" -%include "daemon.strand.strand.go.h" -%include "daemon.visor.go.h" - -%include "api.webrpc.block.go.h" -%include "api.webrpc.client.go.h" -%include "api.webrpc.gateway.go.h" -%include "api.webrpc.outputs.go.h" -%include "api.webrpc.status.go.h" -%include "api.webrpc.transaction.go.h" -%include "api.webrpc.uxout.go.h" -%include "api.webrpc.webrpc.go.h" -%include "wallet.addresses.go.h" %include "wallet.balance.go.h" -%include "wallet.crypto.go.h" %include "wallet.entry.go.h" %include "wallet.notes.go.h" -%include "wallet.readable.go.h" -%include "wallet.secrets.go.h" -%include "wallet.service.go.h" %include "wallet.wallet.go.h" -%include "wallet.wallets.go.h" %include "api.client.go.h" -%include "api.explorer.go.h" -%include "api.spend.go.h" -%include "api.wallet.go.h" -%include "cli.check_balance.go.h" %include "cli.cli.go.h" -%include "cli.create_rawtx.go.h" \ No newline at end of file +%include "cli.create_rawtx.go.h" +%include "util.http.json.go.h" From ed3babadcb45a352ec8f383cd770a6b2675d7b85 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 17 Jul 2018 15:12:18 +0000 Subject: [PATCH 141/399] [swig] refs #1568. Compile libskycoin if header files are changed. Fix in structs.i. --- Makefile | 5 +++-- lib/swig/structs.i | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1e6c368781..dfd93b9faf 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ BUILDLIB_DIR = $(BUILD_DIR)/libskycoin LIB_DIR = lib LIB_FILES = $(shell find ./lib/cgo -type f -name "*.go") SRC_FILES = $(shell find ./src -type f -name "*.go") +HEADER_FILES = $(shell find ./src -type f -name "*.h") BIN_DIR = bin DOC_DIR = docs INCLUDE_DIR = include @@ -77,12 +78,12 @@ configure-build: mkdir -p $(BUILD_DIR)/usr/tmp $(BUILD_DIR)/usr/lib $(BUILD_DIR)/usr/include mkdir -p $(BUILDLIB_DIR) $(BIN_DIR) $(INCLUDE_DIR) -$(BUILDLIB_DIR)/libskycoin.so: $(LIB_FILES) $(SRC_FILES) +$(BUILDLIB_DIR)/libskycoin.so: $(LIB_FILES) $(SRC_FILES) $(HEADER_FILES) rm -Rf $(BUILDLIB_DIR)/libskycoin.so go build -buildmode=c-shared -o $(BUILDLIB_DIR)/libskycoin.so $(LIB_FILES) mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ -$(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) +$(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) $(HEADER_FILES) rm -Rf $(BUILDLIB_DIR)/libskycoin.a go build -buildmode=c-archive -o $(BUILDLIB_DIR)/libskycoin.a $(LIB_FILES) mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/ diff --git a/lib/swig/structs.i b/lib/swig/structs.i index 0d163495e0..bdc6984bc8 100644 --- a/lib/swig/structs.i +++ b/lib/swig/structs.i @@ -3,7 +3,6 @@ %include "cipher.crypto.go.h" %include "cipher.encoder.field.go.h" %include "cipher.encrypt.scrypt_chacha20poly1305.go.h" -%include "cipher.encrypt.sha256xor.go.h" %include "cipher.secp256k1-go.secp256k1-go2.field.go.h" %include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" From db4b866c7a046df3bc6979cf4928e17cd7b960c3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 17 Jul 2018 15:28:16 +0000 Subject: [PATCH 142/399] [swig] Fix in make rule, compile libskycoin if headers are changed. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dfd93b9faf..fbc17b0714 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ BUILDLIB_DIR = $(BUILD_DIR)/libskycoin LIB_DIR = lib LIB_FILES = $(shell find ./lib/cgo -type f -name "*.go") SRC_FILES = $(shell find ./src -type f -name "*.go") -HEADER_FILES = $(shell find ./src -type f -name "*.h") +HEADER_FILES = $(shell find ./include -type f -name "*.h") BIN_DIR = bin DOC_DIR = docs INCLUDE_DIR = include From de6c2aa35283d3369a636ec7ab97243a455081a9 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 17 Jul 2018 22:14:58 +0000 Subject: [PATCH 143/399] [libc] refs #1191. Changes in test check_cipher.address [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.address.c | 312 ++++++++++++------------ lib/cgo/tests/check_coin.transactions.c | 2 +- 2 files changed, 160 insertions(+), 154 deletions(-) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 13e068dbc7..edc2e08ad5 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -19,51 +19,55 @@ unsigned char buff[1024]; Test(cipher_address, TestDecodeBase58Address) { - GoString strAddr = { - SKYCOIN_ADDRESS_VALID, - 35 - }; - cipher__Address addr; + cipher__Address a; + cipher__PubKey p; + cipher__SecKey s; - cr_assert( SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_OK, "accept valid address"); + cr_assert(SKY_cipher_GenerateKeyPair(&p, &s) == SKY_OK); + cr_assert(SKY_cipher_AddressFromPubKey(&p, &a) == SKY_OK); + cr_assert(SKY_cipher_Address_Verify(&a, &p) == SKY_OK); - char tempStr[50]; + cipher__Address addr; + GoString strAddr = {SKYCOIN_ADDRESS_VALID, 35}; + cr_assert(SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_OK, + "accept valid address"); + char tempStr[50]; // preceding whitespace is invalid strcpy(tempStr, " "); strcat(tempStr, SKYCOIN_ADDRESS_VALID); strAddr.p = tempStr; strAddr.n = strlen(tempStr); - cr_assert( SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, "preceding whitespace is invalid"); + cr_assert(SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, + "preceding whitespace is invalid"); // preceding zeroes are invalid strcpy(tempStr, "000"); strcat(tempStr, SKYCOIN_ADDRESS_VALID); strAddr.p = tempStr; strAddr.n = strlen(tempStr); - cr_assert( SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, "leading zeroes prefix are invalid"); + cr_assert(SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, + "leading zeroes prefix are invalid"); // trailing whitespace is invalid strcpy(tempStr, SKYCOIN_ADDRESS_VALID); strcat(tempStr, " "); strAddr.p = tempStr; strAddr.n = strlen(tempStr); - cr_assert( SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, " trailing whitespace is invalid"); + cr_assert(SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, + " trailing whitespace is invalid"); // trailing zeroes are invalid strcpy(tempStr, SKYCOIN_ADDRESS_VALID); strcat(tempStr, "000"); strAddr.p = tempStr; strAddr.n = strlen(tempStr); - cr_assert( SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, " trailing zeroes suffix are invalid"); - + cr_assert(SKY_cipher_DecodeBase58Address(strAddr, &addr) == SKY_ERROR, + " trailing zeroes suffix are invalid"); } -Test(cipher_address, TestAddressFromBytes){ - GoString strAddr = { - SKYCOIN_ADDRESS_VALID, - 35 - }; +Test(cipher_address, TestAddressFromBytes) { + GoString strAddr = {SKYCOIN_ADDRESS_VALID, 35}; cipher__Address addr, addr2; GoSlice bytes; @@ -74,21 +78,26 @@ Test(cipher_address, TestAddressFromBytes){ SKY_cipher_DecodeBase58Address(strAddr, &addr); SKY_cipher_Address_BitcoinBytes(&addr, (GoSlice_ *)&bytes); cr_assert(bytes.len > 0, "address bytes written"); - cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == SKY_OK, "convert bytes to SKY address"); + cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == SKY_OK, + "convert bytes to SKY address"); cr_assert(eq(type(cipher__Address), addr, addr2)); int bytes_len = bytes.len; bytes.len = bytes.len - 2; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == SKY_ErrInvalidLength, "no SKY address due to short bytes length"); + cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == + SKY_ErrInvalidLength, + "no SKY address due to short bytes length"); bytes.len = bytes_len; - ((char *) bytes.data)[bytes.len - 1] = '2'; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == SKY_ErrInvalidChecksum, "no SKY address due to corrupted bytes"); + ((char *)bytes.data)[bytes.len - 1] = '2'; + cr_assert(SKY_cipher_BitcoinAddressFromBytes(bytes, &addr2) == + SKY_ErrInvalidChecksum, + "no SKY address due to corrupted bytes"); } -Test(cipher_address, TestAddressVerify){ +Test(cipher_address, TestAddressVerify) { cipher__PubKey pubkey; cipher__SecKey seckey; @@ -96,148 +105,146 @@ Test(cipher_address, TestAddressVerify){ cipher__SecKey seckey2; cipher__Address addr; - SKY_cipher_GenerateKeyPair(&pubkey,&seckey); - SKY_cipher_AddressFromPubKey(&pubkey,&addr); + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); + SKY_cipher_AddressFromPubKey(&pubkey, &addr); // Valid pubkey+address - cr_assert( SKY_cipher_Address_Verify(&addr,&pubkey) == SKY_OK ,"Valid pubkey + address"); + cr_assert(SKY_cipher_Address_Verify(&addr, &pubkey) == SKY_OK, + "Valid pubkey + address"); - SKY_cipher_GenerateKeyPair(&pubkey,&seckey2); + SKY_cipher_GenerateKeyPair(&pubkey, &seckey2); // // Invalid pubkey - cr_assert( SKY_cipher_Address_Verify(&addr,&pubkey) == SKY_ErrInvalidPubKey," Invalid pubkey"); + cr_assert(SKY_cipher_Address_Verify(&addr, &pubkey) == SKY_ErrInvalidPubKey, + " Invalid pubkey"); // Bad version addr.Version = 0x01; - cr_assert( SKY_cipher_Address_Verify(&addr,&pubkey) == SKY_ErrInvalidVersion," Bad version"); + cr_assert(SKY_cipher_Address_Verify(&addr, &pubkey) == SKY_ErrInvalidVersion, + " Bad version"); } -Test(cipher_address,TestAddressString){ +Test(cipher_address, TestAddressString) { cipher__PubKey p; cipher__SecKey s1; GoInt result; - result = SKY_cipher_GenerateKeyPair(&p,&s1); - cr_assert(result==SKY_OK,"SKY_cipher_GenerateKeyPair failed"); + result = SKY_cipher_GenerateKeyPair(&p, &s1); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); cipher__Address a; - result = SKY_cipher_AddressFromPubKey(&p,&a); - cr_assert(result==SKY_OK,"SKY_cipher_AddressFromPubKey failed"); + result = SKY_cipher_AddressFromPubKey(&p, &a); + cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); char buffer_s[1024]; - GoString_ s= {buffer_s,0}; - result =SKY_cipher_Address_String(&a,&s); - cr_assert(result==SKY_OK,"SKY_cipher_Address_String failed"); + GoString_ s = {buffer_s, 0}; + result = SKY_cipher_Address_String(&a, &s); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); cipher__Address a2; char buffer_sConvert[1024]; - GoString sConvert={buffer_sConvert,0}; - toGoString(&s,&sConvert); - result = SKY_cipher_DecodeBase58Address(sConvert,&a2); + GoString sConvert = {buffer_sConvert, 0}; + toGoString(&s, &sConvert); + result = SKY_cipher_DecodeBase58Address(sConvert, &a2); cr_assert(result == SKY_OK); - cr_assert(eq(type(cipher__Address),a,a2)); + cr_assert(eq(type(cipher__Address), a, a2)); char buffer_s2[1024]; - GoString_ s2={buffer_s2,0}; - result = SKY_cipher_Address_String(&a2,&s2); - cr_assert(result == SKY_OK,"SKY_cipher_Address_String failed"); + GoString_ s2 = {buffer_s2, 0}; + result = SKY_cipher_Address_String(&a2, &s2); + cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); cipher__Address a3; char buffer_s2Convert[1024]; - GoString s2Convert={buffer_s2Convert,0}; - toGoString(&s2,&s2Convert); - result =SKY_cipher_DecodeBase58Address(s2Convert,&a3); - cr_assert(result == SKY_OK,"SKY_cipher_DecodeBase58Address failed"); - cr_assert(eq(type(cipher__Address),a2,a3)); - + GoString s2Convert = {buffer_s2Convert, 0}; + toGoString(&s2, &s2Convert); + result = SKY_cipher_DecodeBase58Address(s2Convert, &a3); + cr_assert(result == SKY_OK, "SKY_cipher_DecodeBase58Address failed"); + cr_assert(eq(type(cipher__Address), a2, a3)); } -Test (cipher, TestBitcoinAddress1){ +Test(cipher, TestBitcoinAddress1) { cipher__SecKey seckey; cipher__PubKey pubkey; - GoString str = { - "1111111111111111111111111111111111111111111111111111111111111111", - 64 - }, s1, s2; + GoString + str = {"1111111111111111111111111111111111111111111111111111111111111111", + 64}, + s1, s2; - unsigned int error; + unsigned int error; error = SKY_cipher_SecKeyFromHex(str, &seckey); cr_assert(error == SKY_OK, "Create SecKey from Hex"); - error = SKY_cipher_PubKeyFromSecKey(&seckey,&pubkey); + error = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); cr_assert(error == SKY_OK, "Create PubKey from SecKey"); - GoString pubkeyStr = { "034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa", 66 }; + GoString pubkeyStr = { + "034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa", 66}; - SKY_cipher_PubKey_Hex(&pubkey, (GoString_ *) &s1); - registerMemCleanup((void *) s1.p); + SKY_cipher_PubKey_Hex(&pubkey, (GoString_ *)&s1); + registerMemCleanup((void *)s1.p); cr_assert(eq(type(GoString), pubkeyStr, s1)); - GoString bitcoinStr = {"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9",34}; - SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *) &s2); - registerMemCleanup((void *) s2.p); + GoString bitcoinStr = {"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", 34}; + SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *)&s2); + registerMemCleanup((void *)s2.p); cr_assert(eq(type(GoString), bitcoinStr, s2)); } -Test (cipher, TestBitcoinAddress2){ +Test(cipher, TestBitcoinAddress2) { cipher__SecKey seckey; - cipher__PubKey pubkey ; - GoString str = { - "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", - 64 - }, s1, s2; + cipher__PubKey pubkey; + GoString + str = {"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", + 64}, + s1, s2; - unsigned int error; + unsigned int error; error = SKY_cipher_SecKeyFromHex(str, &seckey); cr_assert(error == SKY_OK, "Create SecKey from Hex"); - error = SKY_cipher_PubKeyFromSecKey(&seckey,&pubkey); + error = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); cr_assert(error == SKY_OK, "Create PubKey from SecKey"); char strBuff[101]; GoString pubkeyStr = { - "02ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bd", - 66 - }; - SKY_cipher_PubKey_Hex(&pubkey, (GoString_ *) &s1); - registerMemCleanup((void *) s1.p); + "02ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bd", 66}; + SKY_cipher_PubKey_Hex(&pubkey, (GoString_ *)&s1); + registerMemCleanup((void *)s1.p); cr_assert(eq(type(GoString), pubkeyStr, s1)); - GoString bitcoinStr = {"1NKRhS7iYUGTaAfaR5z8BueAJesqaTyc4a",34}; - SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *) &s2); - registerMemCleanup((void *) s2.p); + GoString bitcoinStr = {"1NKRhS7iYUGTaAfaR5z8BueAJesqaTyc4a", 34}; + SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *)&s2); + registerMemCleanup((void *)s2.p); cr_assert(eq(type(GoString), bitcoinStr, s2)); - } -Test (cipher, TestBitcoinAddress3){ +Test(cipher, TestBitcoinAddress3) { cipher__SecKey seckey; cipher__PubKey pubkey; GoString str = { - "47f7616ea6f9b923076625b4488115de1ef1187f760e65f89eb6f4f7ff04b012", - 64 - }; + "47f7616ea6f9b923076625b4488115de1ef1187f760e65f89eb6f4f7ff04b012", 64}; - unsigned int error; + unsigned int error; error = SKY_cipher_SecKeyFromHex(str, &seckey); cr_assert(error == SKY_OK, "Create SecKey from Hex"); - error = SKY_cipher_PubKeyFromSecKey(&seckey,&pubkey); + error = SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); cr_assert(error == SKY_OK, "Create PubKey from SecKey"); char strBuff[101]; - GoString pubkeyStr = { - "032596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3", - 66 - }, s1, s2; + GoString + pubkeyStr = + {"032596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3", + 66}, + s1, s2; SKY_cipher_PubKey_Hex(&pubkey, (GoString_ *)&s1); - registerMemCleanup((void *) s1.p); + registerMemCleanup((void *)s1.p); cr_assert(eq(type(GoString), pubkeyStr, s1)); - GoString bitcoinStr = {"19ck9VKC6KjGxR9LJg4DNMRc45qFrJguvV",34}; + GoString bitcoinStr = {"19ck9VKC6KjGxR9LJg4DNMRc45qFrJguvV", 34}; SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *)&s2); - registerMemCleanup((void *) s2.p); + registerMemCleanup((void *)s2.p); cr_assert(eq(type(GoString), bitcoinStr, s2)); - } -Test(cipher_address, TestBitcoinWIPRoundTrio){ +Test(cipher_address, TestBitcoinWIPRoundTrio) { cipher__SecKey seckey; cipher__PubKey pubkey; @@ -246,40 +253,40 @@ Test(cipher_address, TestBitcoinWIPRoundTrio){ slice.cap = sizeof(buff); slice.len = 33; - SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); GoString_ wip1; - SKY_cipher_BitcoinWalletImportFormatFromSeckey(&seckey,&wip1); + SKY_cipher_BitcoinWalletImportFormatFromSeckey(&seckey, &wip1); cipher__SecKey seckey2; unsigned int err; - err = SKY_cipher_SecKeyFromWalletImportFormat( (*((GoString *) &wip1)) ,&seckey2); + err = + SKY_cipher_SecKeyFromWalletImportFormat((*((GoString *)&wip1)), &seckey2); GoString_ wip2; - SKY_cipher_BitcoinWalletImportFormatFromSeckey(&seckey2,&wip2); + SKY_cipher_BitcoinWalletImportFormatFromSeckey(&seckey2, &wip2); cr_assert(err == SKY_OK); - cr_assert(eq(u8[sizeof(cipher__SecKey)],seckey,seckey2)); + cr_assert(eq(u8[sizeof(cipher__SecKey)], seckey, seckey2)); GoString_ seckeyhex1; GoString_ seckeyhex2; - SKY_cipher_SecKey_Hex(&seckey,&seckeyhex1); - SKY_cipher_SecKey_Hex(&seckey2,&seckeyhex2); - cr_assert(eq(type(GoString), (*(GoString*)&seckeyhex1),(*(GoString*)&seckeyhex2) )); - cr_assert(eq(type(GoString), (*(GoString*)&wip1),(*(GoString*)&wip2) )); - + SKY_cipher_SecKey_Hex(&seckey, &seckeyhex1); + SKY_cipher_SecKey_Hex(&seckey2, &seckeyhex2); + cr_assert(eq(type(GoString), (*(GoString *)&seckeyhex1), + (*(GoString *)&seckeyhex2))); + cr_assert(eq(type(GoString), (*(GoString *)&wip1), (*(GoString *)&wip2))); } +Test(cipher_address, TestBitcoinWIP) { -Test(cipher_address, TestBitcoinWIP ){ - - //wallet input format string + // wallet input format string GoString wip[3]; wip[0].p = "KwntMbt59tTsj8xqpqYqRRWufyjGunvhSyeMo3NTYpFYzZbXJ5Hp"; @@ -292,78 +299,76 @@ Test(cipher_address, TestBitcoinWIP ){ // // //the expected pubkey to generate GoString_ pub[3]; - pub[0].p="034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa"; - pub[1].p="02ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bd"; - pub[2].p="032596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3"; + pub[0].p = + "034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa"; + pub[1].p = + "02ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bd"; + pub[2].p = + "032596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3"; pub[0].n = 66; pub[1].n = 66; pub[2].n = 66; - // //the expected addrss to generate GoString addr[3]; - addr[0].p="1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9"; - addr[1].p="1NKRhS7iYUGTaAfaR5z8BueAJesqaTyc4a"; - addr[2].p="19ck9VKC6KjGxR9LJg4DNMRc45qFrJguvV"; - - addr[0].n =34; - addr[1].n=34; - addr[2].n=34; + addr[0].p = "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9"; + addr[1].p = "1NKRhS7iYUGTaAfaR5z8BueAJesqaTyc4a"; + addr[2].p = "19ck9VKC6KjGxR9LJg4DNMRc45qFrJguvV"; + addr[0].n = 34; + addr[1].n = 34; + addr[2].n = 34; - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { cipher__SecKey seckey; unsigned int err; - err = SKY_cipher_SecKeyFromWalletImportFormat(wip[i],&seckey); - cr_assert(err==SKY_OK); + err = SKY_cipher_SecKeyFromWalletImportFormat(wip[i], &seckey); + cr_assert(err == SKY_OK); cipher__PubKey pubkey; - SKY_cipher_PubKeyFromSecKey(&seckey,&pubkey); + SKY_cipher_PubKeyFromSecKey(&seckey, &pubkey); - unsigned char * pubkeyhextmp; + unsigned char *pubkeyhextmp; GoString_ string; - SKY_cipher_PubKey_Hex(&pubkey,&string); - cr_assert(eq(type(GoString), (*(GoString*)&string),(*(GoString*)&pub[i]) )); + SKY_cipher_PubKey_Hex(&pubkey, &string); + cr_assert( + eq(type(GoString), (*(GoString *)&string), (*(GoString *)&pub[i]))); GoString bitcoinAddr; SKY_cipher_BitcoinAddressFromPubkey(&pubkey, (GoString_ *)&bitcoinAddr); - cr_assert(eq(type(GoString),addr[i],bitcoinAddr)); - + cr_assert(eq(type(GoString), addr[i], bitcoinAddr)); } } -Test(cipher_address, TestAddressBulk){ +Test(cipher_address, TestAddressBulk) { unsigned char buff[50]; - GoSlice slice = { buff, 0, 50 }; + GoSlice slice = {buff, 0, 50}; - for (int i = 0; i < 1024; ++i) - { - randBytes(&slice,32); + for (int i = 0; i < 1024; ++i) { + randBytes(&slice, 32); cipher__PubKey pubkey; cipher__SecKey seckey; - SKY_cipher_GenerateDeterministicKeyPair( slice,&pubkey,&seckey); + SKY_cipher_GenerateDeterministicKeyPair(slice, &pubkey, &seckey); cipher__Address addr; - SKY_cipher_AddressFromPubKey(&pubkey,&addr); + SKY_cipher_AddressFromPubKey(&pubkey, &addr); unsigned int err; - err = SKY_cipher_Address_Verify(&addr,&pubkey); + err = SKY_cipher_Address_Verify(&addr, &pubkey); cr_assert(err == SKY_OK); GoString strAddr; SKY_cipher_Address_String(&addr, (GoString_ *)&strAddr); - registerMemCleanup((void *) strAddr.p); + registerMemCleanup((void *)strAddr.p); cipher__Address addr2; - err = SKY_cipher_DecodeBase58Address(strAddr,&addr2); + err = SKY_cipher_DecodeBase58Address(strAddr, &addr2); cr_assert(err == SKY_OK); - cr_assert(eq(type(cipher__Address),addr,addr2)); + cr_assert(eq(type(cipher__Address), addr, addr2)); } - } Test(cipher_address, TestBitcoinAddressFromBytes) { @@ -396,13 +401,15 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { b.len = b.len - 2; cipher__Address addr2; GoSlice b_convert = {b.data, b.len, b.cap}; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ErrInvalidLength, + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == + SKY_ErrInvalidLength, "Invalid address length"); // Invalid checksum b_convert.len = b_len; (((char *)b_convert.data)[b_convert.len - 1])++; - cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == SKY_ErrInvalidChecksum, + cr_assert(SKY_cipher_BitcoinAddressFromBytes(b_convert, &addr2) == + SKY_ErrInvalidChecksum, "Invalid checksum"); result = SKY_cipher_AddressFromPubKey(&p, &a); @@ -505,7 +512,7 @@ Test(cipher_address, TestMustDecodeBase58Address) { // trailing whitespace is invalid strcpy(strbadAddr, addStr.p); strcat(strbadAddr, " "); - badAddr.p = strbadAddr; + badAddr.p = strbadAddr; badAddr.n = strlen(strbadAddr); result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); cr_assert(result == SKY_ERROR); @@ -513,13 +520,13 @@ Test(cipher_address, TestMustDecodeBase58Address) { // trailing zeroes are invalid strcpy(strbadAddr, addStr.p); strcat(strbadAddr, "000"); - badAddr.p = strbadAddr; + badAddr.p = strbadAddr; badAddr.n = strlen(strbadAddr); result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); cr_assert(result == SKY_ERROR); } -Test(cipher_address,TestAddressRoundtrip){ +Test(cipher_address, TestAddressRoundtrip) { cipher__PubKey p; cipher__SecKey s; GoInt result; @@ -529,7 +536,7 @@ Test(cipher_address,TestAddressRoundtrip){ result = SKY_cipher_AddressFromPubKey(&p, &a); cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); char buffer_aBytes[1024]; - cipher__PubKeySlice aBytes= {buffer_aBytes,0,1024}; + cipher__PubKeySlice aBytes = {buffer_aBytes, 0, 1024}; result = SKY_cipher_Address_Bytes(&a, &aBytes); cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); GoSlice aBytesSlice = {aBytes.data, aBytes.len, aBytes.cap}; @@ -537,16 +544,15 @@ Test(cipher_address,TestAddressRoundtrip){ result = SKY_cipher_AddressFromBytes(aBytesSlice, &a2); cr_assert(result == SKY_OK, "SKY_cipher_AddressFromBytes failed"); - cr_assert(eq(type(cipher__Address),a,a2)); + cr_assert(eq(type(cipher__Address), a, a2)); char buffer_aString[1024]; char buffer_a2String[1024]; - GoString_ aString = {buffer_aString,0}; - GoString_ a2String = {buffer_a2String,0}; - result = SKY_cipher_Address_String(&a,&aString); - result = SKY_cipher_Address_String(&a2,&a2String); - - cr_assert(eq(type(GoString_),a2String,aString)); + GoString_ aString = {buffer_aString, 0}; + GoString_ a2String = {buffer_a2String, 0}; + result = SKY_cipher_Address_String(&a, &aString); + result = SKY_cipher_Address_String(&a2, &a2String); + cr_assert(eq(type(GoString_), a2String, aString)); } Test(cipher_address, TestAddressNull) { diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 58d497ed0d..cfa87f2d03 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -598,7 +598,7 @@ Test(coin_transactions, TestTransactionOutputHours) { result = SKY_coin_Transaction_PushOutput(handle, &addr, 1000000, 0xFFFFFFFFFFFFFFFF - 700); result = SKY_coin_Transaction_OutputHours(handle, &hours); - cr_assert(result != SKY_OK); + cr_assert(result == SKY_ERROR); } Test(coin_transactions, TestTransactionsHashes) { From 140c645aee7aec0b9e72e725a3f5ffd282931de0 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 18 Jul 2018 11:21:31 +0000 Subject: [PATCH 144/399] [swig] refs #1568 Extend cipher structures to have comparison methods. --- lib/swig/skycoin.cipher.crypto.i | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index 157a2c7031..2d1634d90f 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -7,6 +7,43 @@ } } +%extend cipher_PubKey { + int isEqual(cipher_PubKey* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_SecKey { + int isEqual(cipher_SecKey* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Ripemd160 { + int isEqual(cipher_Ripemd160* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Sig { + int isEqual(cipher_Sig* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_SHA256 { + int isEqual(cipher_SHA256* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Checksum { + int isEqual(cipher_Checksum* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + + %extend cipher_SecKeys { cipher_SecKey* getAt(int i){ if( i < $self->count ){ @@ -25,6 +62,10 @@ } } + int isEqual(cipher_SecKeys* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SecKey) * $self->count) == 0; + } + void allocate(int n){ $self->data = malloc(n * sizeof(*($self->data))); $self->count = n; @@ -63,6 +104,10 @@ } } + int isEqual(cipher_PubKeys* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_PubKey) * $self->count) == 0; + } + void allocate(int n){ $self->data = malloc(n * sizeof(*($self->data))); $self->count = n; From 346ee39f0f97c50a0ee3857e204a06047dcdfceb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 18 Jul 2018 14:47:36 +0000 Subject: [PATCH 145/399] [swig] refs #1568. Define == operator for cipher__address. --- lib/swig/python_skycoin.cipher.crypto.i | 96 +++++++++++++++++++++++++ lib/swig/skycoin.cipher.crypto.i | 2 +- lib/swig/skycoin.i | 2 +- 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 lib/swig/python_skycoin.cipher.crypto.i diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i new file mode 100644 index 0000000000..77646ffff3 --- /dev/null +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -0,0 +1,96 @@ + + +%extend cipher__Address{ + int __eq__(cipher__Address* a){ + if( $self->Version == a->Version ){ + return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; + } + return 0; + } +} + + +%extend cipher_SecKeys { + cipher_SecKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, cipher_SecKey* seckey){ + if( i < $self->count){ + memcpy(&self->data[i], seckey, sizeof(*seckey)); + return i; + } else { + return -1; + } + } + + int isEqual(cipher_SecKeys* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SecKey) * $self->count) == 0; + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + destroy_cipher_SecKeys($self); + } +} + +%inline{ + void destroy_cipher_SecKeys(cipher_SecKeys* p){ + if( p != NULL ){ + if( p->data != NULL ){ + free( p->data ); + } + } + } +} + +%extend cipher_PubKeys { + cipher_PubKey* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, cipher_PubKey* pubkey){ + if( i < $self->count){ + memcpy(&self->data[i], pubkey, sizeof(*pubkey)); + return i; + } else { + return -1; + } + } + + int isEqual(cipher_PubKeys* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_PubKey) * $self->count) == 0; + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + destroy_cipher_PubKeys($self); + } +} + + +%inline{ + void destroy_cipher_PubKeys(cipher_PubKeys* p){ + if( p != NULL ){ + if( p->data != NULL ){ + free( p->data ); + } + } + } +} diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index 2d1634d90f..b61b53e0ab 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -1,6 +1,6 @@ %extend cipher__Address { int isEqual(cipher__Address* a){ - if( $self-> Version == a->Version ){ + if( $self->Version == a->Version ){ return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; } return 0; diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index e740299062..ae66b63a84 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -12,7 +12,7 @@ #if defined(SWIGPYTHON) %include "golang.cgo.i" %include "skycoin.mem.i" -%include "skycoin.cipher.crypto.i" +%include "python_skycoin.cipher.crypto.i" %include "structs_typemaps.i" #else %include "skycoin.cipher.crypto.i" From cb7207e049911237502a185952fba0b0d6b5666b Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 18 Jul 2018 16:01:46 +0000 Subject: [PATCH 146/399] [swig] refs #1568. Define == operator for cipher structs. --- lib/swig/python_skycoin.cipher.crypto.i | 40 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 77646ffff3..b0fa42ebec 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -9,6 +9,42 @@ } } +%extend cipher_PubKey { + int __eq__(cipher_PubKey* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_SecKey { + int __eq__(cipher_SecKey* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Ripemd160 { + int __eq__(cipher_Ripemd160* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Sig { + int __eq__(cipher_Sig* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_SHA256 { + int __eq__(cipher_SHA256* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + +%extend cipher_Checksum { + int __eq__(cipher_Checksum* a){ + return memcmp($self->data, a->data, sizeof(a->data)) == 0; + } +} + %extend cipher_SecKeys { cipher_SecKey* getAt(int i){ @@ -28,7 +64,7 @@ } } - int isEqual(cipher_SecKeys* a){ + int __eq__(cipher_SecKeys* a){ return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SecKey) * $self->count) == 0; } @@ -70,7 +106,7 @@ } } - int isEqual(cipher_PubKeys* a){ + int __eq__(cipher_PubKeys* a){ return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_PubKey) * $self->count) == 0; } From 614f4e6075de9f28fc3a9935e22085db8e7fac2d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 18 Jul 2018 17:31:30 +0000 Subject: [PATCH 147/399] [libc] refs #1191. Added new exported functions from package ripemd160. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- include/skytypes.h | 6 +++ lib/cgo/cipher.ripemd160.ripemd160.go | 66 +++++++++++++++++++++++++++ lib/cgo/libsky_handle.go | 16 +++++++ 3 files changed, 88 insertions(+) create mode 100644 lib/cgo/cipher.ripemd160.ripemd160.go diff --git a/include/skytypes.h b/include/skytypes.h index e0d844929c..6a9c62c6ac 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -345,6 +345,12 @@ typedef Handle AddressUxOuts_Handle; typedef Handle BuildInfo_Handle; +/** + * Memory handle for hash (ripemd160.digest) + */ + +typedef Handle Hash_Handle; + typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); #endif diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go new file mode 100644 index 0000000000..99392b919d --- /dev/null +++ b/lib/cgo/cipher.ripemd160.ripemd160.go @@ -0,0 +1,66 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/skycoin/skycoin/src/cipher/ripemd160" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_ripemd160_New +func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + hash := ripemd160.New() + *handle = registerHashHandle(&hash) + return +} + +//export SKY_ripemd160_Write +func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + h, ok := lookupHashHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + p := *(*[]byte)(unsafe.Pointer(&_p)) + nn, error := (*h).Write(p) + if error != nil { + ____error_code = SKY_ERROR + return + } + *_nn = nn + return +} + +//export SKY_ripemd160_Sum +func SKY_ripemd160_Sum(handle C.Hash_Handle, _p []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + h, ok := lookupHashHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + p := *(*[]byte)(unsafe.Pointer(&_p)) + __arg1 := (*h).Sum(p) + copyToGoSlice(reflect.ValueOf(__arg1[:]), _arg1) + return +} diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 6b6dd861bf..9d8f29de1d 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -11,6 +11,8 @@ package main import "C" import ( + "hash" + api "github.com/skycoin/skycoin/src/api" webrpc "github.com/skycoin/skycoin/src/api/webrpc" cli "github.com/skycoin/skycoin/src/cli" @@ -497,6 +499,20 @@ func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*visor.BuildInfo, bool) { return nil, false } +func registerHashHandle(obj *hash.Hash) C.Hash_Handle { + return (C.Hash_Handle)(registerHandle(obj)) +} + +func lookupHashHandle(handle C.Hash_Handle) (*hash.Hash, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*hash.Hash); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } From 9e77c2b13cc4558dddc4b0d288e9c83885f8c22c Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 11:14:50 +0000 Subject: [PATCH 148/399] [swig] refs #1568. Add comparison function isEqual and operator == to type coin__BlockHeader. --- lib/swig/python_skycoin.coin.i | 14 ++++++++++++++ lib/swig/skycoin.coin.i | 14 ++++++++++++++ lib/swig/skycoin.i | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 lib/swig/python_skycoin.coin.i create mode 100644 lib/swig/skycoin.coin.i diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i new file mode 100644 index 0000000000..c31aca127e --- /dev/null +++ b/lib/swig/python_skycoin.coin.i @@ -0,0 +1,14 @@ +%extend coin__BlockHeader { + int __eq__(coin__BlockHeader* a){ + if( $self->Version != a->Version || $self->Time != a->Time || + $self->BkSeq != a->BkSeq || $self->Fee != a->Fee) + return 0; + if( memcmp( &$self->PrevHash, a->PrevHash, sizeof(a->PrevHash) ) != 0 ) + return 0; + if( memcmp( &$self->BodyHash, a->PrevHash, sizeof(a->BodyHash) ) != 0 ) + return 0; + if( memcmp( &$self->UxHash, a->PrevHash, sizeof(a->UxHash) ) != 0 ) + return 0; + return 1; + } +} diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i new file mode 100644 index 0000000000..a107dbe900 --- /dev/null +++ b/lib/swig/skycoin.coin.i @@ -0,0 +1,14 @@ +%extend coin__BlockHeader { + int isEqual(coin__BlockHeader* a){ + if( $self->Version != a->Version || $self->Time != a->Time || + $self->BkSeq != a->BkSeq || $self->Fee != a->Fee) + return 0; + if( memcmp( &$self->PrevHash, a->PrevHash, sizeof(a->PrevHash) ) != 0 ) + return 0; + if( memcmp( &$self->BodyHash, a->PrevHash, sizeof(a->BodyHash) ) != 0 ) + return 0; + if( memcmp( &$self->UxHash, a->PrevHash, sizeof(a->UxHash) ) != 0 ) + return 0; + return 1; + } +} diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index ae66b63a84..6a18b02b8f 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -13,9 +13,11 @@ %include "golang.cgo.i" %include "skycoin.mem.i" %include "python_skycoin.cipher.crypto.i" +%include "python_skycoin.coin.i" %include "structs_typemaps.i" #else %include "skycoin.cipher.crypto.i" +%include "skycoin.coin.i" #endif %include "swig.h" From ada52e3678d43eb0e079ddd5ac37b55b8b270b38 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 14:23:07 +0000 Subject: [PATCH 149/399] [swig] refs #1568. Add method compareToString to cipher structs that wrap fixed size GoUint8 arrays. --- lib/swig/python_skycoin.cipher.crypto.i | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index b0fa42ebec..3008d2d599 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -13,36 +13,72 @@ int __eq__(cipher_PubKey* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } %extend cipher_SecKey { int __eq__(cipher_SecKey* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } %extend cipher_Ripemd160 { int __eq__(cipher_Ripemd160* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } %extend cipher_Sig { int __eq__(cipher_Sig* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } %extend cipher_SHA256 { int __eq__(cipher_SHA256* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } %extend cipher_Checksum { int __eq__(cipher_Checksum* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + int compareToString(PyObject * str){ + char* s = SWIG_Python_str_AsChar(str); + int result = memcmp(s, $self->data, sizeof($self->data)); + SWIG_Python_str_DelForPy3(s); + return result; + } } @@ -130,3 +166,4 @@ } } } + From e45ede3d2c32fa8f94e0887dce43b6bf711e732b Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 15:50:59 +0000 Subject: [PATCH 150/399] [swig] refs #1568. Use SWIG_POINTER_OWN instead of SWIG_POINTER_NOSHADOW when calling SWIG_NewPointerObj. Organize includes in skycoin.i. --- lib/swig/python_seckeys.i | 2 +- lib/swig/skycoin.i | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index ca54d79468..1cc5796307 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -11,7 +11,7 @@ PyObject *list = PyList_New(0); for (i = 0; i < $1->count; i++) { cipher_SecKey* key = &($1->data[i]); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW ); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); PyList_Append(list, o); //Py_DECREF(o); } diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index 6a18b02b8f..31854b68d7 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -7,14 +7,20 @@ %} -//Apply typemaps only for Python +//Apply typemaps for Python for now //It can be applied to other languages that fit in +//Not languages can't return multiple values #if defined(SWIGPYTHON) %include "golang.cgo.i" %include "skycoin.mem.i" +%include "structs_typemaps.i" +#endif + +//Apply strictly to python +//Not for other languages +#if defined(SWIGPYTHON) %include "python_skycoin.cipher.crypto.i" %include "python_skycoin.coin.i" -%include "structs_typemaps.i" #else %include "skycoin.cipher.crypto.i" %include "skycoin.coin.i" From 0d69e5d681b370d0a277be8b051a90be81edfca2 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 17:26:00 +0000 Subject: [PATCH 151/399] [swig] refs #1568. Added method toStr to cipher structs wrapping fixed size GoInt8 arrays. --- lib/swig/python_skycoin.cipher.crypto.i | 21 +++++++++++++++++++++ lib/swig/python_skycoin.coin.i | 15 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 3008d2d599..2d29038f67 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -7,6 +7,9 @@ } return 0; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->Key, sizeof($self->Key)); + } } %extend cipher_PubKey { @@ -19,6 +22,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } %extend cipher_SecKey { @@ -31,6 +37,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } %extend cipher_Ripemd160 { @@ -43,6 +52,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } %extend cipher_Sig { @@ -55,6 +67,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } %extend cipher_SHA256 { @@ -67,6 +82,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } %extend cipher_Checksum { @@ -79,6 +97,9 @@ SWIG_Python_str_DelForPy3(s); return result; } + PyObject* toStr(){ + return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + } } diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index c31aca127e..9908027bbf 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -12,3 +12,18 @@ return 1; } } + +/*%typemap(in, numinputs=0) (coin__Transaction**) (coin__Transaction* temp) { + temp = NULL; + $1 = &temp; +}*/ + + +/*Return a pointer created with SWIG_POINTER_NOSHADOW because +Python will not own the object + */ +/*%typemap(argout) (coin__Transaction**) { + %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Transaction, SWIG_POINTER_OWN ) ); +}*/ + + From 9eb93d8c13c487cfb00af8acd0f2893438de41ef Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 17:58:42 +0000 Subject: [PATCH 152/399] [swig] refs #1568. Use PyBytes_FromStringAndSize to create return value for toStr functions. --- lib/swig/python_skycoin.cipher.crypto.i | 14 +++++++------- lib/swig/python_skycoin.coin.i | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 2d29038f67..4bc231b1a2 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -8,7 +8,7 @@ return 0; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->Key, sizeof($self->Key)); + return PyBytes_FromStringAndSize((const char*)$self->Key, sizeof($self->Key)); } } @@ -23,7 +23,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } @@ -38,7 +38,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } @@ -53,7 +53,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } @@ -68,7 +68,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } @@ -83,7 +83,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } @@ -98,7 +98,7 @@ return result; } PyObject* toStr(){ - return PyString_FromStringAndSize((const char*)$self->data, sizeof($self->data)); + return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } } diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 9908027bbf..189634bb82 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -13,17 +13,17 @@ } } -/*%typemap(in, numinputs=0) (coin__Transaction**) (coin__Transaction* temp) { +%typemap(in, numinputs=0) (coin__Transaction**) (coin__Transaction* temp) { temp = NULL; $1 = &temp; -}*/ +} /*Return a pointer created with SWIG_POINTER_NOSHADOW because Python will not own the object */ -/*%typemap(argout) (coin__Transaction**) { - %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Transaction, SWIG_POINTER_OWN ) ); -}*/ +%typemap(argout) (coin__Transaction**) { + %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Transaction, 0 ) ); +} From dfa545a215492705a0f5b6ed41126468136bf806 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 18:33:53 +0000 Subject: [PATCH 153/399] [swig] refs #1568. Added typemaps for coin__Block** and coin__UxArray**. --- lib/swig/python_skycoin.coin.i | 36 ++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 189634bb82..15450e6ad5 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -18,12 +18,44 @@ $1 = &temp; } - -/*Return a pointer created with SWIG_POINTER_NOSHADOW because +/*Return a pointer created with own = 0 because Python will not own the object */ %typemap(argout) (coin__Transaction**) { %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Transaction, 0 ) ); } +%typemap(in, numinputs=0) (coin__Block**) (coin__Block* temp) { + temp = NULL; + $1 = &temp; +} + +/*Return a pointer created with own = 0 because +Python will not own the object + */ +%typemap(argout) (coin__Block**) { + %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Block, 0 ) ); +} + + +%typemap(in, numinputs=0) (coin__UxArray**) (coin__UxArray* temp){ + temp = NULL; + $1 = &temp; +} + +%typemap(argout) (coin__UxArray**) { + int i; + PyObject *list = PyList_New(0); + coin__Transaction* pTrans = (*$1)->data; + i = (*$1)->count; + for (; i > 0; i--) { + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(pTrans), SWIGTYPE_p_coin__Transaction, 0 ); + PyList_Append(list, o); + pTrans++; + } + %append_output( list ); +} + + + From 62637def24e893356a586729b46109b76e870819 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 18:39:22 +0000 Subject: [PATCH 154/399] [swig] refs #1568. Use SWIG_POINTER_NOSHADOW back in cipher_SecKeys* typemap. --- lib/swig/python_seckeys.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index 1cc5796307..ca54d79468 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -11,7 +11,7 @@ PyObject *list = PyList_New(0); for (i = 0; i < $1->count; i++) { cipher_SecKey* key = &($1->data[i]); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW ); PyList_Append(list, o); //Py_DECREF(o); } From e9866082042279c76eaedcd120246ee03c17d093 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 18:43:11 +0000 Subject: [PATCH 155/399] [swig] refs #1568. Fix bug in coin__UxArray** typemap. --- lib/swig/python_skycoin.coin.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 15450e6ad5..a925aeb7b8 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -47,7 +47,7 @@ Python will not own the object int i; PyObject *list = PyList_New(0); coin__Transaction* pTrans = (*$1)->data; - i = (*$1)->count; + i = (*$1)->len; for (; i > 0; i--) { PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(pTrans), SWIGTYPE_p_coin__Transaction, 0 ); PyList_Append(list, o); From c08f2317d21b5656a9236885bdbd770194548778 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 19:19:58 +0000 Subject: [PATCH 156/399] [swig] refs #1568. Fix bug in cipher_SecKeys typemap. --- lib/swig/python_seckeys.i | 4 +++- lib/swig/python_skycoin.cipher.crypto.i | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index ca54d79468..365acf2b17 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -11,7 +11,9 @@ PyObject *list = PyList_New(0); for (i = 0; i < $1->count; i++) { cipher_SecKey* key = &($1->data[i]); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(key), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_NOSHADOW ); + cipher_SecKey* newKey = malloc(sizeof(cipher_SecKey)); + memcpy(newKey, key, sizeof(cipher_SecKey)); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); PyList_Append(list, o); //Py_DECREF(o); } diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 4bc231b1a2..985e933d68 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -114,7 +114,7 @@ int setAt(int i, cipher_SecKey* seckey){ if( i < $self->count){ - memcpy(&self->data[i], seckey, sizeof(*seckey)); + memcpy(&$self->data[i], seckey, sizeof(*seckey)); return i; } else { return -1; From dd316a3ac3a3ce22063c47b9812845333ce3b917 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 19 Jul 2018 19:41:26 +0000 Subject: [PATCH 157/399] [swig] refs #1568. Do Py_DECREF in cipher_SecKeys typemap. --- lib/swig/python_seckeys.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index 365acf2b17..c41ec4b411 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -15,7 +15,7 @@ memcpy(newKey, key, sizeof(cipher_SecKey)); PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); PyList_Append(list, o); - //Py_DECREF(o); + Py_DECREF(o); } if( $1->data != NULL) free( (void*)$1->data ); From f1da228ff64cc27fe067c1c593f4b1e0b722f17c Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 20 Jul 2018 10:30:01 +0000 Subject: [PATCH 158/399] [libc] refs #1191. Added exported function SKY_cipher_SHA256_Null. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- lib/cgo/cipher.hash.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/cgo/cipher.hash.go b/lib/cgo/cipher.hash.go index e3048f24d2..385c10bea8 100644 --- a/lib/cgo/cipher.hash.go +++ b/lib/cgo/cipher.hash.go @@ -124,3 +124,14 @@ func SKY_cipher_MustSumSHA256(_b []byte, _n int, _arg2 *C.cipher__SHA256) (____e copyToBuffer(reflect.ValueOf(__arg2[:]), unsafe.Pointer(_arg2), uint(SizeofSHA256)) return } + +//export SKY_cipher_SHA256_Null +func SKY_cipher_SHA256_Null(_g *C.cipher__SHA256, _arg0 *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + g := (*cipher.SHA256)(unsafe.Pointer(_g)) + *_arg0 = g.Null() + return +} From 09335215c4e2d83fad58413f469b12a75074d384 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Fri, 20 Jul 2018 11:33:10 +0000 Subject: [PATCH 159/399] [libc][test] refs #1191 Added test in check_cipher_hash TestSHA256Null [====] Synthesis: Tested: 144 | Passing: 144 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/check_cipher.hash.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index f92f488546..16af68d1f6 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -361,4 +361,19 @@ Test(cipher_hash, TestMustSumSHA256) { memset(&sha, 0, sizeof(cipher__SHA256)); freshSumSHA256(b, &sha); cr_assert(eq(u8[32], h, sha)); +} + +Test(cipher_hash, TestSHA256Null) { + cipher__SHA256 x; + memset(&x, 0, sizeof(cipher__SHA256)); + GoUint32 result; + GoUint8 isNull; + cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); + cr_assert(isNull); + char buff[130]; + GoSlice b = {buff, 0, 129}; + randBytes(&b, 128); + cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); + cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); + cr_assert(not(isNull)); } \ No newline at end of file From fba5ad7d14f6d38501fc940effc0907c2f68a914 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 20 Jul 2018 16:39:55 +0000 Subject: [PATCH 160/399] [swig] #1568. Added == operator and/or isEqual function to some coin structs. --- lib/swig/cmp.i | 46 ++++++++++++++++++++++++++++++++ lib/swig/python_skycoin.coin.i | 48 +++++++++++++++++++++++++++------- lib/swig/skycoin.coin.i | 48 +++++++++++++++++++++++++++------- 3 files changed, 124 insertions(+), 18 deletions(-) create mode 100644 lib/swig/cmp.i diff --git a/lib/swig/cmp.i b/lib/swig/cmp.i new file mode 100644 index 0000000000..812ae2c764 --- /dev/null +++ b/lib/swig/cmp.i @@ -0,0 +1,46 @@ +%inline { + int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ + if(slice1->len != slice2->len) + return 0; + return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; + } + int equalTransactions(coin__Transaction* t1, coin__Transaction* t2){ + if( t1->Length != t2->Length || t1->Type != t2->Type ){ + return 0; + } + if( memcmp(&t1->InnerHash, &t2->InnerHash, sizeof(cipher__SHA256)) != 0 ) + return 0; + if(!equalSlices((GoSlice*)&t1->Sigs, (GoSlice*)&t2->Sigs, sizeof(cipher__Sig))) + return 0; + if(!equalSlices((GoSlice*)&t1->In, (GoSlice*)&t2->In, sizeof(cipher__SHA256))) + return 0; + if(!equalSlices((GoSlice*)&t1->Out, (GoSlice*)&t2->Out, sizeof(coin__TransactionOutput))) + return 0; + return 1; + } + int equalTransactionsArrays(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ + if( pTxs1->len != pTxs2->len ) + return 0; + coin__Transaction* pTx1 = pTxs1->data; + coin__Transaction* pTx2 = pTxs2->data; + for(int i = 0; i < pTxs1->len; i++){ + if(!equalTransactions(pTx1, pTx2)) + return 0; + pTx1++; + pTx2++; + } + return 1; + } + int equalBlockHeaders(coin__BlockHeader* bh1, coin__BlockHeader* bh2){ + if( bh1->Version != bh2->Version || bh1->Time != bh2->Time || + bh1->BkSeq != bh2->BkSeq || bh1->Fee != bh2->Fee) + return 0; + if( memcmp( &bh1->PrevHash, bh2->PrevHash, sizeof(bh2->PrevHash) ) != 0 ) + return 0; + if( memcmp( &bh1->BodyHash, bh2->PrevHash, sizeof(bh2->BodyHash) ) != 0 ) + return 0; + if( memcmp( &bh1->UxHash, bh2->PrevHash, sizeof(bh2->UxHash) ) != 0 ) + return 0; + return 1; + } +} diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index a925aeb7b8..5fd1e7c5a4 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -1,15 +1,45 @@ +%include "cmp.i" + %extend coin__BlockHeader { - int __eq__(coin__BlockHeader* a){ - if( $self->Version != a->Version || $self->Time != a->Time || - $self->BkSeq != a->BkSeq || $self->Fee != a->Fee) - return 0; - if( memcmp( &$self->PrevHash, a->PrevHash, sizeof(a->PrevHash) ) != 0 ) - return 0; - if( memcmp( &$self->BodyHash, a->PrevHash, sizeof(a->BodyHash) ) != 0 ) + int __eq__(coin__BlockHeader* bh){ + return equalBlockHeaders($self, bh); + } +} + +%extend coin__Transaction { + int __eq__(coin__Transaction* t){ + return equalTransactions($self, t); + } +} + +%extend coin__Transactions { + int __eq__(coin__Transactions* t){ + return equalTransactionsArrays($self, t); + } +} + +%extend coin__BlockBody { + int __eq__(coin__BlockBody* b){ + return equalTransactionsArrays(&$self->Transactions, &b->Transactions); + } +} + +%extend coin__UxOut { + int __eq__(coin__UxOut* u){ + return memcmp(&$self, u, sizeof(coin__UxOut)) == 0; + } +} + +%extend coin__TransactionOutput { + int __eq__(coin__TransactionOutput* t){ + if( $self->Coins != t->Coins || + $self->Hours != t->Hours ){ return 0; - if( memcmp( &$self->UxHash, a->PrevHash, sizeof(a->UxHash) ) != 0 ) + } + + if(memcmp(&$self->Address, &t->Address, sizeof(cipher__Address)) != 0) return 0; - return 1; + return 1; } } diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i index a107dbe900..6a769bb2cb 100644 --- a/lib/swig/skycoin.coin.i +++ b/lib/swig/skycoin.coin.i @@ -1,14 +1,44 @@ +%include "cmp.i" + %extend coin__BlockHeader { - int isEqual(coin__BlockHeader* a){ - if( $self->Version != a->Version || $self->Time != a->Time || - $self->BkSeq != a->BkSeq || $self->Fee != a->Fee) - return 0; - if( memcmp( &$self->PrevHash, a->PrevHash, sizeof(a->PrevHash) ) != 0 ) - return 0; - if( memcmp( &$self->BodyHash, a->PrevHash, sizeof(a->BodyHash) ) != 0 ) + int isEqual(coin__BlockHeader* bh){ + return equalBlockHeaders($self, bh); + } +} + +%extend coin__Transaction { + int isEqual(coin__Transaction* t){ + return equalTransactions($self, t); + } +} + +%extend coin__Transactions { + int isEqual(coin__Transactions* t){ + return equalTransactionsArrays($self, t); + } +} + +%extend coin__BlockBody { + int isEqual(coin__BlockBody* b){ + return equalTransactionsArrays(&$self->Transactions, &b->Transactions); + } +} + +%extend coin__UxOut { + int isEqual(coin__UxOut* u){ + return memcmp(&$self, u, sizeof(coin__UxOut)) == 0; + } +} + +%extend coin__TransactionOutput { + int isEqual(coin__TransactionOutput* t){ + if( $self->Coins != t->Coins || + $self->Hours != t->Hours ){ return 0; - if( memcmp( &$self->UxHash, a->PrevHash, sizeof(a->UxHash) ) != 0 ) + } + + if(memcmp(&$self->Address, &t->Address, sizeof(cipher__Address)) != 0) return 0; - return 1; + return 1; } } From 7ff32ec40c5889e8e63a73489a8dfcfb94624d1e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 20 Jul 2018 17:04:03 +0000 Subject: [PATCH 161/399] [swig] refs #1568. Loop initial declarators moved outside loop. --- lib/swig/cmp.i | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/swig/cmp.i b/lib/swig/cmp.i index 812ae2c764..8a85c4bb50 100644 --- a/lib/swig/cmp.i +++ b/lib/swig/cmp.i @@ -23,7 +23,8 @@ return 0; coin__Transaction* pTx1 = pTxs1->data; coin__Transaction* pTx2 = pTxs2->data; - for(int i = 0; i < pTxs1->len; i++){ + int i; + for(i = 0; i < pTxs1->len; i++){ if(!equalTransactions(pTx1, pTx2)) return 0; pTx1++; From c11004a1993d14d8bc96935477f5172be3a8141f Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 20 Jul 2018 18:07:06 +0000 Subject: [PATCH 162/399] [swig] refs #1568. Removed extensions for coin__Transactions. --- lib/swig/python_skycoin.coin.i | 6 ------ lib/swig/skycoin.coin.i | 6 ------ 2 files changed, 12 deletions(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 5fd1e7c5a4..57b6c74f0e 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -12,12 +12,6 @@ } } -%extend coin__Transactions { - int __eq__(coin__Transactions* t){ - return equalTransactionsArrays($self, t); - } -} - %extend coin__BlockBody { int __eq__(coin__BlockBody* b){ return equalTransactionsArrays(&$self->Transactions, &b->Transactions); diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i index 6a769bb2cb..d47c2bc3fa 100644 --- a/lib/swig/skycoin.coin.i +++ b/lib/swig/skycoin.coin.i @@ -12,12 +12,6 @@ } } -%extend coin__Transactions { - int isEqual(coin__Transactions* t){ - return equalTransactionsArrays($self, t); - } -} - %extend coin__BlockBody { int isEqual(coin__BlockBody* b){ return equalTransactionsArrays(&$self->Transactions, &b->Transactions); From 0f0f93879792dbbeed90bca2f59809bcf5a5c1f8 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 21 Jul 2018 21:36:49 +0000 Subject: [PATCH 163/399] [swig] refs #1568. Added Number and Signature types. --- lib/swig/skycoin.i | 1 + lib/swig/skycoin.sig.i | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 lib/swig/skycoin.sig.i diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index 31854b68d7..a2c8422820 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -30,3 +30,4 @@ /* Find the modified copy of libskycoin */ %include "libskycoin.h" %include "structs.i" +%include "skycoin.sig.i" diff --git a/lib/swig/skycoin.sig.i b/lib/swig/skycoin.sig.i new file mode 100644 index 0000000000..0da1a386d6 --- /dev/null +++ b/lib/swig/skycoin.sig.i @@ -0,0 +1,10 @@ +typedef struct { + BOOL neg; + GoSlice_ nat; +} Number; + +typedef struct { + //TODO: stdevEclipse Define Signature + Number R; + Number S; +} Signature; From 580b0a3edde307b20d8232e279dd03596c869798 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 21 Jul 2018 21:38:51 +0000 Subject: [PATCH 164/399] [swig] refs #1568. Removed incorrect typemap for coin__UxArray**. --- lib/swig/python_skycoin.coin.i | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 57b6c74f0e..0826ea08f8 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -62,24 +62,3 @@ Python will not own the object } -%typemap(in, numinputs=0) (coin__UxArray**) (coin__UxArray* temp){ - temp = NULL; - $1 = &temp; -} - -%typemap(argout) (coin__UxArray**) { - int i; - PyObject *list = PyList_New(0); - coin__Transaction* pTrans = (*$1)->data; - i = (*$1)->len; - for (; i > 0; i--) { - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(pTrans), SWIGTYPE_p_coin__Transaction, 0 ); - PyList_Append(list, o); - pTrans++; - } - %append_output( list ); -} - - - - From 176f9ebfb0715369a2a6b57c04c2b5b6526d466b Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 22 Jul 2018 02:25:44 +0000 Subject: [PATCH 165/399] [libc] refs #1191. Add handles for types Number and Signature. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing. --- include/skytypes.h | 12 ++ .../cipher.secp256k1-go.secp256k1-go2.num.go | 64 ++++++-- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 122 ++++++++++++--- .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 22 ++- lib/cgo/libsky_handle.go | 29 ++++ .../check_cipher.secp256k1.secp256k1-go2.ec.c | 64 ++++---- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 146 ++++++++++++------ 7 files changed, 352 insertions(+), 107 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 6a9c62c6ac..24b8bbff71 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -351,6 +351,18 @@ typedef Handle BuildInfo_Handle; typedef Handle Hash_Handle; +/** +* Handle for Number type +*/ + +typedef Handle Number_Handle; + +/** +* Handle for Signature type +*/ + +typedef Handle Signature_Handle; + typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); #endif diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go index 383ebac002..786da6e8b6 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -1,8 +1,7 @@ package main import ( - "unsafe" - + "encoding/hex" secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) @@ -15,38 +14,79 @@ import ( */ import "C" +//export SKY_secp256k1go_Number_Create +func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + var num secp256k1go2.Number + *handle = registerNumberHandle(&num) + return +} + //export SKY_secp256k1go_Number_Print -func SKY_secp256k1go_Number_Print(_num *C.Number, _label string) (____error_code uint32) { +func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) - label := _label - num.Print(label) + num, ok := lookupNumberHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + num.Print(_label) return } //export SKY_secp256k1go_Number_SetHex -func SKY_secp256k1go_Number_SetHex(_num *C.Number, _s string) (____error_code uint32) { +func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) - s := _s - num.SetHex(s) + num, ok := lookupNumberHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + num.SetHex(_s) return } //export SKY_secp256k1go_Number_IsOdd -func SKY_secp256k1go_Number_IsOdd(_num *C.Number, _arg0 *bool) (____error_code uint32) { +func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - num := (*secp256k1go2.Number)(unsafe.Pointer(_num)) + num, ok := lookupNumberHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := num.IsOdd() *_arg0 = __arg0 return } + +//export SKY_secp256k1go_Number_IsEqual +func SKY_secp256k1go_Number_IsEqual(handle1 C.Number_Handle, handle2 C.Number_Handle, result *bool) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + num1, ok := lookupNumberHandle(handle1) + if !ok { + ____error_code = SKY_ERROR + return + } + num2, ok := lookupNumberHandle(handle2) + if !ok { + ____error_code = SKY_ERROR + return + } + *result = hex.EncodeToString(num1.Bytes()) == hex.EncodeToString(num2.Bytes()) + return +} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go index 1f4ae602be..6e385c1034 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -16,41 +16,101 @@ import ( */ import "C" +//export SKY_secp256k1go_Signature_Create +func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + var sig secp256k1go2.Signature + *handle = registerSignatureHandle(&sig) + return +} + +//export SKY_secp256k1go_Signature_Get_R +func SKY_secp256k1go_Signature_Get_R(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *r = registerNumberHandle(&sig.R) + return +} + +//export SKY_secp256k1go_Signature_Get_S +func SKY_secp256k1go_Signature_Get_S(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *s = registerNumberHandle(&sig.S) + return +} + //export SKY_secp256k1go_Signature_Print -func SKY_secp256k1go_Signature_Print(_sig *C.Signature, _lab string) (____error_code uint32) { +func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) - lab := _lab - sig.Print(lab) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + sig.Print(_lab) return } //export SKY_secp256k1go_Signature_Verify -func SKY_secp256k1go_Signature_Verify(_sig *C.Signature, _pubkey *C.secp256k1go__XY, _message *C.Number, _arg2 *bool) (____error_code uint32) { +func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _arg2 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) - message := (*secp256k1go2.Number)(unsafe.Pointer(_message)) + message, okm := lookupNumberHandle(_message) + if !okm { + ____error_code = SKY_ERROR + return + } __arg2 := sig.Verify(pubkey, message) *_arg2 = __arg2 return } //export SKY_secp256k1go_Signature_Recover -func SKY_secp256k1go_Signature_Recover(_sig *C.Signature, _pubkey *C.secp256k1go__XY, _m *C.Number, _recid int, _arg3 *bool) (____error_code uint32) { +func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _recid int, _arg3 *bool) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) - m := (*secp256k1go2.Number)(unsafe.Pointer(_m)) + m, okm := lookupNumberHandle(_message) + if !okm { + ____error_code = SKY_ERROR + return + } recid := _recid __arg3 := sig.Recover(pubkey, m, recid) *_arg3 = __arg3 @@ -58,15 +118,31 @@ func SKY_secp256k1go_Signature_Recover(_sig *C.Signature, _pubkey *C.secp256k1go } //export SKY_secp256k1go_Signature_Sign -func SKY_secp256k1go_Signature_Sign(_sig *C.Signature, _seckey, _message, _nonce *C.Number, _recid *int, _arg2 *int) (____error_code uint32) { +func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message, _nonce C.Number_Handle, _recid *int, _arg2 *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) - seckey := (*secp256k1go2.Number)(unsafe.Pointer(_seckey)) - message := (*secp256k1go2.Number)(unsafe.Pointer(_message)) - nonce := (*secp256k1go2.Number)(unsafe.Pointer(_nonce)) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + seckey, oks := lookupNumberHandle(_seckey) + if !oks { + ____error_code = SKY_ERROR + return + } + message, okm := lookupNumberHandle(_message) + if !okm { + ____error_code = SKY_ERROR + return + } + nonce, okn := lookupNumberHandle(_nonce) + if !okn { + ____error_code = SKY_ERROR + return + } recid := _recid __arg2 := sig.Sign(seckey, message, nonce, recid) *_arg2 = __arg2 @@ -74,24 +150,32 @@ func SKY_secp256k1go_Signature_Sign(_sig *C.Signature, _seckey, _message, _nonce } //export SKY_secp256k1go_Signature_ParseBytes -func SKY_secp256k1go_Signature_ParseBytes(_sig *C.Signature, _v []byte) (____error_code uint32) { +func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } v := *(*[]byte)(unsafe.Pointer(&_v)) sig.ParseBytes(v) return } //export SKY_secp256k1go_Signature_Bytes -func SKY_secp256k1go_Signature_Bytes(_sig *C.Signature, _arg0 *C.GoSlice_) (____error_code uint32) { +func SKY_secp256k1go_Signature_Bytes(handle C.Signature_Handle, _arg0 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() - sig := (*secp256k1go2.Signature)(unsafe.Pointer(_sig)) + sig, ok := lookupSignatureHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } __arg0 := sig.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) return diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go index 008d7b64af..400d66c184 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go @@ -88,15 +88,23 @@ func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ } //export SKY_secp256k1go_XYZ_ECmult -func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng *C.Number) (____error_code uint32) { +func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng C.Number_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - na := (*secp256k1go2.Number)(unsafe.Pointer(_na)) - ng := (*secp256k1go2.Number)(unsafe.Pointer(_ng)) + na, ok1 := lookupNumberHandle(_na) + if !ok1 { + ____error_code = SKY_ERROR + return + } + ng, ok2 := lookupNumberHandle(_ng) + if !ok2 { + ____error_code = SKY_ERROR + return + } xyz.ECmult(r, na, ng) return } @@ -152,13 +160,17 @@ func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XY } //export SKY_secp256k1go_ECmultGen -func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a *C.Number) (____error_code uint32) { +func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a C.Number_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - a := (*secp256k1go2.Number)(unsafe.Pointer(_a)) + a, ok := lookupNumberHandle(_a) + if !ok { + ____error_code = SKY_ERROR + return + } secp256k1go2.ECmultGen(r, a) return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 9d8f29de1d..9d3c546acd 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -20,6 +20,7 @@ import ( "github.com/skycoin/skycoin/src/visor" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) type Handle uint64 @@ -513,6 +514,34 @@ func lookupHashHandle(handle C.Hash_Handle) (*hash.Hash, bool) { return nil, false } +func registerNumberHandle(obj *secp256k1go2.Number) C.Number_Handle { + return (C.Number_Handle)(registerHandle(obj)) +} + +func lookupNumberHandle(handle C.Number_Handle) (*secp256k1go2.Number, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*secp256k1go2.Number); isOK { + return obj, true + } + } + return nil, false +} + +func registerSignatureHandle(obj *secp256k1go2.Signature) C.Signature_Handle { + return (C.Signature_Handle)(registerHandle(obj)) +} + +func lookupSignatureHandle(handle C.Signature_Handle) (*secp256k1go2.Signature, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*secp256k1go2.Signature); isOK { + return obj, true + } + } + return nil, false +} + func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c index 56a61280db..396425e90a 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c @@ -30,88 +30,97 @@ TestSuite(cipher_secp256k1_xyz, .init = setup, .fini = teardown); -Test(cipher_secp256k1_xyz, TestXYZECMult){ +Test(cipher_secp256k1_xyz, TestXYZECMult){ secp256k1go__XYZ pubkey; //pubkey secp256k1go__XYZ pr; //result of ECmult secp256k1go__XYZ e; //expected - Number u1, u2, nonce; + Number_Handle u1, u2; secp256k1go__Field x, y, z; GoInt32 error_code; memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); memset(&pr, 0, sizeof(secp256k1go__XYZ)); memset(&e, 0, sizeof(secp256k1go__XYZ)); - memset(&u1, 0, sizeof(Number)); - memset(&u2, 0, sizeof(Number)); - memset(&nonce, 0, sizeof(Number)); + u1 = 0; + u2 = 0; memset(&x, 0, sizeof(secp256k1go__Field)); memset(&y, 0, sizeof(secp256k1go__Field)); memset(&z, 0, sizeof(secp256k1go__Field)); - + GoString strAx = {AX, strlen(AX)}; GoString strAy = {AY, strlen(AY)}; GoString strAz = {AZ, strlen(AZ)}; - + GoString strEx = {EX, strlen(EX)}; GoString strEy = {EY, strlen(EY)}; GoString strEz = {EZ, strlen(EZ)}; - + GoString strU1 = {U1, strlen(U1)}; GoString strU2 = {U2, strlen(U2)}; - + + error_code = SKY_secp256k1go_Number_Create(&u1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(u1); + + error_code = SKY_secp256k1go_Number_Create(&u2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(u2); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Number_SetHex(&u1, strU1); + + error_code = SKY_secp256k1go_Number_SetHex(u1, strU1); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - error_code = SKY_secp256k1go_Number_SetHex(&u2, strU2); + error_code = SKY_secp256k1go_Number_SetHex(u2, strU2); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, &u2, &u1); + + error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, u2, u1); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); - + GoInt8 equal = 0; error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); } -Test(cipher_secp256k1_xyz, TestXYZECMultGen){ +Test(cipher_secp256k1_xyz, TestXYZECMultGen){ secp256k1go__XYZ pubkey; //pubkey secp256k1go__XYZ pr; //result of ECmult secp256k1go__XYZ e; //expected - Number u1, u2, nonce; + Number_Handle nonce; secp256k1go__Field x, y, z; GoInt32 error_code; memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); memset(&pr, 0, sizeof(secp256k1go__XYZ)); memset(&e, 0, sizeof(secp256k1go__XYZ)); - memset(&u1, 0, sizeof(Number)); - memset(&u2, 0, sizeof(Number)); - memset(&nonce, 0, sizeof(Number)); + nonce = 0; memset(&x, 0, sizeof(secp256k1go__Field)); memset(&y, 0, sizeof(secp256k1go__Field)); memset(&z, 0, sizeof(secp256k1go__Field)); - + GoString strNonce = {NONCE, strlen(NONCE)}; GoString strEx = {E2X, strlen(E2X)}; GoString strEy = {E2Y, strlen(E2Y)}; GoString strEz = {E2Z, strlen(E2Z)}; - - error_code = SKY_secp256k1go_Number_SetHex(&nonce, strNonce); + + error_code = SKY_secp256k1go_Number_Create(&nonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(nonce); + + error_code = SKY_secp256k1go_Number_SetHex(nonce, strNonce); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); @@ -119,8 +128,8 @@ Test(cipher_secp256k1_xyz, TestXYZECMultGen){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - - error_code = SKY_secp256k1go_ECmultGen(&pr, &nonce); + + error_code = SKY_secp256k1go_ECmultGen(&pr, nonce); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); error_code = SKY_secp256k1go_Field_Normalize(&pr.X); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); @@ -128,7 +137,7 @@ Test(cipher_secp256k1_xyz, TestXYZECMultGen){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - + GoInt8 equal = 0; error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); @@ -140,4 +149,3 @@ Test(cipher_secp256k1_xyz, TestXYZECMultGen){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); } - diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index bcdfd96432..ab63d2c7cb 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -31,15 +31,15 @@ TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); Test(cipher_secp256k1_sig, TestSigRecover){ GoUint32 error_code; - Signature sig; - Number msg; + Signature_Handle sig; + Number_Handle msg; secp256k1go__XY pubKey; secp256k1go__XY expected; memset(&pubKey, 0, sizeof(secp256k1go__XY)); memset(&expected, 0, sizeof(secp256k1go__XY)); - memset(&sig, 0, sizeof(Signature)); - memset(&msg, 0, sizeof(Number)); + sig = 0; + msg = 0; GoString R = {R1, strlen(R1)}; GoString S = {S1, strlen(S1)}; @@ -49,18 +49,31 @@ Test(cipher_secp256k1_sig, TestSigRecover){ GoInt rid = 0; GoInt8 result; - error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + error_code = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); + Number_Handle r; + error_code = SKY_secp256k1go_Signature_Get_R(sig, &r); + registerHandleClose(r); + Number_Handle s; + error_code = SKY_secp256k1go_Signature_Get_S(sig, &s); + registerHandleClose(s); + error_code = SKY_secp256k1go_Number_Create(&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); + + error_code = SKY_secp256k1go_Number_SetHex(r, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + error_code = SKY_secp256k1go_Number_SetHex(s, S); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); @@ -79,18 +92,18 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Y.n = strlen(Y2); rid = 1; - error_code = SKY_secp256k1go_Number_SetHex(&sig.R, R); + error_code = SKY_secp256k1go_Number_SetHex(r, R); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(&sig.S, S); + error_code = SKY_secp256k1go_Number_SetHex(s, S); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(&msg, MSG); + error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - error_code = SKY_secp256k1go_Signature_Recover(&sig, &pubKey, &msg, rid, &result); + error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); @@ -103,26 +116,40 @@ Test(cipher_secp256k1_sig, TestSigRecover){ Test(cipher_secp256k1_sig, TestSigVerify) { - Number msg; - Signature sig; + Number_Handle msg; + Signature_Handle sig; secp256k1go__XY key; - memset(&msg, 0, sizeof(Number)); - memset(&sig, 0, sizeof(Signature)); + msg = 0; + sig = 0; memset(&key, 0, sizeof(secp256k1go__XY)); + GoUint32 result; + + result = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); + Number_Handle r; + result = SKY_secp256k1go_Signature_Get_R(sig, &r); + registerHandleClose(r); + Number_Handle s; + result = SKY_secp256k1go_Signature_Get_S(sig, &s); + registerHandleClose(s); + result = SKY_secp256k1go_Number_Create(&msg); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); GoString str = { "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA", 64}; - GoUint32 result; - result = SKY_secp256k1go_Number_SetHex(&msg, str); + + result = SKY_secp256k1go_Number_SetHex(msg, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "98F9D784BA6C5C77BB7323D044C0FC9F2B27BAA0A5B0718FE88596CC56681980"; - result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + result = SKY_secp256k1go_Number_SetHex(r, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; - result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + result = SKY_secp256k1go_Number_SetHex(s, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "7d709f85a331813f9ae6046c56b3a42737abf4eb918b2e7afee285070e968b93"; @@ -133,20 +160,20 @@ Test(cipher_secp256k1_sig, TestSigVerify) { result = SKY_secp256k1go_Field_SetHex(&key.Y, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); GoUint8 valid; - result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + result = SKY_secp256k1go_Signature_Verify(sig, &key, msg, &valid); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); cr_assert(valid, "sig.Verify 1"); str.p = "2c43a883f4edc2b66c67a7a355b9312a565bb3d33bb854af36a06669e2028377"; - result = SKY_secp256k1go_Number_SetHex(&msg, str); + result = SKY_secp256k1go_Number_SetHex(msg, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "6b2fa9344462c958d4a674c2a42fbedf7d6159a5276eb658887e2e1b3915329b"; - result = SKY_secp256k1go_Number_SetHex(&sig.R, str); + result = SKY_secp256k1go_Number_SetHex(r, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "eddc6ea7f190c14a0aa74e41519d88d2681314f011d253665f301425caf86b86"; - result = SKY_secp256k1go_Number_SetHex(&sig.S, str); + result = SKY_secp256k1go_Number_SetHex(s, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); char buffer_xy[1024]; cipher__PubKeySlice xy = {buffer_xy, 0, 1024}; @@ -157,44 +184,60 @@ Test(cipher_secp256k1_sig, TestSigVerify) { GoSlice xyConvert = {xy.data, xy.len, xy.cap}; result = SKY_secp256k1go_XY_ParsePubkey(&key, xyConvert, &valid); cr_assert(result == SKY_OK && valid, "SKY_secp256k1go_XY_ParsePubkey failed"); - result = SKY_secp256k1go_Signature_Verify(&sig, &key, &msg, &valid); + result = SKY_secp256k1go_Signature_Verify(sig, &key, msg, &valid); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); cr_assert(valid, "sig.Verify 2"); } Test(cipher_secp256k1_sig, TestSigSign) { - Number sec; - Number msg; - Number non; - Signature sig; + Number_Handle sec; + Number_Handle msg; + Number_Handle non; + Signature_Handle sig; GoInt recid; + GoUint32 result; + + sec = 0; + msg = 0; + non = 0; + sig = 0; - memset(&sec, 0, sizeof(Number)); - memset(&msg, 0, sizeof(Number)); - memset(&non, 0, sizeof(Number)); + result = SKY_secp256k1go_Number_Create(&sec); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); - memset(&sig, 0, sizeof(Signature)); + result = SKY_secp256k1go_Number_Create(&msg); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); + + result = SKY_secp256k1go_Number_Create(&non); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); GoString str = { "73641C99F7719F57D8F4BEB11A303AFCD190243A51CED8782CA6D3DBE014D146", 64}; - GoUint32 result; - result = SKY_secp256k1go_Number_SetHex(&sec, str); + result = SKY_secp256k1go_Number_SetHex(sec, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA"; str.n = 64; - result = SKY_secp256k1go_Number_SetHex(&msg, str); + result = SKY_secp256k1go_Number_SetHex(msg, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); str.p = "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E"; str.n = 64; - result = SKY_secp256k1go_Number_SetHex(&non, str); + result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + result = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); + GoInt res; + GoInt8 equal; - result = SKY_secp256k1go_Signature_Sign(&sig, &sec, &msg, &non, &recid, &res); + result = SKY_secp256k1go_Signature_Sign(sig, sec, msg, non, &recid, &res); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); cr_assert(res == 1, "res failed %d", res); @@ -205,20 +248,37 @@ Test(cipher_secp256k1_sig, TestSigSign) { } str.p = "98f9d784ba6c5c77bb7323d044c0fc9f2b27baa0a5b0718fe88596cc56681980"; str.n = 64; - result = SKY_secp256k1go_Number_SetHex(&non, str); + result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - cr_assert(eq(type(Number), sig.R, non)); + + Number_Handle r; + result = SKY_secp256k1go_Signature_Get_R(sig, &r); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_R failed"); + registerHandleClose(r); + + equal = 0; + result = SKY_secp256k1go_Number_IsEqual(r, non, &equal); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_IsEqual failed"); + cr_assert(equal != 0); if (forceLowS) { str.p = "1ca662aaefd6cc958ba4604fea999db133a75bf34c13334dabac7124ff0cfcc1"; str.n = 64; - result = SKY_secp256k1go_Number_SetHex(&non, str); + result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); } else { str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; str.n = 64; - result = SKY_secp256k1go_Number_SetHex(&non, str); + result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); } - cr_assert(eq(type(Number), sig.S, non)); + Number_Handle s; + result = SKY_secp256k1go_Signature_Get_S(sig, &s); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_S failed"); + registerHandleClose(s); + + equal = 0; + result = SKY_secp256k1go_Number_IsEqual(s, non, &equal); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_S failed"); + cr_assert(equal != 0); } From 68780c65dc1a1b6e8372528a2ae5743f46df67b4 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 22 Jul 2018 09:16:28 +0000 Subject: [PATCH 166/399] [libc] refs 1191. Fix lint issues. --- lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go | 1 + lib/cgo/libsky_handle.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go index 786da6e8b6..6bfc7414b7 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -2,6 +2,7 @@ package main import ( "encoding/hex" + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 9d3c546acd..179bf2ec41 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -15,12 +15,12 @@ import ( api "github.com/skycoin/skycoin/src/api" webrpc "github.com/skycoin/skycoin/src/api/webrpc" + secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" cli "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/visor" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) type Handle uint64 From 7f7bbafc4664c875af222a5ad6df5d3177b48d50 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 22 Jul 2018 09:29:53 +0000 Subject: [PATCH 167/399] [swig] refs #1568. Added typemaps for handles Number_Handle and Signature_Handle. Removed structs Number and Signature. --- lib/swig/skycoin.i | 1 - lib/swig/skycoin.mem.i | 4 ++-- lib/swig/skycoin.sig.i | 10 ---------- 3 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 lib/swig/skycoin.sig.i diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index a2c8422820..31854b68d7 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -30,4 +30,3 @@ /* Find the modified copy of libskycoin */ %include "libskycoin.h" %include "structs.i" -%include "skycoin.sig.i" diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 6eddd4f19c..0124bad3b8 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -95,7 +95,7 @@ GoStringMap, PasswordReader__Handle_, Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle + Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle } %apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, @@ -103,5 +103,5 @@ App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle* + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle* } diff --git a/lib/swig/skycoin.sig.i b/lib/swig/skycoin.sig.i deleted file mode 100644 index 0da1a386d6..0000000000 --- a/lib/swig/skycoin.sig.i +++ /dev/null @@ -1,10 +0,0 @@ -typedef struct { - BOOL neg; - GoSlice_ nat; -} Number; - -typedef struct { - //TODO: stdevEclipse Define Signature - Number R; - Number S; -} Signature; From aac8e6536a64621f95035fe791b7e1a361efabe9 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 22 Jul 2018 11:56:44 +0000 Subject: [PATCH 168/399] [swig] refs #1568. Added methods GetSrcTransaction and SetSrcTransaction to coin__UxBody. --- lib/swig/python_skycoin.coin.i | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 0826ea08f8..705d07f047 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -61,4 +61,16 @@ Python will not own the object %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Block, 0 ) ); } - +%extend coin__UxBody { + PyObject* GetSrcTransaction(){ + return SWIG_NewPointerObj(SWIG_as_voidptr(&$self->SrcTransaction), SWIGTYPE_p_cipher_SHA256, 0 ); + } + void SetSrcTransaction(PyObject* o){ + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); + if (SWIG_IsOK(res)){ + cipher_SHA256* p = (cipher_SHA256*)argp; + memcpy( &$self->SrcTransaction, &p->data, sizeof(cipher__SHA256)); + } + } +} From 0c5feb200ffce332dc2c8bd8460fc3971ce8b922 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 22 Jul 2018 15:48:43 +0000 Subject: [PATCH 169/399] [swig] refs #1568. Added methods assignTo and assignFrom to cipher structs. Removed method GetSrcTransaction and SetSrcTransaction from coin__UxBody. --- lib/swig/python_skycoin.cipher.crypto.i | 36 +++++++++++++++++++++++++ lib/swig/skycoin.cipher.crypto.i | 36 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 985e933d68..4058e720a7 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -25,6 +25,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_SecKey { @@ -40,6 +46,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Ripemd160 { @@ -55,6 +67,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Sig { @@ -70,6 +88,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_SHA256 { @@ -85,6 +109,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Checksum { @@ -100,6 +130,12 @@ PyObject* toStr(){ return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index b61b53e0ab..27a6c34c66 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -11,36 +11,72 @@ int isEqual(cipher_PubKey* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_SecKey { int isEqual(cipher_SecKey* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Ripemd160 { int isEqual(cipher_Ripemd160* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Sig { int isEqual(cipher_Sig* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_SHA256 { int isEqual(cipher_SHA256* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } %extend cipher_Checksum { int isEqual(cipher_Checksum* a){ return memcmp($self->data, a->data, sizeof(a->data)) == 0; } + void assignFrom(void* data){ + memcpy(&$self->data, data, sizeof($self->data)); + } + void assignTo(void* data){ + memcpy(data, &$self->data, sizeof($self->data)); + } } From 85921c155a4f44b073842b29cd07b5b61536e245 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 11:35:42 +0000 Subject: [PATCH 170/399] [libc] refs #1191. Added methods for dealing with slice fields in coin.Transaction type. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- lib/cgo/coin.transactions.go | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index f294d2a682..d826b8ed8c 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -85,6 +85,79 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( return } +//export SKY_coin_Transaction_Get_Input_At +func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.In) { + ____error_code = SKY_ERROR + return + } + *input = *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) + return +} + +//export SKY_coin_Transaction_Get_Output_At +func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.Out) { + ____error_code = SKY_ERROR + return + } + *output = *(*C.coin__TransactionOutput)(unsafe.Pointer(&txn.Out[i])) + return +} + +//export SKY_coin_Transaction_Get_Signature_At +func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.Sigs) { + ____error_code = SKY_ERROR + return + } + *sig = *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) + return +} + +//export SKY_coin_Transaction_Push_Signature +func SKY_coin_Transaction_Push_Signature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + sig := *(*cipher.Sig)(unsafe.Pointer(_sig)) + txn.Sigs = append(txn.Sigs, sig) + return +} + //export SKY_coin_Transaction_ResetOutputs func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { ____error_code = 0 From e61116f17bbb0089dbd9e2f536fa5c29650eef37 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 13:07:42 +0000 Subject: [PATCH 171/399] [libc] refs #1191. Added methods for return length of slice fields inside coin.Transaction type. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- lib/cgo/coin.transactions.go | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index d826b8ed8c..1861df6c28 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -85,6 +85,21 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( return } +//export SKY_coin_Transaction_Get_Inputs_Count +func SKY_coin_Transaction_Get_Inputs_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *length = len(txn.In) + return +} + //export SKY_coin_Transaction_Get_Input_At func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 @@ -104,6 +119,21 @@ func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, inpu return } +//export SKY_coin_Transaction_Get_Outputs_Count +func SKY_coin_Transaction_Get_Outputs_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *length = len(txn.Out) + return +} + //export SKY_coin_Transaction_Get_Output_At func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { ____error_code = 0 @@ -123,6 +153,21 @@ func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, out return } +//export SKY_coin_Transaction_Get_Signatures_Count +func SKY_coin_Transaction_Get_Signatures_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + *length = len(txn.Sigs) + return +} + //export SKY_coin_Transaction_Get_Signature_At func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { ____error_code = 0 From 8dc33e9f35c9c3b8ea4fd479a7212b6361a3716b Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 13:38:58 +0000 Subject: [PATCH 172/399] [swig] refs #1568. Added typemap for pointer to function FeeCalculator. --- lib/swig/python_skycoin.callback.i | 23 +++++++++++++++++++++++ lib/swig/skycoin.i | 1 + 2 files changed, 24 insertions(+) create mode 100644 lib/swig/python_skycoin.callback.i diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i new file mode 100644 index 0000000000..a67e15c28c --- /dev/null +++ b/lib/swig/python_skycoin.callback.i @@ -0,0 +1,23 @@ +%{ +typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); + +static __thread PyObject *callback; + +GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ + PyObject *result = PyObject_CallFunctionObjArgs(callback, PyLong_FromLong(handle), NULL); + const GoUint64_ ret = PyLong_AsLong(result); + Py_DECREF(result); + if(pFee) + *pFee = ret; + return 0; + else + return -1; +} + +%} + +%typemap(in) FeeCalc { + if (!PyCallable_Check($input)) SWIG_fail; + $1 = _WrapperFeeCalculator; + callback = $input; +} diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index 31854b68d7..e6d5a68d65 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -21,6 +21,7 @@ #if defined(SWIGPYTHON) %include "python_skycoin.cipher.crypto.i" %include "python_skycoin.coin.i" +%include "python_skycoin.callback.i" #else %include "skycoin.cipher.crypto.i" %include "skycoin.coin.i" From 1186f2f0f1e4d6cdf0dd1f6764b0c7006af10842 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 13:43:23 +0000 Subject: [PATCH 173/399] [swig] refs #1568. In typemap for pointer to function use nested function to be thread safe. --- lib/swig/python_skycoin.callback.i | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i index a67e15c28c..4d63249727 100644 --- a/lib/swig/python_skycoin.callback.i +++ b/lib/swig/python_skycoin.callback.i @@ -1,22 +1,17 @@ -%{ -typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); - -static __thread PyObject *callback; - -GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ +%typemap(in) FeeCalc { + PyObject *callback; + GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ PyObject *result = PyObject_CallFunctionObjArgs(callback, PyLong_FromLong(handle), NULL); const GoUint64_ ret = PyLong_AsLong(result); Py_DECREF(result); - if(pFee) + if(pFee){ *pFee = ret; return 0; - else + } + else{ return -1; -} - -%} - -%typemap(in) FeeCalc { + } + } if (!PyCallable_Check($input)) SWIG_fail; $1 = _WrapperFeeCalculator; callback = $input; From ba336c541368efb7ba7be05346a313610dbea69c Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 15:03:54 +0000 Subject: [PATCH 174/399] [swig] refs #1568. Fix bug intypemap for pointer to function. --- lib/swig/python_skycoin.callback.i | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i index 4d63249727..8c23cd9dc9 100644 --- a/lib/swig/python_skycoin.callback.i +++ b/lib/swig/python_skycoin.callback.i @@ -1,6 +1,7 @@ -%typemap(in) FeeCalc { - PyObject *callback; - GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ +%{ +static __thread PyObject *callback; + +GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ PyObject *result = PyObject_CallFunctionObjArgs(callback, PyLong_FromLong(handle), NULL); const GoUint64_ ret = PyLong_AsLong(result); Py_DECREF(result); @@ -8,10 +9,13 @@ *pFee = ret; return 0; } - else{ + else return -1; - } - } +} + +%} + +%typemap(in) FeeCalc { if (!PyCallable_Check($input)) SWIG_fail; $1 = _WrapperFeeCalculator; callback = $input; From 42aa8ad4658471874cd606770096a813ed34e6b3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 15:20:06 +0000 Subject: [PATCH 175/399] [swig] refs #1568. Use nested function for pointer to function typemap. --- lib/swig/python_skycoin.callback.i | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i index 8c23cd9dc9..bc9e781d05 100644 --- a/lib/swig/python_skycoin.callback.i +++ b/lib/swig/python_skycoin.callback.i @@ -1,7 +1,7 @@ -%{ -static __thread PyObject *callback; -GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ +%typemap(in) FeeCalc { + PyObject *callback; + GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ PyObject *result = PyObject_CallFunctionObjArgs(callback, PyLong_FromLong(handle), NULL); const GoUint64_ ret = PyLong_AsLong(result); Py_DECREF(result); @@ -11,11 +11,8 @@ GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ } else return -1; -} + } -%} - -%typemap(in) FeeCalc { if (!PyCallable_Check($input)) SWIG_fail; $1 = _WrapperFeeCalculator; callback = $input; From 88ec70ebd24b46c58060bee9d195f354594943f3 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 17:05:55 +0000 Subject: [PATCH 176/399] [libc] refs #1191. Added context for FeeCalculator callback function. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- include/feecalc.h | 4 +-- include/skytypes.h | 11 ++++++- include/transutil.h | 2 +- lib/cgo/coin.block.go | 2 +- lib/cgo/coin.transactions.go | 6 ++-- lib/cgo/tests/check_coin.block.c | 12 +++++--- lib/cgo/tests/check_coin.transactions.c | 41 +++++++++++++++---------- lib/cgo/tests/testutils/transutils.c | 2 +- 8 files changed, 49 insertions(+), 31 deletions(-) diff --git a/include/feecalc.h b/include/feecalc.h index 13dacfdd47..1370de56ba 100644 --- a/include/feecalc.h +++ b/include/feecalc.h @@ -1,6 +1,6 @@ #ifndef CALLFEECALCULATOR #define CALLFEECALCULATOR -static inline GoUint32_ callFeeCalculator(FeeCalc feeCalc, Transaction__Handle handle, GoUint64_* pFee){ - return feeCalc(handle, pFee); +static inline GoUint32_ callFeeCalculator(FeeCalculator* feeCalc, Transaction__Handle handle, GoUint64_* pFee){ + return feeCalc->callback(handle, pFee, feeCalc->context); } #endif diff --git a/include/skytypes.h b/include/skytypes.h index 24b8bbff71..fc1a424d9c 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -2,6 +2,10 @@ #ifndef SKYTYPES_H #define SKYTYPES_H +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ unsigned int +#endif + /** * Go 8-bit signed integer values. */ @@ -363,6 +367,11 @@ typedef Handle Number_Handle; typedef Handle Signature_Handle; -typedef GoUint32_ (*FeeCalc)(Transaction__Handle handle, GoUint64_* pFee); +typedef GoUint32_ (*FeeCalcFunc)(Transaction__Handle handle, GoUint64_* pFee, void* context); + +typedef struct { + FeeCalcFunc callback; + void* context; +} FeeCalculator ; #endif diff --git a/include/transutil.h b/include/transutil.h index 70d7baeb52..acadff5163 100644 --- a/include/transutil.h +++ b/include/transutil.h @@ -11,7 +11,7 @@ #include "skytest.h" #include "skytypes.h" -GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee); +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context); int makeKeysAndAddress(cipher__PubKey* ppubkey, cipher__SecKey* pseckey, cipher__Address* paddress); diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index ecfb158297..4fc763cc07 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -20,7 +20,7 @@ import ( import "C" //export SKY_coin_NewBlock -func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc C.FeeCalc, _arg2 *C.Block__Handle) (____error_code uint32) { +func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc *C.FeeCalculator, _arg2 *C.Block__Handle) (____error_code uint32) { feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 1861df6c28..d08a0cc984 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -570,7 +570,7 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han } //export SKY_coin_Transactions_Fees -func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, _result *uint64) (____error_code uint32) { +func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, _result *uint64) (____error_code uint32) { feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) @@ -670,7 +670,7 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int } //export SKY_coin_SortTransactions -func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.Transactions__Handle) (____error_code uint32) { +func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, ptsh *C.Transactions__Handle) (____error_code uint32) { feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) @@ -697,7 +697,7 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, p } //export SKY_coin_NewSortableTransactions -func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc C.FeeCalc, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { +func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 2dcef38111..cefba05ba6 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -52,13 +52,14 @@ int makeNewBlock(cipher__SHA256* uxHash, Block__Handle* newBlock){ cr_assert(result == SKY_OK, "SKY_coin_Get_Block_Body failed"); result = SKY_coin_BlockBody_Hash(body, &bodyhash); cr_assert(result == SKY_OK, "SKY_coin_BlockBody_Hash failed"); - result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, zeroFeeCalculator, newBlock); + FeeCalculator zf = {zeroFeeCalculator, NULL}; + result = SKY_coin_NewBlock(block, 100 + 200, uxHash, transactions, &zf, newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose( *newBlock ); return result; } -GoUint32_ fix121FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ fix121FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 121; return SKY_OK; } @@ -92,8 +93,8 @@ Test(coin_block, TestNewBlock) { registerMemCleanup( slice.data ); result = SKY_cipher_SumSHA256( slice, &hash ); cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); - - result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, zeroFeeCalculator, &newBlock); + FeeCalculator zf = {zeroFeeCalculator, NULL}; + result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, &zf, &newBlock); cr_assert(result == SKY_ERROR, "SKY_coin_NewBlock has to fail with no transactions"); registerHandleClose( newBlock ); @@ -110,7 +111,8 @@ Test(coin_block, TestNewBlock) { GoUint64 fee = 121; GoUint64 currentTime = 133; - result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, fix121FeeCalculator, &newBlock); + FeeCalculator f121 = {fix121FeeCalculator, NULL}; + result = SKY_coin_NewBlock(prevBlock, currentTime, &hash, transactions, &f121, &newBlock); cr_assert(result == SKY_OK, "SKY_coin_NewBlock failed"); registerHandleClose(newBlock); result = SKY_coin_GetBlockObject(newBlock, &pNewBlock); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index cfa87f2d03..c630932a82 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -835,16 +835,16 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { } } -GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 1; return SKY_OK; } -GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ return SKY_ERROR; } -GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 0xFFFFFFFFFFFFFFFF; return SKY_OK; } @@ -857,7 +857,8 @@ Test(coin_transactions, TestTransactionsFees) { // Nil txns makeTransactions(0, &transactionsHandle); - result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + FeeCalculator f1 = {fix1FeeCalculator, NULL}; + result = SKY_coin_Transactions_Fees(transactionsHandle, &f1, &fee); cr_assert(result == SKY_OK); cr_assert(fee == 0); @@ -868,20 +869,22 @@ Test(coin_transactions, TestTransactionsFees) { result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); cr_assert(result == SKY_OK); // 2 transactions, calc() always returns 1 - result = SKY_coin_Transactions_Fees(transactionsHandle, fix1FeeCalculator, &fee); + result = SKY_coin_Transactions_Fees(transactionsHandle, &f1, &fee); cr_assert(result == SKY_OK); cr_assert(fee == 2); // calc error - result = SKY_coin_Transactions_Fees(transactionsHandle, badFeeCalculator, &fee); + FeeCalculator badFee = {badFeeCalculator, NULL}; + result = SKY_coin_Transactions_Fees(transactionsHandle, &badFee, &fee); cr_assert(result == SKY_ERROR); // summing of calculated fees overflows - result = SKY_coin_Transactions_Fees(transactionsHandle, overflowFeeCalculator, &fee); + FeeCalculator overflow = {overflowFeeCalculator, NULL}; + result = SKY_coin_Transactions_Fees(transactionsHandle, &overflow, &fee); cr_assert(result == SKY_ERROR); } -GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee, void* context){ coin__Transaction* pTx; int result = SKY_coin_Get_Transaction_Object( handle, &pTx ); if(result == SKY_OK){ @@ -891,7 +894,7 @@ GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee){ return result; } -GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 100 * Million; return SKY_OK; } @@ -910,7 +913,7 @@ void assertTransactionsHandleEqual(Transaction__Handle h1, Transaction__Handle h void testTransactionSorting(Transactions__Handle hTrans, int* original_indexes, int original_indexes_count, - int* expected_indexes, int expected_indexes_count, FeeCalc feeCalc, + int* expected_indexes, int expected_indexes_count, FeeCalculator *feeCalc, char* testName ){ @@ -973,13 +976,15 @@ Test(coin_transactions, TestSortTransactions) { int index1[] = {0, 1}; int expec1[] = {0, 1}; - testTransactionSorting(transactionsHandle, index1, 2, expec1, 2, feeCalculator1, "Already sorted"); + FeeCalculator fc1 = {feeCalculator1, NULL}; + testTransactionSorting(transactionsHandle, index1, 2, expec1, 2, &fc1, "Already sorted"); int index2[] = {1, 0}; int expec2[] = {0, 1}; - testTransactionSorting(transactionsHandle, index2, 2, expec2, 2, feeCalculator1, "reverse sorted"); - testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, feeCalculator2, "hash tiebreaker"); + testTransactionSorting(transactionsHandle, index2, 2, expec2, 2, &fc1, "reverse sorted"); + FeeCalculator fc2 = {feeCalculator2, NULL}; + testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, &fc2, "hash tiebreaker"); - GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ *pFee){ + GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ *pFee, void* context){ cipher__SHA256 hash; int result = SKY_coin_Transaction_Hash(handle, &hash); if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ @@ -996,9 +1001,10 @@ Test(coin_transactions, TestSortTransactions) { } int index3[] = {1, 2, 0}; int expec3[] = {2, 0, 1}; - testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, feeCalculator3, "invalid fee multiplication is capped"); + FeeCalculator f3 = {feeCalculator3, NULL}; + testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, &f3, "invalid fee multiplication is capped"); - GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ *pFee){ + GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ *pFee, void* context){ cipher__SHA256 hash; int result = SKY_coin_Transaction_Hash(handle, &hash); if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ @@ -1017,5 +1023,6 @@ Test(coin_transactions, TestSortTransactions) { int index4[] = {1, 2, 0}; int expec4[] = {0, 1}; - testTransactionSorting(transactionsHandle, index4, 3, expec4, 2, feeCalculator4, "failed fee calc is filtered"); + FeeCalculator f4 = {feeCalculator4, NULL}; + testTransactionSorting(transactionsHandle, index4, 3, expec4, 2, &f4, "failed fee calc is filtered"); } diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index ed9f7fc652..827be26de2 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -11,7 +11,7 @@ #include "skytest.h" #include "transutil.h" -GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee){ +GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 0; return SKY_OK; } From 6f14ab73d013ac7df9c660d9c512b19eae1c3e6a Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 17:27:32 +0000 Subject: [PATCH 177/399] [swig] refs #1568. In typemap for FeeCalculator pass the Python function to call in the context field. --- lib/swig/python_skycoin.callback.i | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i index bc9e781d05..ff5ebebbbb 100644 --- a/lib/swig/python_skycoin.callback.i +++ b/lib/swig/python_skycoin.callback.i @@ -1,8 +1,8 @@ +%{ -%typemap(in) FeeCalc { - PyObject *callback; - GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee){ - PyObject *result = PyObject_CallFunctionObjArgs(callback, PyLong_FromLong(handle), NULL); +GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee, void* context){ + PyObject* feeCalc = (PyObject*)context; + PyObject *result = PyObject_CallFunctionObjArgs(feeCalc, PyLong_FromLong(handle), NULL); const GoUint64_ ret = PyLong_AsLong(result); Py_DECREF(result); if(pFee){ @@ -11,9 +11,12 @@ } else return -1; - } +} +%} +%typemap(in) FeeCalculator* (FeeCalculator temp) { if (!PyCallable_Check($input)) SWIG_fail; - $1 = _WrapperFeeCalculator; - callback = $input; + temp.callback = _WrapperFeeCalculator; + temp.context = $input; + $1 = &temp; } From d63b5a2f115e4c01af34f3d0c57c96b8ea57e190 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 17:49:46 +0000 Subject: [PATCH 178/399] [swig] refs #1568. Added swig and Pyskycoin reference in README.md. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a635eca0f9..9ab4c44e4d 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,7 @@ Skycoin implements client libraries which export core functionality for usage fr other programming languages. * `lib/cgo/` - libskycoin C client library ( [overview](lib/cgo/README.md), [API reference](docs/libc/API.md) ) +* `Swig` - Skycoin contains Swig interface files to generate libraries in different languages. ( Python library [Pyskycoin] (https://github.com/skycoin/pyskycoin)) For further details run `make docs` to generate documetation and read the corresponding README and API references. From c28548ab9c1a898d93c5aaad0ee918abb18032d2 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 23 Jul 2018 21:12:20 +0000 Subject: [PATCH 179/399] [swig] refs #1568. Callback function feeCalculator returns error and fee. --- lib/swig/python_skycoin.callback.i | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i index ff5ebebbbb..8bc1e9a722 100644 --- a/lib/swig/python_skycoin.callback.i +++ b/lib/swig/python_skycoin.callback.i @@ -3,14 +3,22 @@ GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee, void* context){ PyObject* feeCalc = (PyObject*)context; PyObject *result = PyObject_CallFunctionObjArgs(feeCalc, PyLong_FromLong(handle), NULL); - const GoUint64_ ret = PyLong_AsLong(result); + GoUint32_ error = 0; + if(PyTuple_Check(result)){ + PyObject* objerror = PyTuple_GetItem(result, 0); + error = PyLong_AsLong(objerror); + result = PyTuple_GetItem(result, 1); + } + if(error != 0) + return error; + GoUint64_ ret = PyLong_AsLong(result); Py_DECREF(result); if(pFee){ *pFee = ret; return 0; } else - return -1; + return 1; } %} From 1c9c15021a700b1ceecf983a445596fd890eb0fb Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 24 Jul 2018 13:32:12 +0000 Subject: [PATCH 180/399] [swig] refs #1568. Fix issue with GoUint64 typemap. --- lib/swig/golang.cgo.i | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 0c9c85ebf7..7ad931a3d6 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -65,6 +65,17 @@ free( (void*)$1->p ); } +/*GoUint64* parameter as reference */ +%typemap(in, numinputs=0) GoUint64* (GoUint64 temp) { + temp = 0; + $1 = &temp; +} + +/*GoUint64* as function return typemap*/ +%typemap(argout) GoUint64* { + %append_output( SWIG_From_long( *$1 ) ); +} + %apply GoString {GoString_} %apply GoString* {GoString_*} @@ -76,8 +87,6 @@ %apply int* OUTPUT {GoInt16*} %apply int* OUTPUT {GoUint32*} %apply int* OUTPUT {GoInt32*} -%apply int* OUTPUT {GoUint64*} -%apply int* OUTPUT {GoInt64*} typedef GoInt GoInt_; typedef GoUint GoUint_; From 49bbde25b880166a1349978f0ff89a04605bf437 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 24 Jul 2018 13:36:08 +0000 Subject: [PATCH 181/399] [swig] refs #1568. Apply same GoUint64 typemap to GoInt64 typemap. --- lib/swig/golang.cgo.i | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i index 7ad931a3d6..5fe2b9d95b 100644 --- a/lib/swig/golang.cgo.i +++ b/lib/swig/golang.cgo.i @@ -76,6 +76,17 @@ %append_output( SWIG_From_long( *$1 ) ); } +/*GoInt64* parameter as reference */ +%typemap(in, numinputs=0) GoInt64* (GoInt64 temp) { + temp = 0; + $1 = &temp; +} + +/*GoInt64* as function return typemap*/ +%typemap(argout) GoInt64* { + %append_output( SWIG_From_long( *$1 ) ); +} + %apply GoString {GoString_} %apply GoString* {GoString_*} From c2b18c565badd1c3e35d68033143ebe60e77c717 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 24 Jul 2018 17:22:32 +0000 Subject: [PATCH 182/399] [swig] refs #1568. Added wrapper for function SKY_coin_Transaction_SignInputs to handle slice as list of Secret Keys . --- lib/swig/python_pubkeys.i | 3 ++- lib/swig/python_seckeys.i | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i index bebebbf84d..50f7cfc4a9 100644 --- a/lib/swig/python_pubkeys.i +++ b/lib/swig/python_pubkeys.i @@ -1,6 +1,7 @@ /*cipher_PubKeys* input parameter */ -%typemap(in) (cipher_PubKeys* __in_pubKeys) { +%typemap(in) (cipher_PubKeys* __in_pubKeys) (cipher_PubKeys temp) { int i; + $1 = &temp; $1->count = PyList_Size($input); $1->data = malloc(sizeof(cipher_PubKey) * $1->count); cipher_PubKey* pdata = $1->data; diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index c41ec4b411..dac30f2d82 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -1,3 +1,42 @@ +%typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { + $1 = PyInt_Check($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_SecKeys* { + $1 = PyList_Check($input) ? 1 : 0; +} + +/* Handle not as pointer is input. */ +%typemap(in) Transaction__Handle { + SWIG_AsVal_long($input, (long*)&$1); +} + +/*cipher_PubKeys* input parameter */ +%typemap(in) (cipher_SecKeys* __in_secKeys) (cipher_SecKeys temp) { + int i; + $1 = &temp; + temp.count = 0; + temp.data = NULL; + $1 = &temp; + $1->count = PyList_Size($input); + $1->data = malloc(sizeof(cipher_SecKey) * $1->count); + cipher_SecKey* pdata = $1->data; + for(i = 0; i < $1->count; i++){ + PyObject *o = PyList_GetItem($input, i); + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SecKey, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type SecKey"); + cipher_SecKey* p = (cipher_SecKey*)argp; + memcpy(p, pdata, sizeof(cipher_SecKey)); + pdata++; + } +} + +%typemap(freearg) (cipher_SecKeys* __in_secKeys) { + if ($1->data) free($1->data); +} + /*cipher_SecKeys* parameter to return as a list */ %typemap(in, numinputs=0) (cipher_SecKeys* __out_secKeys) (cipher_SecKeys temp) { temp.data = NULL; @@ -22,6 +61,17 @@ %append_output( list ); } +%rename(SKY_coin_Transaction_SignInputs) wrap_SKY_coin_Transaction_SignInputs; +%inline{ + GoUint32 wrap_SKY_coin_Transaction_SignInputs(Transaction__Handle handle, cipher_SecKeys* __in_secKeys){ + GoSlice data; + data.data = __in_secKeys->data; + data.len = __in_secKeys->count; + data.cap = __in_secKeys->count; + return SKY_coin_Transaction_SignInputs(handle, data); + } +} + %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { From 70a62fa7a089b243c7b7dee3721b41a4d8e829ba Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 24 Jul 2018 20:44:20 +0000 Subject: [PATCH 183/399] [swig] refs #1568. Fix bug in cipher_SecKeys and cipher__PubKeys typemap. --- lib/swig/python_pubkeys.i | 2 +- lib/swig/python_seckeys.i | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i index 50f7cfc4a9..35f18a59d6 100644 --- a/lib/swig/python_pubkeys.i +++ b/lib/swig/python_pubkeys.i @@ -12,7 +12,7 @@ if (!SWIG_IsOK(res)) SWIG_exception_fail(SWIG_TypeError, "expecting type PubKey"); cipher_PubKey* p = (cipher_PubKey*)argp; - memcpy(p, pdata, sizeof(cipher_PubKey)); + memcpy(pdata, p, sizeof(cipher_PubKey)); pdata++; } } diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index dac30f2d82..b96398a2c5 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -15,9 +15,6 @@ %typemap(in) (cipher_SecKeys* __in_secKeys) (cipher_SecKeys temp) { int i; $1 = &temp; - temp.count = 0; - temp.data = NULL; - $1 = &temp; $1->count = PyList_Size($input); $1->data = malloc(sizeof(cipher_SecKey) * $1->count); cipher_SecKey* pdata = $1->data; @@ -28,7 +25,7 @@ if (!SWIG_IsOK(res)) SWIG_exception_fail(SWIG_TypeError, "expecting type SecKey"); cipher_SecKey* p = (cipher_SecKey*)argp; - memcpy(p, pdata, sizeof(cipher_SecKey)); + memcpy(pdata, p, sizeof(cipher_SecKey)); pdata++; } } From c46df688dcf99ef23980ce4207010b9e0feba904 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Thu, 26 Jul 2018 19:04:02 +0000 Subject: [PATCH 184/399] [swig] refs #1568. Added typemaps for slices of coin.UxOut. --- include/swig.h | 5 ++ lib/swig/python_pubkeys.i | 36 --------- lib/swig/python_seckeys.i | 50 ------------- lib/swig/python_uxarray.i | 52 +++++++++++++ lib/swig/skycoin.cipher.crypto.i | 13 +--- lib/swig/skycoin.coin.i | 34 +++++++++ lib/swig/skycoin.mem.i | 123 +++++++++++++++++++++++++------ 7 files changed, 192 insertions(+), 121 deletions(-) create mode 100644 lib/swig/python_uxarray.i diff --git a/include/swig.h b/include/swig.h index 89d47f8089..5f730e471d 100644 --- a/include/swig.h +++ b/include/swig.h @@ -33,3 +33,8 @@ typedef struct{ int count; } cipher_PubKeys; +typedef struct{ + coin__UxOut* data; + int count; +} coin_UxOutArray; + diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i index 35f18a59d6..174eaa15e5 100644 --- a/lib/swig/python_pubkeys.i +++ b/lib/swig/python_pubkeys.i @@ -21,39 +21,3 @@ if ($1->data) free($1->data); } -%rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); - return result; - } -} - -%rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); - return result; - } -} - -%rename(SKY_cipher_PubKeySlice_Swap) wrap_SKY_cipher_PubKeySlice_Swap; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); - return result; - } -} - diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index b96398a2c5..ef860b2c8b 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -6,11 +6,6 @@ $1 = PyList_Check($input) ? 1 : 0; } -/* Handle not as pointer is input. */ -%typemap(in) Transaction__Handle { - SWIG_AsVal_long($input, (long*)&$1); -} - /*cipher_PubKeys* input parameter */ %typemap(in) (cipher_SecKeys* __in_secKeys) (cipher_SecKeys temp) { int i; @@ -58,50 +53,5 @@ %append_output( list ); } -%rename(SKY_coin_Transaction_SignInputs) wrap_SKY_coin_Transaction_SignInputs; -%inline{ - GoUint32 wrap_SKY_coin_Transaction_SignInputs(Transaction__Handle handle, cipher_SecKeys* __in_secKeys){ - GoSlice data; - data.data = __in_secKeys->data; - data.len = __in_secKeys->count; - data.cap = __in_secKeys->count; - return SKY_coin_Transaction_SignInputs(handle, data); - } -} - -%rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; -%inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ - __out_secKeys->data = NULL; - __out_secKeys->count = 0; - GoSlice_ data; - data.data = malloc(sizeof(cipher_SecKey) * n); - data.len = n; - data.cap = n; - GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); - if( result == 0){ - __out_secKeys->data = data.data; - __out_secKeys->count = data.len; - } - return result; - } -} - -%inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ - __out_secKeys->data = NULL; - __out_secKeys->count = 0; - GoSlice_ data; - data.data = malloc(sizeof(cipher_SecKey) * n); - data.len = n; - data.cap = n; - GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); - if( result == 0){ - __out_secKeys->data = data.data; - __out_secKeys->count = data.len; - } - return result; - } -} diff --git a/lib/swig/python_uxarray.i b/lib/swig/python_uxarray.i new file mode 100644 index 0000000000..afc5add335 --- /dev/null +++ b/lib/swig/python_uxarray.i @@ -0,0 +1,52 @@ +%typecheck(SWIG_TYPECHECK_STRING_ARRAY) coin_UxOutArray* { + $1 = PyList_Check($input) ? 1 : 0; +} + +/*coin_UxOutArray* input parameter */ +%typemap(in) (coin_UxOutArray* __uxIn) (coin_UxOutArray temp) { + int i; + $1 = &temp; + $1->count = PyList_Size($input); + $1->data = malloc(sizeof(coin__UxOut) * $1->count); + coin__UxOut* pdata = $1->data; + for(i = 0; i < $1->count; i++){ + PyObject *o = PyList_GetItem($input, i); + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_coin__UxOut, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type UxOut"); + coin__UxOut* p = (coin__UxOut*)argp; + memcpy(pdata, p, sizeof(coin__UxOut)); + pdata++; + } +} + +%typemap(freearg) (coin_UxOutArray* __uxIn) { + if ($1->data) free($1->data); +} + +%apply (coin_UxOutArray* __uxIn) {(coin_UxOutArray* __uxOut)} + +/*coin_UxOutArray* parameter to return as a list */ +%typemap(in, numinputs=0) (coin_UxOutArray* __return_Ux) (coin_UxOutArray temp) { + temp.data = NULL; + temp.count = 0; + $1 = &temp; +} + +/*coin_UxOutArray* as function return typemap*/ +%typemap(argout) (coin_UxOutArray* __return_Ux) { + int i; + PyObject *list = PyList_New(0); + for (i = 0; i < $1->count; i++) { + coin__UxOut* key = &($1->data[i]); + coin__UxOut* newKey = malloc(sizeof(coin__UxOut)); + memcpy(newKey, key, sizeof(coin__UxOut)); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_coin__UxOut, SWIG_POINTER_OWN ); + PyList_Append(list, o); + Py_DECREF(o); + } + if( $1->data != NULL) + free( (void*)$1->data ); + %append_output( list ); +} diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index 27a6c34c66..e04859459f 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -150,17 +150,8 @@ } void release(){ - destroy_cipher_PubKeys($self); + if($self-data != NULL) + free($self->data); } } - -%inline{ - void destroy_cipher_PubKeys(cipher_PubKeys* p){ - if( p != NULL ){ - if( p->data != NULL ){ - free( p->data ); - } - } - } -} diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i index d47c2bc3fa..d22625c62b 100644 --- a/lib/swig/skycoin.coin.i +++ b/lib/swig/skycoin.coin.i @@ -24,6 +24,39 @@ } } +%extend coin_UxOutArray { + coin__UxOut* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, coin__UxOut* uxout){ + if( i < $self->count){ + memcpy(&self->data[i], uxout, sizeof(*uxout)); + return i; + } else { + return -1; + } + } + + int isEqual(coin_UxOutArray* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(coin__UxOut) * $self->count) == 0; + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + if($self-data != NULL) + free($self->data); + } +} + %extend coin__TransactionOutput { int isEqual(coin__TransactionOutput* t){ if( $self->Coins != t->Coins || @@ -36,3 +69,4 @@ return 1; } } + diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 0124bad3b8..1b1d2a25ae 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,38 +1,68 @@ +/* Handle not as pointer is input. */ +%typemap(in) Transaction__Handle { + SWIG_AsVal_long($input, (long*)&$1); +} + #if defined(SWIGPYTHON) %include "python_seckeys.i" %include "python_pubkeys.i" -#else + %include "python_uxarray.i" +#endif + +%rename(SKY_coin_Transaction_SignInputs) wrap_SKY_coin_Transaction_SignInputs; +%inline{ + GoUint32 wrap_SKY_coin_Transaction_SignInputs(Transaction__Handle handle, cipher_SecKeys* __in_secKeys){ + GoSlice data; + data.data = __in_secKeys->data; + data.len = __in_secKeys->count; + data.cap = __in_secKeys->count; + return SKY_coin_Transaction_SignInputs(handle, data); + } +} + + %rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; %inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* secKeys){ + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ + __out_secKeys->data = NULL; + __out_secKeys->count = 0; GoSlice_ data; - data.data = secKeys->data; - data.len = secKeys->count; - data.cap = secKeys->count; + data.data = malloc(sizeof(cipher_SecKey) * n); + data.len = n; + data.cap = n; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); + if( result == 0){ + __out_secKeys->data = data.data; + __out_secKeys->count = data.len; + } return result; } } -%rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* secKeys){ + GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ + __out_secKeys->data = NULL; + __out_secKeys->count = 0; GoSlice_ data; - data.data = secKeys->data; - data.len = secKeys->count; - data.cap = secKeys->count; + data.data = malloc(sizeof(cipher_SecKey) * n); + data.len = n; + data.cap = n; GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); + if( result == 0){ + __out_secKeys->data = data.data; + __out_secKeys->count = data.len; + } return result; } } %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* pubKeys){ + GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys){ GoSlice_ data; - data.data = pubKeys->data; - data.len = pubKeys->count; - data.cap = pubKeys->count; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); return result; } @@ -40,11 +70,11 @@ %rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; %inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ + GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - data.data = pubKeys->data; - data.len = pubKeys->count; - data.cap = pubKeys->count; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); return result; } @@ -52,20 +82,65 @@ %rename(SKY_cipher_PubKeySlice_Swap) wrap_SKY_cipher_PubKeySlice_Swap; %inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* pubKeys, GoInt p1, GoInt p2){ + GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ GoSlice_ data; - data.data = pubKeys->data; - data.len = pubKeys->count; - data.cap = pubKeys->count; + data.data = __in_pubKeys->data; + data.len = __in_pubKeys->count; + data.cap = __in_pubKeys->count; GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); return result; } } -#endif - +%rename(SKY_coin_VerifyTransactionCoinsSpending) wrap_SKY_coin_VerifyTransactionCoinsSpending; +%inline { + GoUint32 wrap_SKY_coin_VerifyTransactionCoinsSpending(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxOut){ + GoSlice_ dataIn; + dataIn.data = __uxIn->data; + dataIn.len = __uxIn->count; + dataIn.cap = __uxIn->count; + GoSlice_ dataOut; + dataOut.data = __uxOut->data; + dataOut.len = __uxOut->count; + dataOut.cap = __uxOut->count; + GoUint32 result = SKY_coin_VerifyTransactionCoinsSpending(&dataIn, &dataOut); + return result; + }; +} +%rename(SKY_coin_VerifyTransactionHoursSpending) wrap_SKY_coin_VerifyTransactionHoursSpending; +%inline { + GoUint32 wrap_SKY_coin_VerifyTransactionHoursSpending(GoUint64 _headTime , coin_UxOutArray* __uxIn, coin_UxOutArray* __uxOut){ + GoSlice_ dataIn; + dataIn.data = __uxIn->data; + dataIn.len = __uxIn->count; + dataIn.cap = __uxIn->count; + GoSlice_ dataOut; + dataOut.data = __uxOut->data; + dataOut.len = __uxOut->count; + dataOut.cap = __uxOut->count; + GoUint32 result = SKY_coin_VerifyTransactionHoursSpending(_headTime, &dataIn, &dataOut); + return result; + }; +} +%rename(SKY_coin_CreateUnspents) wrap_SKY_coin_CreateUnspents; +%inline { + GoUint32 wrap_SKY_coin_CreateUnspents(coin__BlockHeader* bh, Transaction__Handle t, coin_UxOutArray* __return_Ux){ + __return_Ux->data = NULL; + __return_Ux->count = 0; + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_coin_CreateUnspents(bh, t, &data); + if( result == 0){ + __return_Ux->data = data.data; + __return_Ux->count = data.len; + } + return result; + } +} /** * From 808e1faeb5bc79dbd634a45ba087c700de8a008e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 27 Jul 2018 17:36:49 +0000 Subject: [PATCH 185/399] [swig] refs #1568. Deal with function SKY_coin_Transaction_VerifyInput. --- lib/swig/skycoin.mem.i | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 1b1d2a25ae..150788198c 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -142,6 +142,17 @@ } } +%rename(SKY_coin_Transaction_VerifyInput) wrap_SKY_coin_Transaction_VerifyInput; +%inline{ + GoUint32 wrap_SKY_coin_Transaction_VerifyInput(Transaction__Handle handle, coin_UxOutArray* __uxIn){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_Transaction_VerifyInput(handle, &data); + } +} + /** * * typemaps for Handles From 2915f1159d468451e8dec164d8e9cdf7e891680e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 27 Jul 2018 18:36:05 +0000 Subject: [PATCH 186/399] [libc] refs #1191. Added method for setting inputs, outputs and signatures in transactions. --- lib/cgo/coin.transactions.go | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index d08a0cc984..9ab6747d5f 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -119,6 +119,25 @@ func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, inpu return } +//export SKY_coin_Transaction_Set_Input_At +func SKY_coin_Transaction_Set_Input_At(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.In) { + ____error_code = SKY_ERROR + return + } + *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) = *input + return +} + //export SKY_coin_Transaction_Get_Outputs_Count func SKY_coin_Transaction_Get_Outputs_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { ____error_code = 0 @@ -153,6 +172,25 @@ func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, out return } +//export SKY_coin_Transaction_Set_Output_At +func SKY_coin_Transaction_Set_Output_At(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.Out) { + ____error_code = SKY_ERROR + return + } + *(*C.coin__TransactionOutput)(unsafe.Pointer(&txn.Out[i])) = *output + return +} + //export SKY_coin_Transaction_Get_Signatures_Count func SKY_coin_Transaction_Get_Signatures_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { ____error_code = 0 @@ -187,6 +225,25 @@ func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, return } +//export SKY_coin_Transaction_Set_Signature_At +func SKY_coin_Transaction_Set_Signature_At(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { + ____error_code = 0 + defer func() { + ____error_code = catchApiPanic(____error_code, recover()) + }() + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_ERROR + return + } + if i >= len(txn.Sigs) { + ____error_code = SKY_ERROR + return + } + *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) = *sig + return +} + //export SKY_coin_Transaction_Push_Signature func SKY_coin_Transaction_Push_Signature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { ____error_code = 0 From f787cb3cf10862fca9896ae55dd97158359d2368 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 27 Jul 2018 19:16:37 +0000 Subject: [PATCH 187/399] [libc] refs #1191. Return SKY_BAD_HANDLE error when a handle is not found. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0. --- lib/cgo/api.client.go | 98 +++++++++---------- lib/cgo/api.spend.go | 6 +- lib/cgo/api.wallet.go | 2 +- lib/cgo/api.webrpc.client.go | 20 ++-- lib/cgo/cipher.ripemd160.ripemd160.go | 4 +- .../cipher.secp256k1-go.secp256k1-go2.num.go | 10 +- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 26 ++--- .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 6 +- lib/cgo/cli.add_private_key.go | 4 +- lib/cgo/cli.check_balance.go | 4 +- lib/cgo/cli.cli.go | 10 +- lib/cgo/cli.create_rawtx.go | 4 +- lib/cgo/cli.generate_addrs.go | 2 +- lib/cgo/cli.generate_wallet.go | 2 +- lib/cgo/cli.outputs.go | 6 +- lib/cgo/cli_helper.go | 8 +- lib/cgo/coin.block.go | 38 +++---- lib/cgo/coin.outputs.go | 22 +++-- lib/cgo/coin.transactions.go | 96 +++++++++--------- lib/cgo/tests/check_coin.block.c | 2 +- lib/cgo/util.fee.fee.go | 4 +- lib/cgo/wallet.notes.go | 14 +-- lib/cgo/wallet.readable.go | 8 +- 23 files changed, 201 insertions(+), 195 deletions(-) diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 6d1c864fe1..6d3e9e33b8 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -35,7 +35,7 @@ func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_cod }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.CSRF() @@ -54,7 +54,7 @@ func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.Version() @@ -73,7 +73,7 @@ func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.Outputs() @@ -92,7 +92,7 @@ func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _a }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -112,7 +112,7 @@ func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } hashes := *(*[]string)(unsafe.Pointer(&_hashes)) @@ -132,7 +132,7 @@ func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.CoinSupply() @@ -151,7 +151,7 @@ func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Hand }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } hash := _hash @@ -171,7 +171,7 @@ func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } seq := _seq @@ -191,7 +191,7 @@ func SKY_api_Client_Blocks(_c C.Client__Handle, _start, _end int, _arg1 *C.Handl }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } start := _start @@ -212,7 +212,7 @@ func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n int, _arg1 *C.Handle) (__ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } n := _n @@ -232,7 +232,7 @@ func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (__ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.BlockchainMetadata() @@ -251,7 +251,7 @@ func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (__ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.BlockchainProgress() @@ -270,7 +270,7 @@ func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.walle }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -290,7 +290,7 @@ func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (_ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } uxID := _uxID @@ -310,7 +310,7 @@ func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Ha }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addr := _addr @@ -330,7 +330,7 @@ func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletRespo }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -350,7 +350,7 @@ func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.Wallets() @@ -369,7 +369,7 @@ func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label s }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } seed := _seed @@ -391,7 +391,7 @@ func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _p }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } seed := _seed @@ -414,7 +414,7 @@ func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _p }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -436,7 +436,7 @@ func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wall }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -456,7 +456,7 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -479,12 +479,12 @@ func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } req, okreq := lookupCreateTransactionRequestHandle(C.CreateTransactionRequest__Handle(*_req)) if !okreq { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg1, ____return_err := c.CreateTransaction(*req) @@ -503,7 +503,7 @@ func SKY_api_Client_WalletTransactions(_c C.Client__Handle, _id string, _arg1 *C }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -523,7 +523,7 @@ func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____e }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -543,7 +543,7 @@ func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.WalletFolderName() @@ -562,7 +562,7 @@ func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } entropy := _entropy @@ -582,7 +582,7 @@ func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password str }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -603,7 +603,7 @@ func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 * }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addr := _addr @@ -623,7 +623,7 @@ func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (__ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.NetworkConnections() @@ -642,7 +642,7 @@ func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Hand }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.NetworkDefaultConnections() @@ -661,7 +661,7 @@ func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Hand }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.NetworkTrustedConnections() @@ -680,7 +680,7 @@ func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.NetworkExchangeableConnections() @@ -699,7 +699,7 @@ func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (_ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.PendingTransactions() @@ -718,7 +718,7 @@ func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Hand }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txid := _txid @@ -738,7 +738,7 @@ func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C. }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -758,7 +758,7 @@ func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -778,7 +778,7 @@ func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -798,7 +798,7 @@ func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx string, _arg1 }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } rawTx := _rawTx @@ -818,7 +818,7 @@ func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C. }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.ResendUnconfirmedTransactions() @@ -837,7 +837,7 @@ func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.G }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txid := _txid @@ -857,7 +857,7 @@ func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addr := _addr @@ -877,7 +877,7 @@ func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } params := (*api.RichlistParams)(unsafe.Pointer(_params)) @@ -897,7 +897,7 @@ func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_ }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.AddressCount() @@ -916,7 +916,7 @@ func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_cod }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -935,7 +935,7 @@ func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.Health() @@ -954,7 +954,7 @@ func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password str }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id @@ -975,7 +975,7 @@ func SKY_api_Client_DecryptWallet(_c C.Client__Handle, _id string, _password str }() c, okc := lookupClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } id := _id diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index 5a65ac3c1f..d230a697af 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -26,7 +26,7 @@ func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs [] }() txn, ok := lookupTransactionHandle(_txn) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) @@ -46,7 +46,7 @@ func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.walle }() txn, ok := lookupTransactionHandle(_txn) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) @@ -66,7 +66,7 @@ func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _ }() r, ok := lookupCreatedTransactionHandle(_r) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := r.ToTransaction() diff --git a/lib/cgo/api.wallet.go b/lib/cgo/api.wallet.go index 8eb41e4e15..7a0d44203d 100644 --- a/lib/cgo/api.wallet.go +++ b/lib/cgo/api.wallet.go @@ -19,7 +19,7 @@ func SKY_api_NewWalletResponse(_w C.Wallet__Handle, _arg1 *C.WalletResponse__Han }() w, okw := lookupWalletHandle(_w) if !okw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg1, ____return_err := api.NewWalletResponse(w) diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index c933d4facf..fa26f559c8 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -58,7 +58,7 @@ func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []str }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -78,7 +78,7 @@ func SKY_webrpc_Client_InjectTransactionString(_c C.WebRpcClient__Handle, _rawtx }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } rawtx := _rawtx @@ -98,12 +98,12 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transa }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } tx, ok := lookupTransactionHandle(_tx) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg1, ____return_err := c.InjectTransaction(tx) @@ -122,7 +122,7 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResul }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := c.GetStatus() @@ -141,7 +141,7 @@ func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid strin }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txid := _txid @@ -161,7 +161,7 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) @@ -181,7 +181,7 @@ func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } start := _start @@ -202,7 +202,7 @@ func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _ }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ss := *(*[]uint64)(unsafe.Pointer(&_ss)) @@ -222,7 +222,7 @@ func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } n := _n diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go index 99392b919d..3f5b90c815 100644 --- a/lib/cgo/cipher.ripemd160.ripemd160.go +++ b/lib/cgo/cipher.ripemd160.ripemd160.go @@ -35,7 +35,7 @@ func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_c }() h, ok := lookupHashHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } p := *(*[]byte)(unsafe.Pointer(&_p)) @@ -56,7 +56,7 @@ func SKY_ripemd160_Sum(handle C.Hash_Handle, _p []byte, _arg1 *C.GoSlice_) (____ }() h, ok := lookupHashHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } p := *(*[]byte)(unsafe.Pointer(&_p)) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go index 6bfc7414b7..0d151b091f 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -34,7 +34,7 @@ func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____er }() num, ok := lookupNumberHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } num.Print(_label) @@ -49,7 +49,7 @@ func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error }() num, ok := lookupNumberHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } num.SetHex(_s) @@ -64,7 +64,7 @@ func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____erro }() num, ok := lookupNumberHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := num.IsOdd() @@ -80,12 +80,12 @@ func SKY_secp256k1go_Number_IsEqual(handle1 C.Number_Handle, handle2 C.Number_Ha }() num1, ok := lookupNumberHandle(handle1) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } num2, ok := lookupNumberHandle(handle2) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *result = hex.EncodeToString(num1.Bytes()) == hex.EncodeToString(num2.Bytes()) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go index 6e385c1034..298730ac4c 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -35,7 +35,7 @@ func SKY_secp256k1go_Signature_Get_R(handle C.Signature_Handle, r *C.Number_Hand }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *r = registerNumberHandle(&sig.R) @@ -50,7 +50,7 @@ func SKY_secp256k1go_Signature_Get_S(handle C.Signature_Handle, s *C.Number_Hand }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *s = registerNumberHandle(&sig.S) @@ -65,7 +65,7 @@ func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (__ }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } sig.Print(_lab) @@ -80,13 +80,13 @@ func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) message, okm := lookupNumberHandle(_message) if !okm { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg2 := sig.Verify(pubkey, message) @@ -102,13 +102,13 @@ func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.sec }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) m, okm := lookupNumberHandle(_message) if !okm { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } recid := _recid @@ -125,22 +125,22 @@ func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } seckey, oks := lookupNumberHandle(_seckey) if !oks { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } message, okm := lookupNumberHandle(_message) if !okm { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } nonce, okn := lookupNumberHandle(_nonce) if !okn { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } recid := _recid @@ -157,7 +157,7 @@ func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } v := *(*[]byte)(unsafe.Pointer(&_v)) @@ -173,7 +173,7 @@ func SKY_secp256k1go_Signature_Bytes(handle C.Signature_Handle, _arg0 *C.GoSlice }() sig, ok := lookupSignatureHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := sig.Bytes() diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go index 400d66c184..200b40d572 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go @@ -97,12 +97,12 @@ func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) na, ok1 := lookupNumberHandle(_na) if !ok1 { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ng, ok2 := lookupNumberHandle(_ng) if !ok2 { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } xyz.ECmult(r, na, ng) @@ -168,7 +168,7 @@ func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a C.Number_Handle) (____ r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) a, ok := lookupNumberHandle(_a) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } secp256k1go2.ECmultGen(r, a) diff --git a/lib/cgo/cli.add_private_key.go b/lib/cgo/cli.add_private_key.go index 923447792b..f5ee27bb72 100644 --- a/lib/cgo/cli.add_private_key.go +++ b/lib/cgo/cli.add_private_key.go @@ -21,7 +21,7 @@ func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code u }() wlt, okwlt := lookupWalletHandle(_wlt) if !okwlt { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } key := _key @@ -42,7 +42,7 @@ func SKY_cli_AddPrivateKeyToFile(_walletFile, _key string, pwd C.PasswordReader_ key := _key pr, okc := lookupPasswordReaderHandle(pwd) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ____return_err := cli.AddPrivateKeyToFile(walletFile, key, *pr) diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go index 4313be2697..c1543ddf17 100644 --- a/lib/cgo/cli.check_balance.go +++ b/lib/cgo/cli.check_balance.go @@ -23,7 +23,7 @@ func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _ }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } walletFile := _walletFile @@ -43,7 +43,7 @@ func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _ }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } addrs := *(*[]string)(unsafe.Pointer(&_addrs)) diff --git a/lib/cgo/cli.cli.go b/lib/cgo/cli.cli.go index 454ff07efe..a237f7b717 100644 --- a/lib/cgo/cli.cli.go +++ b/lib/cgo/cli.cli.go @@ -39,7 +39,7 @@ func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (___ }() __c, okc := lookupConfigHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } c := *__c @@ -56,7 +56,7 @@ func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____err }() __c, okc := lookupConfigHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } c := *__c @@ -73,7 +73,7 @@ func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code }() __cfg, okcfg := lookupConfigHandle(_cfg) if !okcfg { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } cfg := *__cfg @@ -93,7 +93,7 @@ func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__H }() c, okc := lookupContextHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } webrpcClient := c.App.Metadata["rpc"].(*webrpc.Client) @@ -109,7 +109,7 @@ func SKY_cli_ConfigFromContext(_c C.Context__Handle, _arg1 *C.Config__Handle) (_ }() c, okc := lookupContextHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } config := c.App.Metadata["config"].(cli.Config) diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index 5f7b4e30fd..4db59336c8 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -35,7 +35,7 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) pr, okp := lookupPasswordReaderHandle(pwd) if !okp { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg4, ____return_err := cli.CreateRawTxFromWallet(c, walletFile, chgAddr, toAddrs, *pr) @@ -63,7 +63,7 @@ func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFil toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) pr, okp := lookupPasswordReaderHandle(pwd) if !okp { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg4, ____return_err := cli.CreateRawTxFromAddress(c, addr, walletFile, chgAddr, toAddrs, *pr) diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go index a65914161b..f2117f0c60 100644 --- a/lib/cgo/cli.generate_addrs.go +++ b/lib/cgo/cli.generate_addrs.go @@ -27,7 +27,7 @@ func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.Pass num := _num pr, okc := lookupPasswordReaderHandle(pwd) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg3, ____return_err := cli.GenerateAddressesInFile(walletFile, num, *pr) diff --git a/lib/cgo/cli.generate_wallet.go b/lib/cgo/cli.generate_wallet.go index 45f963a862..e9537f07ad 100644 --- a/lib/cgo/cli.generate_wallet.go +++ b/lib/cgo/cli.generate_wallet.go @@ -22,7 +22,7 @@ func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAd walletFile := _walletFile __opts, okopts := lookupOptionsHandle(*_opts) if !okopts { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } opts := *__opts diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index b8686bb876..463c664ee8 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -21,7 +21,7 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } walletFile := _walletFile @@ -41,12 +41,12 @@ func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, }() c, okc := lookupWebRpcClientHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } wlt, okwlt := lookupWalletHandle(*_wlt) if !okwlt { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) diff --git a/lib/cgo/cli_helper.go b/lib/cgo/cli_helper.go index 5c470decbd..6e8b7709be 100644 --- a/lib/cgo/cli_helper.go +++ b/lib/cgo/cli_helper.go @@ -23,7 +23,7 @@ func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { }() app, okapp := lookupAppHandle(_app) if !okapp { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } args := splitCliArgs(_args) @@ -42,7 +42,7 @@ func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_ }() __c, okc := lookupConfigHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } c := *__c @@ -59,7 +59,7 @@ func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____ }() __c, okc := lookupConfigHandle(_c) if !okc { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } c := *__c @@ -76,7 +76,7 @@ func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) }() app, okapp := lookupAppHandle(_app) if !okapp { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg1 := app.App.Metadata["rpc"].(*webrpc.Client) diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index 4fc763cc07..697a76d12a 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -39,13 +39,13 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } hash := *(*cipher.SHA256)(unsafe.Pointer(_hash)) txns, ok := lookupTransactionsHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalc) @@ -96,7 +96,7 @@ func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (___ }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.HashHeader() @@ -112,7 +112,7 @@ func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) ( }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.PreHashHeader() @@ -128,7 +128,7 @@ func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.Time() @@ -144,7 +144,7 @@ func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint3 }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.Seq() @@ -160,7 +160,7 @@ func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____e }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.HashBody() @@ -176,7 +176,7 @@ func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.Size() @@ -192,7 +192,7 @@ func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_co }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := b.String() @@ -208,7 +208,7 @@ func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256 }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txHash := *(*cipher.SHA256)(unsafe.Pointer(_txHash)) @@ -230,7 +230,7 @@ func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA2 fee := _fee body, ok := lookupBlockBodyHandle(_body) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg4 := coin.NewBlockHeader(prev, uxHash, currentTime, fee, *body) @@ -282,7 +282,7 @@ func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) }() body, ok := lookupBlockBodyHandle(_body) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := body.Hash() @@ -298,7 +298,7 @@ func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_co }() bb, ok := lookupBlockBodyHandle(*_bb) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := bb.Size() @@ -314,7 +314,7 @@ func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____e }() bb, ok := lookupBlockBodyHandle(_bb) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := bb.Bytes() @@ -331,7 +331,7 @@ func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg2 := coin.CreateUnspents(bh, *tx) @@ -348,7 +348,7 @@ func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } outIndex := _outIndex @@ -368,7 +368,7 @@ func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_ }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE } else { *_p = (*C.coin__Block)(unsafe.Pointer(b)) } @@ -383,7 +383,7 @@ func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____err }() b, ok := lookupBlockHandle(_b) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE } else { *_p = registerBlockBodyHandle(&b.Body) } @@ -398,7 +398,7 @@ func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle, handle *C.Block__Handl }() txns, ok := lookupTransactionsHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } body := coin.BlockBody{ diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index d093dbe380..8fcc2bae02 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -220,7 +220,7 @@ func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C. }() address_outs, ok := lookupAddressUxOutHandle(_address_outs) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } keys := (*address_outs).Keys() @@ -236,7 +236,7 @@ func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C }() address_outs, ok := lookupAddressUxOutHandle(_address_outs) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ux := (*address_outs).Flatten() @@ -252,12 +252,12 @@ func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO }() auo1, ok := lookupAddressUxOutHandle(_auo1) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } auo2, ok := lookupAddressUxOutHandle(_auo2) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } auo_result := (*auo1).Sub(*auo2) @@ -273,12 +273,12 @@ func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO }() auo1, ok := lookupAddressUxOutHandle(_auo1) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } auo2, ok := lookupAddressUxOutHandle(_auo2) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } auo_result := (*auo1).Add(*auo2) @@ -296,6 +296,8 @@ func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__A copyToGoSlice(reflect.ValueOf(uxOuts), _uxOuts) return SKY_OK } + } else { + return SKY_BAD_HANDLE } return SKY_ERROR } @@ -308,6 +310,8 @@ func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher _, found := (*a)[key] *_hasKey = found return SKY_OK + } else { + return SKY_BAD_HANDLE } return SKY_ERROR } @@ -322,6 +326,8 @@ func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *_length = len(uxOuts) return SKY_OK } + } else { + return SKY_BAD_HANDLE } return SKY_ERROR } @@ -333,7 +339,7 @@ func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) *_length = len(*a) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_coin_AddressUxOuts_Set @@ -345,5 +351,5 @@ func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__A (*a)[key] = uxOuts return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 9ab6747d5f..a1ddf06bb4 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -38,7 +38,7 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact }() tx, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ntx := coin.Transaction{} @@ -63,7 +63,7 @@ func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coi }() ptx, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE } else { *_pptx = (*C.coin__Transaction)(unsafe.Pointer(ptx)) } @@ -78,7 +78,7 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txn.In = make([]cipher.SHA256, count) @@ -93,7 +93,7 @@ func SKY_coin_Transaction_Get_Inputs_Count(handle C.Transaction__Handle, length }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *length = len(txn.In) @@ -108,11 +108,11 @@ func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, inpu }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.In) { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *input = *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) @@ -127,11 +127,11 @@ func SKY_coin_Transaction_Set_Input_At(handle C.Transaction__Handle, i int, inpu }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.In) { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) = *input @@ -146,7 +146,7 @@ func SKY_coin_Transaction_Get_Outputs_Count(handle C.Transaction__Handle, length }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *length = len(txn.Out) @@ -161,7 +161,7 @@ func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, out }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.Out) { @@ -180,7 +180,7 @@ func SKY_coin_Transaction_Set_Output_At(handle C.Transaction__Handle, i int, out }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.Out) { @@ -199,7 +199,7 @@ func SKY_coin_Transaction_Get_Signatures_Count(handle C.Transaction__Handle, len }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *length = len(txn.Sigs) @@ -214,11 +214,11 @@ func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.Sigs) { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *sig = *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) @@ -233,11 +233,11 @@ func SKY_coin_Transaction_Set_Signature_At(handle C.Transaction__Handle, i int, }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if i >= len(txn.Sigs) { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) = *sig @@ -252,7 +252,7 @@ func SKY_coin_Transaction_Push_Signature(handle C.Transaction__Handle, _sig *C.c }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } sig := *(*cipher.Sig)(unsafe.Pointer(_sig)) @@ -268,7 +268,7 @@ func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txn.Out = make([]coin.TransactionOutput, count) @@ -283,7 +283,7 @@ func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count in }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txn.Sigs = make([]cipher.Sig, count) @@ -298,7 +298,7 @@ func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code u }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ____return_err := txn.Verify() @@ -316,7 +316,7 @@ func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coi }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) @@ -335,7 +335,7 @@ func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.ciph }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) @@ -365,7 +365,7 @@ func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.ciphe }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } dst := *(*cipher.Address)(unsafe.Pointer(_dst)) @@ -383,7 +383,7 @@ func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cip }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) @@ -399,7 +399,7 @@ func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____er }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.Size() @@ -415,7 +415,7 @@ func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SH }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.Hash() @@ -431,7 +431,7 @@ func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _ar }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, __arg1 := txn.SizeHash() @@ -448,7 +448,7 @@ func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.TxID() @@ -464,7 +464,7 @@ func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoStrin }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.TxIDHex() @@ -480,7 +480,7 @@ func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_ }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txn.UpdateHeader() @@ -495,7 +495,7 @@ func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.ciphe }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.HashInner() @@ -511,7 +511,7 @@ func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSli }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txn.Serialize() @@ -554,7 +554,7 @@ func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint6 }() txn, ok := lookupTransactionHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := txn.OutputHours() @@ -580,7 +580,7 @@ func SKY_coin_Get_Transactions_Object(handle C.Transactions__Handle, _pptx **C.c }() ptx, ok := lookupTransactionsHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE } else { *_pptx = (*C.coin__Transactions)(unsafe.Pointer(ptx)) } @@ -595,7 +595,7 @@ func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) ( }() txns, ok := lookupTransactionsHandle(handle) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *_length = len(*txns) @@ -610,12 +610,12 @@ func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Han }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } tx, okt := lookupTransactionHandle(th) if !okt { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } *txns = append(*txns, *tx) @@ -645,7 +645,7 @@ func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcu }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } result, err := txns.Fees(feeCalc) @@ -665,7 +665,7 @@ func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transa }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } if n >= len(*txns) { @@ -685,7 +685,7 @@ func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txns.Hashes() @@ -701,7 +701,7 @@ func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____err }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txns.Size() @@ -717,7 +717,7 @@ func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } size := _size @@ -745,7 +745,7 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcul }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } sorted := coin.SortTransactions(*txns, feeCalc) @@ -772,7 +772,7 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.Fe }() txns, ok := lookupTransactionsHandle(tsh) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } sorted := coin.NewSortableTransactions(*txns, feeCalc) @@ -788,7 +788,7 @@ func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle }() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } txns.Sort() @@ -803,7 +803,7 @@ func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, }() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := txns.Len() @@ -819,7 +819,7 @@ func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle }() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } i := _i @@ -837,7 +837,7 @@ func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle }() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } i := _i diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index cefba05ba6..48f2832443 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -95,7 +95,7 @@ Test(coin_block, TestNewBlock) { cr_assert(result == SKY_OK, "SKY_cipher_SumSHA256 failed"); FeeCalculator zf = {zeroFeeCalculator, NULL}; result = SKY_coin_NewBlock(prevBlock, 133, &hash, 0, &zf, &newBlock); - cr_assert(result == SKY_ERROR, "SKY_coin_NewBlock has to fail with no transactions"); + cr_assert(result != SKY_OK, "SKY_coin_NewBlock has to fail with no transactions"); registerHandleClose( newBlock ); transactions = 0; diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go index 6e5e7f9969..473af09711 100644 --- a/lib/cgo/util.fee.fee.go +++ b/lib/cgo/util.fee.fee.go @@ -24,7 +24,7 @@ func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____er }() t, ok := lookupTransactionHandle(_t) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } ____return_err := fee.VerifyTransactionFee(t, _fee) @@ -80,7 +80,7 @@ func SKY_fee_TransactionFee(_tx C.Transaction__Handle, _headTime uint64, _inUxs }() tx, ok := lookupTransactionHandle(_tx) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } headTime := _headTime diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go index 6d6f160ab3..3936afe5b3 100644 --- a/lib/cgo/wallet.notes.go +++ b/lib/cgo/wallet.notes.go @@ -64,7 +64,7 @@ func SKY_wallet_ReadableNotes_Load(_rns C.WalletReadableNotes_Handle, _filename }() rns, ok := lookupWalletReadableNotesHandle(_rns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } filename := _filename @@ -83,7 +83,7 @@ func SKY_wallet_ReadableNotes_ToNotes(_rns C.WalletReadableNotes_Handle, _arg0 * }() rns, ok := lookupWalletReadableNotesHandle(_rns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0, ____return_err := rns.ToNotes() @@ -103,7 +103,7 @@ func SKY_wallet_ReadableNotes_Save(_rns C.WalletReadableNotes_Handle, _filename }() rns, ok := lookupWalletReadableNotesHandle(_rns) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } filename := _filename @@ -135,7 +135,7 @@ func SKY_wallet_NewReadableNotesFromNotes(_w C.WalletNotes_Handle, _arg1 *C.Wall }() w, ok := lookupWalletNotesHandle(_w) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg1 := wallet.NewReadableNotesFromNotes(*w) @@ -151,7 +151,7 @@ func SKY_wallet_Notes_Save(_notes C.WalletNotes_Handle, _dir string, _fileName s }() notes, ok := lookupWalletNotesHandle(_notes) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } dir := _dir @@ -171,7 +171,7 @@ func SKY_wallet_Notes_SaveNote(_notes C.WalletNotes_Handle, _dir string, _note * }() notes, ok := lookupWalletNotesHandle(_notes) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } dir := _dir @@ -191,7 +191,7 @@ func SKY_wallet_Notes_ToReadable(_notes C.WalletNotes_Handle, _arg0 *C.WalletRea }() notes, ok := lookupWalletNotesHandle(_notes) if !ok { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } __arg0 := notes.ToReadable() diff --git a/lib/cgo/wallet.readable.go b/lib/cgo/wallet.readable.go index 5105d8f993..2f6a07a4dc 100644 --- a/lib/cgo/wallet.readable.go +++ b/lib/cgo/wallet.readable.go @@ -62,7 +62,7 @@ func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string }() re, okre := lookupReadableEntryHandle(_re) if !okre { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } filename := _filename @@ -96,7 +96,7 @@ func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename stri }() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } filename := _filename @@ -115,7 +115,7 @@ func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename stri }() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } filename := _filename @@ -134,7 +134,7 @@ func SKY_wallet_ReadableWallet_Erase(_rw C.ReadableWallet__Handle) (____error_co }() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { - ____error_code = SKY_ERROR + ____error_code = SKY_BAD_HANDLE return } rw.Erase() From c9ed962436ebaf92cdc07a20b36c9597421d68b0 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 27 Jul 2018 22:44:10 +0000 Subject: [PATCH 188/399] [swig] refs #1568. Rename functions taking coin__UxArray parameters. --- lib/swig/skycoin.mem.i | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 150788198c..c74bc54f32 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -153,6 +153,61 @@ } } +%rename(SKY_coin_UxArray_HasDupes) wrap_SKY_coin_UxArray_HasDupes; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_HasDupes(coin_UxOutArray* __uxIn, GoUint8* p1){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_UxArray_HasDupes(&data, p1); + } +} + +%rename(SKY_coin_UxArray_Coins) wrap_SKY_coin_UxArray_Coins; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Coins(coin_UxOutArray* __uxIn, GoUint64* p1){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_UxArray_Coins(&data, p1); + } +} + +%rename(SKY_coin_UxArray_CoinHours) wrap_SKY_coin_UxArray_CoinHours; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_CoinHours(coin_UxOutArray* __uxIn, GoUint64 p1, GoUint64* p2){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_UxArray_CoinHours(&data, p1, p2); + } +} + +%rename(SKY_coin_UxArray_Less) wrap_SKY_coin_UxArray_Less; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Less(coin_UxOutArray* __uxIn, GoInt p1, GoInt p2, GoUint8* p3){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_UxArray_Less(&data, p1, p2, p3); + } +} + +%rename(SKY_coin_UxArray_Swap) wrap_SKY_coin_UxArray_Swap; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Swap(coin_UxOutArray* __uxIn, GoInt p1, GoInt p2){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_UxArray_Swap(&data, p1, p2); + } +} + /** * * typemaps for Handles From 5bd65ede167e8c52f4b6e44a81348aee4cbfd056 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 27 Jul 2018 23:46:15 +0000 Subject: [PATCH 189/399] [swig] refs #1568. Rename functions taking coin__UxArray parameters so these parameters can be typemapped as python lists. --- lib/swig/python_uxarray.i | 2 +- lib/swig/skycoin.mem.i | 102 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/lib/swig/python_uxarray.i b/lib/swig/python_uxarray.i index afc5add335..5d35da7bcd 100644 --- a/lib/swig/python_uxarray.i +++ b/lib/swig/python_uxarray.i @@ -25,7 +25,7 @@ if ($1->data) free($1->data); } -%apply (coin_UxOutArray* __uxIn) {(coin_UxOutArray* __uxOut)} +%apply (coin_UxOutArray* __uxIn) {(coin_UxOutArray* __uxOut), (coin_UxOutArray* __uxIn2)} /*coin_UxOutArray* parameter to return as a list */ %typemap(in, numinputs=0) (coin_UxOutArray* __return_Ux) (coin_UxOutArray temp) { diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index c74bc54f32..050d8943f9 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -208,6 +208,108 @@ } } +%rename(SKY_coin_UxArray_Sub) wrap_SKY_coin_UxArray_Sub; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Sub(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxIn2, coin_UxOutArray* __return_Ux){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + GoSlice_ data2; + data2.data = __uxIn2->data; + data2.len = __uxIn2->count; + data2.cap = __uxIn2->count; + GoSlice_ data3; + data3.data = NULL; + data3.len = 0; + data3.cap = 0; + GoUint32 result = SKY_coin_UxArray_Sub(&data, &data2, &data3); + if( result == 0){ + __return_Ux->data = data3.data; + __return_Ux->count = data3.len; + } + return result; + } +} + +%rename(SKY_coin_UxArray_Add) wrap_SKY_coin_UxArray_Add; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Add(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxIn2, coin_UxOutArray* __return_Ux){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + GoSlice_ data2; + data2.data = __uxIn2->data; + data2.len = __uxIn2->count; + data2.cap = __uxIn2->count; + GoSlice_ data3; + data3.data = NULL; + data3.len = 0; + data3.cap = 0; + GoUint32 result = SKY_coin_UxArray_Add(&data, &data2, &data3); + if( result == 0){ + __return_Ux->data = data3.data; + __return_Ux->count = data3.len; + } + return result; + } +} + +%rename(SKY_coin_NewAddressUxOuts) wrap_SKY_coin_NewAddressUxOuts; +%inline{ + GoUint32 wrap_SKY_coin_NewAddressUxOuts(coin_UxOutArray* __uxIn, AddressUxOuts_Handle* p1){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_NewAddressUxOuts(&data, p1); + } +} + +%rename(SKY_coin_AddressUxOuts_Flatten) wrap_SKY_coin_AddressUxOuts_Flatten; +%inline{ + GoUint32 wrap_SKY_coin_AddressUxOuts_Flatten(AddressUxOuts_Handle p0, coin_UxOutArray* __return_Ux){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_coin_AddressUxOuts_Flatten(p0, &data); + if( result != 0 ){ + __return_Ux->data = data.data; + __return_Ux->count = data.len; + } + return result; + } +} + +%rename(SKY_coin_AddressUxOuts_Get) wrap_SKY_coin_AddressUxOuts_Get; +%inline{ + GoUint32 wrap_SKY_coin_AddressUxOuts_Get(AddressUxOuts_Handle p0, cipher__Address* p1, coin_UxOutArray* __return_Ux){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_coin_AddressUxOuts_Get(p0, p1, &data); + if( result != 0 ){ + __return_Ux->data = data.data; + __return_Ux->count = data.len; + } + return result; + } +} + +%rename(SKY_coin_AddressUxOuts_Set) wrap_SKY_coin_AddressUxOuts_Set; +%inline{ + GoUint32 wrap_SKY_coin_AddressUxOuts_Set(AddressUxOuts_Handle p0, cipher__Address* p1, coin_UxOutArray* __uxIn){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + return SKY_coin_AddressUxOuts_Set(p0, p1, &data); + } +} + /** * * typemaps for Handles From 79bb85b9fd68d94545c8bc8737dfa2af1edecb46 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 28 Jul 2018 00:15:28 +0000 Subject: [PATCH 190/399] [swig] #1568. Added typemap for slices of cipher__SHA256. --- include/swig.h | 5 +++ lib/swig/python_seckeys.i | 2 +- lib/swig/python_sha256s.i | 53 +++++++++++++++++++++++++ lib/swig/python_skycoin.cipher.crypto.i | 31 +++++++++++++++ lib/swig/skycoin.cipher.crypto.i | 32 +++++++++++++++ lib/swig/skycoin.mem.i | 16 ++++++++ 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 lib/swig/python_sha256s.i diff --git a/include/swig.h b/include/swig.h index 5f730e471d..5ab19910d9 100644 --- a/include/swig.h +++ b/include/swig.h @@ -33,6 +33,11 @@ typedef struct{ int count; } cipher_PubKeys; +typedef struct{ + cipher_SHA256* data; + int count; +} cipher_SHA256s; + typedef struct{ coin__UxOut* data; int count; diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index ef860b2c8b..bc186a946d 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -6,7 +6,7 @@ $1 = PyList_Check($input) ? 1 : 0; } -/*cipher_PubKeys* input parameter */ +/*cipher_SecKeys* input parameter */ %typemap(in) (cipher_SecKeys* __in_secKeys) (cipher_SecKeys temp) { int i; $1 = &temp; diff --git a/lib/swig/python_sha256s.i b/lib/swig/python_sha256s.i new file mode 100644 index 0000000000..88a53efe03 --- /dev/null +++ b/lib/swig/python_sha256s.i @@ -0,0 +1,53 @@ +%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_SHA256s* { + $1 = PyList_Check($input) ? 1 : 0; +} + +/*cipher_SHA256s* input parameter */ +%typemap(in) (cipher_SHA256s* __in_hashes) (cipher_SHA256s temp) { + int i; + $1 = &temp; + $1->count = PyList_Size($input); + $1->data = malloc(sizeof(cipher_SHA256) * $1->count); + cipher_SHA256* pdata = $1->data; + for(i = 0; i < $1->count; i++){ + PyObject *o = PyList_GetItem($input, i); + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type cipher_SHA256"); + cipher_SHA256* p = (cipher_SHA256*)argp; + memcpy(pdata, p, sizeof(cipher_SHA256)); + pdata++; + } +} + +%typemap(freearg) (cipher_SHA256s* __in_hashes) { + if ($1->data) free($1->data); +} + +/*cipher_SHA256s* parameter to return as a list */ +%typemap(in, numinputs=0) (cipher_SHA256s* __out_hashes) (cipher_SHA256s temp) { + temp.data = NULL; + temp.count = 0; + $1 = &temp; +} + +/*cipher_SHA256s* as function return typemap*/ +%typemap(argout) (cipher_SHA256s* __out_hashes) { + int i; + PyObject *list = PyList_New(0); + for (i = 0; i < $1->count; i++) { + cipher_SHA256* key = &($1->data[i]); + cipher_SHA256* newKey = malloc(sizeof(cipher_SHA256)); + memcpy(newKey, key, sizeof(cipher_SHA256)); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher_SHA256, SWIG_POINTER_OWN ); + PyList_Append(list, o); + Py_DECREF(o); + } + if( $1->data != NULL) + free( (void*)$1->data ); + %append_output( list ); +} + + + diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 4058e720a7..359744d07c 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -213,6 +213,37 @@ } } +%extend cipher_SHA256s { + cipher_SHA256* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, cipher_SHA256* hash){ + if( i < $self->count){ + memcpy(&self->data[i], hash, sizeof(*hash)); + return i; + } else { + return -1; + } + } + + int __eq__(cipher_SHA256s* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SHA256) * $self->count) == 0; + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + if($self->data != NULL) free($self->data); + } +} %inline{ void destroy_cipher_PubKeys(cipher_PubKeys* p){ diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index e04859459f..910b327321 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -112,6 +112,38 @@ } } +%extend cipher_SHA256s { + cipher_SHA256* getAt(int i){ + if( i < $self->count ){ + return &$self->data[i]; + } + else + return NULL; + } + + int setAt(int i, cipher_SHA256* hash){ + if( i < $self->count){ + memcpy(&self->data[i], hash, sizeof(*hash)); + return i; + } else { + return -1; + } + } + + int isEqual(cipher_SHA256s* a){ + return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SHA256) * $self->count) == 0; + } + + void allocate(int n){ + $self->data = malloc(n * sizeof(*($self->data))); + $self->count = n; + } + + void release(){ + if($self->data != NULL) free($self->data); + } +} + %inline{ void destroy_cipher_SecKeys(cipher_SecKeys* p){ if( p != NULL ){ diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 050d8943f9..4db8152842 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -310,6 +310,22 @@ } } +%rename(SKY_coin_AddressUxOuts_Keys) wrap_SKY_coin_AddressUxOuts_Keys; +%inline{ + GoUint32 wrap_SKY_coin_AddressUxOuts_Keys(AddressUxOuts_Handle p0, cipher_SHA256s* __out_hashes){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_coin_AddressUxOuts_Keys(p0, &data); + if( result != 0){ + __out_hashes->data = data.data; + __out_hashes->count = data.len; + } + return result; + } +} + /** * * typemaps for Handles From f0876af077c0146d1218ecda9ac84fdc91c42807 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 30 Jul 2018 19:42:35 +0000 Subject: [PATCH 191/399] [swig] refs #1568 - Rename function SKY_coin_Transactions_Hashes --- lib/swig/skycoin.mem.i | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 4db8152842..61073c2d34 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -326,6 +326,22 @@ } } +%rename(SKY_coin_Transactions_Hashes) wrap_SKY_coin_Transactions_Hashes; +%inline{ + GoUint32 wrap_SKY_coin_Transactions_Hashes(Transactions__Handle p0, cipher_SHA256s* __out_hashes){ + GoSlice_ data; + data.data = NULL; + data.len = 0; + data.cap = 0; + GoUint32 result = SKY_coin_Transactions_Hashes(p0, &data); + if( result != 0){ + __out_hashes->data = data.data; + __out_hashes->count = data.len; + } + return result; + } +} + /** * * typemaps for Handles From 8a00ac96ffee27232570de024daf67fb5e0b0702 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 31 Jul 2018 10:53:46 +0000 Subject: [PATCH 192/399] [swig] refs #1568 - Add typecheck for Transactions_Handle. Organize handles typemaps. --- lib/swig/python_seckeys.i | 7 ---- lib/swig/skycoin.mem.i | 81 ++++++++++++++++++++------------------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i index bc186a946d..3808de7716 100644 --- a/lib/swig/python_seckeys.i +++ b/lib/swig/python_seckeys.i @@ -1,7 +1,3 @@ -%typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { - $1 = PyInt_Check($input) ? 1 : 0; -} - %typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_SecKeys* { $1 = PyList_Check($input) ? 1 : 0; } @@ -52,6 +48,3 @@ free( (void*)$1->data ); %append_output( list ); } - - - diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 61073c2d34..704167d4c4 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -1,8 +1,49 @@ +/** +* +* typemaps for Handles +* +**/ + +/* Handle reference typemap. */ +%typemap(in, numinputs=0) Handle* (Handle temp) { + $1 = &temp; +} + +/* Handle out typemap. */ +%typemap(argout) Handle* { + %append_output( SWIG_From_long(*$1) ); +} + /* Handle not as pointer is input. */ -%typemap(in) Transaction__Handle { +%typemap(in) Handle { SWIG_AsVal_long($input, (long*)&$1); } + +%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, + WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, + GoStringMap, PasswordReader__Handle_, + Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, + CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, + Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle + } + +%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, + WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, + App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, + Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, + CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle* + } + +%typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { + $1 = PyInt_Check($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_INTEGER) Transactions__Handle { + $1 = PyInt_Check($input) ? 1 : 0; +} + #if defined(SWIGPYTHON) %include "python_seckeys.i" %include "python_pubkeys.i" @@ -342,41 +383,3 @@ } } -/** -* -* typemaps for Handles -* -**/ - - -/* Handle reference typemap. */ -%typemap(in, numinputs=0) Handle* (Handle temp) { - $1 = &temp; -} - -/* Handle out typemap. */ -%typemap(argout) Handle* { - %append_output( SWIG_From_long(*$1) ); -} - -/* Handle not as pointer is input. */ -%typemap(in) Handle { - SWIG_AsVal_long($input, (long*)&$1); -} - - -%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, - WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, - GoStringMap, PasswordReader__Handle_, - Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, - CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle - } - -%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, - WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, - App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, - Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, - CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle* - } From 2e193533cfc90a6826cb84eb60e169b0bad08d67 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Tue, 31 Jul 2018 12:05:12 +0000 Subject: [PATCH 193/399] [swig] refs #1568 - Bug fixes --- lib/swig/skycoin.i | 21 +++++++++++---------- lib/swig/skycoin.mem.i | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i index e6d5a68d65..511341b16e 100755 --- a/lib/swig/skycoin.i +++ b/lib/swig/skycoin.i @@ -6,20 +6,12 @@ #include "swig.h" %} - -//Apply typemaps for Python for now -//It can be applied to other languages that fit in -//Not languages can't return multiple values -#if defined(SWIGPYTHON) -%include "golang.cgo.i" -%include "skycoin.mem.i" -%include "structs_typemaps.i" -#endif - //Apply strictly to python //Not for other languages #if defined(SWIGPYTHON) %include "python_skycoin.cipher.crypto.i" +%include "python_uxarray.i" +%include "python_sha256s.i" %include "python_skycoin.coin.i" %include "python_skycoin.callback.i" #else @@ -27,6 +19,15 @@ %include "skycoin.coin.i" #endif +//Apply typemaps for Python for now +//It can be applied to other languages that fit in +//Not languages can't return multiple values +#if defined(SWIGPYTHON) +%include "golang.cgo.i" +%include "structs_typemaps.i" +%include "skycoin.mem.i" +#endif + %include "swig.h" /* Find the modified copy of libskycoin */ %include "libskycoin.h" diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 704167d4c4..18dec14a55 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -316,7 +316,7 @@ data.len = 0; data.cap = 0; GoUint32 result = SKY_coin_AddressUxOuts_Flatten(p0, &data); - if( result != 0 ){ + if( result == 0 ){ __return_Ux->data = data.data; __return_Ux->count = data.len; } @@ -332,7 +332,7 @@ data.len = 0; data.cap = 0; GoUint32 result = SKY_coin_AddressUxOuts_Get(p0, p1, &data); - if( result != 0 ){ + if( result == 0 ){ __return_Ux->data = data.data; __return_Ux->count = data.len; } @@ -359,7 +359,7 @@ data.len = 0; data.cap = 0; GoUint32 result = SKY_coin_AddressUxOuts_Keys(p0, &data); - if( result != 0){ + if( result == 0){ __out_hashes->data = data.data; __out_hashes->count = data.len; } @@ -375,7 +375,7 @@ data.len = 0; data.cap = 0; GoUint32 result = SKY_coin_Transactions_Hashes(p0, &data); - if( result != 0){ + if( result == 0){ __out_hashes->data = data.data; __out_hashes->count = data.len; } From 8a2a7cd57c5aec9d0ef91bfb36c8d9e4d95daa1e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 1 Aug 2018 11:38:14 +0000 Subject: [PATCH 194/399] [libc] refs #1191 - Rename of some exported functions to keep the same pattern of the generated wrapper functions. [====] Synthesis: Tested: 143 | Passing: 143 | Failing: 0 | Crashing: 0 --- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 8 ++-- lib/cgo/coin.transactions.go | 48 +++++++++---------- lib/cgo/libsky_map.go | 12 ++--- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 18 +++---- lib/cgo/tests/check_coin.block.c | 2 +- lib/cgo/tests/check_coin.transactions.c | 12 ++--- lib/cgo/tests/testutils/transutils.c | 12 ++--- 7 files changed, 56 insertions(+), 56 deletions(-) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go index 298730ac4c..c6e96f08f7 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -27,8 +27,8 @@ func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_cod return } -//export SKY_secp256k1go_Signature_Get_R -func SKY_secp256k1go_Signature_Get_R(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { +//export SKY_secp256k1go_Signature_GetR +func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -42,8 +42,8 @@ func SKY_secp256k1go_Signature_Get_R(handle C.Signature_Handle, r *C.Number_Hand return } -//export SKY_secp256k1go_Signature_Get_S -func SKY_secp256k1go_Signature_Get_S(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { +//export SKY_secp256k1go_Signature_GetS +func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index a1ddf06bb4..8399520857 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -55,8 +55,8 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact return } -//export SKY_coin_Get_Transaction_Object -func SKY_coin_Get_Transaction_Object(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { +//export SKY_coin_GetTransactionObject +func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -85,8 +85,8 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( return } -//export SKY_coin_Transaction_Get_Inputs_Count -func SKY_coin_Transaction_Get_Inputs_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { +//export SKY_coin_Transaction_GetInputsCount +func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -100,8 +100,8 @@ func SKY_coin_Transaction_Get_Inputs_Count(handle C.Transaction__Handle, length return } -//export SKY_coin_Transaction_Get_Input_At -func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { +//export SKY_coin_Transaction_GetInputAt +func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -119,8 +119,8 @@ func SKY_coin_Transaction_Get_Input_At(handle C.Transaction__Handle, i int, inpu return } -//export SKY_coin_Transaction_Set_Input_At -func SKY_coin_Transaction_Set_Input_At(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { +//export SKY_coin_Transaction_SetInputAt +func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -138,8 +138,8 @@ func SKY_coin_Transaction_Set_Input_At(handle C.Transaction__Handle, i int, inpu return } -//export SKY_coin_Transaction_Get_Outputs_Count -func SKY_coin_Transaction_Get_Outputs_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { +//export SKY_coin_Transaction_GetOutputsCount +func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -153,8 +153,8 @@ func SKY_coin_Transaction_Get_Outputs_Count(handle C.Transaction__Handle, length return } -//export SKY_coin_Transaction_Get_Output_At -func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { +//export SKY_coin_Transaction_GetOutputAt +func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -172,8 +172,8 @@ func SKY_coin_Transaction_Get_Output_At(handle C.Transaction__Handle, i int, out return } -//export SKY_coin_Transaction_Set_Output_At -func SKY_coin_Transaction_Set_Output_At(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { +//export SKY_coin_Transaction_SetOutputAt +func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -191,8 +191,8 @@ func SKY_coin_Transaction_Set_Output_At(handle C.Transaction__Handle, i int, out return } -//export SKY_coin_Transaction_Get_Signatures_Count -func SKY_coin_Transaction_Get_Signatures_Count(handle C.Transaction__Handle, length *int) (____error_code uint32) { +//export SKY_coin_Transaction_GetSignaturesCount +func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -206,8 +206,8 @@ func SKY_coin_Transaction_Get_Signatures_Count(handle C.Transaction__Handle, len return } -//export SKY_coin_Transaction_Get_Signature_At -func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { +//export SKY_coin_Transaction_GetSignatureAt +func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -225,8 +225,8 @@ func SKY_coin_Transaction_Get_Signature_At(handle C.Transaction__Handle, i int, return } -//export SKY_coin_Transaction_Set_Signature_At -func SKY_coin_Transaction_Set_Signature_At(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { +//export SKY_coin_Transaction_SetSignatureAt +func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -244,8 +244,8 @@ func SKY_coin_Transaction_Set_Signature_At(handle C.Transaction__Handle, i int, return } -//export SKY_coin_Transaction_Push_Signature -func SKY_coin_Transaction_Push_Signature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { +//export SKY_coin_Transaction_PushSignature +func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -572,8 +572,8 @@ func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_cod return SKY_OK } -//export SKY_coin_Get_Transactions_Object -func SKY_coin_Get_Transactions_Object(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { +//export SKY_coin_GetTransactionsObject +func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) diff --git a/lib/cgo/libsky_map.go b/lib/cgo/libsky_map.go index 03addb621e..77bf5436d9 100644 --- a/lib/cgo/libsky_map.go +++ b/lib/cgo/libsky_map.go @@ -9,8 +9,8 @@ package main */ import "C" -//export SKY_map_get -func SKY_map_get(gomap *C.GoStringMap_, key string, value *C.GoString_) (____error_code uint32) { +//export SKY_map_Get +func SKY_map_Get(gomap *C.GoStringMap_, key string, value *C.GoString_) (____error_code uint32) { obj, ok := lookupHandle(C.Handle(*gomap)) ____error_code = SKY_ERROR if ok { @@ -25,8 +25,8 @@ func SKY_map_get(gomap *C.GoStringMap_, key string, value *C.GoString_) (____err return } -//export SKY_map_has_key -func SKY_map_has_key(gomap *C.GoStringMap_, key string) (found bool) { +//export SKY_map_HasKey +func SKY_map_HasKey(gomap *C.GoStringMap_, key string) (found bool) { obj, ok := lookupHandle(C.Handle(*gomap)) found = false if ok { @@ -37,8 +37,8 @@ func SKY_map_has_key(gomap *C.GoStringMap_, key string) (found bool) { return } -//export SKY_map_close -func SKY_map_close(gomap *C.GoStringMap_) (____error_code uint32) { +//export SKY_map_Close +func SKY_map_Close(gomap *C.GoStringMap_) (____error_code uint32) { obj, ok := lookupHandle(C.Handle(*gomap)) ____error_code = SKY_ERROR if ok { diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index ab63d2c7cb..2ab3287d41 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -53,10 +53,10 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); registerHandleClose(sig); Number_Handle r; - error_code = SKY_secp256k1go_Signature_Get_R(sig, &r); + error_code = SKY_secp256k1go_Signature_GetR(sig, &r); registerHandleClose(r); Number_Handle s; - error_code = SKY_secp256k1go_Signature_Get_S(sig, &s); + error_code = SKY_secp256k1go_Signature_GetS(sig, &s); registerHandleClose(s); error_code = SKY_secp256k1go_Number_Create(&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); @@ -129,10 +129,10 @@ Test(cipher_secp256k1_sig, TestSigVerify) { cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); registerHandleClose(sig); Number_Handle r; - result = SKY_secp256k1go_Signature_Get_R(sig, &r); + result = SKY_secp256k1go_Signature_GetR(sig, &r); registerHandleClose(r); Number_Handle s; - result = SKY_secp256k1go_Signature_Get_S(sig, &s); + result = SKY_secp256k1go_Signature_GetS(sig, &s); registerHandleClose(s); result = SKY_secp256k1go_Number_Create(&msg); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); @@ -252,8 +252,8 @@ Test(cipher_secp256k1_sig, TestSigSign) { cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); Number_Handle r; - result = SKY_secp256k1go_Signature_Get_R(sig, &r); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_R failed"); + result = SKY_secp256k1go_Signature_GetR(sig, &r); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetR failed"); registerHandleClose(r); equal = 0; @@ -273,12 +273,12 @@ Test(cipher_secp256k1_sig, TestSigSign) { cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); } Number_Handle s; - result = SKY_secp256k1go_Signature_Get_S(sig, &s); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_S failed"); + result = SKY_secp256k1go_Signature_GetS(sig, &s); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); registerHandleClose(s); equal = 0; result = SKY_secp256k1go_Number_IsEqual(s, non, &equal); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Get_S failed"); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); cr_assert(equal != 0); } diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 48f2832443..726bcb4621 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -118,7 +118,7 @@ Test(coin_block, TestNewBlock) { result = SKY_coin_GetBlockObject(newBlock, &pNewBlock); cr_assert(result == SKY_OK, "SKY_coin_GetBlockObject failed"); coin__Transactions* pTransactions = NULL; - SKY_coin_Get_Transactions_Object(transactions, &pTransactions); + SKY_coin_GetTransactionsObject(transactions, &pTransactions); cr_assert( eq( type(coin__Transactions), pNewBlock->Body.Transactions, *pTransactions ) ); cr_assert( eq(pNewBlock->Head.Fee, fee * (GoUint64)( pTransactions->len ))); cr_assert( eq(pNewBlock->Head.Time, currentTime)); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index c630932a82..d54f651b29 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -567,7 +567,7 @@ Test(coin_transactions, TestTransactionSerialization) { GoSlice d = {data.data, data.len, data.cap}; result = SKY_coin_TransactionDeserialize(d, &handle2); cr_assert(result == SKY_OK); - result = SKY_coin_Get_Transaction_Object(handle2, &ptx2); + result = SKY_coin_GetTransactionObject(handle2, &ptx2); cr_assert(result == SKY_OK); cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); } @@ -886,7 +886,7 @@ Test(coin_transactions, TestTransactionsFees) { GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee, void* context){ coin__Transaction* pTx; - int result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + int result = SKY_coin_GetTransactionObject( handle, &pTx ); if(result == SKY_OK){ coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; @@ -904,9 +904,9 @@ void assertTransactionsHandleEqual(Transaction__Handle h1, Transaction__Handle h coin__Transaction *pTx1; coin__Transaction *pTx2; int result; - result = SKY_coin_Get_Transaction_Object( h1, &pTx1 ); + result = SKY_coin_GetTransactionObject( h1, &pTx1 ); cr_assert(result == SKY_OK); - result = SKY_coin_Get_Transaction_Object( h2, &pTx2 ); + result = SKY_coin_GetTransactionObject( h2, &pTx2 ); cr_assert(result == SKY_OK); cr_assert(eq(type(coin__Transaction), *pTx1, *pTx2), "Failed SortTransactions test \"%s\"", testName); } @@ -991,7 +991,7 @@ Test(coin_transactions, TestSortTransactions) { *pFee = MaxUint64 / 2; } else { coin__Transaction* pTx; - result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + result = SKY_coin_GetTransactionObject( handle, &pTx ); if(result == SKY_OK){ coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; @@ -1012,7 +1012,7 @@ Test(coin_transactions, TestSortTransactions) { result = SKY_ERROR; } else { coin__Transaction* pTx; - result = SKY_coin_Get_Transaction_Object( handle, &pTx ); + result = SKY_coin_GetTransactionObject( handle, &pTx ); if(result == SKY_OK){ coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 827be26de2..67c75b4225 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -91,8 +91,8 @@ coin__Transaction* makeTransactionFromUxOut(coin__UxOut* puxOut, cipher__SecKey* result = SKY_coin_Create_Transaction(handle); cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); registerHandleClose(*handle); - result = SKY_coin_Get_Transaction_Object( *handle, &ptransaction ); - cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); + result = SKY_coin_GetTransactionObject( *handle, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_GetTransactionObject failed"); cipher__SHA256 sha256; result = SKY_coin_UxOut_Hash(puxOut, &sha256); cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); @@ -139,8 +139,8 @@ coin__Transaction* makeEmptyTransaction(Transaction__Handle* handle){ result = SKY_coin_Create_Transaction(handle); cr_assert(result == SKY_OK, "SKY_coin_Create_Transaction failed"); registerHandleClose(*handle); - result = SKY_coin_Get_Transaction_Object( *handle, &ptransaction ); - cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); + result = SKY_coin_GetTransactionObject( *handle, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_GetTransactionObject failed"); return ptransaction; } @@ -213,8 +213,8 @@ coin__Transaction* copyTransaction(Transaction__Handle handle, Transaction__Hand result = SKY_coin_Transaction_Copy(handle, handle2); cr_assert(result == SKY_OK); registerHandleClose(*handle2); - result = SKY_coin_Get_Transaction_Object( *handle2, &ptransaction ); - cr_assert(result == SKY_OK, "SKY_coin_Get_Transaction_Object failed"); + result = SKY_coin_GetTransactionObject( *handle2, &ptransaction ); + cr_assert(result == SKY_OK, "SKY_coin_GetTransactionObject failed"); return ptransaction; } From 69a1368358203476488984641f48cf6e9f2f8218 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 1 Aug 2018 13:20:47 +0000 Subject: [PATCH 195/399] [libc] refs #1191 - Added function SKY_handle_copy to copy a handle --- lib/cgo/libsky_handle.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 179bf2ec41..ad84ecbbf6 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -550,3 +550,14 @@ func closeHandle(handle Handle) { func SKY_handle_close(handle C.Handle) { closeHandle(Handle(handle)) } + +//export SKY_handle_copy +func SKY_handle_copy(handle C.Handle, copy *C.Handle) uint32 { + obj, ok := lookupHandle(handle) + if ok { + *copy = registerHandle(obj) + return 0 + } else { + return SKY_BAD_HANDLE + } +} From 2d64a2dd1355529e93500be70888e63d860646d4 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Wed, 1 Aug 2018 13:48:32 +0000 Subject: [PATCH 196/399] [libc] refs #1191 - Fix lint issues --- lib/cgo/libsky_handle.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index ad84ecbbf6..aee0f024dd 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -553,11 +553,11 @@ func SKY_handle_close(handle C.Handle) { //export SKY_handle_copy func SKY_handle_copy(handle C.Handle, copy *C.Handle) uint32 { - obj, ok := lookupHandle(handle) - if ok { - *copy = registerHandle(obj) - return 0 - } else { - return SKY_BAD_HANDLE - } + obj, ok := lookupHandle(handle) + if ok { + *copy = registerHandle(obj) + return 0 + } else { + return SKY_BAD_HANDLE + } } From d1e65320f8d284a144c624a74374ddad338cb2e8 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Fri, 3 Aug 2018 17:50:26 +0000 Subject: [PATCH 197/399] [libc] refs #1191 - Add rename for function SKY_coin_UxArray_Hashes --- lib/swig/skycoin.mem.i | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 18dec14a55..288fe3eae3 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -308,6 +308,26 @@ } } +%rename(SKY_coin_UxArray_Hashes) wrap_SKY_coin_UxArray_Hashes; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Hashes(coin_UxOutArray* __uxIn, cipher_SHA256s* __out_hashes){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + GoSlice_ dataOut; + dataOut.data = NULL; + dataOut.len = 0; + dataOut.cap = 0; + GoUint32 result = SKY_coin_UxArray_Hashes(&data, &dataOut); + if(result == 0){ + __out_hashes->data = dataOut.data; + __out_hashes->count = dataOut.len; + } + return result; + } +} + %rename(SKY_coin_AddressUxOuts_Flatten) wrap_SKY_coin_AddressUxOuts_Flatten; %inline{ GoUint32 wrap_SKY_coin_AddressUxOuts_Flatten(AddressUxOuts_Handle p0, coin_UxOutArray* __return_Ux){ From ff7775bdf39d4e7845ac8bc7b0187870b28f1906 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sat, 4 Aug 2018 18:41:55 +0000 Subject: [PATCH 198/399] [libc] refs #1191 - Fixed sintax error in swig files --- lib/swig/skycoin.cipher.crypto.i | 2 +- lib/swig/skycoin.coin.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i index 910b327321..06ac4dcf27 100644 --- a/lib/swig/skycoin.cipher.crypto.i +++ b/lib/swig/skycoin.cipher.crypto.i @@ -182,7 +182,7 @@ } void release(){ - if($self-data != NULL) + if($self->data != NULL) free($self->data); } } diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i index d22625c62b..e66c63845a 100644 --- a/lib/swig/skycoin.coin.i +++ b/lib/swig/skycoin.coin.i @@ -52,7 +52,7 @@ } void release(){ - if($self-data != NULL) + if($self->data != NULL) free($self->data); } } From 267834320babb26fa106a8ae0a1ed2ef80f4007e Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Sun, 5 Aug 2018 15:33:01 +0000 Subject: [PATCH 199/399] [swig] refs #1568 - Fix in equal operator for coin_UxOut --- lib/swig/python_skycoin.coin.i | 14 +++++++++++++- lib/swig/skycoin.coin.i | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i index 705d07f047..40068a285f 100644 --- a/lib/swig/python_skycoin.coin.i +++ b/lib/swig/python_skycoin.coin.i @@ -20,7 +20,19 @@ %extend coin__UxOut { int __eq__(coin__UxOut* u){ - return memcmp(&$self, u, sizeof(coin__UxOut)) == 0; + if($self->Head.Time != u->Head.Time) + return 0; + if($self->Head.BkSeq != u->Head.BkSeq) + return 0; + if($self->Body.Coins != u->Body.Coins) + return 0; + if($self->Body.Hours != u->Body.Hours) + return 0; + if(memcmp(&$self->Body.Address, &u->Body.Address, sizeof(cipher__Address)) != 0) + return 0; + if(memcmp(&$self->Body.SrcTransaction, &u->Body.SrcTransaction, sizeof(cipher__SHA256)) != 0) + return 0; + return 1; } } diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i index d22625c62b..938aec9536 100644 --- a/lib/swig/skycoin.coin.i +++ b/lib/swig/skycoin.coin.i @@ -20,7 +20,19 @@ %extend coin__UxOut { int isEqual(coin__UxOut* u){ - return memcmp(&$self, u, sizeof(coin__UxOut)) == 0; + if($self->Head.Time != u->Head.Time) + return 0; + if($self->Head.BkSeq != u->Head.BkSeq) + return 0; + if($self->Body.Coins != u->Body.Coins) + return 0; + if($self->Body.Hours != u->Body.Hours) + return 0; + if(memcmp(&$self->Body.Address, &u->Body.Address, sizeof(cipher__Address)) != 0) + return 0; + if(memcmp(&$self->Body.SrcTransaction, &u->Body.SrcTransaction, sizeof(cipher__SHA256)) != 0) + return 0; + return 1; } } From 5f1f831c67293777b80454dd2c67a53455315851 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 6 Aug 2018 18:41:14 +0000 Subject: [PATCH 200/399] [swig] refs #1568 - Apply Handle typemap AddressUxOuts_Handle. Added rename of function SKY_coin_UxArray_Sort. --- lib/swig/python_skycoin.cipher.crypto.i | 3 +++ lib/swig/skycoin.mem.i | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 359744d07c..5d0b843983 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -115,6 +115,9 @@ void assignTo(void* data){ memcpy(data, &$self->data, sizeof($self->data)); } + void corrupt(){ + $self->data[31] += 1; + } } %extend cipher_Checksum { diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 288fe3eae3..7371089184 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -25,7 +25,7 @@ GoStringMap, PasswordReader__Handle_, Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle + Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle, AddressUxOuts_Handle } %apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, @@ -33,7 +33,7 @@ App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle* + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*, AddressUxOuts_Handle* } %typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { @@ -80,6 +80,7 @@ } } +%rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; %inline { GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ __out_secKeys->data = NULL; @@ -403,3 +404,20 @@ } } +%rename(SKY_coin_UxArray_Sort) wrap_SKY_coin_UxArray_Sort; +%inline{ + GoUint32 wrap_SKY_coin_UxArray_Sort(coin_UxOutArray* __uxIn, coin_UxOutArray* __return_Ux){ + GoSlice_ data; + data.data = __uxIn->data; + data.len = __uxIn->count; + data.cap = __uxIn->count; + GoUint32 result = SKY_coin_UxArray_Sort(&data); + if( result == 0){ + __return_Ux->data = malloc(data.len * sizeof(coin__UxOut)); + __return_Ux->count = data.len; + memcpy(__return_Ux->data, data.data, data.len * sizeof(coin__UxOut)); + } + return result; + } +} + From 9c3678d1aca32dc1222d53bb2aba2065564601a7 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 6 Aug 2018 20:04:06 +0000 Subject: [PATCH 201/399] [swig] refs #1568 - Added type cipher_Addresses. Used for function SKY_coin_AddressUxOuts_Keys --- include/swig.h | 5 ++++ lib/swig/python_addresses.i | 53 +++++++++++++++++++++++++++++++++++++ lib/swig/skycoin.mem.i | 20 +++++++++----- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 lib/swig/python_addresses.i diff --git a/include/swig.h b/include/swig.h index 5ab19910d9..add18857d6 100644 --- a/include/swig.h +++ b/include/swig.h @@ -43,3 +43,8 @@ typedef struct{ int count; } coin_UxOutArray; +typedef struct{ + cipher__Address* data; + int count; +} cipher_Addresses; + diff --git a/lib/swig/python_addresses.i b/lib/swig/python_addresses.i new file mode 100644 index 0000000000..2383ca2414 --- /dev/null +++ b/lib/swig/python_addresses.i @@ -0,0 +1,53 @@ +%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_Addresses* { + $1 = PyList_Check($input) ? 1 : 0; +} + +/*cipher_Addresses* input parameter */ +%typemap(in) (cipher_Addresses* __in_addresses) (cipher_Addresses temp) { + int i; + $1 = &temp; + $1->count = PyList_Size($input); + $1->data = malloc(sizeof(cipher__Address) * $1->count); + cipher__Address* pdata = $1->data; + for(i = 0; i < $1->count; i++){ + PyObject *o = PyList_GetItem($input, i); + void *argp = 0; + int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher__Address, 0 | 0); + if (!SWIG_IsOK(res)) + SWIG_exception_fail(SWIG_TypeError, "expecting type cipher__Address"); + cipher__Address* p = (cipher__Address*)argp; + memcpy(pdata, p, sizeof(cipher__Address)); + pdata++; + } +} + +%typemap(freearg) (cipher_Addresses* __in_addresses) { + if ($1->data) free($1->data); +} + +/*cipher_Addresses* parameter to return as a list */ +%typemap(in, numinputs=0) (cipher_Addresses* __out_addresses) (cipher_Addresses temp) { + temp.data = NULL; + temp.count = 0; + $1 = &temp; +} + +/*cipher_Addresses* as function return typemap*/ +%typemap(argout) (cipher_Addresses* __out_addresses) { + int i; + PyObject *list = PyList_New(0); + for (i = 0; i < $1->count; i++) { + cipher__Address* key = &($1->data[i]); + cipher__Address* newKey = malloc(sizeof(cipher__Address)); + memcpy(newKey, key, sizeof(cipher__Address)); + PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher__Address, SWIG_POINTER_OWN ); + PyList_Append(list, o); + Py_DECREF(o); + } + if( $1->data != NULL) + free( (void*)$1->data ); + %append_output( list ); +} + + + diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 7371089184..0b1b283ca9 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -36,6 +36,8 @@ Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*, AddressUxOuts_Handle* } +#if defined(SWIGPYTHON) + %typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { $1 = PyInt_Check($input) ? 1 : 0; } @@ -44,10 +46,14 @@ $1 = PyInt_Check($input) ? 1 : 0; } -#if defined(SWIGPYTHON) - %include "python_seckeys.i" - %include "python_pubkeys.i" - %include "python_uxarray.i" +%typecheck(SWIG_TYPECHECK_INTEGER) AddressUxOuts_Handle { + $1 = PyInt_Check($input) ? 1 : 0; +} + +%include "python_seckeys.i" +%include "python_pubkeys.i" +%include "python_uxarray.i" +%include "python_addresses.i" #endif %rename(SKY_coin_Transaction_SignInputs) wrap_SKY_coin_Transaction_SignInputs; @@ -374,15 +380,15 @@ %rename(SKY_coin_AddressUxOuts_Keys) wrap_SKY_coin_AddressUxOuts_Keys; %inline{ - GoUint32 wrap_SKY_coin_AddressUxOuts_Keys(AddressUxOuts_Handle p0, cipher_SHA256s* __out_hashes){ + GoUint32 wrap_SKY_coin_AddressUxOuts_Keys(AddressUxOuts_Handle p0, cipher_Addresses* __out_addresses){ GoSlice_ data; data.data = NULL; data.len = 0; data.cap = 0; GoUint32 result = SKY_coin_AddressUxOuts_Keys(p0, &data); if( result == 0){ - __out_hashes->data = data.data; - __out_hashes->count = data.len; + __out_addresses->data = data.data; + __out_addresses->count = data.len; } return result; } From c3283d8dc45e6614b9c1a34b1015699e3b66266d Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 6 Aug 2018 20:15:55 +0000 Subject: [PATCH 202/399] [swig] refs #1568 - Removed function added just for debugging --- lib/swig/python_skycoin.cipher.crypto.i | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i index 5d0b843983..359744d07c 100644 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ b/lib/swig/python_skycoin.cipher.crypto.i @@ -115,9 +115,6 @@ void assignTo(void* data){ memcpy(data, &$self->data, sizeof($self->data)); } - void corrupt(){ - $self->data[31] += 1; - } } %extend cipher_Checksum { From 7f2859f03a88bbe51f29b6cc7f0338b45a33f1db Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 9 Aug 2018 13:00:16 -0400 Subject: [PATCH 203/399] [libc][test] refs #1191 repairs errors in hash --- .../cipher.encrypt.scrypt_chacha20poly1305.go | 6 +- lib/cgo/coin.outputs.go | 9 +- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 109 ++++--- lib/cgo/tests/check_cipher.hash.c | 291 +++++++++--------- 4 files changed, 225 insertions(+), 190 deletions(-) diff --git a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go index 21e0d32506..b9515ad20f 100644 --- a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go +++ b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go @@ -17,7 +17,7 @@ import ( import "C" //export SKY_encrypt_ScryptChacha20poly1305_Encrypt -func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { +func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = 0 defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -34,8 +34,8 @@ func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20pol } //export SKY_encrypt_ScryptChacha20poly1305_Decrypt -func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 +func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 77e2ddfcf5..84f52aafe8 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -327,7 +327,6 @@ func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__A } else { ____error_code = SKY_BAD_HANDLE } - ____error_code = SKY_ERROR return } @@ -347,7 +346,6 @@ func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher } else { ____error_code = SKY_BAD_HANDLE } - ____error_code = SKY_ERROR return } @@ -369,7 +367,6 @@ func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key } else { ____error_code = SKY_BAD_HANDLE } - ____error_code = SKY_ERROR return } @@ -384,8 +381,9 @@ func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) if ok { *_length = len(*a) ____error_code = SKY_OK + } else { + ____error_code = SKY_BAD_HANDLE } - ____error_code = SKY_BAD_HANDLE return } @@ -402,7 +400,8 @@ func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__A uxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) (*a)[key] = uxOuts ____error_code = SKY_OK + } else { + ____error_code = SKY_BAD_HANDLE } - ____error_code = SKY_BAD_HANDLE return } diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c index 341f670a98..58589fbea6 100644 --- a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -21,49 +21,69 @@ TestSuite(cipher_encrypt_scrypt_chacha20poly1305, .init = setup, .fini = teardown); -void parseJsonMetaData(char* metadata, int* n, int* r, int* p, int* keyLen){ +void parseJsonMetaData(char *metadata, int *n, int *r, int *p, int *keyLen) +{ *n = *r = *p = *keyLen = 0; int length = strlen(metadata); int openingQuote = -1; - const char* keys[] = {"n", "r", "p", "keyLen"}; + const char *keys[] = {"n", "r", "p", "keyLen"}; int keysCount = 4; int keyIndex = -1; int startNumber = -1; - for(int i = 0; i < length; i++){ - if( metadata[i] == '\"'){ + for (int i = 0; i < length; i++) + { + if (metadata[i] == '\"') + { startNumber = -1; - if(openingQuote >= 0){ + if (openingQuote >= 0) + { keyIndex = -1; metadata[i] = 0; - for(int k = 0; k < keysCount; k++){ - if(strcmp(metadata + openingQuote + 1, keys[k]) == 0){ + for (int k = 0; k < keysCount; k++) + { + if (strcmp(metadata + openingQuote + 1, keys[k]) == 0) + { keyIndex = k; } } openingQuote = -1; - } else { + } + else + { openingQuote = i; } - } else if( metadata[i] >= '0' && metadata[i] <= '9' ){ - if(startNumber < 0) + } + else if (metadata[i] >= '0' && metadata[i] <= '9') + { + if (startNumber < 0) startNumber = i; - } else if( metadata[i] == ',' ){ - if(startNumber >= 0){ + } + else if (metadata[i] == ',') + { + if (startNumber >= 0) + { metadata[i] = 0; int number = atoi(metadata + startNumber); startNumber = -1; - if(keyIndex == 0) *n = number; - else if(keyIndex == 1) *r = number; - else if(keyIndex == 2) *p = number; - else if(keyIndex == 3) *keyLen = number; + if (keyIndex == 0) + *n = number; + else if (keyIndex == 1) + *r = number; + else if (keyIndex == 2) + *p = number; + else if (keyIndex == 3) + *keyLen = number; } - } else { + } + else + { startNumber = -1; } } } -Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt) +{ GoSlice result; GoSlice nullData; GoSlice nullPassword; @@ -73,7 +93,7 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ GoSlice password2; GoSlice wrong_password; GoSlice encrypted; - + memset(&text, 0, sizeof(GoSlice)); memset(&password, 0, sizeof(GoSlice)); memset(&password2, 0, sizeof(GoSlice)); @@ -82,7 +102,7 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ memset(&nullData, 0, sizeof(GoSlice)); memset(&nullPassword, 0, sizeof(GoSlice)); memset(str, 0, BUFFER_SIZE); - + text.data = PLAINTEXT; text.len = strlen(PLAINTEXT); text.cap = text.len; @@ -98,34 +118,37 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ encrypted.data = ENCRYPTED; encrypted.len = strlen(ENCRYPTED); encrypted.cap = encrypted.len; - + GoUint32 errcode; unsigned int metalength; encrypt__ScryptChacha20poly1305 encrypt = {1, 8, 1, 32}; - for(int i = 1; i <= 20; i++) { + for (int i = 1; i <= 20; i++) + { memset(&result, 0, sizeof(GoSlice)); encrypt.N = 1 << i; errcode = SKY_encrypt_ScryptChacha20poly1305_Encrypt( - &encrypt, text, password, (coin__UxArray*)&result); + &encrypt, text, password, (coin__UxArray *)&result); cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed"); - registerMemCleanup( (void*) result.data ); + registerMemCleanup((void *)result.data); cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); - int decode_len = b64_decode((const unsigned char*)result.data, - result.len, str); + int decode_len = b64_decode((const unsigned char *)result.data, + result.len, str); cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); - metalength = (unsigned int) str[0]; - for(int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++){ - if(str[m] > 0){ + metalength = (unsigned int)str[0]; + for (int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++) + { + if (str[m] > 0) + { metalength += (((unsigned int)str[m]) << (m * 8)); } } cr_assert(metalength + SCRYPTCHACHA20METALENGTHSIZE < decode_len, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata length greater than result lentgh."); - char* meta = str + SCRYPTCHACHA20METALENGTHSIZE; + char *meta = str + SCRYPTCHACHA20METALENGTHSIZE; meta[metalength] = 0; int n, r, p, keyLen; parseJsonMetaData(meta, &n, &r, &p, &keyLen); - + cr_assert(n == encrypt.N, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value N incorrect."); cr_assert(r == encrypt.R, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value R incorrect."); cr_assert(p == encrypt.P, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value P incorrect."); @@ -133,7 +156,8 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt){ } } -Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ +Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt) +{ GoSlice result; GoSlice nullData; GoSlice nullPassword; @@ -142,7 +166,7 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ GoSlice password2; GoSlice wrong_password; GoSlice encrypted; - + memset(&text, 0, sizeof(GoSlice)); memset(&password, 0, sizeof(GoSlice)); memset(&password2, 0, sizeof(GoSlice)); @@ -151,7 +175,7 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ memset(&nullData, 0, sizeof(GoSlice)); memset(&nullPassword, 0, sizeof(GoSlice)); memset(&result, 0, sizeof(coin__UxArray)); - + text.data = PLAINTEXT; text.len = strlen(PLAINTEXT); text.cap = text.len; @@ -167,22 +191,17 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt){ encrypted.data = ENCRYPTED; encrypted.len = strlen(ENCRYPTED); encrypted.cap = encrypted.len; - + GoUint32 errcode; encrypt__ScryptChacha20poly1305 encrypt = {0, 0, 0, 0}; - - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (coin__UxArray*)&result); + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (coin__UxArray *)&result); cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt failed"); - registerMemCleanup( (void*) result.data ); - cr_assert( eq(type(GoSlice), text, result) ); - + registerMemCleanup((void *)result.data); + cr_assert(eq(type(GoSlice), text, result)); result.cap = result.len = 0; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray*)&result); + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray *)&result); cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); result.cap = result.len = 0; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, nullData, password2, (coin__UxArray*)&result); - cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null encrypted data."); - result.cap = result.len = 0; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray*)&result); + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray *)&result); cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); } diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index dc6063d96e..234dc6d0c5 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -8,134 +9,143 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" +#if __APPLE__ +#include "TargetConditionals.h" +#endif -TestSuite(cipher_hash, .init = setup, .fini = teardown); +TestSuite(cipher_hash, .init = setup, .fini = teardown, .signal = SIGABRT, .exit_code = 2); -void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160 *rp160){ +void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160 *rp160) +{ SKY_cipher_HashRipemd160(bytes, rp160); } -void freshSumSHA256(GoSlice bytes, cipher__SHA256 *sha256){ +void freshSumSHA256(GoSlice bytes, cipher__SHA256 *sha256) +{ SKY_cipher_SumSHA256(bytes, sha256); } -Test(cipher,TestHashRipemd160){ +Test(cipher, TestHashRipemd160) +{ cipher__Ripemd160 tmp; cipher__Ripemd160 r; cipher__Ripemd160 r2; unsigned char buff[257]; - GoSlice slice = { buff, 0, 257 }; + GoSlice slice = {buff, 0, 257}; - randBytes(&slice,128); - SKY_cipher_HashRipemd160(slice,&tmp); - randBytes(&slice,160); - SKY_cipher_HashRipemd160(slice,&r); - cr_assert(not(eq(u8[sizeof(cipher__Ripemd160)],tmp,r))); + randBytes(&slice, 128); + SKY_cipher_HashRipemd160(slice, &tmp); + randBytes(&slice, 160); + SKY_cipher_HashRipemd160(slice, &r); + cr_assert(not(eq(u8[sizeof(cipher__Ripemd160)], tmp, r))); unsigned char buff1[257]; - GoSlice b = { buff1, 0, 257 }; - randBytes(&b,256); - SKY_cipher_HashRipemd160(b,&r2); - cr_assert(not(eq(u8[sizeof(cipher__Ripemd160)],r2,tmp))); - freshSumRipemd160(b,&tmp); - cr_assert(eq(u8[20],tmp,r2)); + GoSlice b = {buff1, 0, 257}; + randBytes(&b, 256); + SKY_cipher_HashRipemd160(b, &r2); + cr_assert(not(eq(u8[sizeof(cipher__Ripemd160)], r2, tmp))); + freshSumRipemd160(b, &tmp); + cr_assert(eq(u8[20], tmp, r2)); } -Test(cipher_hash,TestRipemd160Set){ +Test(cipher_hash, TestRipemd160Set) +{ cipher__Ripemd160 h; unsigned char buff[101]; - GoSlice slice = { buff, 0, 101 }; + GoSlice slice = {buff, 0, 101}; int error; memset(h, 0, sizeof(cipher__Ripemd160)); - randBytes(&slice,21); + randBytes(&slice, 21); - error = SKY_cipher_Ripemd160_Set(&h,slice); - cr_assert( error == SKY_ErrInvalidLengthRipemd160); + error = SKY_cipher_Ripemd160_Set(&h, slice); + cr_assert(error == SKY_ErrInvalidLengthRipemd160); - randBytes(&slice,100); - error = SKY_cipher_Ripemd160_Set(&h,slice); + randBytes(&slice, 100); + error = SKY_cipher_Ripemd160_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthRipemd160); - randBytes(&slice,19); - error = SKY_cipher_Ripemd160_Set(&h,slice); + randBytes(&slice, 19); + error = SKY_cipher_Ripemd160_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthRipemd160); - randBytes(&slice,0); - error = SKY_cipher_Ripemd160_Set(&h,slice); + randBytes(&slice, 0); + error = SKY_cipher_Ripemd160_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthRipemd160); - randBytes(&slice,20); - error = SKY_cipher_Ripemd160_Set(&h,slice); + randBytes(&slice, 20); + error = SKY_cipher_Ripemd160_Set(&h, slice); cr_assert(error == SKY_OK); cr_assert(eq(u8[20], h, buff)); } -Test(cipher_hash,TestSHA256Set){ +Test(cipher_hash, TestSHA256Set) +{ cipher__SHA256 h; unsigned char buff[101]; - GoSlice slice = { buff, 0, 101 }; + GoSlice slice = {buff, 0, 101}; int error; - randBytes(&slice,33); - error=SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 33); + error = SKY_cipher_SHA256_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthSHA256); - randBytes(&slice,100); - error=SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 100); + error = SKY_cipher_SHA256_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthSHA256); - randBytes(&slice,31); - error=SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 31); + error = SKY_cipher_SHA256_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthSHA256); - randBytes(&slice,0); - error=SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 0); + error = SKY_cipher_SHA256_Set(&h, slice); cr_assert(error == SKY_ErrInvalidLengthSHA256); - randBytes(&slice,32); - error=SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 32); + error = SKY_cipher_SHA256_Set(&h, slice); cr_assert(error == SKY_OK); cr_assert(eq(u8[32], h, slice.data)); } -Test(cipher_hash,TestSHA256Hex){ +Test(cipher_hash, TestSHA256Hex) +{ cipher__SHA256 h; unsigned char buff[101]; - GoSlice slice = { buff, 0, 101 }; + GoSlice slice = {buff, 0, 101}; int error; memset(&h, 0, sizeof(h)); - randBytes(&slice,32); - SKY_cipher_SHA256_Set(&h,slice); + randBytes(&slice, 32); + SKY_cipher_SHA256_Set(&h, slice); GoString s; SKY_cipher_SHA256_Hex(&h, (GoString_ *)&s); - registerMemCleanup((void*) s.p); + registerMemCleanup((void *)s.p); cipher__SHA256 h2; - error = SKY_cipher_SHA256FromHex(s, &h2 ); + error = SKY_cipher_SHA256FromHex(s, &h2); cr_assert(error == SKY_OK); - cr_assert(eq(u8[32],h,h2)); + cr_assert(eq(u8[32], h, h2)); GoString s2; - SKY_cipher_SHA256_Hex(&h2, (GoString_ *) &s2); - registerMemCleanup((void*) s2.p); - cr_assert(eq(type(GoString),s,s2)); + SKY_cipher_SHA256_Hex(&h2, (GoString_ *)&s2); + registerMemCleanup((void *)s2.p); + cr_assert(eq(type(GoString), s, s2)); } -Test(cipher_hash,TestSHA256KnownValue){ - +Test(cipher_hash, TestSHA256KnownValue) +{ - typedef struct + typedef struct { char *input; char *output; @@ -159,146 +169,151 @@ Test(cipher_hash,TestSHA256KnownValue){ slice_input.data = vals[i].input; slice_input.len = strlen(vals[i].input); - slice_input.cap = strlen(vals[i].input)+1; + slice_input.cap = strlen(vals[i].input) + 1; cipher__SHA256 sha; - SKY_cipher_SumSHA256(slice_input,&sha); + SKY_cipher_SumSHA256(slice_input, &sha); GoString_ tmp_output; - SKY_cipher_SHA256_Hex(&sha,&tmp_output); - registerMemCleanup((void*) tmp_output.p); + SKY_cipher_SHA256_Hex(&sha, &tmp_output); + registerMemCleanup((void *)tmp_output.p); - cr_assert(strcmp(tmp_output.p,vals[i].output)== SKY_OK); + cr_assert(strcmp(tmp_output.p, vals[i].output) == SKY_OK); } } -Test(cipher_hash,TestSumSHA256){ +Test(cipher_hash, TestSumSHA256) +{ unsigned char bbuff[257], - cbuff[257]; - GoSlice b = { bbuff, 0, 257 }; + cbuff[257]; + GoSlice b = {bbuff, 0, 257}; cipher__SHA256 h1; - randBytes(&b,256); - SKY_cipher_SumSHA256(b,&h1); + randBytes(&b, 256); + SKY_cipher_SumSHA256(b, &h1); cipher__SHA256 tmp; - cr_assert(not(eq(u8[32],h1,tmp))); - GoSlice c = { cbuff, 0, 257 }; - randBytes(&c,256); + cr_assert(not(eq(u8[32], h1, tmp))); + GoSlice c = {cbuff, 0, 257}; + randBytes(&c, 256); cipher__SHA256 h2; - SKY_cipher_SumSHA256(c,&h2); - cr_assert(not(eq(u8[32],h2,tmp))); + SKY_cipher_SumSHA256(c, &h2); + cr_assert(not(eq(u8[32], h2, tmp))); cipher__SHA256 tmp_h2; - freshSumSHA256(c,&tmp_h2); - cr_assert(eq(u8[32],h2,tmp_h2)); + freshSumSHA256(c, &tmp_h2); + cr_assert(eq(u8[32], h2, tmp_h2)); } -Test(cipher_hash,TestSHA256FromHex){ +Test(cipher_hash, TestSHA256FromHex) +{ unsigned int error; cipher__SHA256 tmp; // Invalid hex hash - GoString tmp_string = {"cawcd",5}; - error = SKY_cipher_SHA256FromHex(tmp_string,&tmp); + GoString tmp_string = {"cawcd", 5}; + error = SKY_cipher_SHA256FromHex(tmp_string, &tmp); cr_assert(error == SKY_ERROR); // Truncated hex hash cipher__SHA256 h; unsigned char buff[130]; char sbuff[300]; - GoSlice slice = { buff,0,130 }; - randBytes(&slice,128); - SKY_cipher_SumSHA256(slice,&h); - strnhex(h,sbuff,sizeof(h) >> 1); - GoString s1 = { sbuff, strlen(sbuff) }; - error = SKY_cipher_SHA256FromHex(s1,&h); + GoSlice slice = {buff, 0, 130}; + randBytes(&slice, 128); + SKY_cipher_SumSHA256(slice, &h); + strnhex(h, sbuff, sizeof(h) >> 1); + GoString s1 = {sbuff, strlen(sbuff)}; + error = SKY_cipher_SHA256FromHex(s1, &h); cr_assert(error == SKY_ErrInvalidHexLength); // Valid hex hash // char sbuff1[300]; GoString_ s2; // strnhex(h,sbuff1,sizeof(h)); - SKY_cipher_SHA256_Hex(&h, &s2 ); + SKY_cipher_SHA256_Hex(&h, &s2); cipher__SHA256 h2; - error = SKY_cipher_SHA256FromHex((*((GoString *) &s2)),&h2); + error = SKY_cipher_SHA256FromHex((*((GoString *)&s2)), &h2); cr_assert(error == SKY_OK); - cr_assert(eq(u8[32],h,h2)); + cr_assert(eq(u8[32], h, h2)); } - -Test(cipher_hash,TestDoubleSHA256){ +Test(cipher_hash, TestDoubleSHA256) +{ unsigned char bbuff[130]; - GoSlice b = { bbuff, 0, 130 }; - randBytes(&b,128); + GoSlice b = {bbuff, 0, 130}; + randBytes(&b, 128); cipher__SHA256 h; cipher__SHA256 tmp; - SKY_cipher_DoubleSHA256(b,&h); - cr_assert(not(eq(u8[32],tmp,h))); - freshSumSHA256(b,&tmp); - cr_assert(not(eq(u8[32],tmp,h))); + SKY_cipher_DoubleSHA256(b, &h); + cr_assert(not(eq(u8[32], tmp, h))); + freshSumSHA256(b, &tmp); + cr_assert(not(eq(u8[32], tmp, h))); } -Test(cipher_hash,TestAddSHA256){ +Test(cipher_hash, TestAddSHA256) +{ unsigned char bbuff[130]; - GoSlice b = { bbuff, 0, 130 }; - randBytes(&b,128); + GoSlice b = {bbuff, 0, 130}; + randBytes(&b, 128); cipher__SHA256 h; - SKY_cipher_SumSHA256(b,&h); + SKY_cipher_SumSHA256(b, &h); unsigned char cbuff[130]; - GoSlice c = { cbuff, 0, 130 }; - randBytes(&c,64); + GoSlice c = {cbuff, 0, 130}; + randBytes(&c, 64); cipher__SHA256 i; - SKY_cipher_SumSHA256(c,&i); + SKY_cipher_SumSHA256(c, &i); cipher__SHA256 add; cipher__SHA256 tmp; - SKY_cipher_AddSHA256(&h,&i,&add); + SKY_cipher_AddSHA256(&h, &i, &add); - cr_assert(not(eq(u8[32],add,tmp))); - cr_assert(not(eq(u8[32],add,h))); - cr_assert(not(eq(u8[32],add,i))); + cr_assert(not(eq(u8[32], add, tmp))); + cr_assert(not(eq(u8[32], add, h))); + cr_assert(not(eq(u8[32], add, i))); } -Test(cipher_hash,TestXorSHA256){ +Test(cipher_hash, TestXorSHA256) +{ unsigned char bbuff[129], - cbuff[129]; - GoSlice b = { bbuff, 0, 129 } ; - GoSlice c = { cbuff, 0, 129 }; + cbuff[129]; + GoSlice b = {bbuff, 0, 129}; + GoSlice c = {cbuff, 0, 129}; cipher__SHA256 h, i; - randBytes(&b,128); - SKY_cipher_SumSHA256(b,&h); - randBytes(&c,128); - SKY_cipher_SumSHA256(c,&i); + randBytes(&b, 128); + SKY_cipher_SumSHA256(b, &h); + randBytes(&c, 128); + SKY_cipher_SumSHA256(c, &i); cipher__SHA256 tmp_xor1; cipher__SHA256 tmp_xor2; cipher__SHA256 tmp; - SKY_cipher_SHA256_Xor(&h,&i,&tmp_xor1); - SKY_cipher_SHA256_Xor(&i,&h,&tmp_xor2); - - cr_assert(not(eq(u8[32],tmp_xor1,h))); - cr_assert(not(eq(u8[32],tmp_xor1,i))); - cr_assert(not(eq(u8[32],tmp_xor1,tmp))); - cr_assert(eq(u8[32],tmp_xor1,tmp_xor2)); + SKY_cipher_SHA256_Xor(&h, &i, &tmp_xor1); + SKY_cipher_SHA256_Xor(&i, &h, &tmp_xor2); + cr_assert(not(eq(u8[32], tmp_xor1, h))); + cr_assert(not(eq(u8[32], tmp_xor1, i))); + cr_assert(not(eq(u8[32], tmp_xor1, tmp))); + cr_assert(eq(u8[32], tmp_xor1, tmp_xor2)); } -Test(cipher_hash,TestMerkle){ +Test(cipher_hash, TestMerkle) +{ unsigned char buff[129]; cipher__SHA256 hashlist[5]; - GoSlice b = { buff, 0, 129 }, - hashes = { hashlist, 0, 5 }; + GoSlice b = {buff, 0, 129}, + hashes = {hashlist, 0, 5}; cipher__SHA256 h, zero, out, out1, out2, out3, out4; int i; memset(zero, 0, sizeof(zero)); - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) + { randBytes(&b, 128); SKY_cipher_SumSHA256(b, &hashlist[i]); } @@ -310,40 +325,41 @@ Test(cipher_hash,TestMerkle){ // 2 hashes should be Addcipher__SHA256 of them hashes.len = 2; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 3 hashes should be Add(Add()) hashes.len = 3; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &zero, &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &zero, &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 4 hashes should be Add(Add()) hashes.len = 4; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 5 hashes hashes.len = 5; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out3); - SKY_cipher_AddSHA256(&hashlist[4], &zero, &out1); - SKY_cipher_AddSHA256(&zero, &zero, &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out4); - SKY_cipher_AddSHA256(&out3, &out4, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out3); + SKY_cipher_AddSHA256(&hashlist[4], &zero, &out1); + SKY_cipher_AddSHA256(&zero, &zero, &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out4); + SKY_cipher_AddSHA256(&out3, &out4, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); } -Test(cipher_hash, TestMustSumSHA256) { +Test(cipher_hash, TestMustSumSHA256, .signal = SIGABRT) +{ char buffer_b[1024]; GoSlice b = {buffer_b, 0, 1024}; randBytes(&b, 128); @@ -363,7 +379,8 @@ Test(cipher_hash, TestMustSumSHA256) { cr_assert(eq(u8[32], h, sha)); } -Test(cipher_hash, TestSHA256Null) { +Test(cipher_hash, TestSHA256Null) +{ cipher__SHA256 x; memset(&x, 0, sizeof(cipher__SHA256)); GoUint32 result; From 9af6ef4888b2bddd2c9b48debe786fc7e0be75ac Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 9 Aug 2018 17:51:34 -0400 Subject: [PATCH 204/399] [libc][test] Test in panics --- lib/cgo/tests/check_cipher.hash.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 234dc6d0c5..9e27260e6f 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -9,11 +9,8 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#if __APPLE__ -#include "TargetConditionals.h" -#endif -TestSuite(cipher_hash, .init = setup, .fini = teardown, .signal = SIGABRT, .exit_code = 2); +TestSuite(cipher_hash, .init = setup, .fini = teardown); void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160 *rp160) { @@ -154,13 +151,16 @@ Test(cipher_hash, TestSHA256KnownValue) tmpstruct vals[3]; vals[0].input = "skycoin"; - vals[0].output = "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; + vals[0].output = + "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; vals[1].input = "hello world"; - vals[1].output = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"; + vals[1].output = + "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"; vals[2].input = "hello world asd awd awd awdapodawpokawpod "; - vals[2].output = "99d71f95cafe05ea2dddebc35b6083bd5af0e44850c9dc5139b4476c99950be4"; + vals[2].output = + "99d71f95cafe05ea2dddebc35b6083bd5af0e44850c9dc5139b4476c99950be4"; for (int i = 0; i < 3; ++i) { @@ -187,8 +187,7 @@ Test(cipher_hash, TestSHA256KnownValue) Test(cipher_hash, TestSumSHA256) { - unsigned char bbuff[257], - cbuff[257]; + unsigned char bbuff[257], cbuff[257]; GoSlice b = {bbuff, 0, 257}; cipher__SHA256 h1; randBytes(&b, 256); @@ -277,8 +276,7 @@ Test(cipher_hash, TestAddSHA256) Test(cipher_hash, TestXorSHA256) { - unsigned char bbuff[129], - cbuff[129]; + unsigned char bbuff[129], cbuff[129]; GoSlice b = {bbuff, 0, 129}; GoSlice c = {cbuff, 0, 129}; cipher__SHA256 h, i; @@ -305,8 +303,7 @@ Test(cipher_hash, TestMerkle) { unsigned char buff[129]; cipher__SHA256 hashlist[5]; - GoSlice b = {buff, 0, 129}, - hashes = {hashlist, 0, 5}; + GoSlice b = {buff, 0, 129}, hashes = {hashlist, 0, 5}; cipher__SHA256 h, zero, out, out1, out2, out3, out4; int i; @@ -358,7 +355,7 @@ Test(cipher_hash, TestMerkle) cr_assert(eq(u8[32], out, h)); } -Test(cipher_hash, TestMustSumSHA256, .signal = SIGABRT) +Test(cipher_hash, TestMustSumSHA256, .signal = ((__linux__) ? SIGABRT : 2)) { char buffer_b[1024]; GoSlice b = {buffer_b, 0, 1024}; From 4e475348a9d4aadcb347359ca89c1e5df04ceb1f Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Fri, 10 Aug 2018 18:44:06 +0000 Subject: [PATCH 205/399] [daemon] refs #735 - Send GIVP then (new) RJCT on peer overflow --- src/daemon/errors.go | 12 ++--- src/daemon/messages.go | 95 ++++++++++--------------------------- src/daemon/messages_test.go | 36 +++++--------- 3 files changed, 42 insertions(+), 101 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 9967efa526..4d8880f4e5 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -33,28 +33,28 @@ var errorByCode = [...]error{ pex.ErrPortTooLow, pex.ErrBlacklistedAddress} -var errorCodeByError map[error]uint16 +var errorCodeByError map[error]uint32 var initErrorCodeMap = func() { - errorCodeByError = make(map[error]uint16) + errorCodeByError = make(map[error]uint32) for i, err := range errorByCode { - errorCodeByError[err] = uint16(i) + errorCodeByError[err] = uint32(i) } } // ErrorCodeUnknown is used on unexpected error condition detected -const ErrorCodeUnknown = 0xFFFF +const ErrorCodeUnknown = 0xFFFFFFFF // Success error code const Success = 0 // GetError Retrieve error object by corresponding error code -func GetError(code uint16) error { +func GetError(code uint32) error { return errorByCode[code] } // GetErrorCode Retrieve error code representing corresponding error object -func GetErrorCode(err error) uint16 { +func GetErrorCode(err error) uint32 { if initErrorCodeMap != nil { initErrorCodeMap() initErrorCodeMap = nil diff --git a/src/daemon/messages.go b/src/daemon/messages.go index eef2f100ea..091f596dd5 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -20,8 +20,8 @@ import ( var ( // Every rejection message prefix must start with "RJC" prefix rejectPrefix = [...]byte{82, 74, 67} - // ErrAckRejectWithPeers disconnect since peer sent RJCP message - ErrAckRejectWithPeers gnet.DisconnectReason = errors.New("Disconnect after processing peers") + // ErrAckReject disconnect since peer sent RJCT message + ErrAckReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") ) // Message represent a packet to be serialized over the network by @@ -63,7 +63,7 @@ func getMessageConfigs() []MessageConfig { NewMessageConfig("GETT", GetTxnsMessage{}), NewMessageConfig("GIVT", GiveTxnsMessage{}), NewMessageConfig("ANNT", AnnounceTxnsMessage{}), - NewMessageConfig("RJCP", RejectWithPeersMessage{}), + NewMessageConfig("RJCT", RejectMessage{}), } } @@ -366,26 +366,11 @@ func (intro *IntroductionMessage) Process(d Daemoner) { d.RemoveFromExpectingIntroductions(intro.c.Addr) if intro.validationError != nil { if intro.validationError == pex.ErrPeerlistFull { - // FIXME: Quite similar to NewGivePeersMessage. Merge'em both peers := d.RandomExchangeable(d.PexConfig().ReplyCount) - ipAddrs := make([]IPAddr, len(peers)) - badAddrs := []string{} - for _, peer := range peers { - ipAddr, err := NewIPAddr(peer.Addr) - if err != nil { - badAddrs = append(badAddrs, peer.Addr) - } else { - ipAddrs = append(ipAddrs, ipAddr) - } - } - if len(badAddrs) > 0 { - logger.Debugf("IntroductionMessage skipping addresses in RJCP peer list %v", badAddrs) - } - if len(ipAddrs) == 0 { - logger.Debug("We have no peers to send in reply") - } - rejectMsg := NewRejectWithPeersMessage(intro, pex.ErrPeerlistFull, "", ipAddrs) - d.SendMessage(intro.c.Addr, rejectMsg) + givpMsg := NewGivePeersMessage(peers) + d.SendMessage(intro.c.Addr, givpMsg) + rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") + d.SendMessage(intro.c.Addr, rjctMsg) } return } @@ -449,37 +434,26 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err return nil } -// RejectHeader contains metadata describing message rejection +// RejectMessage sent to inform peers of a protocol failure. +// Whenever possible the node should send back prior to this +// other message including data useful for peer recovery, especially +// before disconnecting it // -// Should be at the beginning of every RJC? message -type RejectHeader struct { +// Must never Reject a Reject message (infinite loop) +type RejectMessage struct { // Prefix of the (previous) message that's been rejected TargetPrefix gnet.MessagePrefix // Error code - ErrorCode uint16 + ErrorCode uint32 // Reason message. Included only in very particular cases Reason string -} - -// RejectWithPeersMessage a RejectWithPeersMessage is sent to inform peers of -// a protocol failure. Whenever possible the node should -// send back data useful for peer recovery, especially -// before disconnecting it -// -// Must never Reject a Reject message (infinite loop) -type RejectWithPeersMessage struct { - // Reject message header - RejectHeader - // Peers list - Peers []IPAddr // Reserved for future use Reserved []byte - - c *gnet.MessageContext `enc:"-"` + c *gnet.MessageContext `enc:"-"` } -// NewRejectWithPeersMessage creates message sent to reject previously received message -func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers []IPAddr) *RejectWithPeersMessage { +// NewRejectMessage creates message sent to reject previously received message +func NewRejectMessage(msg gnet.Message, err error, reason string) *RejectMessage { t := reflect.Indirect(reflect.ValueOf(msg)).Type() prefix, exists := gnet.MessageIDMap[t] if !exists { @@ -489,42 +463,23 @@ func NewRejectWithPeersMessage(msg gnet.Message, err error, reason string, peers logger.Panicf("Message type %s (prefix = %s) may not be rejected", t, prefix) } - return &RejectWithPeersMessage{ - RejectHeader: RejectHeader{ - TargetPrefix: prefix, - // TODO: Return error code - ErrorCode: GetErrorCode(err), - Reason: reason, - }, - Peers: peers, - Reserved: nil, + return &RejectMessage{ + TargetPrefix: prefix, + ErrorCode: GetErrorCode(err), + Reason: reason, + Reserved: nil, } } // Handle an event queued by Handle() -func (rpm *RejectWithPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { +func (rpm *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { rpm.c = mc return daemon.(Daemoner).RecordMessageEvent(rpm, mc) } -// dataMessageForReject returns the data message equivalent to a reject message -func dataMessageForReject(msg gnet.Message) gnet.Message { - switch msg.(type) { - case *RejectWithPeersMessage: - rejectMsg, _ := msg.(*RejectWithPeersMessage) - return &GivePeersMessage{ - Peers: rejectMsg.Peers, - } - default: - return nil - } -} - // Process Recover from message rejection state -func (rpm *RejectWithPeersMessage) Process(d Daemoner) { - gpm, _ := dataMessageForReject(rpm).(*RejectWithPeersMessage) - gpm.Process(d) - d.Disconnect(rpm.c.Addr, ErrAckRejectWithPeers) +func (rpm *RejectMessage) Process(d Daemoner) { + d.Disconnect(rpm.c.Addr, ErrAckReject) } // GetBlocksMessage sent to request blocks since LastBlock diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 746412c6e8..92bb691b05 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -830,39 +830,25 @@ func TestIntroductionMessage(t *testing.T) { } -func ExampleRejectWithPeersMessage() { +func ExampleRejectMessage() { defer gnet.EraseMessages() setupMsgEncoding() - peers := make([]IPAddr, 0) - addr, _ := NewIPAddr("192.168.1.1:6001") - peers = append(peers, addr) - addr, _ = NewIPAddr("192.168.1.2:6002") - peers = append(peers, addr) - addr, _ = NewIPAddr("192.168.1.3:6003") - peers = append(peers, addr) - addr, _ = NewIPAddr("192.168.1.4:6004") - peers = append(peers, addr) - rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, []byte{}) - message := NewRejectWithPeersMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, - "ExampleRejectWithPeersMessage", peers) + message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") fmt.Println("RejectWithPeersMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) util.HexDumpFromIterator(gnet.EncodeMessage(message), &mai, w) // Output: // RejectWithPeersMessage: - // 0x0000 | 4b 00 00 00 ....................................... Length - // 0x0004 | 52 4a 43 50 ....................................... Prefix - // 0x0008 | 49 4e 54 52 0c 00 1d 00 00 00 45 78 61 6d 70 6c - // 0x0018 | 65 52 65 6a 65 63 74 57 69 74 68 50 65 65 72 73 - // 0x0028 | 4d 65 73 73 61 67 65 .............................. RejectHeader - // 0x002f | 04 00 00 00 ....................................... Peers length - // 0x0033 | 01 01 a8 c0 71 17 ................................. Peers[0] - // 0x0039 | 02 01 a8 c0 72 17 ................................. Peers[1] - // 0x003f | 03 01 a8 c0 73 17 ................................. Peers[2] - // 0x0045 | 04 01 a8 c0 74 17 ................................. Peers[3] - // 0x004b | 00 00 00 00 ....................................... Reserved length - // 0x004f | + // 0x0000 | 31 00 00 00 ....................................... Length + // 0x0004 | 52 4a 43 54 ....................................... Prefix + // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix + // 0x000c | 0c 00 00 00 ....................................... ErrorCode + // 0x0010 | 1d 00 00 00 45 78 61 6d 70 6c 65 52 65 6a 65 63 + // 0x0020 | 74 57 69 74 68 50 65 65 72 73 4d 65 73 73 61 67 + // 0x0030 | 65 ................................................ Reason + // 0x0031 | 00 00 00 00 ....................................... Reserved length + // 0x0035 | } From 5dec9f6e95b7f644a02c69401baf619c61be845f Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sat, 11 Aug 2018 02:07:04 +0000 Subject: [PATCH 206/399] refs #735 - Explain changes INTR => GIVP + RJCT in chengelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf5b09f54..f0249d727c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added +- RJCT network message + ### Fixed ### Changed +- Reply to `INTR` message with `GIVP` + `RJCT` on peer overflow + ### Removed ## [0.24.1] - 2018-07-30 From 4f10f7543f70fb29ebebc18155a6583471fcb490 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 11 Aug 2018 04:02:51 +0000 Subject: [PATCH 207/399] refs #735 - Style changes in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0249d727c..c9eb7d5fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed -- Reply to `INTR` message with `GIVP` + `RJCT` on peer overflow +- Reply to `INTR` message with `GIVP` + `RJCT` on pex pool overflow ### Removed From f85e9e225e1a6e849b0b427221865aa096cd26c7 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sat, 11 Aug 2018 01:22:39 -0400 Subject: [PATCH 208/399] [libc][test][core] refs #1191 Added errors --- include/skyerrors.h | 306 ++++---- lib/cgo/cipher.encrypt.sha256xor.go | 4 +- ...cipher.secp256k1-go.secp256k1-go2.field.go | 38 +- lib/cgo/cipher.secp256k1-go.secp256k1.go | 32 +- lib/cgo/libsky_error.go | 33 +- lib/cgo/tests/check_cipher.address.c | 4 +- .../tests/check_cipher.encrypt.sha256xor.c | 4 +- .../tests/check_cipher.secp256k1.secp256_2.c | 681 ++++++++++-------- lib/cgo/tests/check_coin.outputs.c | 3 - lib/cgo/tests/check_coin.transactions.c | 228 +++--- src/cipher/encrypt/sha256xor.go | 38 +- 11 files changed, 776 insertions(+), 595 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 1c7c0dad82..3d5ca6360a 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -2,167 +2,167 @@ #ifndef SKY_ERRORS_H #define SKY_ERRORS_H -#define SKY_OK 0 -#define SKY_ERROR 0x7FFFFFFF +#define SKY_OK 0 +#define SKY_ERROR 0x7FFFFFFF -#define SKY_PKG_API 0x01000000 -#define SKY_PKG_CIPHER 0x02000000 -#define SKY_PKG_CLI 0x03000000 -#define SKY_PKG_COIN 0x04000000 +#define SKY_PKG_API 0x01000000 +#define SKY_PKG_CIPHER 0x02000000 +#define SKY_PKG_CLI 0x03000000 +#define SKY_PKG_COIN 0x04000000 #define SKY_PKG_CONSENSUS 0x05000000 -#define SKY_PKG_DAEMON 0x06000000 -#define SKY_PKG_GUI 0x07000000 -#define SKY_PKG_SKYCOIN 0x08000000 -#define SKY_PKG_UTIL 0x09000000 -#define SKY_PKG_VISOR 0x0A000000 -#define SKY_PKG_WALLET 0x0B000000 +#define SKY_PKG_DAEMON 0x06000000 +#define SKY_PKG_GUI 0x07000000 +#define SKY_PKG_SKYCOIN 0x08000000 +#define SKY_PKG_UTIL 0x09000000 +#define SKY_PKG_VISOR 0x0A000000 +#define SKY_PKG_WALLET 0x0B000000 -#define SKY_ErrAddressInvalidLength 0x02000000 -#define SKY_ErrAddressInvalidChecksum 0x02000001 -#define SKY_ErrAddressInvalidVersion 0x02000002 -#define SKY_ErrAddressInvalidPubKey 0x02000003 -#define SKY_ErrAddressInvalidFirstByte 0x02000004 -#define SKY_ErrAddressInvalidLastByte 0x02000005 -#define SKY_ErrBufferUnderflow 0x02000006 -#define SKY_ErrInvalidOmitEmpty 0x02000007 -#define SKY_ErrInvalidLengthPubKey 0x02000008 -#define SKY_ErrPubKeyFromNullSecKey 0x02000009 -#define SKY_ErrPubKeyFromBadSecKey 0x0200000A -#define SKY_ErrInvalidLengthSecKey 0x0200000B -#define SKY_ErrECHDInvalidPubKey 0x0200000C -#define SKY_ErrECHDInvalidSecKey 0x0200000D -#define SKY_ErrInvalidLengthSig 0x0200000E -#define SKY_ErrInvalidLengthRipemd160 0x0200000F -#define SKY_ErrInvalidLengthSHA256 0x02000010 -#define SKY_ErrInvalidBase58Char 0x02000011 -#define SKY_ErrInvalidBase58String 0x02000012 -#define SKY_ErrInvalidBase58Length 0x02000013 -#define SKY_ErrInvalidHexLength 0x02000014 -#define SKY_ErrInvalidBytesLength 0x02000015 -#define SKY_ErrInvalidPubKey 0x02000016 -#define SKY_ErrInvalidSecKey 0x02000017 -#define SKY_ErrInvalidSigForPubKey 0x02000018 -#define SKY_ErrInvalidSecKeyHex 0x02000019 -#define SKY_ErrInvalidAddressForSig 0x0200001A -#define SKY_ErrInvalidHashForSig 0x0200001B -#define SKY_ErrPubKeyRecoverMismatch 0x0200001C -#define SKY_ErrInvalidSigInvalidPubKey 0x0200001D -#define SKY_ErrInvalidSigValidity 0x0200001E -#define SKY_ErrInvalidSigForMessage 0x0200001F -#define SKY_ErrInvalidSecKyVerification 0x02000020 -#define SKY_ErrNullPubKeyFromSecKey 0x02000021 -#define SKY_ErrInvalidDerivedPubKeyFromSecKey 0x02000022 -#define SKY_ErrInvalidPubKeyFromHash 0x02000023 -#define SKY_ErrPubKeyFromSecKeyMissmatch 0x02000024 +#define SKY_ErrAddressInvalidLength 0x02000000 +#define SKY_ErrAddressInvalidChecksum 0x02000001 +#define SKY_ErrAddressInvalidVersion 0x02000002 +#define SKY_ErrAddressInvalidPubKey 0x02000003 +#define SKY_ErrAddressInvalidFirstByte 0x02000004 +#define SKY_ErrAddressInvalidLastByte 0x02000005 +#define SKY_ErrBufferUnderflow 0x02000006 +#define SKY_ErrInvalidOmitEmpty 0x02000007 +#define SKY_ErrInvalidLengthPubKey 0x02000008 +#define SKY_ErrPubKeyFromNullSecKey 0x02000009 +#define SKY_ErrPubKeyFromBadSecKey 0x0200000A +#define SKY_ErrInvalidLengthSecKey 0x0200000B +#define SKY_ErrECHDInvalidPubKey 0x0200000C +#define SKY_ErrECHDInvalidSecKey 0x0200000D +#define SKY_ErrInvalidLengthSig 0x0200000E +#define SKY_ErrInvalidLengthRipemd160 0x0200000F +#define SKY_ErrInvalidLengthSHA256 0x02000010 +#define SKY_ErrInvalidBase58Char 0x02000011 +#define SKY_ErrInvalidBase58String 0x02000012 +#define SKY_ErrInvalidBase58Length 0x02000013 +#define SKY_ErrInvalidHexLength 0x02000014 +#define SKY_ErrInvalidBytesLength 0x02000015 +#define SKY_ErrInvalidPubKey 0x02000016 +#define SKY_ErrInvalidSecKey 0x02000017 +#define SKY_ErrInvalidSigForPubKey 0x02000018 +#define SKY_ErrInvalidSecKeyHex 0x02000019 +#define SKY_ErrInvalidAddressForSig 0x0200001A +#define SKY_ErrInvalidHashForSig 0x0200001B +#define SKY_ErrPubKeyRecoverMismatch 0x0200001C +#define SKY_ErrInvalidSigInvalidPubKey 0x0200001D +#define SKY_ErrInvalidSigValidity 0x0200001E +#define SKY_ErrInvalidSigForMessage 0x0200001F +#define SKY_ErrInvalidSecKyVerification 0x02000020 +#define SKY_ErrNullPubKeyFromSecKey 0x02000021 +#define SKY_ErrInvalidDerivedPubKeyFromSecKey 0x02000022 +#define SKY_ErrInvalidPubKeyFromHash 0x02000023 +#define SKY_ErrPubKeyFromSecKeyMissmatch 0x02000024 -#define SKY_ErrTemporaryInsufficientBalance 0x03000000 -#define SKY_ErrAddress 0x03000001 -#define SKY_ErrWalletName 0x03000002 -#define SKY_ErrJSONMarshal 0x03000003 -#define SKY_WalletLoadError 0x03000004 -#define SKY_WalletSaveError 0x03000005 +#define SKY_ErrTemporaryInsufficientBalance 0x03000000 +#define SKY_ErrAddress 0x03000001 +#define SKY_ErrWalletName 0x03000002 +#define SKY_ErrJSONMarshal 0x03000003 +#define SKY_WalletLoadError 0x03000004 +#define SKY_WalletSaveError 0x03000005 #define SKY_ErrAddEarnedCoinHoursAdditionOverflow 0x04000000 -#define SKY_ErrUint64MultOverflow 0x04000001 -#define SKY_ErrUint64AddOverflow 0x04000002 -#define SKY_ErrUint32AddOverflow 0x04000003 -#define SKY_ErrUint64OverflowsInt64 0x04000004 -#define SKY_ErrInt64UnderflowsUint64 0x04000005 +#define SKY_ErrUint64MultOverflow 0x04000001 +#define SKY_ErrUint64AddOverflow 0x04000002 +#define SKY_ErrUint32AddOverflow 0x04000003 +#define SKY_ErrUint64OverflowsInt64 0x04000004 +#define SKY_ErrInt64UnderflowsUint64 0x04000005 -#define SKY_ErrPeerlistFull 0x06000000 -#define SKY_ErrInvalidAddress 0x06000001 -#define SKY_ErrNoLocalhost 0x06000002 -#define SKY_ErrNotExternalIP 0x06000003 -#define SKY_ErrPortTooLow 0x06000004 -#define SKY_ErrBlacklistedAddress 0x06000005 -#define SKY_ErrDisconnectReadFailed 0x06000006 -#define SKY_ErrDisconnectWriteFailed 0x06000007 -#define SKY_ErrDisconnectSetReadDeadlineFailed 0x06000008 -#define SKY_ErrDisconnectInvalidMessageLength 0x06000009 -#define SKY_ErrDisconnectMalformedMessage 0x0600000A -#define SKY_ErrDisconnectUnknownMessage 0x0600000B -#define SKY_ErrDisconnectUnexpectedError 0x0600000C -#define SKY_ErrConnectionPoolClosed 0x0600000D -#define SKY_ErrWriteQueueFull 0x0600000E -#define SKY_ErrNoReachableConnections 0x0600000F -#define SKY_ErrMaxDefaultConnectionsReached 0x06000010 -#define SKY_ErrDisconnectInvalidVersion 0x06000011 -#define SKY_ErrDisconnectIntroductionTimeout 0x06000012 -#define SKY_ErrDisconnectVersionSendFailed 0x06000013 -#define SKY_ErrDisconnectIsBlacklisted 0x06000014 -#define SKY_ErrDisconnectSelf 0x06000015 -#define SKY_ErrDisconnectConnectedTwice 0x06000016 -#define SKY_ErrDisconnectIdle 0x06000017 -#define SKY_ErrDisconnectNoIntroduction 0x06000018 -#define SKY_ErrDisconnectIPLimitReached 0x06000019 -#define SKY_ErrDisconnectOtherError 0x0600001A -#define SKY_ErrDisconnectMaxDefaultConnectionReached 0x0600001B -#define SKY_ErrDisconnectMaxOutgoingConnectionsReached 0x0600001C -#define SKY_ConnectionError 0x0600001D +#define SKY_ErrPeerlistFull 0x06000000 +#define SKY_ErrInvalidAddress 0x06000001 +#define SKY_ErrNoLocalhost 0x06000002 +#define SKY_ErrNotExternalIP 0x06000003 +#define SKY_ErrPortTooLow 0x06000004 +#define SKY_ErrBlacklistedAddress 0x06000005 +#define SKY_ErrDisconnectReadFailed 0x06000006 +#define SKY_ErrDisconnectWriteFailed 0x06000007 +#define SKY_ErrDisconnectSetReadDeadlineFailed 0x06000008 +#define SKY_ErrDisconnectInvalidMessageLength 0x06000009 +#define SKY_ErrDisconnectMalformedMessage 0x0600000A +#define SKY_ErrDisconnectUnknownMessage 0x0600000B +#define SKY_ErrDisconnectUnexpectedError 0x0600000C +#define SKY_ErrConnectionPoolClosed 0x0600000D +#define SKY_ErrWriteQueueFull 0x0600000E +#define SKY_ErrNoReachableConnections 0x0600000F +#define SKY_ErrMaxDefaultConnectionsReached 0x06000010 +#define SKY_ErrDisconnectInvalidVersion 0x06000011 +#define SKY_ErrDisconnectIntroductionTimeout 0x06000012 +#define SKY_ErrDisconnectVersionSendFailed 0x06000013 +#define SKY_ErrDisconnectIsBlacklisted 0x06000014 +#define SKY_ErrDisconnectSelf 0x06000015 +#define SKY_ErrDisconnectConnectedTwice 0x06000016 +#define SKY_ErrDisconnectIdle 0x06000017 +#define SKY_ErrDisconnectNoIntroduction 0x06000018 +#define SKY_ErrDisconnectIPLimitReached 0x06000019 +#define SKY_ErrDisconnectOtherError 0x0600001A +#define SKY_ErrDisconnectMaxDefaultConnectionReached 0x0600001B +#define SKY_ErrDisconnectMaxOutgoingConnectionsReached 0x0600001C +#define SKY_ConnectionError 0x0600001D -#define SKY_ErrTxnNoFee 0x09000000 -#define SKY_ErrTxnInsufficientFee 0x09000001 -#define SKY_ErrTxnInsufficientCoinHours 0x09000002 -#define SKY_ErrNegativeValue 0x09000003 -#define SKY_ErrTooManyDecimals 0x09000004 -#define SKY_ErrTooLarge 0x09000005 -#define SKY_ErrEmptyDirectoryName 0x09000006 -#define SKY_ErrDotDirectoryName 0x09000007 +#define SKY_ErrTxnNoFee 0x09000000 +#define SKY_ErrTxnInsufficientFee 0x09000001 +#define SKY_ErrTxnInsufficientCoinHours 0x09000002 +#define SKY_ErrNegativeValue 0x09000003 +#define SKY_ErrTooManyDecimals 0x09000004 +#define SKY_ErrTooLarge 0x09000005 +#define SKY_ErrEmptyDirectoryName 0x09000006 +#define SKY_ErrDotDirectoryName 0x09000007 -#define SKY_ErrHistoryDBCorrupted 0x0A000000 -#define SKY_ErrUxOutNotExist 0x0A000001 -#define SKY_ErrNoHeadBlock 0x0A000002 -#define SKY_ErrMissingSignature 0x0A000003 -#define SKY_ErrUnspentNotExist 0x0A000004 -#define SKY_ErrVerifyStopped 0x0A000005 -#define SKY_ErrCreateBucketFailed 0x0A000000 -#define SKY_ErrBucketNotExist 0x0A000006 -#define SKY_ErrTxnViolatesHardConstraint 0x0A000007 -#define SKY_ErrTxnViolatesSoftConstraint 0x0A000008 -#define SKY_ErrTxnViolatesUserConstraint 0x0A000009 - -#define SKY_ErrInsufficientBalance 0x0B000000 -#define SKY_ErrInsufficientHours 0x0B000001 -#define SKY_ErrZeroSpend 0x0B000002 -#define SKY_ErrSpendingUnconfirmed 0x0B000003 -#define SKY_ErrInvalidEncryptedField 0x0B000004 -#define SKY_ErrWalletEncrypted 0x0B000005 -#define SKY_ErrWalletNotEncrypted 0x0B000006 -#define SKY_ErrMissingPassword 0x0B000007 -#define SKY_ErrMissingEncrypt 0x0B000008 -#define SKY_ErrInvalidPassword 0x0B000009 -#define SKY_ErrMissingSeed 0x0B00000A -#define SKY_ErrMissingAuthenticated 0x0B00000B -#define SKY_ErrWrongCryptoType 0x0B00000C -#define SKY_ErrWalletNotExist 0x0B00000D -#define SKY_ErrSeedUsed 0x0B00000E -#define SKY_ErrWalletAPIDisabled 0x0B00000F -#define SKY_ErrSeedAPIDisabled 0x0B000010 -#define SKY_ErrWalletNameConflict 0x0B000011 -#define SKY_ErrInvalidHoursSelectionMode 0x0B000012 -#define SKY_ErrInvalidHoursSelectionType 0x0B000013 -#define SKY_ErrUnknownAddress 0x0B000014 -#define SKY_ErrUnknownUxOut 0x0B000015 -#define SKY_ErrNoUnspents 0x0B000016 -#define SKY_ErrNullChangeAddress 0x0B000017 -#define SKY_ErrMissingTo 0x0B000018 -#define SKY_ErrZeroCoinsTo 0x0B000019 -#define SKY_ErrNullAddressTo 0x0B00001A -#define SKY_ErrDuplicateTo 0x0B00001B -#define SKY_ErrMissingWalletID 0x0B00001C -#define SKY_ErrIncludesNullAddress 0x0B00001D -#define SKY_ErrDuplicateAddresses 0x0B00001E -#define SKY_ErrZeroToHoursAuto 0x0B00001F -#define SKY_ErrMissingModeAuto 0x0B000020 -#define SKY_ErrInvalidHoursSelMode 0x0B000021 -#define SKY_ErrInvalidModeManual 0x0B000022 -#define SKY_ErrInvalidHoursSelType 0x0B000023 -#define SKY_ErrMissingShareFactor 0x0B000024 -#define SKY_ErrInvalidShareFactor 0x0B000025 -#define SKY_ErrShareFactorOutOfRange 0x0B000026 -#define SKY_ErrWalletConstraint 0x0B000027 -#define SKY_ErrDuplicateUxOuts 0x0B000028 -#define SKY_ErrUnknownWalletID 0x0B000029 +#define SKY_ErrHistoryDBCorrupted 0x0A000000 +#define SKY_ErrUxOutNotExist 0x0A000001 +#define SKY_ErrNoHeadBlock 0x0A000002 +#define SKY_ErrMissingSignature 0x0A000003 +#define SKY_ErrUnspentNotExist 0x0A000004 +#define SKY_ErrVerifyStopped 0x0A000005 +#define SKY_ErrCreateBucketFailed 0x0A000000 +#define SKY_ErrBucketNotExist 0x0A000006 +#define SKY_ErrTxnViolatesHardConstraint 0x0A000007 +#define SKY_ErrTxnViolatesSoftConstraint 0x0A000008 +#define SKY_ErrTxnViolatesUserConstraint 0x0A000009 +#define SKY_ErrInsufficientBalance 0x0B000000 +#define SKY_ErrInsufficientHours 0x0B000001 +#define SKY_ErrZeroSpend 0x0B000002 +#define SKY_ErrSpendingUnconfirmed 0x0B000003 +#define SKY_ErrInvalidEncryptedField 0x0B000004 +#define SKY_ErrWalletEncrypted 0x0B000005 +#define SKY_ErrWalletNotEncrypted 0x0B000006 +#define SKY_ErrMissingPassword 0x0B000007 +#define SKY_ErrMissingEncrypt 0x0B000008 +#define SKY_ErrInvalidPassword 0x0B000009 +#define SKY_ErrMissingSeed 0x0B00000A +#define SKY_ErrMissingAuthenticated 0x0B00000B +#define SKY_ErrWrongCryptoType 0x0B00000C +#define SKY_ErrWalletNotExist 0x0B00000D +#define SKY_ErrSeedUsed 0x0B00000E +#define SKY_ErrWalletAPIDisabled 0x0B00000F +#define SKY_ErrSeedAPIDisabled 0x0B000010 +#define SKY_ErrWalletNameConflict 0x0B000011 +#define SKY_ErrInvalidHoursSelectionMode 0x0B000012 +#define SKY_ErrInvalidHoursSelectionType 0x0B000013 +#define SKY_ErrUnknownAddress 0x0B000014 +#define SKY_ErrUnknownUxOut 0x0B000015 +#define SKY_ErrNoUnspents 0x0B000016 +#define SKY_ErrNullChangeAddress 0x0B000017 +#define SKY_ErrMissingTo 0x0B000018 +#define SKY_ErrZeroCoinsTo 0x0B000019 +#define SKY_ErrNullAddressTo 0x0B00001A +#define SKY_ErrDuplicateTo 0x0B00001B +#define SKY_ErrMissingWalletID 0x0B00001C +#define SKY_ErrIncludesNullAddress 0x0B00001D +#define SKY_ErrDuplicateAddresses 0x0B00001E +#define SKY_ErrZeroToHoursAuto 0x0B00001F +#define SKY_ErrMissingModeAuto 0x0B000020 +#define SKY_ErrInvalidHoursSelMode 0x0B000021 +#define SKY_ErrInvalidModeManual 0x0B000022 +#define SKY_ErrInvalidHoursSelType 0x0B000023 +#define SKY_ErrMissingShareFactor 0x0B000024 +#define SKY_ErrInvalidShareFactor 0x0B000025 +#define SKY_ErrShareFactorOutOfRange 0x0B000026 +#define SKY_ErrWalletConstraint 0x0B000027 +#define SKY_ErrDuplicateUxOuts 0x0B000028 +#define SKY_ErrUnknownWalletID 0x0B000029 +#define SKY_ErrSHA256orMissingPassword 0x0B00002A +#define SKY_ErrSHA256LenghtDataOverflowMaxUint32 0x0B00002B #endif - diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go index aa4f1bc6a6..6ee24cedda 100644 --- a/lib/cgo/cipher.encrypt.sha256xor.go +++ b/lib/cgo/cipher.encrypt.sha256xor.go @@ -18,7 +18,7 @@ import "C" //export SKY_encrypt_Sha256Xor_Encrypt func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -35,7 +35,7 @@ func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSl //export SKY_encrypt_Sha256Xor_Decrypt func SKY_encrypt_Sha256Xor_Decrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go index d29d496b5c..c65f7ad25a 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go @@ -17,7 +17,7 @@ import "C" //export SKY_secp256k1go_Field_String func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -29,7 +29,7 @@ func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) //export SKY_secp256k1go_Field_Print func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -41,7 +41,7 @@ func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____er //export SKY_secp256k1go_Field_SetB32 func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -53,7 +53,7 @@ func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____err //export SKY_secp256k1go_Field_SetBytes func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -65,7 +65,7 @@ func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____e //export SKY_secp256k1go_Field_SetHex func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -77,7 +77,7 @@ func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____err //export SKY_secp256k1go_Field_IsOdd func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -89,7 +89,7 @@ func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____er //export SKY_secp256k1go_Field_IsZero func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -101,7 +101,7 @@ func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____e //export SKY_secp256k1go_Field_SetInt func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -113,7 +113,7 @@ func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____err //export SKY_secp256k1go_Field_Normalize func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -124,7 +124,7 @@ func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code //export SKY_secp256k1go_Field_GetB32 func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -136,7 +136,7 @@ func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____err //export SKY_secp256k1go_Field_Equals func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__Field, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -149,7 +149,7 @@ func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__ //export SKY_secp256k1go_Field_SetAdd func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -161,7 +161,7 @@ func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__ //export SKY_secp256k1go_Field_MulInt func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -173,7 +173,7 @@ func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____err //export SKY_secp256k1go_Field_Negate func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field, _m uint32) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -186,7 +186,7 @@ func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ //export SKY_secp256k1go_Field_Inv func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -198,7 +198,7 @@ func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fie //export SKY_secp256k1go_Field_Sqrt func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -210,7 +210,7 @@ func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fi //export SKY_secp256k1go_Field_InvVar func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -222,7 +222,7 @@ func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ //export SKY_secp256k1go_Field_Mul func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -235,7 +235,7 @@ func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go_ //export SKY_secp256k1go_Field_Sqr func SKY_secp256k1go_Field_Sqr(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go index b9416d99e1..9236ffa50d 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1.go @@ -18,7 +18,7 @@ import "C" //export SKY_secp256k1_GenerateKeyPair func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -30,7 +30,7 @@ func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____er //export SKY_secp256k1_PubkeyFromSeckey func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -42,7 +42,7 @@ func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____erro //export SKY_secp256k1_UncompressPubkey func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -54,7 +54,7 @@ func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____erro //export SKY_secp256k1_UncompressedPubkeyFromSeckey func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -66,7 +66,7 @@ func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice //export SKY_secp256k1_Secp256k1Hash func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -78,7 +78,7 @@ func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_cod //export SKY_secp256k1_GenerateDeterministicKeyPair func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -91,7 +91,7 @@ func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, //export SKY_secp256k1_DeterministicKeyPairIterator func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -105,7 +105,7 @@ func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice //export SKY_secp256k1_Sign func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -118,7 +118,7 @@ func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____err //export SKY_secp256k1_SignDeterministic func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []byte, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -132,7 +132,7 @@ func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []b //export SKY_secp256k1_VerifySeckey func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -144,7 +144,7 @@ func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint //export SKY_secp256k1_VerifyPubkey func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -156,7 +156,7 @@ func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint //export SKY_secp256k1_VerifySignatureValidity func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -168,7 +168,7 @@ func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_c //export SKY_secp256k1_VerifySignature func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -182,7 +182,7 @@ func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _a //export SKY_secp256k1_SignatureErrorString func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -196,7 +196,7 @@ func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byt //export SKY_secp256k1_RecoverPubkey func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -209,7 +209,7 @@ func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (_ //export SKY_secp256k1_ECDH func SKY_secp256k1_ECDH(_pub []byte, _sec []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 82313cdedc..a874820f2f 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -6,6 +6,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/base58" "github.com/skycoin/skycoin/src/cipher/encoder" + "github.com/skycoin/skycoin/src/cipher/encrypt" "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" @@ -375,6 +376,26 @@ const ( SKY_ErrDuplicateUxOuts // SKY_ErrUnknownWalletID params.Wallet.ID does not match wallet SKY_ErrUnknownWalletID + // SKY_ErrSHA256orMissingPassword missing password + SKY_ErrSHA256orMissingPassword + // SKY_ErrSHA256LenghtDataOverflowMaxUint32 data length overflowed, it must <= math.MaxUint32(4294967295) + SKY_ErrLenghtDataOverflowMaxUint32 + // SKY_ErrInvalidChecksumLength invalid checksum length + SKY_ErrInvalidChecksumLength + // SKY_ErrInvalidDataChecksumNotMatched invalid data, checksum is not matched + SKY_ErrInvalidDataChecksumNotMatched + // SKY_ErrInvalidNonceLength invalid nonce length + SKY_ErrInvalidNonceLength + // SKY_ErrInvalidBlockSizeMultiple32Bytes invalid block size, must be multiple of 32 bytes + SKY_ErrInvalidBlockSizeMultiple32Bytes + // SKY_ErrReadDataHashFailedLength read data hash failed: read length != 32 + SKY_ErrReadDataHashFailedLength + // SKY_ErrSHA256orInvalidPassword invalid password SHA256or + SKY_ErrSHA256orInvalidPassword + // SKY_ErrReadDataLengthFailed read data length failed + SKY_ErrReadDataLengthFailed + // SKY_ErrInvalidDataLength invalid data length + SKY_ErrInvalidDataLength ) var ( @@ -458,7 +479,6 @@ var ( gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, - gnet.ErrMaxDefaultConnectionsReached: SKY_ErrMaxDefaultConnectionsReached, daemon.ErrDisconnectInvalidVersion: SKY_ErrDisconnectInvalidVersion, daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, daemon.ErrDisconnectVersionSendFailed: SKY_ErrDisconnectVersionSendFailed, @@ -526,6 +546,17 @@ var ( wallet.ErrWalletConstraint: SKY_ErrWalletConstraint, wallet.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts, wallet.ErrUnknownWalletID: SKY_ErrUnknownWalletID, + // Encrypt + encrypt.ErrSHA256orMissingPassword: SKY_ErrSHA256orMissingPassword, + encrypt.ErrLenghtDataOverflowMaxUint32: SKY_ErrLenghtDataOverflowMaxUint32, + encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, + encrypt.ErrInvalidDataChecksumNotMatched: SKY_ErrInvalidDataChecksumNotMatched, + encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, + encrypt.ErrInvalidBlockSizeMultiple32Bytes: SKY_ErrInvalidBlockSizeMultiple32Bytes, + encrypt.ErrReadDataHashFailedLength: SKY_ErrReadDataHashFailedLength, + encrypt.ErrSHA256orInvalidPassword: SKY_ErrSHA256orInvalidPassword, + encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, + encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, } ) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 1c6809242e..0880ab48ea 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -1,7 +1,7 @@ #include #include - +#include #include #include @@ -431,7 +431,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_ErrAddressInvalidVersion, "Invalid version"); } -Test(cipher_address, TestMustDecodeBase58Address) { +Test(cipher_address, TestMustDecodeBase58Address, .signal = ((__linux__) ? SIGABRT : 2)) { cipher__PubKey p; cipher__SecKey s; diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 9d6f141e62..9f92d5e39e 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -169,7 +169,7 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); } else { - cr_assert(errcode == SKY_ERROR, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); + cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); } if( errcode == SKY_OK ){ cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); @@ -280,7 +280,7 @@ Test(cipher_encrypt_sha256xor, TestDecrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); } else { - cr_assert(errcode == SKY_ERROR, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful."); + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful. %x\n",errcode); } } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c index 3e2fadf77b..c811248fdb 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c @@ -12,11 +12,11 @@ #include "skytest.h" #define BUFFER_SIZE 128 -#define TESTS 1 +#define TESTS 1 #define SigSize 65 int keys_count = 4; -const char* test_keys[] = { +const char *test_keys[] = { "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", @@ -24,7 +24,8 @@ const char* test_keys[] = { }; //test size of messages -Test(cipher_secp256k1, Test_Secp256_02s){ +Test(cipher_secp256k1, Test_Secp256_02s) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferSec1[BUFFER_SIZE]; @@ -32,26 +33,27 @@ Test(cipher_secp256k1, Test_Secp256_02s){ unsigned char buff[32]; GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char*) sig.data)[64]; - cr_assert( last <= 4 ); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last <= 4); } //test signing message -Test(cipher_secp256k1, Test_Secp256_02){ +Test(cipher_secp256k1, Test_Secp256_02) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; @@ -61,23 +63,23 @@ Test(cipher_secp256k1, Test_Secp256_02){ GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - + GoInt result; error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); @@ -85,7 +87,8 @@ Test(cipher_secp256k1, Test_Secp256_02){ } //test pubkey recovery -Test(cipher_secp256k1, Test_Secp256_02a){ +Test(cipher_secp256k1, Test_Secp256_02a) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; @@ -95,30 +98,31 @@ Test(cipher_secp256k1, Test_Secp256_02a){ GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); GoInt result; error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); cr_assert(result, "Signature invalid"); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); } //test random messages for the same pub/private key -Test(cipher_secp256k1, Test_Secp256_03){ +Test(cipher_secp256k1, Test_Secp256_03) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; @@ -128,29 +132,31 @@ Test(cipher_secp256k1, Test_Secp256_03){ GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for( int i = 0; i < TESTS; i++ ) { + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(pub2.len > 0, "Invalid public key"); } } //test random messages for different pub/private keys -Test(cipher_secp256k1, Test_Secp256_04){ +Test(cipher_secp256k1, Test_Secp256_04) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; @@ -160,69 +166,81 @@ Test(cipher_secp256k1, Test_Secp256_04){ GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for( int i = 0; i < TESTS; i++ ) { + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char*) sig.data)[64]; - cr_assert( last < 4 ); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last < 4); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(pub2.len > 0, "Invalid public key"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); } } -Test(cipher_secp256k1, Test_Secp256_06a_alt0){ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - GoInt result; - for(int i = 0; i < TESTS; i++){ - error_code = SKY_secp256k1_RandByte(65, (coin__UxArray*)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - ((unsigned char*)sig.data)[32] = ((unsigned char*)sig.data)[32] & 0x70; - ((unsigned char*)sig.data)[64] = ((unsigned char*)sig.data)[64] % 4; - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); - SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); - cr_assert(pub2.len == 0 || result, "Public key is not valid"); - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(result == 0, "Public key should not be valid"); - } -} +// Test(cipher_secp256k1, Test_Secp256_06a_alt0) +// { +// GoInt32 error_code; +// char bufferPub1[BUFFER_SIZE]; +// char bufferPub2[BUFFER_SIZE]; +// char bufferSec1[BUFFER_SIZE]; +// char bufferSig1[BUFFER_SIZE]; +// unsigned char buff[32]; +// GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; +// GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; +// GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; +// GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; +// GoSlice msg = {buff, 0, 32}; +// char SecUxArrayBuffer[BUFFER_SIZE]; +// char PubUxArrayBuffer[BUFFER_SIZE]; +// coin__UxArray SecUxArray = {SecUxArrayBuffer, 0, BUFFER_SIZE}; +// coin__UxArray PubUxArray = {PubUxArrayBuffer, 0, BUFFER_SIZE}; -Test(cipher_secp256k1, Test_Secp256_06b){ +// error_code = SKY_secp256k1_GenerateKeyPair(&SecUxArray, &PubUxArray); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); +// error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); +// copySlice(&SecUxArray, (GoSlice_ *)&sec1, sizeof(coin__UxArray)); +// error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); +// cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + +// for (int i = 0; i < TESTS; i++) +// { +// GoInt result; +// error_code = SKY_secp256k1_RandByte(65, (coin__UxArray *)&sig); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); +// cr_assert(sig.len == 65, "Signature should be 65 bytes long."); +// ((unsigned char *)sig.data)[32] = ((unsigned char *)sig.data)[32] & 0x70; +// ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; +// char bufferpub3[1024]; +// GoSlice pub3 = {bufferpub3, 0, 1024}; +// error_code = SKY_secp256k1_RecoverPubkey(msg, sig, &pub3); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); +// cr_assert(cr_user_GoSlice_noteq(&pub1, &pub3), "Public keys must be different."); +// GoSlice pub2convert = {pub3.data, pub3.len, pub3.cap}; +// error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2convert, &result); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); +// cr_assert(pub3.len == 0 || result, "Public key is not valid"); +// error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); +// cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature"); +// cr_assert(result == 0, "Public key should not be valid"); +// } +// } + +Test(cipher_secp256k1, Test_Secp256_06b) +{ GoInt32 error_code; char bufferPub1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; @@ -232,22 +250,23 @@ Test(cipher_secp256k1, Test_Secp256_06b){ GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pub1, (coin__UxArray*)&sec1); + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_*)&sig); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - + GoInt result; - for(int i = 0; i < TESTS; i++){ - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&pub2); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); @@ -257,14 +276,15 @@ Test(cipher_secp256k1, Test_Secp256_06b){ } } -Test(cipher_secp256k1, Test_Deterministic_Keypairs_00){ +Test(cipher_secp256k1, Test_Deterministic_Keypairs_00) +{ char bufferSeed[BUFFER_SIZE]; char bufferHash[BUFFER_SIZE]; char bufferPub1[BUFFER_SIZE]; char bufferSec1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; char bufferSec2[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; @@ -272,32 +292,34 @@ Test(cipher_secp256k1, Test_Deterministic_Keypairs_00){ GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; GoInt32 error_code; - - for( int i = 0; i < 64; i++){ - error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&hash, - (coin__UxArray*)&pub1, - (coin__UxArray*)&sec1); + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray*)&pub2, - (coin__UxArray*)&sec2); + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); } } -Test(cipher_secp256k1, Test_Deterministic_Keypairs_01){ +Test(cipher_secp256k1, Test_Deterministic_Keypairs_01) +{ char bufferSeed[BUFFER_SIZE]; char bufferHash[BUFFER_SIZE]; char bufferPub1[BUFFER_SIZE]; char bufferSec1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; char bufferSec2[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; @@ -305,32 +327,34 @@ Test(cipher_secp256k1, Test_Deterministic_Keypairs_01){ GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; GoInt32 error_code; - - for( int i = 0; i < 64; i++){ - error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&hash, - (coin__UxArray*)&pub1, - (coin__UxArray*)&sec1); + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray*)&pub2, - (coin__UxArray*)&sec2); + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); } } -Test(cipher_secp256k1, Test_Deterministic_Keypairs_02){ +Test(cipher_secp256k1, Test_Deterministic_Keypairs_02) +{ char bufferSeed[BUFFER_SIZE]; char bufferHash[BUFFER_SIZE]; char bufferPub1[BUFFER_SIZE]; char bufferSec1[BUFFER_SIZE]; char bufferPub2[BUFFER_SIZE]; char bufferSec2[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; @@ -338,89 +362,125 @@ Test(cipher_secp256k1, Test_Deterministic_Keypairs_02){ GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; GoInt32 error_code; - - for( int i = 0; i < 64; i++){ - error_code = SKY_secp256k1_RandByte( 32, (coin__UxArray*)&seed); + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&hash, - (coin__UxArray*)&pub1, - (coin__UxArray*)&sec1); + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray*)&pub2, - (coin__UxArray*)&sec2); + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); } } -Test(cipher_secp256k1, Test_Deterministic_Keypairs_03){ +Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) +{ int test_count = 16; - const char* testArray[] = { - "tQ93w5Aqcunm9SGUfnmF4fJv", "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", - "DC7qdQQtbWSSaekXnFmvQgse", "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", - "X8EkuUZC7Td7PAXeS7Duc7vR", "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", - "tVqPYHHNVPRWyEed62v7f23u", "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", - "kCy4R57HDfLqF3pVhBWxuMcg", "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", - "j8bjv86ZNjKqzafR6mtSUVCE", "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", - "qShryAzVY8EtsuD3dsAc7qnG", "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", - "5FGG7ZBa8wVMBJkmzpXj5ESX", "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", - "f46TZG4xJHXUGWx8ekbNqa9F", "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", - "XkZdQJ5LT96wshN8JBH8rvEt", "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", - "GFDqXU4zYymhJJ9UGqRgS8ty", "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", - "tmwZksH2XyvuamnddYxyJ5Lp", "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", - "EuqZFsbAV5amTzkhgAMgjr7W", "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", - "TW6j8rMffZfmhyDEt2JUCrLB", "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", - "8rvkBnygfhWP8kjX9aXq68CY", "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", - "phyRfPDuf9JMRFaWdGh7NXPX", "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", + const char *testArray[] = { + "tQ93w5Aqcunm9SGUfnmF4fJv", + "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", + "DC7qdQQtbWSSaekXnFmvQgse", + "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", + "X8EkuUZC7Td7PAXeS7Duc7vR", + "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", + "tVqPYHHNVPRWyEed62v7f23u", + "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", + "kCy4R57HDfLqF3pVhBWxuMcg", + "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", + "j8bjv86ZNjKqzafR6mtSUVCE", + "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", + "qShryAzVY8EtsuD3dsAc7qnG", + "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", + "5FGG7ZBa8wVMBJkmzpXj5ESX", + "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", + "f46TZG4xJHXUGWx8ekbNqa9F", + "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", + "XkZdQJ5LT96wshN8JBH8rvEt", + "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", + "GFDqXU4zYymhJJ9UGqRgS8ty", + "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", + "tmwZksH2XyvuamnddYxyJ5Lp", + "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", + "EuqZFsbAV5amTzkhgAMgjr7W", + "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", + "TW6j8rMffZfmhyDEt2JUCrLB", + "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", + "8rvkBnygfhWP8kjX9aXq68CY", + "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", + "phyRfPDuf9JMRFaWdGh7NXPX", + "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", }; - + GoInt32 error_code; char bufferSec1[BUFFER_SIZE]; char bufferSec2[BUFFER_SIZE]; char buffer1[BUFFER_SIZE]; char buffer2[BUFFER_SIZE]; - + GoSlice seed = {NULL, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for(int i = 0; i < test_count; i++){ - seed.data = (void*)testArray[2 * i]; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + seed.data = (void *)testArray[2 * i]; seed.len = strlen(testArray[2 * i]); seed.cap = seed.len; sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&s1, (coin__UxArray*)&s2, - (coin__UxArray*)&sec2); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&s1, (coin__UxArray *)&s2, + (coin__UxArray *)&sec2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); } } -Test(cipher_secp256k1, Test_DeterministicWallets1){ +Test(cipher_secp256k1, Test_DeterministicWallets1) +{ int test_count = 16; - const char* testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", }; GoInt32 error_code; char bufferSeed[BUFFER_SIZE]; @@ -428,43 +488,61 @@ Test(cipher_secp256k1, Test_DeterministicWallets1){ char bufferSec2[BUFFER_SIZE]; char buffer1[BUFFER_SIZE]; char buffer2[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for(int i = 0; i < test_count; i++){ + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&s1, (coin__UxArray*)&s2, - (coin__UxArray*)&sec2); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&s1, (coin__UxArray *)&s2, + (coin__UxArray *)&sec2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); } } -Test(cipher_secp256k1, Test_Secp256k1_Hash){ +Test(cipher_secp256k1, Test_Secp256k1_Hash) +{ int test_count = 16; - const char* testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", }; GoInt32 error_code; char bufferHash1[BUFFER_SIZE]; @@ -473,164 +551,173 @@ Test(cipher_secp256k1, Test_Secp256k1_Hash){ GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; - - for(int i = 0; i < test_count; i++){ + + for (int i = 0; i < test_count; i++) + { hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); - error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray*)&hash3); + error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray *)&hash3); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); } } - -Test(cipher_secp256k1, Test_Secp256k1_Equal){ +Test(cipher_secp256k1, Test_Secp256k1_Equal) +{ char bufferSeed[BUFFER_SIZE]; char bufferHash1[BUFFER_SIZE]; char bufferHash2[BUFFER_SIZE]; char bufferPrivate[BUFFER_SIZE]; char bufferPublic[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; GoInt32 error_code; - - for(int i = 0; i < 64; i++) { - error_code = SKY_secp256k1_RandByte( 128, (coin__UxArray*)&seed); + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(128, (coin__UxArray *)&seed); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray*)&hash1); + error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray *)&hash1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&hash2, - (coin__UxArray*)&public, - (coin__UxArray*)&private); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&hash2, + (coin__UxArray *)&public, + (coin__UxArray *)&private); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); } } -Test(cipher_secp256k1, Test_DeterministicWalletGeneration){ - const char* pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; - const char* pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; - const char* pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; - +Test(cipher_secp256k1, Test_DeterministicWalletGeneration) +{ + const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; + const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; + const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; + char bufferSeed[BUFFER_SIZE]; char bufferPrivate[BUFFER_SIZE]; char bufferPublic[BUFFER_SIZE]; char bufferNewSeed[BUFFER_SIZE]; char bufferPrivateExpected[BUFFER_SIZE]; char bufferPublicExpected[BUFFER_SIZE]; - + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; - + strcpy(bufferSeed, pSeed); seed.len = strlen(pSeed); - + GoInt32 error_code; - - for( int i = 0; i < 1024; i++ ) { - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray*)&newSeed, - (coin__UxArray*)&public, - (coin__UxArray*)&private); + + for (int i = 0; i < 1024; i++) + { + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&newSeed, + (coin__UxArray *)&public, + (coin__UxArray *)&private); cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - memcpy( seed.data, newSeed.data, newSeed.len); + memcpy(seed.data, newSeed.data, newSeed.len); seed.len = newSeed.len; } - + privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); - + cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); } -Test(cipher_secp256k1, Test_ECDH) { +Test(cipher_secp256k1, Test_ECDH) +{ cipher__PubKey pubkey1; cipher__SecKey seckey1; cipher__PubKey pubkey2; cipher__SecKey seckey2; unsigned char bufferECDH1[BUFFER_SIZE]; unsigned char bufferECDH2[BUFFER_SIZE]; - + GoInt32 error_code; GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; - GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; - + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); } -Test(cipher_secp256k1, Test_ECDH2) { +Test(cipher_secp256k1, Test_ECDH2) +{ cipher__PubKey pubkey1; cipher__SecKey seckey1; cipher__PubKey pubkey2; cipher__SecKey seckey2; unsigned char bufferECDH1[BUFFER_SIZE]; unsigned char bufferECDH2[BUFFER_SIZE]; - + GoInt32 error_code; GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; - GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; - - for( int i = 0; i < 32; i++ ) { + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + + for (int i = 0; i < 32; i++) + { error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pubKeySlice1, (coin__UxArray*)&secKeySlice1); + (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray*)&pubKeySlice2, (coin__UxArray*)&secKeySlice2); + (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray*)&ecdh1); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray*)&ecdh2); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); } } -Test(cipher_secp256k1, Test_Abnormal_Keys) { +Test(cipher_secp256k1, Test_Abnormal_Keys) +{ char seedBuffer[64]; GoSlice seed = {seedBuffer, 0, 64}; unsigned char bufferPrivatekey[BUFFER_SIZE]; unsigned char bufferPubKey[BUFFER_SIZE]; - GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; - GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; GoInt32 error_code; - - for( int i = 0; i < 32; i++ ) { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray*)&seed); + + for (int i = 0; i < 32; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray*)&privatekey, (coin__UxArray*)& pubKey); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray *)&privatekey, (coin__UxArray *)&pubKey); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); GoInt verified = 0; error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); @@ -639,18 +726,20 @@ Test(cipher_secp256k1, Test_Abnormal_Keys) { } } -Test(cipher_secp256k1, Test_Abnormal_Keys2) { +Test(cipher_secp256k1, Test_Abnormal_Keys2) +{ unsigned char bufferPrivatekey[BUFFER_SIZE]; unsigned char bufferPubKey[BUFFER_SIZE]; - - GoSlice privatekey = { bufferPrivatekey, 0, BUFFER_SIZE }; - GoSlice pubKey = { bufferPubKey, 0, BUFFER_SIZE }; + + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; GoInt32 error_code; - - for(int i = 0; i < keys_count; i++){ + + for (int i = 0; i < keys_count; i++) + { int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); privatekey.len = sizePrivatekey; - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray*)&pubKey); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray *)&pubKey); cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); GoInt verified = 0; @@ -660,43 +749,45 @@ Test(cipher_secp256k1, Test_Abnormal_Keys2) { } } -Test(cipher_secp256k1, Test_Abnormal_Keys3) { +Test(cipher_secp256k1, Test_Abnormal_Keys3) +{ unsigned char bufferPrivatekey1[BUFFER_SIZE]; unsigned char bufferPubKey1[BUFFER_SIZE]; unsigned char bufferPrivatekey2[BUFFER_SIZE]; unsigned char bufferPubKey2[BUFFER_SIZE]; unsigned char bufferECDH1[BUFFER_SIZE]; unsigned char bufferECDH2[BUFFER_SIZE]; - + int sizePrivatekey1, sizePrivatekey2; int sizePubKey1, sizePubKey2; - GoSlice privatekey1 = { bufferPrivatekey1, 0, BUFFER_SIZE }; - GoSlice privatekey2 = { bufferPrivatekey2, 0, BUFFER_SIZE }; - GoSlice pubKey1 = { bufferPubKey1, 0, BUFFER_SIZE }; - GoSlice pubKey2 = { bufferPubKey2, 0, BUFFER_SIZE }; - GoSlice ecdh1 = { bufferECDH1, 0, BUFFER_SIZE }; - GoSlice ecdh2 = { bufferECDH2, 0, BUFFER_SIZE }; + GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; + GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; + GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; + GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; GoInt32 error_code; - - for(int i = 0; i < keys_count; i++){ + + for (int i = 0; i < keys_count; i++) + { int randn = rand() % keys_count; sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); privatekey1.len = sizePrivatekey1; privatekey2.len = sizePrivatekey2; - - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray*)&pubKey1); + + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray *)&pubKey1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray*)&pubKey2); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray *)&pubKey2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - - SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray*)&ecdh1); + + SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray *)&ecdh1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray*)&ecdh2); + SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray *)&ecdh2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); } } \ No newline at end of file diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 4b3ef14256..e2410a5d88 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -329,7 +329,6 @@ Test(coin_outputs, TestUxArraySub){ cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); cutSlice(&uxa, 0, 2, elems_size, &t1); cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); - //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxd), *((GoSlice*)&t1)) ); // No intersection memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); @@ -341,8 +340,6 @@ Test(coin_outputs, TestUxArraySub){ registerMemCleanup( t2.data ); cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); - //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxa), *((GoSlice*)&t1)) ); - //cr_assert( eq( type(GoSlice), *((GoSlice*)&uxb), *((GoSlice*)&t2)) ); } int isUxArraySorted(coin__UxArray* uxa){ diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index d54f651b29..87ee4cd875 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -1,7 +1,7 @@ #include #include - +#include #include #include @@ -17,7 +17,8 @@ TestSuite(coin_transaction, .init = setup, .fini = teardown); GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; GoUint64 Million = 1000000; -Test(coin_transaction, TestTransactionVerify) { +Test(coin_transaction, TestTransactionVerify) +{ int result; coin__Transaction *ptx; Transaction__Handle handle; @@ -25,7 +26,7 @@ Test(coin_transaction, TestTransactionVerify) { ptx = makeTransaction(&handle); memset(ptx->InnerHash, 0, sizeof(cipher__SHA256)); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result == SKY_ERROR); + cr_assert(result == SKY_ERROR); // No inputs ptx = makeTransaction(&handle); @@ -113,7 +114,7 @@ Test(coin_transaction, TestTransactionVerify) { ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result == SKY_ERROR); + cr_assert(result == SKY_ErrInvalidSigForPubKey); // Output coins are 0 ptx = makeTransaction(&handle); @@ -167,7 +168,8 @@ Test(coin_transaction, TestTransactionVerify) { cr_assert(result == SKY_OK); } -Test(coin_transaction, TestTransactionPushInput) { +Test(coin_transaction, TestTransactionPushInput, .signal = SIGABRT) +{ int result; Transaction__Handle handle; coin__Transaction *ptx; @@ -202,7 +204,8 @@ Test(coin_transaction, TestTransactionPushInput) { cr_assert(result == SKY_ERROR); } -Test(coin_transaction, TestTransactionPushOutput) { +Test(coin_transaction, TestTransactionPushOutput) +{ int result; Transaction__Handle handle; coin__Transaction *ptx; @@ -219,7 +222,8 @@ Test(coin_transaction, TestTransactionPushOutput) { output.Coins = 100; output.Hours = 150; cr_assert(eq(type(coin__TransactionOutput), output, *pOutput)); - for (int i = 1; i < 20; i++) { + for (int i = 1; i < 20; i++) + { makeAddress(&addr); result = SKY_coin_Transaction_PushOutput(handle, &addr, i * 100, i * 50); cr_assert(result == SKY_OK); @@ -233,7 +237,8 @@ Test(coin_transaction, TestTransactionPushOutput) { } } -Test(coin_transaction, TestTransactionHash) { +Test(coin_transaction, TestTransactionHash) +{ int result; Transaction__Handle handle; coin__Transaction *ptx; @@ -249,7 +254,8 @@ Test(coin_transaction, TestTransactionHash) { cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash2, hash1))); } -Test(coin_transaction, TestTransactionUpdateHeader) { +Test(coin_transaction, TestTransactionUpdateHeader) +{ int result; Transaction__Handle handle; coin__Transaction *ptx; @@ -266,13 +272,15 @@ Test(coin_transaction, TestTransactionUpdateHeader) { cr_assert(eq(u8[sizeof(cipher__SHA256)], hashInner, ptx->InnerHash)); } -Test(coin_transaction, TestTransactionsSize) { +Test(coin_transaction, TestTransactionsSize) +{ int result; Transactions__Handle txns; result = makeTransactions(10, &txns); cr_assert(result == SKY_OK); GoInt size = 0; - for (size_t i = 0; i < 10; i++) { + for (size_t i = 0; i < 10; i++) + { Transaction__Handle handle; result = SKY_coin_Transactions_GetAt(txns, i, &handle); registerHandleClose(handle); @@ -290,7 +298,8 @@ Test(coin_transaction, TestTransactionsSize) { cr_assert(sizeTransactions == size); } -Test(coin_transactions, TestTransactionVerifyInput) { +Test(coin_transactions, TestTransactionVerifyInput, .signal = SIGABRT) +{ int result; Transaction__Handle handle; coin__Transaction *ptx; @@ -392,7 +401,8 @@ Test(coin_transactions, TestTransactionVerifyInput) { cr_assert(result == SKY_OK); } -Test(coin_transactions, TestTransactionSignInputs) { +Test(coin_transactions, TestTransactionSignInputs, .signal = SIGABRT) +{ int result; coin__Transaction *ptx; Transaction__Handle handle; @@ -486,7 +496,8 @@ Test(coin_transactions, TestTransactionSignInputs) { cr_assert(result == SKY_ERROR); } -Test(coin_transactions, TestTransactionHashInner) { +Test(coin_transactions, TestTransactionHashInner) +{ int result; Transaction__Handle handle1 = 0, handle2 = 0; coin__Transaction *ptx = NULL; @@ -552,7 +563,8 @@ Test(coin_transactions, TestTransactionHashInner) { cr_assert(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)); } -Test(coin_transactions, TestTransactionSerialization) { +Test(coin_transactions, TestTransactionSerialization) +{ int result; coin__Transaction *ptx; Transaction__Handle handle; @@ -572,7 +584,8 @@ Test(coin_transactions, TestTransactionSerialization) { cr_assert(eq(type(coin__Transaction), *ptx, *ptx2)); } -Test(coin_transactions, TestTransactionOutputHours) { +Test(coin_transactions, TestTransactionOutputHours) +{ coin__Transaction *ptx; Transaction__Handle handle; ptx = makeEmptyTransaction(&handle); @@ -601,7 +614,8 @@ Test(coin_transactions, TestTransactionOutputHours) { cr_assert(result == SKY_ERROR); } -Test(coin_transactions, TestTransactionsHashes) { +Test(coin_transactions, TestTransactionsHashes) +{ int result; GoSlice_ hashes = {NULL, 0, 0}; Transactions__Handle hTxns; @@ -614,7 +628,8 @@ Test(coin_transactions, TestTransactionsHashes) { cr_assert(hashes.len == 4); cipher__SHA256 *ph = hashes.data; cipher__SHA256 hash; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) + { Transaction__Handle handle; result = SKY_coin_Transactions_GetAt(hTxns, i, &handle); cr_assert(result == SKY_OK); @@ -625,7 +640,8 @@ Test(coin_transactions, TestTransactionsHashes) { } } -Test(coin_transactions, TestTransactionsTruncateBytesTo) { +Test(coin_transactions, TestTransactionsTruncateBytesTo) +{ int result; Transactions__Handle h1, h2; result = makeTransactions(10, &h1); @@ -635,7 +651,8 @@ Test(coin_transactions, TestTransactionsTruncateBytesTo) { cr_assert(result == SKY_OK); int trunc = 0; GoInt size; - for (int i = 0; i < length / 2; i++) { + for (int i = 0; i < length / 2; i++) + { Transaction__Handle handle; result = SKY_coin_Transactions_GetAt(h1, i, &handle); registerHandleClose(handle); @@ -670,12 +687,14 @@ Test(coin_transactions, TestTransactionsTruncateBytesTo) { cr_assert(trunc - 1 == size); } -typedef struct { +typedef struct +{ GoUint64 coins; GoUint64 hours; } test_ux; -typedef struct { +typedef struct +{ test_ux *inUxs; test_ux *outUxs; int sizeIn; @@ -684,8 +703,10 @@ typedef struct { int failure; } test_case; -int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { - if (size <= 0) { +int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) +{ + if (size <= 0) + { pArray->len = 0; pArray->cap = 0; pArray->data = NULL; @@ -702,7 +723,8 @@ int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { pArray->len = size; pArray->cap = size; coin__UxOut *p = data; - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { p->Body.Coins = elems[i].coins; p->Body.Hours = elems[i].hours; p++; @@ -710,7 +732,8 @@ int makeTestCaseArrays(test_ux *elems, int size, coin__UxArray *pArray) { return SKY_OK; } -Test(coin_transactions, TestVerifyTransactionCoinsSpending) { +Test(coin_transactions, TestVerifyTransactionCoinsSpending) +{ // Input coins overflow test_ux in1[] = {{MaxUint64 - Million + 1, 10}, {Million, 0}}; @@ -736,8 +759,8 @@ Test(coin_transactions, TestVerifyTransactionCoinsSpending) { {in2, out2, 1, 2, 0, 1}, // Output coins overflow {in3, out3, 2, 2, 0, 1}, // Destroyed coins {in4, out4, 1, 1, Million, - 1}, // Invalid (coin hours overflow when adding earned hours, which is - // treated as 0, and now enough coin hours) + 1}, // Invalid (coin hours overflow when adding earned hours, which is + // treated as 0, and now enough coin hours) {in5, out5, 2, 3, 0, 0} // Valid }; @@ -745,7 +768,8 @@ Test(coin_transactions, TestVerifyTransactionCoinsSpending) { coin__UxArray outArray; int result; int count = sizeof(tests) / sizeof(tests[0]); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); cr_assert(result == SKY_OK); result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); @@ -760,7 +784,8 @@ Test(coin_transactions, TestVerifyTransactionCoinsSpending) { } } -Test(coin_transactions, TestVerifyTransactionHoursSpending) { +Test(coin_transactions, TestVerifyTransactionHoursSpending) +{ GoUint64 MaxUint64 = 0xFFFFFFFFFFFFFFFF; GoUint64 Million = 1000000; @@ -811,15 +836,16 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { 0}, // Valid (coin hours overflow when adding earned hours, which is // treated as 0, but not sending any hours) {in6, out6, 2, 2, 1492707255, - 0}, // Valid (base inputs have insufficient coin hours, but have - // sufficient after adjusting coinhours by headTime) + 0}, // Valid (base inputs have insufficient coin hours, but have + // sufficient after adjusting coinhours by headTime) {in7, out7, 2, 3, 0, 0}, // Valid }; coin__UxArray inArray; coin__UxArray outArray; int result; int count = sizeof(tests) / sizeof(tests[0]); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { result = makeTestCaseArrays(tests[i].inUxs, tests[i].sizeIn, &inArray); cr_assert(result == SKY_OK); result = makeTestCaseArrays(tests[i].outUxs, tests[i].sizeOut, &outArray); @@ -835,21 +861,25 @@ Test(coin_transactions, TestVerifyTransactionHoursSpending) { } } -GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ +GoUint32_ fix1FeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void *context) +{ *pFee = 1; return SKY_OK; } -GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ +GoUint32_ badFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void *context) +{ return SKY_ERROR; } -GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ +GoUint32_ overflowFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void *context) +{ *pFee = 0xFFFFFFFFFFFFFFFF; return SKY_OK; } -Test(coin_transactions, TestTransactionsFees) { +Test(coin_transactions, TestTransactionsFees) +{ GoUint64 fee; int result; Transactions__Handle transactionsHandle = 0; @@ -884,68 +914,74 @@ Test(coin_transactions, TestTransactionsFees) { cr_assert(result == SKY_ERROR); } -GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee, void* context){ - coin__Transaction* pTx; - int result = SKY_coin_GetTransactionObject( handle, &pTx ); - if(result == SKY_OK){ +GoUint32_ feeCalculator1(Transaction__Handle handle, GoUint64_ *pFee, void *context) +{ + coin__Transaction *pTx; + int result = SKY_coin_GetTransactionObject(handle, &pTx); + if (result == SKY_OK) + { coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; } return result; } -GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee, void* context){ +GoUint32_ feeCalculator2(Transaction__Handle handle, GoUint64_ *pFee, void *context) +{ *pFee = 100 * Million; return SKY_OK; } void assertTransactionsHandleEqual(Transaction__Handle h1, Transaction__Handle h2, - char* testName){ + char *testName) +{ coin__Transaction *pTx1; coin__Transaction *pTx2; int result; - result = SKY_coin_GetTransactionObject( h1, &pTx1 ); + result = SKY_coin_GetTransactionObject(h1, &pTx1); cr_assert(result == SKY_OK); - result = SKY_coin_GetTransactionObject( h2, &pTx2 ); + result = SKY_coin_GetTransactionObject(h2, &pTx2); cr_assert(result == SKY_OK); cr_assert(eq(type(coin__Transaction), *pTx1, *pTx2), "Failed SortTransactions test \"%s\"", testName); } void testTransactionSorting(Transactions__Handle hTrans, - int* original_indexes, int original_indexes_count, - int* expected_indexes, int expected_indexes_count, FeeCalculator *feeCalc, - char* testName - ){ + int *original_indexes, int original_indexes_count, + int *expected_indexes, int expected_indexes_count, FeeCalculator *feeCalc, + char *testName) +{ - int result; - Transactions__Handle transactionsHandle, sortedTxnsHandle; - Transaction__Handle handle; - makeTransactions(0, &transactionsHandle); - for(int i = 0; i < original_indexes_count; i++){ - result = SKY_coin_Transactions_GetAt(hTrans, original_indexes[i], &handle); - cr_assert(result == SKY_OK); - registerHandleClose(handle); - result = SKY_coin_Transactions_Add(transactionsHandle, handle); - cr_assert(result == SKY_OK); - } - result = SKY_coin_SortTransactions(transactionsHandle, feeCalc, &sortedTxnsHandle); - cr_assert(result == SKY_OK, "SKY_coin_SortTransactions"); - registerHandleClose(sortedTxnsHandle); - Transaction__Handle h1, h2; - for(int i = 0; i < expected_indexes_count; i++){ - int expected_index = expected_indexes[i]; - result = SKY_coin_Transactions_GetAt(sortedTxnsHandle, i, &h1); - cr_assert(result == SKY_OK); - registerHandleClose(h1); - result = SKY_coin_Transactions_GetAt(hTrans, expected_index, &h2); - cr_assert(result == SKY_OK); - registerHandleClose(h2); - assertTransactionsHandleEqual(h1, h2, testName); - } + int result; + Transactions__Handle transactionsHandle, sortedTxnsHandle; + Transaction__Handle handle; + makeTransactions(0, &transactionsHandle); + for (int i = 0; i < original_indexes_count; i++) + { + result = SKY_coin_Transactions_GetAt(hTrans, original_indexes[i], &handle); + cr_assert(result == SKY_OK); + registerHandleClose(handle); + result = SKY_coin_Transactions_Add(transactionsHandle, handle); + cr_assert(result == SKY_OK); + } + result = SKY_coin_SortTransactions(transactionsHandle, feeCalc, &sortedTxnsHandle); + cr_assert(result == SKY_OK, "SKY_coin_SortTransactions"); + registerHandleClose(sortedTxnsHandle); + Transaction__Handle h1, h2; + for (int i = 0; i < expected_indexes_count; i++) + { + int expected_index = expected_indexes[i]; + result = SKY_coin_Transactions_GetAt(sortedTxnsHandle, i, &h1); + cr_assert(result == SKY_OK); + registerHandleClose(h1); + result = SKY_coin_Transactions_GetAt(hTrans, expected_index, &h2); + cr_assert(result == SKY_OK); + registerHandleClose(h2); + assertTransactionsHandleEqual(h1, h2, testName); + } } - -Test(coin_transactions, TestSortTransactions) { +Test(coin_transactions, TestSortTransactions) +{ int n = 6; int i; int result; @@ -958,7 +994,8 @@ Test(coin_transactions, TestSortTransactions) { cipher__Address addr; makeTransactions(0, &transactionsHandle); cipher__SHA256 thirdHash; - for(i = 0; i < 6; i++){ + for (i = 0; i < 6; i++) + { makeEmptyTransaction(&transactionHandle); makeAddress(&addr); result = SKY_coin_Transaction_PushOutput(transactionHandle, &addr, 1000000, i * 1000); @@ -967,7 +1004,8 @@ Test(coin_transactions, TestSortTransactions) { cr_assert(result == SKY_OK); result = SKY_coin_Transactions_Add(transactionsHandle, transactionHandle); cr_assert(result == SKY_OK); - if( i == 2 ){ + if (i == 2) + { result = SKY_coin_Transaction_Hash(transactionHandle, &thirdHash); cr_assert(result == SKY_OK); } @@ -984,15 +1022,20 @@ Test(coin_transactions, TestSortTransactions) { FeeCalculator fc2 = {feeCalculator2, NULL}; testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, &fc2, "hash tiebreaker"); - GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ *pFee, void* context){ + GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ * pFee, void *context) + { cipher__SHA256 hash; int result = SKY_coin_Transaction_Hash(handle, &hash); - if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + { *pFee = MaxUint64 / 2; - } else { - coin__Transaction* pTx; - result = SKY_coin_GetTransactionObject( handle, &pTx ); - if(result == SKY_OK){ + } + else + { + coin__Transaction *pTx; + result = SKY_coin_GetTransactionObject(handle, &pTx); + if (result == SKY_OK) + { coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; } @@ -1004,16 +1047,21 @@ Test(coin_transactions, TestSortTransactions) { FeeCalculator f3 = {feeCalculator3, NULL}; testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, &f3, "invalid fee multiplication is capped"); - GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ *pFee, void* context){ + GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ * pFee, void *context) + { cipher__SHA256 hash; int result = SKY_coin_Transaction_Hash(handle, &hash); - if(result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)){ + if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + { *pFee = 0; result = SKY_ERROR; - } else { - coin__Transaction* pTx; - result = SKY_coin_GetTransactionObject( handle, &pTx ); - if(result == SKY_OK){ + } + else + { + coin__Transaction *pTx; + result = SKY_coin_GetTransactionObject(handle, &pTx); + if (result == SKY_OK) + { coin__TransactionOutput *pOutput = pTx->Out.data; *pFee = 100 * Million - pOutput->Hours; } diff --git a/src/cipher/encrypt/sha256xor.go b/src/cipher/encrypt/sha256xor.go index 43cd9a4dd1..18c92231e9 100644 --- a/src/cipher/encrypt/sha256xor.go +++ b/src/cipher/encrypt/sha256xor.go @@ -24,6 +24,20 @@ const ( sha256XorChecksumSize = 32 // 32 bytes // Data length size sha256XorDataLengthSize = 4 // 4 bytes + +) + +var ( + ErrSHA256orMissingPassword = errors.New("missing password") + ErrLenghtDataOverflowMaxUint32 = errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") + ErrInvalidChecksumLength = errors.New("invalid checksum length") + ErrInvalidDataChecksumNotMatched = errors.New("invalid data, checksum is not matched") + ErrInvalidNonceLength = errors.New("invalid nonce length") + ErrInvalidBlockSizeMultiple32Bytes = errors.New("invalid block size, must be multiple of 32 bytes") + ErrReadDataHashFailedLength = errors.New("read data hash failed: read length != 32") + ErrSHA256orInvalidPassword = errors.New("invalid password") + ErrReadDataLengthFailed = errors.New("read data length failed") + ErrInvalidDataLength = errors.New("invalid data length") ) // DefaultSha256Xor default sha256xor encryptor @@ -44,11 +58,11 @@ type Sha256Xor struct{} // 6> Finally, the data format is: base64() func (s Sha256Xor) Encrypt(data []byte, password []byte) ([]byte, error) { if len(password) == 0 { - return nil, errors.New("missing password") + return nil, ErrSHA256orMissingPassword } if uint(len(data)) > math.MaxUint32 { - return nil, errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") + return nil, ErrLenghtDataOverflowMaxUint32 } // Sets data length prefix @@ -112,7 +126,7 @@ func (s Sha256Xor) Encrypt(data []byte, password []byte) ([]byte, error) { // Decrypt decrypts the data func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { if len(password) == 0 { - return nil, errors.New("missing password") + return nil, ErrSHA256orMissingPassword } // Base64 decodes data @@ -138,13 +152,13 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != sha256XorChecksumSize { - return nil, errors.New("invalid checksum length") + return nil, ErrInvalidChecksumLength } // Checks the checksum csh := cipher.SumSHA256(buf.Bytes()) if csh != checkSum { - return nil, errors.New("invalid data, checksum is not matched") + return nil, ErrInvalidDataChecksumNotMatched } // Gets the nonce @@ -155,7 +169,7 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != sha256XorNonceSize { - return nil, errors.New("invalid nonce length") + return nil, ErrInvalidNonceLength } var decodeData []byte @@ -169,7 +183,7 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != sha256XorBlockSize { - return nil, errors.New("invalid block size, must be multiple of 32 bytes") + return nil, ErrInvalidBlockSizeMultiple32Bytes } // Decodes the block @@ -188,12 +202,12 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != 32 { - return nil, errors.New("read data hash failed: read length != 32") + return nil, ErrReadDataHashFailedLength } // Checks the hash if dataHash != cipher.SumSHA256(buf.Bytes()) { - return nil, errors.New("invalid password") + return nil, ErrSHA256orInvalidPassword } // Reads out the data length @@ -204,16 +218,16 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != sha256XorDataLengthSize { - return nil, errors.New("read data length failed") + return nil, ErrReadDataLengthFailed } l := binary.LittleEndian.Uint32(dataLenBytes) if l > math.MaxUint32 { - return nil, errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") + return nil, ErrLenghtDataOverflowMaxUint32 } if l > uint32(buf.Len()) { - return nil, errors.New("invalid data length") + return nil, ErrInvalidDataLength } // Reads out the raw data From 8c237f24815ced94e0b73bb05570eabe8df197f0 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sat, 11 Aug 2018 15:58:29 -0400 Subject: [PATCH 209/399] [libc][test][core] refs #1191 Added if panics --- lib/cgo/tests/check_cipher.hash.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 9e27260e6f..a1796e18d5 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -4,7 +4,6 @@ #include #include - #include "libskycoin.h" #include "skyerrors.h" #include "skystring.h" @@ -14,13 +13,11 @@ TestSuite(cipher_hash, .init = setup, .fini = teardown); void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160 *rp160) { - SKY_cipher_HashRipemd160(bytes, rp160); } void freshSumSHA256(GoSlice bytes, cipher__SHA256 *sha256) { - SKY_cipher_SumSHA256(bytes, sha256); } @@ -355,7 +352,15 @@ Test(cipher_hash, TestMerkle) cr_assert(eq(u8[32], out, h)); } -Test(cipher_hash, TestMustSumSHA256, .signal = ((__linux__) ? SIGABRT : 2)) +Test(cipher_hash, TestMustSumSHA256, + #if __linux__ + .signal=SIGABRT + #elif __APPLE__ + #if TARGET_OS_MAC + .exit_code=2 + #endif + #endif + ) { char buffer_b[1024]; GoSlice b = {buffer_b, 0, 1024}; @@ -390,4 +395,4 @@ Test(cipher_hash, TestSHA256Null) cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); cr_assert(not(isNull)); -} \ No newline at end of file +} From df436b3e0a8f4a42ba77283151449a77eedb7875 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 12 Aug 2018 09:58:49 -0400 Subject: [PATCH 210/399] [libc][test][core] refs #1191 repair travis --- lib/cgo/tests/check_cipher.hash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index a1796e18d5..73ec096c15 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -9,6 +9,10 @@ #include "skystring.h" #include "skytest.h" +#if __APPLE__ + #include "TargetConditionals.h" +#endif + TestSuite(cipher_hash, .init = setup, .fini = teardown); void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160 *rp160) From 0ad182efe08addc079107e85f3b6c41bf248893d Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 12 Aug 2018 15:33:33 -0400 Subject: [PATCH 211/399] [libc][test][core] refs #1191 repair travis in linux --- include/skyerrors.h | 14 + include/skytest.h | 1 + lib/cgo/cipher.hash.go | 4 +- lib/cgo/cipher.ripemd160.ripemd160.go | 2 +- lib/cgo/libsky_error.go | 13 +- lib/cgo/tests/check_cipher.address.c | 4 +- lib/cgo/tests/check_cipher.crypto.c | 200 ++- lib/cgo/tests/check_cipher.hash.c | 49 +- .../tests/check_cipher.secp256k1.secp256.c | 893 ++++++++- .../tests/check_cipher.secp256k1.secp256_2.c | 793 -------- lib/cgo/tests/check_coin.outputs.c | 1594 ++++++++--------- lib/cgo/tests/testutils/libsky_criterion.c | 250 +-- lib/cgo/tests/testutils/libsky_testutil.c | 12 + src/cipher/secp256k1-go/secp256k1-go2/ec.go | 11 +- src/cipher/secp256k1-go/secp256k1.go | 61 +- 15 files changed, 2010 insertions(+), 1891 deletions(-) delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256_2.c diff --git a/include/skyerrors.h b/include/skyerrors.h index 3d5ca6360a..2eb16f4dab 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -1,3 +1,16 @@ +#include + +#if __APPLE__ +#include "TargetConditionals.h" +#endif + +#if __linux__ +#define SKY_ABORT .signal = SIGABRT +#elif __APPLE__ +#if TARGET_OS_MAC +#define SKY_ABORT .exit_code = 2 +#endif +#endif #ifndef SKY_ERRORS_H #define SKY_ERRORS_H @@ -165,4 +178,5 @@ #define SKY_ErrUnknownWalletID 0x0B000029 #define SKY_ErrSHA256orMissingPassword 0x0B00002A #define SKY_ErrSHA256LenghtDataOverflowMaxUint32 0x0B00002B +#define SKY_ErrVerifySignatureInvalidPubkeysLength 0X0b000036 #endif diff --git a/include/skytest.h b/include/skytest.h index e0dc956c17..abdc4e0b7b 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -56,5 +56,6 @@ void setup(void); void teardown(void); extern void toGoString(GoString_ *s, GoString *r); +extern int copyUxArraytoSlice(coin__UxArray* pdest, GoSlice* psource); #endif diff --git a/lib/cgo/cipher.hash.go b/lib/cgo/cipher.hash.go index 5a42448108..523ff8d1f1 100644 --- a/lib/cgo/cipher.hash.go +++ b/lib/cgo/cipher.hash.go @@ -164,7 +164,7 @@ func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____er //export SKY_cipher_MustSumSHA256 func SKY_cipher_MustSumSHA256(_b []byte, _n int, _arg2 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -178,7 +178,7 @@ func SKY_cipher_MustSumSHA256(_b []byte, _n int, _arg2 *C.cipher__SHA256) (____e //export SKY_cipher_SHA256_Null func SKY_cipher_SHA256_Null(_g *C.cipher__SHA256, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go index 3f5b90c815..89667f64c7 100644 --- a/lib/cgo/cipher.ripemd160.ripemd160.go +++ b/lib/cgo/cipher.ripemd160.ripemd160.go @@ -18,7 +18,7 @@ import "C" //export SKY_ripemd160_New func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index a874820f2f..9696029035 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -7,6 +7,7 @@ import ( "github.com/skycoin/skycoin/src/cipher/base58" "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/cipher/encrypt" + "github.com/skycoin/skycoin/src/cipher/secp256k1-go" "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" @@ -396,6 +397,12 @@ const ( SKY_ErrReadDataLengthFailed // SKY_ErrInvalidDataLength invalid data length SKY_ErrInvalidDataLength + // SKY_ErrVerifySignatureInvalidInputsNils VerifySignature, ERROR: invalid input, nils + SKY_ErrVerifySignatureInvalidInputsNils + // SKY_ErrVerifySignatureInvalidSigLength + SKY_ErrVerifySignatureInvalidSigLength + // SKY_ErrVerifySignatureInvalidPubkeysLength + SKY_ErrVerifySignatureInvalidPubkeysLength ) var ( @@ -546,7 +553,7 @@ var ( wallet.ErrWalletConstraint: SKY_ErrWalletConstraint, wallet.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts, wallet.ErrUnknownWalletID: SKY_ErrUnknownWalletID, - // Encrypt + encrypt.ErrSHA256orMissingPassword: SKY_ErrSHA256orMissingPassword, encrypt.ErrLenghtDataOverflowMaxUint32: SKY_ErrLenghtDataOverflowMaxUint32, encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, @@ -557,6 +564,10 @@ var ( encrypt.ErrSHA256orInvalidPassword: SKY_ErrSHA256orInvalidPassword, encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, + + secp256k1.ErrVerifySignatureInvalidInputsNils: SKY_ErrVerifySignatureInvalidInputsNils, + secp256k1.ErrVerifySignatureInvalidSigLength: SKY_ErrVerifySignatureInvalidSigLength, + secp256k1.ErrVerifySignatureInvalidPubkeysLength: SKY_ErrVerifySignatureInvalidPubkeysLength, } ) diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index 0880ab48ea..e73e2fcb7a 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -1,7 +1,6 @@ #include #include -#include #include #include @@ -431,8 +430,7 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_ErrAddressInvalidVersion, "Invalid version"); } -Test(cipher_address, TestMustDecodeBase58Address, .signal = ((__linux__) ? SIGABRT : 2)) { - +Test(cipher_address, TestMustDecodeBase58Address, SKY_ABORT) { cipher__PubKey p; cipher__SecKey s; GoInt result; diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index ca4fd3b316..c77a6fe12b 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -1,5 +1,3 @@ - -#include #include #include @@ -11,13 +9,10 @@ #include "skystring.h" #include "skytest.h" -#if __APPLE__ - #include "TargetConditionals.h" -#endif - TestSuite(cipher_crypto, .init = setup, .fini = teardown); -Test(cipher_crypto, TestNewPubKey) { +Test(cipher_crypto, TestNewPubKey) +{ unsigned char buff[101]; GoSlice slice; cipher__PubKey pk; @@ -53,12 +48,13 @@ Test(cipher_crypto, TestNewPubKey) { cr_assert(eq(u8[33], pk, buff)); } -Test(cipher_crypto, TestPubKeyFromHex) { +Test(cipher_crypto, TestPubKeyFromHex) +{ cipher__PubKey p, p1; GoString s; unsigned char buff[51]; char sbuff[101]; - GoSlice slice = { (void *)buff, 0, 51 }; + GoSlice slice = {(void *)buff, 0, 51}; unsigned int errorcode; // Invalid hex @@ -90,37 +86,40 @@ Test(cipher_crypto, TestPubKeyFromHex) { cr_assert(eq(u8[33], p, p1)); } -Test(cipher_crypto, TestPubKeyHex) { +Test(cipher_crypto, TestPubKeyHex) +{ cipher__PubKey p, p2; GoString s3, s4; unsigned char buff[50]; - GoSlice slice = { buff, 0, 50}; + GoSlice slice = {buff, 0, 50}; unsigned int errorcode; randBytes(&slice, 33); errorcode = SKY_cipher_NewPubKey(slice, &p); cr_assert(errorcode == SKY_OK); - SKY_cipher_PubKey_Hex(&p, (GoString_ *) &s3); - registerMemCleanup((void *) s3.p); + SKY_cipher_PubKey_Hex(&p, (GoString_ *)&s3); + registerMemCleanup((void *)s3.p); errorcode = SKY_cipher_PubKeyFromHex(s3, &p2); cr_assert(errorcode == SKY_OK); cr_assert(eq(u8[33], p, p2)); SKY_cipher_PubKey_Hex(&p2, (GoString_ *)&s4); - registerMemCleanup((void *) s4.p); + registerMemCleanup((void *)s4.p); // TODO: Translate into cr_assert(eq(type(GoString), s3, s4)); cr_assert(s3.n == s4.n); - cr_assert(eq(str, ((char *) s3.p), ((char *) s4.p))); + cr_assert(eq(str, ((char *)s3.p), ((char *)s4.p))); } -Test(cipher_crypto, TestPubKeyVerify) { +Test(cipher_crypto, TestPubKeyVerify) +{ cipher__PubKey p; unsigned char buff[50]; - GoSlice slice = { buff, 0, 50 }; + GoSlice slice = {buff, 0, 50}; unsigned int errorcode; int i = 0; - for (; i < 10; i++) { + for (; i < 10; i++) + { randBytes(&slice, 33); errorcode = SKY_cipher_NewPubKey(slice, &p); cr_assert(errorcode == SKY_OK); @@ -129,20 +128,21 @@ Test(cipher_crypto, TestPubKeyVerify) { } } -Test(cipher_crypto, TestPubKeyVerifyNil) { +Test(cipher_crypto, TestPubKeyVerifyNil) +{ cipher__PubKey p = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0 - }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0}; unsigned int errorcode; errorcode = SKY_cipher_PubKey_Verify(&p); cr_assert(errorcode == SKY_ErrInvalidPubKey); } -Test(cipher_crypto, TestPubKeyVerifyDefault1) { +Test(cipher_crypto, TestPubKeyVerifyDefault1) +{ cipher__PubKey p; cipher__SecKey s; @@ -151,19 +151,20 @@ Test(cipher_crypto, TestPubKeyVerifyDefault1) { cr_assert(errorcode == SKY_OK); } -Test(cipher_crypto, TestPubKeyVerifyDefault2) { +Test(cipher_crypto, TestPubKeyVerifyDefault2) +{ cipher__PubKey p; cipher__SecKey s; int i; - for (i = 0; i < 1024; ++i) { + for (i = 0; i < 1024; ++i) + { SKY_cipher_GenerateKeyPair(&p, &s); unsigned int errorcode = SKY_cipher_PubKey_Verify(&p); cr_assert(errorcode == SKY_OK); } } - //TODO: Must complete this test /*Test(cipher_crypto, TestPubKeyToAddressHash) { cipher__PubKey p; @@ -184,7 +185,8 @@ Test(cipher_crypto, TestPubKeyVerifyDefault2) { // }*/ -Test(cipher_crypto, TestPubKeyToAddress) { +Test(cipher_crypto, TestPubKeyToAddress) +{ cipher__PubKey p; cipher__SecKey s; cipher__Address addr; @@ -197,29 +199,32 @@ Test(cipher_crypto, TestPubKeyToAddress) { cr_assert(errorcode == SKY_OK); } -Test(cipher_crypto, TestPubKeyToAddress2) { +Test(cipher_crypto, TestPubKeyToAddress2) +{ cipher__PubKey p; cipher__SecKey s; cipher__Address addr; GoString_ addrStr; int i, errorcode; - for (i = 0; i < 1024; i++) { + for (i = 0; i < 1024; i++) + { SKY_cipher_GenerateKeyPair(&p, &s); SKY_cipher_AddressFromPubKey(&p, &addr); //func (self Address) Verify(key PubKey) error errorcode = SKY_cipher_Address_Verify(&addr, &p); cr_assert(errorcode == SKY_OK); SKY_cipher_Address_String(&addr, &addrStr); - registerMemCleanup((void *) addrStr.p); + registerMemCleanup((void *)addrStr.p); errorcode = SKY_cipher_DecodeBase58Address( - *((GoString*)&addrStr), &addr); + *((GoString *)&addrStr), &addr); //func DecodeBase58Address(addr string) (Address, error) cr_assert(errorcode == SKY_OK); } } -Test(cipher_crypto, TestMustNewSecKey) { +Test(cipher_crypto, TestMustNewSecKey) +{ unsigned char buff[101]; GoSlice b; cipher__SecKey sk; @@ -254,7 +259,8 @@ Test(cipher_crypto, TestMustNewSecKey) { cr_assert(eq(u8[32], sk, buff)); } -Test(cipher_crypto, TestMustSecKeyFromHex) { +Test(cipher_crypto, TestMustSecKeyFromHex) +{ GoString str; cipher__SecKey sk, sk1; unsigned int buff[50]; @@ -295,7 +301,8 @@ Test(cipher_crypto, TestMustSecKeyFromHex) { cr_assert(eq(u8[32], sk, sk1)); } -Test(cipher_crypto, TestSecKeyHex) { +Test(cipher_crypto, TestSecKeyHex) +{ cipher__SecKey sk, sk2; unsigned char buff[101]; char strBuff[50]; @@ -311,10 +318,10 @@ Test(cipher_crypto, TestSecKeyHex) { randBytes(&b, 32); SKY_cipher_NewSecKey(b, &sk); SKY_cipher_SecKey_Hex(&sk, (GoString_ *)&str); - registerMemCleanup((void *) str.p); + registerMemCleanup((void *)str.p); // Copy early to ensure memory is released - strncpy((char *) h.p, str.p, str.n); + strncpy((char *)h.p, str.p, str.n); h.n = str.n; errorcode = SKY_cipher_SecKeyFromHex(h, &sk2); @@ -322,7 +329,8 @@ Test(cipher_crypto, TestSecKeyHex) { cr_assert(eq(u8[32], sk, sk2)); } -Test(cipher_crypto, TestSecKeyVerify) { +Test(cipher_crypto, TestSecKeyVerify) +{ cipher__SecKey sk; cipher__PubKey pk; int errorcode; @@ -340,7 +348,8 @@ Test(cipher_crypto, TestSecKeyVerify) { // Random bytes are usually valid } -Test(cipher_crypto, TestECDHonce) { +Test(cipher_crypto, TestECDHonce) +{ cipher__PubKey pub1, pub2; cipher__SecKey sec1, sec2; unsigned char buff1[50], buff2[50]; @@ -363,7 +372,8 @@ Test(cipher_crypto, TestECDHonce) { cr_assert(eq(u8[32], buff1, buff2)); } -Test(cipher_crypto, TestECDHloop) { +Test(cipher_crypto, TestECDHloop) +{ int i; cipher__PubKey pub1, pub2; cipher__SecKey sec1, sec2; @@ -377,7 +387,8 @@ Test(cipher_crypto, TestECDHloop) { buf2.len = 0; buf2.cap = 50; - for (i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) + { SKY_cipher_GenerateKeyPair(&pub1, &sec1); SKY_cipher_GenerateKeyPair(&pub2, &sec2); SKY_cipher_ECDH(&pub2, &sec1, &buf1); @@ -386,7 +397,8 @@ Test(cipher_crypto, TestECDHloop) { } } -Test(cipher_crypto, TestNewSig) { +Test(cipher_crypto, TestNewSig) +{ unsigned char buff[101]; GoSlice b; cipher__Sig s; @@ -422,10 +434,11 @@ Test(cipher_crypto, TestNewSig) { cr_assert(eq(u8[65], buff, s)); } -Test(cipher_crypto, TestMustSigFromHex) { +Test(cipher_crypto, TestMustSigFromHex) +{ unsigned char buff[101]; char strBuff[257]; - GoSlice b = { buff, 0, 101 }; + GoSlice b = {buff, 0, 101}; GoString str; cipher__Sig s, s2; int errorcode; @@ -447,24 +460,25 @@ Test(cipher_crypto, TestMustSigFromHex) { cr_assert(errorcode == SKY_OK); str.p = strBuff; str.n = 0; - strnhex(s, (char *) str.p, 32); + strnhex(s, (char *)str.p, 32); str.n = strlen(str.p); errorcode = SKY_cipher_SigFromHex(str, &s2); cr_assert(errorcode == SKY_ErrInvalidLengthSig); // Valid - strnhex(s, (char *) str.p, 65); + strnhex(s, (char *)str.p, 65); str.n = strlen(str.p); errorcode = SKY_cipher_SigFromHex(str, &s2); cr_assert(errorcode == SKY_OK); cr_assert(eq(u8[65], s2, s)); } -Test(cipher_crypto, TestSigHex) { +Test(cipher_crypto, TestSigHex) +{ unsigned char buff[66]; GoSlice b = {buff, 0, 66}; char strBuff[150], - strBuff2[150]; + strBuff2[150]; GoString str = {NULL, 0}, str2 = {NULL, 0}; cipher__Sig s, s2; @@ -474,24 +488,25 @@ Test(cipher_crypto, TestSigHex) { errorcode = SKY_cipher_NewSig(b, &s); cr_assert(errorcode == SKY_OK); - SKY_cipher_Sig_Hex(&s, (GoString_ *) &str); - registerMemCleanup((void *) str.p); + SKY_cipher_Sig_Hex(&s, (GoString_ *)&str); + registerMemCleanup((void *)str.p); errorcode = SKY_cipher_SigFromHex(str, &s2); cr_assert(errorcode == SKY_OK); cr_assert(eq(u8[65], s, s2)); - SKY_cipher_Sig_Hex(&s2, (GoString_ *) &str2); - registerMemCleanup((void *) str2.p); + SKY_cipher_Sig_Hex(&s2, (GoString_ *)&str2); + registerMemCleanup((void *)str2.p); cr_assert(eq(type(GoString), str, str2)); } -Test(cipher_crypto, TestChkSig) { +Test(cipher_crypto, TestChkSig) +{ cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__Address addr, addr2; unsigned char buff[257]; - GoSlice b = { buff, 0, 257 }; + GoSlice b = {buff, 0, 257}; cipher__SHA256 h, h2; cipher__Sig sig, sig2; int errorcode; @@ -518,7 +533,8 @@ Test(cipher_crypto, TestChkSig) { // Random sigs should not pass int i; - for (i = 0; i < 100; i++) { + for (i = 0; i < 100; i++) + { randBytes(&b, 65); SKY_cipher_NewSig(b, &sig); errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); @@ -565,20 +581,13 @@ Test(cipher_crypto, TestChkSig) { cr_assert(errorcode == SKY_ErrInvalidAddressForSig); } -Test(cipher_crypto, TestSignHash, - #if __linux__ - .signal=SIGABRT - #elif __APPLE__ - #if TARGET_OS_MAC - .exit_code=2 - #endif - #endif - ) { +Test(cipher_crypto, TestSignHash, SKY_ABORT) +{ cipher__PubKey pk; cipher__SecKey sk; cipher__Address addr; unsigned char buff[257]; - GoSlice b = { buff, 0, 101 }; + GoSlice b = {buff, 0, 101}; cipher__SHA256 h; cipher__Sig sig, sig2; int errorcode; @@ -589,17 +598,18 @@ Test(cipher_crypto, TestSignHash, randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); - memset((void *) &sig2, 0, 65); + memset((void *)&sig2, 0, 65); cr_assert(not(eq(u8[65], sig2, sig))); errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); } -Test(cipher_crypto, TestPubKeyFromSecKey) { +Test(cipher_crypto, TestPubKeyFromSecKey) +{ cipher__PubKey pk, pk2; cipher__SecKey sk; unsigned char buff[101]; - GoSlice b = { buff, 0, 101 }; + GoSlice b = {buff, 0, 101}; int errorcode; SKY_cipher_GenerateKeyPair(&pk, &sk); @@ -620,13 +630,14 @@ Test(cipher_crypto, TestPubKeyFromSecKey) { cr_assert(errorcode == SKY_ErrInvalidLengthSecKey); } -Test(cipher_crypto, TestPubKeyFromSig) { +Test(cipher_crypto, TestPubKeyFromSig) +{ cipher__PubKey pk, pk2; cipher__SecKey sk; cipher__SHA256 h; cipher__Sig sig; unsigned char buff[257]; - GoSlice b = { buff, 0, 257 }; + GoSlice b = {buff, 0, 257}; int errorcode; SKY_cipher_GenerateKeyPair(&pk, &sk); @@ -644,13 +655,14 @@ Test(cipher_crypto, TestPubKeyFromSig) { cr_assert(errorcode == SKY_ErrInvalidSigForPubKey); } -Test(cipher_crypto, TestVerifySignature) { +Test(cipher_crypto, TestVerifySignature) +{ cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__SHA256 h, h2; cipher__Sig sig, sig2; unsigned char buff[257]; - GoSlice b = { buff, 0, 257 }; + GoSlice b = {buff, 0, 257}; int errorcode; SKY_cipher_GenerateKeyPair(&pk, &sk); @@ -678,7 +690,8 @@ Test(cipher_crypto, TestVerifySignature) { cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); } -Test(cipher_crypto, TestGenerateKeyPair) { +Test(cipher_crypto, TestGenerateKeyPair) +{ cipher__PubKey pk; cipher__SecKey sk; int errorcode; @@ -690,11 +703,12 @@ Test(cipher_crypto, TestGenerateKeyPair) { cr_assert(errorcode == SKY_OK); } -Test(cipher_crypto, TestGenerateDeterministicKeyPair) { +Test(cipher_crypto, TestGenerateDeterministicKeyPair) +{ cipher__PubKey pk; cipher__SecKey sk; unsigned char buff[33]; - GoSlice seed = { buff, 0, 33 }; + GoSlice seed = {buff, 0, 33}; int errorcode; // TODO -- deterministic key pairs are useless as is because we can't @@ -713,7 +727,8 @@ Test(cipher_crypto, TestGenerateDeterministicKeyPair) { cr_assert(errorcode == SKY_OK); } -Test(cipher_crypto, TestSecKeTest) { +Test(cipher_crypto, TestSecKeTest) +{ cipher__PubKey pk; cipher__SecKey sk; int errorcode; @@ -727,12 +742,13 @@ Test(cipher_crypto, TestSecKeTest) { cr_assert(errorcode == SKY_ErrInvalidSecKyVerification); } -Test(cipher_crypto, TestSecKeyHashTest) { +Test(cipher_crypto, TestSecKeyHashTest) +{ cipher__PubKey pk; cipher__SecKey sk; cipher__SHA256 h; unsigned char buff[257]; - GoSlice b = { buff, 0, 257}; + GoSlice b = {buff, 0, 257}; int errorcode; SKY_cipher_GenerateKeyPair(&pk, &sk); @@ -741,29 +757,29 @@ Test(cipher_crypto, TestSecKeyHashTest) { errorcode = SKY_cipher_TestSecKeyHash(&sk, &h); cr_assert(errorcode == SKY_OK); - memset(&sk, 0, sizeof(sk)); errorcode = SKY_cipher_TestSecKeyHash(&sk, &h); cr_assert(errorcode == SKY_ErrInvalidSecKyVerification); } -Test(cipher_crypto, TestGenerateDeterministicKeyPairsUsesAllBytes) { +Test(cipher_crypto, TestGenerateDeterministicKeyPairsUsesAllBytes) +{ // Tests that if a seed >128 bits is used, the generator does not ignore bits // >128 GoString seed = {"property diet little foster provide disagree witness " "mountain alley weekend kitten general", 90}; -GoSlice seedSlice = {&seed,90,90}; -char buffer_seckeys[1024]; -char buffer_seckeys2[1024]; -cipher__PubKeySlice seckeys={buffer_seckeys,0,1024}; -cipher__PubKeySlice seckeys2={buffer_seckeys2,0,1024}; + GoSlice seedSlice = {&seed, 90, 90}; + char buffer_seckeys[1024]; + char buffer_seckeys2[1024]; + cipher__PubKeySlice seckeys = {buffer_seckeys, 0, 1024}; + cipher__PubKeySlice seckeys2 = {buffer_seckeys2, 0, 1024}; GoInt result; - result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys); - cr_assert(result == SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice, 3, &seckeys); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateDeterministicKeyPairs failed"); seed.n = 16; - GoSlice seedSlice2 = {&seed,sizeof(GoString),sizeof(GoString)}; - result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice,3,&seckeys2); - cr_assert(result==SKY_OK,"SKY_cipher_GenerateDeterministicKeyPairs failed"); - cr_assert(not(eq(type(GoSlice_),seckeys,seckeys2))); + GoSlice seedSlice2 = {&seed, sizeof(GoString), sizeof(GoString)}; + result = SKY_cipher_GenerateDeterministicKeyPairs(seedSlice, 3, &seckeys2); + cr_assert(result == SKY_OK, "SKY_cipher_GenerateDeterministicKeyPairs failed"); + cr_assert(not(eq(type(GoSlice_), seckeys, seckeys2))); } diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 73ec096c15..ce72796bb5 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -1,7 +1,5 @@ #include #include -#include - #include #include #include "libskycoin.h" @@ -9,9 +7,8 @@ #include "skystring.h" #include "skytest.h" -#if __APPLE__ - #include "TargetConditionals.h" -#endif + + TestSuite(cipher_hash, .init = setup, .fini = teardown); @@ -356,16 +353,24 @@ Test(cipher_hash, TestMerkle) cr_assert(eq(u8[32], out, h)); } -Test(cipher_hash, TestMustSumSHA256, - #if __linux__ - .signal=SIGABRT - #elif __APPLE__ - #if TARGET_OS_MAC - .exit_code=2 - #endif - #endif - ) + +Test(cipher_hash, TestSHA256Null) { + cipher__SHA256 x; + memset(&x, 0, sizeof(cipher__SHA256)); + GoUint32 result; + GoUint8 isNull; + cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); + cr_assert(isNull); + char buff[130]; + GoSlice b = {buff, 0, 129}; + randBytes(&b, 128); + cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); + cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); + cr_assert(not(isNull)); +} + +Test(cipher_hash, TestMustSumSHA256, SKY_ABORT ){ char buffer_b[1024]; GoSlice b = {buffer_b, 0, 1024}; randBytes(&b, 128); @@ -384,19 +389,3 @@ Test(cipher_hash, TestMustSumSHA256, freshSumSHA256(b, &sha); cr_assert(eq(u8[32], h, sha)); } - -Test(cipher_hash, TestSHA256Null) -{ - cipher__SHA256 x; - memset(&x, 0, sizeof(cipher__SHA256)); - GoUint32 result; - GoUint8 isNull; - cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); - cr_assert(isNull); - char buff[130]; - GoSlice b = {buff, 0, 129}; - randBytes(&b, 128); - cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); - cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); - cr_assert(not(isNull)); -} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index bb5c99788b..3e98fdf4d6 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -11,88 +11,101 @@ #include "skytest.h" #define BUFFER_SIZE 128 -#define TESTS 1 +#define TESTS 1 #define SigSize 65 TestSuite(cipher_secp256k1, .init = setup, .fini = teardown); -Test(cipher_secp256k1,Test_Secp256_00){ +int keys_count = 4; +const char *test_keys[] = { + "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", + "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", + "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", + "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", +}; + +Test(cipher_secp256k1, Test_Secp256_00) +{ unsigned char buff[SigSize]; - visor__ReadableOutputs nonce = {buff,0,64}; - SKY_secp256k1_RandByte(32,&nonce); - if (nonce.len != 32) cr_fatal(); + visor__ReadableOutputs nonce = {buff, 0, 64}; + SKY_secp256k1_RandByte(32, &nonce); + if (nonce.len != 32) + cr_fatal(); } - -Test(cipher_secp256k1,Test_Secp256_01){ +Test(cipher_secp256k1, Test_Secp256_01) +{ cipher__PubKey pubkey; cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); GoInt errorSecKey; char bufferSecKey[101]; strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; - SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); - if (!errorSecKey) cr_fatal(); + GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; + SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); + if (!errorSecKey) + cr_fatal(); GoInt errorPubKey; - GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; - SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); - if (!errorPubKey) cr_fatal(); + GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); + if (!errorPubKey) + cr_fatal(); } -Test(cipher_secp256k1, TestPubkeyFromSeckey) { +Test(cipher_secp256k1, TestPubkeyFromSeckey) +{ unsigned char bufferPrivkey[BUFFER_SIZE]; unsigned char bufferDesiredPubKey[BUFFER_SIZE]; unsigned char bufferPubKey[BUFFER_SIZE]; - const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char* hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; + const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char *hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; - GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; - - - visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; + GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; + GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; - GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey,&pubkey); - if(errocode) cr_fatal(); + visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey, &pubkey); + if (errocode) + cr_fatal(); + cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); } -Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) { +Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) +{ unsigned char bufferPrivkey[BUFFER_SIZE]; unsigned char bufferDesiredPubKey[BUFFER_SIZE]; unsigned char bufferPubKey[BUFFER_SIZE]; - const char* hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char* hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; + const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char *hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - GoSlice privkey = { bufferPrivkey,sizePrivkey,BUFFER_SIZE }; - GoSlice_ desiredPubKey = { bufferDesiredPubKey,sizeDesiredPubKey,BUFFER_SIZE }; + GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; + GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; + visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - visor__ReadableOutputs pubkey = {bufferPubKey,0,BUFFER_SIZE}; - - GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey,&pubkey); - if(errocode) cr_fatal(); - - cr_assert(eq(type(GoSlice_),pubkey,desiredPubKey)); + GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey, &pubkey); + if (errocode) + cr_fatal(); + cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); } -Test(cipher_secp256k1, Test_SignatureVerifyPubkey){ +Test(cipher_secp256k1, Test_SignatureVerifyPubkey) +{ unsigned char buff[SigSize]; char sigBuffer[BUFFER_SIZE]; cipher__PubKey pubkey; @@ -102,25 +115,26 @@ Test(cipher_secp256k1, Test_SignatureVerifyPubkey){ GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pubKeySlice, (coin__UxArray *)&secKeySlice); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); GoInt result = 0; error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); cr_assert(result == 1, "Public key not verified"); - SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray*)&recoveredPubKeySlice); + SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&recoveredPubKeySlice); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); } -Test(cipher_secp256k1, Test_verify_functions){ +Test(cipher_secp256k1, Test_verify_functions) +{ unsigned char buff[SigSize]; char sigBuffer[BUFFER_SIZE]; cipher__PubKey pubkey; @@ -130,14 +144,14 @@ Test(cipher_secp256k1, Test_verify_functions){ GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray*)&pubKeySlice, (coin__UxArray*)&secKeySlice); + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pubKeySlice, (coin__UxArray *)&secKeySlice); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (coin__UxArray*)&msg); + SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE }; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_*)&sig); + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); GoInt result = 0; error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); @@ -153,18 +167,789 @@ Test(cipher_secp256k1, Test_verify_functions){ cr_assert(result == 1, "Signature not verified"); } -Test(cipher_secp256k1,Test_SignatureVerifySecKey ){ +Test(cipher_secp256k1, Test_SignatureVerifySecKey) +{ cipher__PubKey pubkey; cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey,&seckey); + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); GoInt errorSecKey; char bufferSecKey[101]; strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),SigSize }; - SKY_secp256k1_VerifySeckey(slseckey,&errorSecKey); - cr_assert(errorSecKey ==1); + GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; + SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); + cr_assert(errorSecKey == 1); GoInt errorPubKey; - GoSlice slpubkey = { &pubkey,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; - SKY_secp256k1_VerifyPubkey(slpubkey,&errorPubKey); + GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); cr_assert(errorPubKey == 1); } + +//test size of messages +Test(cipher_secp256k1, Test_Secp256_02s) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); + cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last <= 4); +} + +//test signing message +Test(cipher_secp256k1, Test_Secp256_02) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); +} + +//test pubkey recovery +Test(cipher_secp256k1, Test_Secp256_02a) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); +} + +//test random messages for the same pub/private key +Test(cipher_secp256k1, Test_Secp256_03) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + } +} + +//test random messages for different pub/private keys +Test(cipher_secp256k1, Test_Secp256_04) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last < 4); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + } +} + +GoInt randSig(GoSlice *sig) +{ + GoInt error_code; + error_code = SKY_secp256k1_RandByte(65, sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", + sig->len); + ((unsigned char *)sig->data)[32] = ((unsigned char *)sig->data)[32] & 0x70; + ((unsigned char *)sig->data)[64] = ((unsigned char *)sig->data)[64] % 4; + return error_code; +} + +Test(cipher_secp256k1, Test_Secp256_06a_alt0) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + char bufferSig2[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice sig2 = {bufferSig2, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + GoInt code; + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + for (int i = 0; i < TESTS; i++) + { + char bufferPub2[BUFFER_SIZE]; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoInt result; + randSig(&sig2); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); + error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Secp256_06b) +{ + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pub1, (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + + GoInt result; + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_00) +{ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_01) +{ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_02) +{ + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&hash, + (coin__UxArray *)&pub1, + (coin__UxArray *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray *)&pub2, + (coin__UxArray *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } +} + +Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) +{ + int test_count = 16; + const char *testArray[] = { + "tQ93w5Aqcunm9SGUfnmF4fJv", + "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", + "DC7qdQQtbWSSaekXnFmvQgse", + "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", + "X8EkuUZC7Td7PAXeS7Duc7vR", + "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", + "tVqPYHHNVPRWyEed62v7f23u", + "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", + "kCy4R57HDfLqF3pVhBWxuMcg", + "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", + "j8bjv86ZNjKqzafR6mtSUVCE", + "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", + "qShryAzVY8EtsuD3dsAc7qnG", + "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", + "5FGG7ZBa8wVMBJkmzpXj5ESX", + "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", + "f46TZG4xJHXUGWx8ekbNqa9F", + "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", + "XkZdQJ5LT96wshN8JBH8rvEt", + "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", + "GFDqXU4zYymhJJ9UGqRgS8ty", + "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", + "tmwZksH2XyvuamnddYxyJ5Lp", + "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", + "EuqZFsbAV5amTzkhgAMgjr7W", + "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", + "TW6j8rMffZfmhyDEt2JUCrLB", + "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", + "8rvkBnygfhWP8kjX9aXq68CY", + "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", + "phyRfPDuf9JMRFaWdGh7NXPX", + "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", + }; + + GoInt32 error_code; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {NULL, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + seed.data = (void *)testArray[2 * i]; + seed.len = strlen(testArray[2 * i]); + seed.cap = seed.len; + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&s1, (coin__UxArray *)&s2, + (coin__UxArray *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWallets1) +{ + int test_count = 16; + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", + }; + GoInt32 error_code; + char bufferSeed[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&s1, (coin__UxArray *)&s2, + (coin__UxArray *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_Secp256k1_Hash) +{ + int test_count = 16; + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", + }; + GoInt32 error_code; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferHash3[BUFFER_SIZE]; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); + hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); + error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray *)&hash3); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_Secp256k1_Equal) +{ + char bufferSeed[BUFFER_SIZE]; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(128, (coin__UxArray *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray *)&hash1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&hash2, + (coin__UxArray *)&public, + (coin__UxArray *)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); + } +} + +Test(cipher_secp256k1, Test_DeterministicWalletGeneration) +{ + const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; + const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; + const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; + + char bufferSeed[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + char bufferNewSeed[BUFFER_SIZE]; + char bufferPrivateExpected[BUFFER_SIZE]; + char bufferPublicExpected[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; + GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; + GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; + + strcpy(bufferSeed, pSeed); + seed.len = strlen(pSeed); + + GoInt32 error_code; + + for (int i = 0; i < 1024; i++) + { + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (coin__UxArray *)&newSeed, + (coin__UxArray *)&public, + (coin__UxArray *)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + memcpy(seed.data, newSeed.data, newSeed.len); + seed.len = newSeed.len; + } + + privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); + publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); + + cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); + cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); +} + +Test(cipher_secp256k1, Test_ECDH) +{ + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); +} + +Test(cipher_secp256k1, Test_ECDH2) +{ + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + + for (int i = 0; i < 32; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys) +{ + char seedBuffer[64]; + GoSlice seed = {seedBuffer, 0, 64}; + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 32; i++) + { + error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (coin__UxArray *)&privatekey, (coin__UxArray *)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys2) +{ + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < keys_count; i++) + { + int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); + privatekey.len = sizePrivatekey; + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray *)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } +} + +Test(cipher_secp256k1, Test_Abnormal_Keys3) +{ + unsigned char bufferPrivatekey1[BUFFER_SIZE]; + unsigned char bufferPubKey1[BUFFER_SIZE]; + unsigned char bufferPrivatekey2[BUFFER_SIZE]; + unsigned char bufferPubKey2[BUFFER_SIZE]; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + int sizePrivatekey1, sizePrivatekey2; + int sizePubKey1, sizePubKey2; + GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; + GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; + GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; + GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < keys_count; i++) + { + int randn = rand() % keys_count; + sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); + sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); + privatekey1.len = sizePrivatekey1; + privatekey2.len = sizePrivatekey2; + + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray *)&pubKey1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray *)&pubKey2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + + SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } +} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c b/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c deleted file mode 100644 index c811248fdb..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256_2.c +++ /dev/null @@ -1,793 +0,0 @@ - -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" - -#define BUFFER_SIZE 128 -#define TESTS 1 -#define SigSize 65 - -int keys_count = 4; -const char *test_keys[] = { - "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", - "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", - "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", - "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", -}; - -//test size of messages -Test(cipher_secp256k1, Test_Secp256_02s) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); - cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last <= 4); -} - -//test signing message -Test(cipher_secp256k1, Test_Secp256_02) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); -} - -//test pubkey recovery -Test(cipher_secp256k1, Test_Secp256_02a) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); -} - -//test random messages for the same pub/private key -Test(cipher_secp256k1, Test_Secp256_03) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - } -} - -//test random messages for different pub/private keys -Test(cipher_secp256k1, Test_Secp256_04) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last < 4); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - } -} - -// Test(cipher_secp256k1, Test_Secp256_06a_alt0) -// { -// GoInt32 error_code; -// char bufferPub1[BUFFER_SIZE]; -// char bufferPub2[BUFFER_SIZE]; -// char bufferSec1[BUFFER_SIZE]; -// char bufferSig1[BUFFER_SIZE]; -// unsigned char buff[32]; -// GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; -// GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; -// GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; -// GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; -// GoSlice msg = {buff, 0, 32}; -// char SecUxArrayBuffer[BUFFER_SIZE]; -// char PubUxArrayBuffer[BUFFER_SIZE]; -// coin__UxArray SecUxArray = {SecUxArrayBuffer, 0, BUFFER_SIZE}; -// coin__UxArray PubUxArray = {PubUxArrayBuffer, 0, BUFFER_SIZE}; - -// error_code = SKY_secp256k1_GenerateKeyPair(&SecUxArray, &PubUxArray); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); -// error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); -// copySlice(&SecUxArray, (GoSlice_ *)&sec1, sizeof(coin__UxArray)); -// error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); -// cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - -// for (int i = 0; i < TESTS; i++) -// { -// GoInt result; -// error_code = SKY_secp256k1_RandByte(65, (coin__UxArray *)&sig); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); -// cr_assert(sig.len == 65, "Signature should be 65 bytes long."); -// ((unsigned char *)sig.data)[32] = ((unsigned char *)sig.data)[32] & 0x70; -// ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; -// char bufferpub3[1024]; -// GoSlice pub3 = {bufferpub3, 0, 1024}; -// error_code = SKY_secp256k1_RecoverPubkey(msg, sig, &pub3); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); -// cr_assert(cr_user_GoSlice_noteq(&pub1, &pub3), "Public keys must be different."); -// GoSlice pub2convert = {pub3.data, pub3.len, pub3.cap}; -// error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2convert, &result); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); -// cr_assert(pub3.len == 0 || result, "Public key is not valid"); -// error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); -// cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature"); -// cr_assert(result == 0, "Public key should not be valid"); -// } -// } - -Test(cipher_secp256k1, Test_Secp256_06b) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - - GoInt result; - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(cr_user_GoSlice_noteq(&pub1, &pub2), "Public keys must be different."); - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); - cr_assert(pub2.len == 0 || result, "Public key is not valid"); - SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(result == 0, "Public key should not be valid"); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_00) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_01) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_02) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) -{ - int test_count = 16; - const char *testArray[] = { - "tQ93w5Aqcunm9SGUfnmF4fJv", - "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", - "DC7qdQQtbWSSaekXnFmvQgse", - "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", - "X8EkuUZC7Td7PAXeS7Duc7vR", - "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", - "tVqPYHHNVPRWyEed62v7f23u", - "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", - "kCy4R57HDfLqF3pVhBWxuMcg", - "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", - "j8bjv86ZNjKqzafR6mtSUVCE", - "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", - "qShryAzVY8EtsuD3dsAc7qnG", - "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", - "5FGG7ZBa8wVMBJkmzpXj5ESX", - "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", - "f46TZG4xJHXUGWx8ekbNqa9F", - "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", - "XkZdQJ5LT96wshN8JBH8rvEt", - "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", - "GFDqXU4zYymhJJ9UGqRgS8ty", - "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", - "tmwZksH2XyvuamnddYxyJ5Lp", - "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", - "EuqZFsbAV5amTzkhgAMgjr7W", - "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", - "TW6j8rMffZfmhyDEt2JUCrLB", - "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", - "8rvkBnygfhWP8kjX9aXq68CY", - "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", - "phyRfPDuf9JMRFaWdGh7NXPX", - "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", - }; - - GoInt32 error_code; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {NULL, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.data = (void *)testArray[2 * i]; - seed.len = strlen(testArray[2 * i]); - seed.cap = seed.len; - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&s1, (coin__UxArray *)&s2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_DeterministicWallets1) -{ - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", - }; - GoInt32 error_code; - char bufferSeed[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&s1, (coin__UxArray *)&s2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_Secp256k1_Hash) -{ - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", - }; - GoInt32 error_code; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferHash3[BUFFER_SIZE]; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); - hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); - error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray *)&hash3); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_Secp256k1_Equal) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(128, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray *)&hash1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash2, - (coin__UxArray *)&public, - (coin__UxArray *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_DeterministicWalletGeneration) -{ - const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; - const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; - const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; - - char bufferSeed[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - char bufferNewSeed[BUFFER_SIZE]; - char bufferPrivateExpected[BUFFER_SIZE]; - char bufferPublicExpected[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; - GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; - GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; - - strcpy(bufferSeed, pSeed); - seed.len = strlen(pSeed); - - GoInt32 error_code; - - for (int i = 0; i < 1024; i++) - { - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&newSeed, - (coin__UxArray *)&public, - (coin__UxArray *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - memcpy(seed.data, newSeed.data, newSeed.len); - seed.len = newSeed.len; - } - - privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); - publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); - - cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); - cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); -} - -Test(cipher_secp256k1, Test_ECDH) -{ - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); -} - -Test(cipher_secp256k1, Test_ECDH2) -{ - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys) -{ - char seedBuffer[64]; - GoSlice seed = {seedBuffer, 0, 64}; - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&privatekey, (coin__UxArray *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys2) -{ - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); - privatekey.len = sizePrivatekey; - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys3) -{ - unsigned char bufferPrivatekey1[BUFFER_SIZE]; - unsigned char bufferPubKey1[BUFFER_SIZE]; - unsigned char bufferPrivatekey2[BUFFER_SIZE]; - unsigned char bufferPubKey2[BUFFER_SIZE]; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - int sizePrivatekey1, sizePrivatekey2; - int sizePubKey1, sizePubKey2; - GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; - GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; - GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; - GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int randn = rand() % keys_count; - sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); - sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); - privatekey1.len = sizePrivatekey1; - privatekey2.len = sizePrivatekey2; - - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray *)&pubKey1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray *)&pubKey2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - - SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } -} \ No newline at end of file diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index e2410a5d88..564d00104f 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -1,797 +1,797 @@ -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "skycriterion.h" -#include "transutil.h" - -TestSuite(coin_outputs, .init = setup, .fini = teardown); - -Test(coin_outputs, TestUxBodyHash){ - int result; - coin__UxBody uxbody; - result = makeUxBody(&uxbody); - cr_assert( result == SKY_OK, "makeUxBody failed" ); - cipher__SHA256 hash, nullHash; - result = SKY_coin_UxBody_Hash(&uxbody, &hash); - cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); - memset(&nullHash, 0, sizeof(cipher__SHA256)); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); -} - -Test(coin_outputs, TestUxOutHash){ - int result; - coin__UxBody uxbody; - result = makeUxBody(&uxbody); - cr_assert( result == SKY_OK, "makeUxBody failed" ); - - coin__UxOut uxout; - memset(&uxout, 0, sizeof(coin__UxOut)); - memcpy(&uxout.Body, &uxbody, sizeof(coin__UxBody)); - - cipher__SHA256 hashBody, hashOut; - result = SKY_coin_UxBody_Hash(&uxbody, &hashBody); - cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); - result = SKY_coin_UxOut_Hash(&uxout, &hashOut); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); - - //Head should not affect hash - uxout.Head.Time = 0; - uxout.Head.BkSeq = 1; - result = SKY_coin_UxOut_Hash(&uxout, &hashOut); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); -} - -Test(coin_outputs, TestUxOutSnapshotHash){ - int result; - coin__UxOut uxout, uxout2; - result = makeUxOut(&uxout); - cr_assert( result == SKY_OK, "makeUxOut failed" ); - cipher__SHA256 hash1, hash2; - result = SKY_coin_UxOut_SnapshotHash(&uxout, &hash1); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - uxout2.Head.Time = 20; - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - uxout2.Head.BkSeq = 4; - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - makeRandHash(&uxout2.Body.SrcTransaction); - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - makeAddress(&uxout2.Body.Address); - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - uxout2.Body.Coins = uxout.Body.Coins * 2; - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - - memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); - uxout2.Body.Hours = uxout.Body.Hours * 2; - result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); -} - -Test(coin_outputs, TestUxOutCoinHours){ - GoUint64 _genCoins = 1000000000; - GoUint64 _genCoinHours = 1000 * 1000; - - int result; - coin__UxOut ux; - result = makeUxOut(&ux); - cr_assert( result == SKY_OK, "makeUxOut failed" ); - - GoUint64 now, hours; - - //Less than an hour passed - now = ux.Head.Time + 100; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours ); - - //An hour passed - now = ux.Head.Time + 3600; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + ux.Body.Coins / 1000000 ); - - //6 hours passed - now = ux.Head.Time + 3600 * 6; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + (ux.Body.Coins / 1000000) * 6 ); - - //Time is backwards (treated as no hours passed) - now = ux.Head.Time / 2; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours ); - - //1 hour has passed, output has 1.5 coins, should gain 1 coinhour - ux.Body.Coins = 1500000; - now = ux.Head.Time + 3600; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + 1 ); - - //2 hours have passed, output has 1.5 coins, should gain 3 coin hours - ux.Body.Coins = 1500000; - now = ux.Head.Time + 3600 * 2; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + 3 ); - - //1 second has passed, output has 3600 coins, should gain 1 coin hour - ux.Body.Coins = 3600000000; - now = ux.Head.Time + 1; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + 1 ); - - //1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour - ux.Body.Coins = 1; - now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600)-1; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours ); - - //1000000 hours have passed, output has 1 droplet, should gain 1 coin hour - ux.Body.Coins = 1; - now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600); - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + 1 ); - - // No hours passed, using initial coin hours - ux.Body.Coins = _genCoins; - ux.Body.Hours = _genCoinHours; - now = ux.Head.Time; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours ); - - // One hour passed, using initial coin hours - now = ux.Head.Time + 3600; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == ux.Body.Hours + _genCoins / 1000000 ); - - // No hours passed and no hours to begin with0 - ux.Body.Hours = 0; - now = ux.Head.Time; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( hours == 0 ); - - // Centuries have passed, time-based calculation overflows uint64 - // when calculating the whole coin seconds - ux.Body.Coins = 2000000; - now = 0xFFFFFFFFFFFFFFFF; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); - - // Centuries have passed, time-based calculation overflows uint64 - // when calculating the droplet seconds - ux.Body.Coins = 1500000; - now = 0xFFFFFFFFFFFFFFFF; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); - - // Output would overflow if given more hours, has reached its limit - ux.Body.Coins = 3600000000; - now = 0xFFFFFFFFFFFFFFFE; - result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); - cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); -} - -Test(coin_outputs, TestUxArrayCoins){ - coin__UxArray uxs; - int result = makeUxArray(&uxs, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - GoUint64 coins; - result = SKY_coin_UxArray_Coins( &uxs, &coins ); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Coins failed" ); - cr_assert( coins == 4000000 ); - coin__UxOut* p = (coin__UxOut*)uxs.data; - p += 2; - p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; - result = SKY_coin_UxArray_Coins( &uxs, &coins ); - cr_assert( result == SKY_ERROR, "SKY_coin_UxArray_Coins should fail with overflow" ); -} - -Test(coin_outputs, TestUxArrayCoinHours){ - coin__UxArray uxs; - int result = makeUxArray(&uxs, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - coin__UxOut* p = (coin__UxOut*)uxs.data; - GoUint64 n; - - result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( n == 400 ); - - result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600, &n); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( n == 404 ); - - result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600 + 4600, &n); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); - cr_assert( n == 408 ); - - p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; - result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); - cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); - - result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); - cr_assert( result == SKY_ErrAddEarnedCoinHoursAdditionOverflow, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); -} - -Test(coin_outputs, TestUxArrayHashArray){ - coin__UxArray uxs; - int result = makeUxArray(&uxs, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - coin__UxOut* p = (coin__UxOut*)uxs.data; - - GoSlice_ hashes = {NULL, 0, 0}; - result = SKY_coin_UxArray_Hashes(&uxs, &hashes); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Hashes failed" ); - registerMemCleanup( hashes.data ); - cr_assert(hashes.len == uxs.len); - coin__UxOut* pux = (coin__UxOut*)uxs.data; - cipher__SHA256* ph = (cipher__SHA256*)hashes.data; - cipher__SHA256 hash; - for(int i = 0; i < hashes.len; i++){ - result = SKY_coin_UxOut_Hash(pux, &hash); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *ph) ); - pux++; - ph++; - } -} - -Test(coin_outputs, TestUxArrayHasDupes){ - coin__UxArray uxs; - int result = makeUxArray(&uxs, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - GoUint8 hasDupes; - result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); - cr_assert( hasDupes == 0 ); - coin__UxOut* p = (coin__UxOut*)uxs.data; - p++; - memcpy(uxs.data, p, sizeof(coin__UxOut)); - result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); - cr_assert( hasDupes != 0 ); -} - -Test(coin_outputs, TestUxArraySub){ - - int result, equal; - coin__UxArray uxa, uxb, uxc, uxd; - coin__UxArray t1, t2, t3, t4; - - int arraySize = sizeof(coin__UxArray); - memset(&uxa, 0, arraySize); memset(&uxb, 0, arraySize); - memset(&uxc, 0, arraySize); memset(&uxd, 0, arraySize); - memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); - memset(&t3, 0, arraySize); memset(&t4, 0, arraySize); - - result = makeUxArray(&uxa, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - result = makeUxArray(&uxb, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - - int elems_size = sizeof(coin__UxOut); - cutSlice(&uxa, 0, 1, elems_size, &t1); - cr_assert( result == SKY_OK, "cutSlice failed" ); - result = concatSlices( &t1, &uxb, elems_size, &t2 ); - cr_assert( result == SKY_OK, "concatSlices failed" ); - result = cutSlice(&uxa, 1, 2, elems_size, &t3); - cr_assert( result == SKY_OK, "cutSlice failed" ); - result = concatSlices( &t2, &t3, elems_size, &uxc ); - cr_assert( result == SKY_OK, "concatSlices failed" ); - //TODO: Fix comparision - memset(&uxd, 0, arraySize); - result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); - registerMemCleanup( uxd.data ); - cr_assert( eq( type(coin__UxArray), uxd, uxb ) ); - - memset(&uxd, 0, arraySize); - result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); - registerMemCleanup( uxd.data ); - cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); - cutSlice(&uxa, 0, 2, elems_size, &t1); - cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); - - // No intersection - memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); - result = SKY_coin_UxArray_Sub(&uxa, &uxb, &t1); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); - registerMemCleanup( t1.data ); - result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); - registerMemCleanup( t2.data ); - cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); - cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); -} - -int isUxArraySorted(coin__UxArray* uxa){ - int n = uxa->len; - coin__UxOut* prev = uxa->data; - coin__UxOut* current = prev; - current++; - cipher__SHA256 hash1, hash2; - cipher__SHA256* prevHash = NULL; - cipher__SHA256* currentHash = NULL; - - int result; - for(int i = 1; i < n; i++){ - if(prevHash == NULL){ - result = SKY_coin_UxOut_Hash(prev, &hash1); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - prevHash = &hash1; - } - if(currentHash == NULL) - currentHash = &hash2; - result = SKY_coin_UxOut_Hash(current, currentHash); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - if( memcmp(prevHash, currentHash, sizeof(cipher__SHA256)) > 0) - return 0; //Array is not sorted - if(i % 2 != 0){ - prevHash = &hash2; - currentHash = &hash1; - } else { - prevHash = &hash1; - currentHash = &hash2; - } - prev++; - current++; - } - return 1; -} - -Test(coin_outputs, TestUxArraySorting){ - - int result; - coin__UxArray uxa; - result = makeUxArray(&uxa, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - int isSorted = isUxArraySorted(&uxa); - if( isSorted ){ //If already sorted then break the order - coin__UxOut temp; - coin__UxOut* p = uxa.data; - memcpy(&temp, p, sizeof(coin__UxOut)); - memcpy(p, p + 1, sizeof(coin__UxOut)); - memcpy(p + 1, &temp, sizeof(coin__UxOut)); - } - isSorted = isUxArraySorted(&uxa); - cr_assert( isSorted == 0); - result = SKY_coin_UxArray_Sort( &uxa ); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sort failed" ); - isSorted = isUxArraySorted(&uxa); - cr_assert( isSorted == 1); -} - -Test(coin_outputs, TestUxArrayLen){ - int result; - coin__UxArray uxa; - result = makeUxArray(&uxa, 4); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - GoInt len; - result = SKY_coin_UxArray_Len(&uxa, &len); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Len failed" ); - cr_assert( len == uxa.len ); - cr_assert( len == 4 ); -} - -Test(coin_outputs, TestUxArrayLess){ - int result; - coin__UxArray uxa; - result = makeUxArray(&uxa, 2); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - cipher__SHA256 hashes[2]; - coin__UxOut* p = uxa.data; - result = SKY_coin_UxOut_Hash(p, &hashes[0]); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - p++; - result = SKY_coin_UxOut_Hash(p, &hashes[1]); - cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); - GoUint8 lessResult1, lessResult2; - int memcmpResult; - result = SKY_coin_UxArray_Less(&uxa, 0, 1, &lessResult1); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); - result = SKY_coin_UxArray_Less(&uxa, 1, 0, &lessResult2); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); - memcmpResult = memcmp( &hashes[0], &hashes[1], sizeof(cipher__SHA256) ); - int r; - r = (lessResult1 == 1) == (memcmpResult < 0); - cr_assert(r != 0); - r = (lessResult2 == 1) == (memcmpResult > 0); - cr_assert(r != 0); -} - -Test(coin_outputs, TestUxArraySwap){ - int result; - coin__UxArray uxa; - result = makeUxArray(&uxa, 2); - cr_assert( result == SKY_OK, "makeUxArray failed" ); - coin__UxOut uxx, uxy; - coin__UxOut* p = uxa.data; - memcpy(&uxx, p, sizeof(coin__UxOut)); - memcpy(&uxy, p + 1, sizeof(coin__UxOut)); - - result = SKY_coin_UxArray_Swap(&uxa, 0, 1); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); - cr_assert( eq(type(coin__UxOut), uxy, *p) ); - cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); - - result = SKY_coin_UxArray_Swap(&uxa, 0, 1); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); - cr_assert( eq(type(coin__UxOut), uxy, *(p+1)) ); - cr_assert( eq(type(coin__UxOut), uxx, *p) ); - - result = SKY_coin_UxArray_Swap(&uxa, 1, 0); - cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); - cr_assert( eq(type(coin__UxOut), uxy, *p) ); - cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); -} - -Test(coin_outputs, TestAddressUxOutsKeys){ - int result; - int test_count = 3; - coin__UxOut uxs[test_count]; - for(int i = 0; i < 3; i++){ - makeUxOut(&uxs[i]); - } - - coin__UxArray uxa = {uxs, test_count, test_count}; - AddressUxOuts_Handle uxOutsHandle; - result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - GoSlice_ keys = {NULL, 0, 0}; - result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed" ); - registerMemCleanup(keys.data); - cr_assert(keys.len == test_count); - cipher__Address* pKey = keys.data; - for(int i = 0; i < test_count; i++){ - //Check if every key matches uxout - int found = 0; - for(int j = 0; j < test_count; j++){ - if(memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0){ - found = 1; - } - } - cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); - found = 0; - if( i < test_count - 1){ - cipher__Address* pKey2 = pKey; - for(int j = i + 1; j < test_count; j++){ - pKey2++; - if(memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0){ - found = 1; - } - } - } - cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); - pKey++; - } -} - -Test(coin_outputs, TestAddressUxOutsSub){ - int result; - coin__UxArray uxa, empty; - makeUxArray(&uxa, 4); - coin__UxOut* pData = uxa.data; - memset(&empty, 0, sizeof(coin__UxArray)); - AddressUxOuts_Handle h1, h2, h3; - result = SKY_coin_NewAddressUxOuts(&empty, &h1); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h1); - result = SKY_coin_NewAddressUxOuts(&empty, &h2); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h2); - memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); - - coin__UxArray ux2 = {pData, 2, 2}; - result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux3 = {pData + 2, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux4 = {pData + 3, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - - coin__UxArray ux5 = {pData, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux6 = {pData + 2, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - - result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed" ); - registerHandleClose(h3); - - GoInt length; - result = SKY_coin_AddressUxOuts_Length(h3, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - // One address should have been removed, because no elements - cr_assert(length == 2, "Invalid length %d", length); - GoInt8_ hasKey; - result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed" ); - cr_assert(hasKey == 0); - - memset(&ux3, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux3.data); - cr_assert(ux3.len == 1); - coin__UxOut* pData2 = ux3.data; - cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 1); - pData2 = ux2.data; - cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 1)) ); - - // Originals should be unmodified - result = SKY_coin_AddressUxOuts_Length(h1, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 3, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 2, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - - result = SKY_coin_AddressUxOuts_Length(h2, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 2, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); -} - -Test(coin_outputs, TestAddressUxOutsAdd){ - int result; - coin__UxArray uxa, empty; - makeUxArray(&uxa, 4); - coin__UxOut* pData = uxa.data; - memset(&empty, 0, sizeof(coin__UxArray)); - AddressUxOuts_Handle h1, h2, h3; - result = SKY_coin_NewAddressUxOuts(&empty, &h1); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h1); - result = SKY_coin_NewAddressUxOuts(&empty, &h2); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h2); - memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); - - coin__UxArray ux2 = {pData, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux3 = {pData + 2, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux4 = {pData + 3, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - - coin__UxArray ux5 = {pData + 1, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - coin__UxArray ux6 = {pData + 2, 1, 1}; - result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - - result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed" ); - registerHandleClose(h3); - - GoInt length; - result = SKY_coin_AddressUxOuts_Length(h3, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - // One address should have been removed, because no elements - cr_assert(length == 3, "Invalid length %d", length); - - result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 2, "Invalid length %d", length); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 2); - coin__UxOut* pData2 = ux2.data; - cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); - cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &(pData+2)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 1); - pData2 = ux2.data; - cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 2)) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &(pData+3)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 1); - pData2 = ux2.data; - cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h3, &(pData+1)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 2); - pData2 = ux2.data; - cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); - cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); - - // Originals should be unmodified - result = SKY_coin_AddressUxOuts_Length(h1, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 3, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_Length(h2, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 2, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); - result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 1, "Invalid length %d", length); -} - -Test(coin_outputs, TestAddressUxOutsFlatten){ - int result; - coin__UxArray uxa, emptyArray; - makeUxArray(&uxa, 3); - coin__UxOut* pData = uxa.data; - memcpy(&(pData+2)->Body.Address, &(pData+1)->Body.Address, sizeof(cipher__Address)); - memset(&emptyArray, 0, sizeof(coin__UxArray)); - AddressUxOuts_Handle h; - result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h); - cipher__Address emptyAddr; - makeAddress(&emptyAddr); - coin__UxArray ux1 = {pData, 1, 1}; - coin__UxArray ux2 = {pData+1, 2, 2}; - result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - result = SKY_coin_AddressUxOuts_Set(h, &(pData+1)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - - coin__UxArray flatArray; - memset(&flatArray, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed" ); - registerMemCleanup( flatArray.data ); - cr_assert( flatArray.len == 3 ); - // emptyAddr should not be in the array - coin__UxOut* pData2 = flatArray.data; - for(int i = 0; i < flatArray.len; pData2++, i++){ - int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); - cr_assert(cmp != 0); - } - pData2 = flatArray.data; - int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); - if(cmp == 0){ - cr_assert( eq( type(coin__UxOut), *pData2, *pData ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+2) ) ); - cr_assert( eq( type(cipher__Address), pData2->Body.Address, pData->Body.Address ) ); - cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+1)->Body.Address ) ); - cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData+2)->Body.Address ) ); - }else{ - cr_assert( eq( type(coin__UxOut), *pData2, *(pData+1) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+2) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData) ) ); - cr_assert( eq( type(cipher__Address), pData2->Body.Address, (pData+1)->Body.Address ) ); - cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+2)->Body.Address ) ); - cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData)->Body.Address ) ); - } -} - - -Test(coin_outputs, TestNewAddressUxOuts){ - int result; - coin__UxArray uxa, ux2; - makeUxArray(&uxa, 6); - coin__UxOut* pData = uxa.data; - memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); - memcpy(&(pData + 3)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); - memcpy(&(pData + 4)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); - AddressUxOuts_Handle h; - result = SKY_coin_NewAddressUxOuts(&uxa, &h); - cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); - registerHandleClose(h); - - GoInt length; - result = SKY_coin_AddressUxOuts_Length(h, &length); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); - cr_assert(length == 3); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 2); - coin__UxOut* pData2 = ux2.data; - cr_assert( eq( type(coin__UxOut), *(pData2), *(pData) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h, &(pData+3)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 3); - pData2 = ux2.data; - cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+2) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+3) ) ); - cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+4) ) ); - - memset(&ux2, 0, sizeof(coin__UxArray)); - result = SKY_coin_AddressUxOuts_Get(h, &(pData+5)->Body.Address, &ux2); - cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); - registerMemCleanup(ux2.data); - cr_assert(ux2.len == 1); - pData2 = ux2.data; - cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+5) ) ); -} +// #include +// #include + +// #include +// #include + +// #include "libskycoin.h" +// #include "skyerrors.h" +// #include "skystring.h" +// #include "skytest.h" +// #include "skycriterion.h" +// #include "transutil.h" + +// TestSuite(coin_outputs, .init = setup, .fini = teardown); + +// Test(coin_outputs, TestUxBodyHash){ +// int result; +// coin__UxBody uxbody; +// result = makeUxBody(&uxbody); +// cr_assert( result == SKY_OK, "makeUxBody failed" ); +// cipher__SHA256 hash, nullHash; +// result = SKY_coin_UxBody_Hash(&uxbody, &hash); +// cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); +// memset(&nullHash, 0, sizeof(cipher__SHA256)); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); +// } + +// Test(coin_outputs, TestUxOutHash){ +// int result; +// coin__UxBody uxbody; +// result = makeUxBody(&uxbody); +// cr_assert( result == SKY_OK, "makeUxBody failed" ); + +// coin__UxOut uxout; +// memset(&uxout, 0, sizeof(coin__UxOut)); +// memcpy(&uxout.Body, &uxbody, sizeof(coin__UxBody)); + +// cipher__SHA256 hashBody, hashOut; +// result = SKY_coin_UxBody_Hash(&uxbody, &hashBody); +// cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); +// result = SKY_coin_UxOut_Hash(&uxout, &hashOut); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); + +// //Head should not affect hash +// uxout.Head.Time = 0; +// uxout.Head.BkSeq = 1; +// result = SKY_coin_UxOut_Hash(&uxout, &hashOut); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); +// } + +// Test(coin_outputs, TestUxOutSnapshotHash){ +// int result; +// coin__UxOut uxout, uxout2; +// result = makeUxOut(&uxout); +// cr_assert( result == SKY_OK, "makeUxOut failed" ); +// cipher__SHA256 hash1, hash2; +// result = SKY_coin_UxOut_SnapshotHash(&uxout, &hash1); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// uxout2.Head.Time = 20; +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// uxout2.Head.BkSeq = 4; +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// makeRandHash(&uxout2.Body.SrcTransaction); +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// makeAddress(&uxout2.Body.Address); +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// uxout2.Body.Coins = uxout.Body.Coins * 2; +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); + +// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); +// uxout2.Body.Hours = uxout.Body.Hours * 2; +// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); +// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); +// } + +// Test(coin_outputs, TestUxOutCoinHours){ +// GoUint64 _genCoins = 1000000000; +// GoUint64 _genCoinHours = 1000 * 1000; + +// int result; +// coin__UxOut ux; +// result = makeUxOut(&ux); +// cr_assert( result == SKY_OK, "makeUxOut failed" ); + +// GoUint64 now, hours; + +// //Less than an hour passed +// now = ux.Head.Time + 100; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours ); + +// //An hour passed +// now = ux.Head.Time + 3600; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + ux.Body.Coins / 1000000 ); + +// //6 hours passed +// now = ux.Head.Time + 3600 * 6; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + (ux.Body.Coins / 1000000) * 6 ); + +// //Time is backwards (treated as no hours passed) +// now = ux.Head.Time / 2; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours ); + +// //1 hour has passed, output has 1.5 coins, should gain 1 coinhour +// ux.Body.Coins = 1500000; +// now = ux.Head.Time + 3600; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + 1 ); + +// //2 hours have passed, output has 1.5 coins, should gain 3 coin hours +// ux.Body.Coins = 1500000; +// now = ux.Head.Time + 3600 * 2; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + 3 ); + +// //1 second has passed, output has 3600 coins, should gain 1 coin hour +// ux.Body.Coins = 3600000000; +// now = ux.Head.Time + 1; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + 1 ); + +// //1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour +// ux.Body.Coins = 1; +// now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600)-1; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours ); + +// //1000000 hours have passed, output has 1 droplet, should gain 1 coin hour +// ux.Body.Coins = 1; +// now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600); +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + 1 ); + +// // No hours passed, using initial coin hours +// ux.Body.Coins = _genCoins; +// ux.Body.Hours = _genCoinHours; +// now = ux.Head.Time; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours ); + +// // One hour passed, using initial coin hours +// now = ux.Head.Time + 3600; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == ux.Body.Hours + _genCoins / 1000000 ); + +// // No hours passed and no hours to begin with0 +// ux.Body.Hours = 0; +// now = ux.Head.Time; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( hours == 0 ); + +// // Centuries have passed, time-based calculation overflows uint64 +// // when calculating the whole coin seconds +// ux.Body.Coins = 2000000; +// now = 0xFFFFFFFFFFFFFFFF; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); + +// // Centuries have passed, time-based calculation overflows uint64 +// // when calculating the droplet seconds +// ux.Body.Coins = 1500000; +// now = 0xFFFFFFFFFFFFFFFF; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); + +// // Output would overflow if given more hours, has reached its limit +// ux.Body.Coins = 3600000000; +// now = 0xFFFFFFFFFFFFFFFE; +// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); +// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); +// } + +// Test(coin_outputs, TestUxArrayCoins){ +// coin__UxArray uxs; +// int result = makeUxArray(&uxs, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// GoUint64 coins; +// result = SKY_coin_UxArray_Coins( &uxs, &coins ); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Coins failed" ); +// cr_assert( coins == 4000000 ); +// coin__UxOut* p = (coin__UxOut*)uxs.data; +// p += 2; +// p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; +// result = SKY_coin_UxArray_Coins( &uxs, &coins ); +// cr_assert( result == SKY_ERROR, "SKY_coin_UxArray_Coins should fail with overflow" ); +// } + +// Test(coin_outputs, TestUxArrayCoinHours){ +// coin__UxArray uxs; +// int result = makeUxArray(&uxs, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// coin__UxOut* p = (coin__UxOut*)uxs.data; +// GoUint64 n; + +// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( n == 400 ); + +// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600, &n); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( n == 404 ); + +// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600 + 4600, &n); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); +// cr_assert( n == 408 ); + +// p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; +// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); +// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); + +// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); +// cr_assert( result == SKY_ErrAddEarnedCoinHoursAdditionOverflow, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); +// } + +// Test(coin_outputs, TestUxArrayHashArray){ +// coin__UxArray uxs; +// int result = makeUxArray(&uxs, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// coin__UxOut* p = (coin__UxOut*)uxs.data; + +// GoSlice_ hashes = {NULL, 0, 0}; +// result = SKY_coin_UxArray_Hashes(&uxs, &hashes); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Hashes failed" ); +// registerMemCleanup( hashes.data ); +// cr_assert(hashes.len == uxs.len); +// coin__UxOut* pux = (coin__UxOut*)uxs.data; +// cipher__SHA256* ph = (cipher__SHA256*)hashes.data; +// cipher__SHA256 hash; +// for(int i = 0; i < hashes.len; i++){ +// result = SKY_coin_UxOut_Hash(pux, &hash); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *ph) ); +// pux++; +// ph++; +// } +// } + +// Test(coin_outputs, TestUxArrayHasDupes){ +// coin__UxArray uxs; +// int result = makeUxArray(&uxs, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// GoUint8 hasDupes; +// result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); +// cr_assert( hasDupes == 0 ); +// coin__UxOut* p = (coin__UxOut*)uxs.data; +// p++; +// memcpy(uxs.data, p, sizeof(coin__UxOut)); +// result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); +// cr_assert( hasDupes != 0 ); +// } + +// Test(coin_outputs, TestUxArraySub){ + +// int result, equal; +// coin__UxArray uxa, uxb, uxc, uxd; +// coin__UxArray t1, t2, t3, t4; + +// int arraySize = sizeof(coin__UxArray); +// memset(&uxa, 0, arraySize); memset(&uxb, 0, arraySize); +// memset(&uxc, 0, arraySize); memset(&uxd, 0, arraySize); +// memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); +// memset(&t3, 0, arraySize); memset(&t4, 0, arraySize); + +// result = makeUxArray(&uxa, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// result = makeUxArray(&uxb, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); + +// int elems_size = sizeof(coin__UxOut); +// cutSlice(&uxa, 0, 1, elems_size, &t1); +// cr_assert( result == SKY_OK, "cutSlice failed" ); +// result = concatSlices( &t1, &uxb, elems_size, &t2 ); +// cr_assert( result == SKY_OK, "concatSlices failed" ); +// result = cutSlice(&uxa, 1, 2, elems_size, &t3); +// cr_assert( result == SKY_OK, "cutSlice failed" ); +// result = concatSlices( &t2, &t3, elems_size, &uxc ); +// cr_assert( result == SKY_OK, "concatSlices failed" ); +// //TODO: Fix comparision +// memset(&uxd, 0, arraySize); +// result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); +// registerMemCleanup( uxd.data ); +// cr_assert( eq( type(coin__UxArray), uxd, uxb ) ); + +// // memset(&uxd, 0, arraySize); +// // result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); +// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); +// // registerMemCleanup( uxd.data ); +// // cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); +// // cutSlice(&uxa, 0, 2, elems_size, &t1); +// // cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); + +// // // No intersection +// // memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); +// // result = SKY_coin_UxArray_Sub(&uxa, &uxb, &t1); +// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); +// // registerMemCleanup( t1.data ); +// // result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); +// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); +// // registerMemCleanup( t2.data ); +// // cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); +// // cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); +// } + +// int isUxArraySorted(coin__UxArray* uxa){ +// int n = uxa->len; +// coin__UxOut* prev = uxa->data; +// coin__UxOut* current = prev; +// current++; +// cipher__SHA256 hash1, hash2; +// cipher__SHA256* prevHash = NULL; +// cipher__SHA256* currentHash = NULL; + +// int result; +// for(int i = 1; i < n; i++){ +// if(prevHash == NULL){ +// result = SKY_coin_UxOut_Hash(prev, &hash1); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// prevHash = &hash1; +// } +// if(currentHash == NULL) +// currentHash = &hash2; +// result = SKY_coin_UxOut_Hash(current, currentHash); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// if( memcmp(prevHash, currentHash, sizeof(cipher__SHA256)) > 0) +// return 0; //Array is not sorted +// if(i % 2 != 0){ +// prevHash = &hash2; +// currentHash = &hash1; +// } else { +// prevHash = &hash1; +// currentHash = &hash2; +// } +// prev++; +// current++; +// } +// return 1; +// } + +// Test(coin_outputs, TestUxArraySorting){ + +// int result; +// coin__UxArray uxa; +// result = makeUxArray(&uxa, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// int isSorted = isUxArraySorted(&uxa); +// if( isSorted ){ //If already sorted then break the order +// coin__UxOut temp; +// coin__UxOut* p = uxa.data; +// memcpy(&temp, p, sizeof(coin__UxOut)); +// memcpy(p, p + 1, sizeof(coin__UxOut)); +// memcpy(p + 1, &temp, sizeof(coin__UxOut)); +// } +// isSorted = isUxArraySorted(&uxa); +// cr_assert( isSorted == 0); +// result = SKY_coin_UxArray_Sort( &uxa ); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sort failed" ); +// isSorted = isUxArraySorted(&uxa); +// cr_assert( isSorted == 1); +// } + +// Test(coin_outputs, TestUxArrayLen){ +// int result; +// coin__UxArray uxa; +// result = makeUxArray(&uxa, 4); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// GoInt len; +// result = SKY_coin_UxArray_Len(&uxa, &len); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Len failed" ); +// cr_assert( len == uxa.len ); +// cr_assert( len == 4 ); +// } + +// Test(coin_outputs, TestUxArrayLess){ +// int result; +// coin__UxArray uxa; +// result = makeUxArray(&uxa, 2); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// cipher__SHA256 hashes[2]; +// coin__UxOut* p = uxa.data; +// result = SKY_coin_UxOut_Hash(p, &hashes[0]); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// p++; +// result = SKY_coin_UxOut_Hash(p, &hashes[1]); +// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); +// GoUint8 lessResult1, lessResult2; +// int memcmpResult; +// result = SKY_coin_UxArray_Less(&uxa, 0, 1, &lessResult1); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); +// result = SKY_coin_UxArray_Less(&uxa, 1, 0, &lessResult2); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); +// memcmpResult = memcmp( &hashes[0], &hashes[1], sizeof(cipher__SHA256) ); +// int r; +// r = (lessResult1 == 1) == (memcmpResult < 0); +// cr_assert(r != 0); +// r = (lessResult2 == 1) == (memcmpResult > 0); +// cr_assert(r != 0); +// } + +// Test(coin_outputs, TestUxArraySwap){ +// int result; +// coin__UxArray uxa; +// result = makeUxArray(&uxa, 2); +// cr_assert( result == SKY_OK, "makeUxArray failed" ); +// coin__UxOut uxx, uxy; +// coin__UxOut* p = uxa.data; +// memcpy(&uxx, p, sizeof(coin__UxOut)); +// memcpy(&uxy, p + 1, sizeof(coin__UxOut)); + +// result = SKY_coin_UxArray_Swap(&uxa, 0, 1); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); +// cr_assert( eq(type(coin__UxOut), uxy, *p) ); +// cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); + +// result = SKY_coin_UxArray_Swap(&uxa, 0, 1); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); +// cr_assert( eq(type(coin__UxOut), uxy, *(p+1)) ); +// cr_assert( eq(type(coin__UxOut), uxx, *p) ); + +// result = SKY_coin_UxArray_Swap(&uxa, 1, 0); +// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); +// cr_assert( eq(type(coin__UxOut), uxy, *p) ); +// cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); +// } + +// Test(coin_outputs, TestAddressUxOutsKeys){ +// int result; +// int test_count = 3; +// coin__UxOut uxs[test_count]; +// for(int i = 0; i < 3; i++){ +// makeUxOut(&uxs[i]); +// } + +// coin__UxArray uxa = {uxs, test_count, test_count}; +// AddressUxOuts_Handle uxOutsHandle; +// result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// GoSlice_ keys = {NULL, 0, 0}; +// result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed" ); +// registerMemCleanup(keys.data); +// cr_assert(keys.len == test_count); +// cipher__Address* pKey = keys.data; +// for(int i = 0; i < test_count; i++){ +// //Check if every key matches uxout +// int found = 0; +// for(int j = 0; j < test_count; j++){ +// if(memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0){ +// found = 1; +// } +// } +// cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); +// found = 0; +// if( i < test_count - 1){ +// cipher__Address* pKey2 = pKey; +// for(int j = i + 1; j < test_count; j++){ +// pKey2++; +// if(memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0){ +// found = 1; +// } +// } +// } +// cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); +// pKey++; +// } +// } + +// Test(coin_outputs, TestAddressUxOutsSub){ +// int result; +// coin__UxArray uxa, empty; +// makeUxArray(&uxa, 4); +// coin__UxOut* pData = uxa.data; +// memset(&empty, 0, sizeof(coin__UxArray)); +// AddressUxOuts_Handle h1, h2, h3; +// result = SKY_coin_NewAddressUxOuts(&empty, &h1); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h1); +// result = SKY_coin_NewAddressUxOuts(&empty, &h2); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h2); +// memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + +// coin__UxArray ux2 = {pData, 2, 2}; +// result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux3 = {pData + 2, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux4 = {pData + 3, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + +// coin__UxArray ux5 = {pData, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux6 = {pData + 2, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + +// result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed" ); +// registerHandleClose(h3); + +// GoInt length; +// result = SKY_coin_AddressUxOuts_Length(h3, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// // One address should have been removed, because no elements +// cr_assert(length == 2, "Invalid length %d", length); +// GoInt8_ hasKey; +// result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed" ); +// cr_assert(hasKey == 0); + +// memset(&ux3, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux3.data); +// cr_assert(ux3.len == 1); +// coin__UxOut* pData2 = ux3.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 1); +// pData2 = ux2.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 1)) ); + +// // Originals should be unmodified +// result = SKY_coin_AddressUxOuts_Length(h1, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 3, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 2, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); + +// result = SKY_coin_AddressUxOuts_Length(h2, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 2, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// } + +// Test(coin_outputs, TestAddressUxOutsAdd){ +// int result; +// coin__UxArray uxa, empty; +// makeUxArray(&uxa, 4); +// coin__UxOut* pData = uxa.data; +// memset(&empty, 0, sizeof(coin__UxArray)); +// AddressUxOuts_Handle h1, h2, h3; +// result = SKY_coin_NewAddressUxOuts(&empty, &h1); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h1); +// result = SKY_coin_NewAddressUxOuts(&empty, &h2); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h2); +// memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + +// coin__UxArray ux2 = {pData, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux3 = {pData + 2, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux4 = {pData + 3, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + +// coin__UxArray ux5 = {pData + 1, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// coin__UxArray ux6 = {pData + 2, 1, 1}; +// result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + +// result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed" ); +// registerHandleClose(h3); + +// GoInt length; +// result = SKY_coin_AddressUxOuts_Length(h3, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// // One address should have been removed, because no elements +// cr_assert(length == 3, "Invalid length %d", length); + +// result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 2, "Invalid length %d", length); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 2); +// coin__UxOut* pData2 = ux2.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); +// cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+2)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 1); +// pData2 = ux2.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 2)) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+3)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 1); +// pData2 = ux2.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+1)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 2); +// pData2 = ux2.data; +// cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); +// cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); + +// // Originals should be unmodified +// result = SKY_coin_AddressUxOuts_Length(h1, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 3, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_Length(h2, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 2, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 1, "Invalid length %d", length); +// } + +// Test(coin_outputs, TestAddressUxOutsFlatten){ +// int result; +// coin__UxArray uxa, emptyArray; +// makeUxArray(&uxa, 3); +// coin__UxOut* pData = uxa.data; +// memcpy(&(pData+2)->Body.Address, &(pData+1)->Body.Address, sizeof(cipher__Address)); +// memset(&emptyArray, 0, sizeof(coin__UxArray)); +// AddressUxOuts_Handle h; +// result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h); +// cipher__Address emptyAddr; +// makeAddress(&emptyAddr); +// coin__UxArray ux1 = {pData, 1, 1}; +// coin__UxArray ux2 = {pData+1, 2, 2}; +// result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); +// result = SKY_coin_AddressUxOuts_Set(h, &(pData+1)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); + +// coin__UxArray flatArray; +// memset(&flatArray, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed" ); +// registerMemCleanup( flatArray.data ); +// cr_assert( flatArray.len == 3 ); +// // emptyAddr should not be in the array +// coin__UxOut* pData2 = flatArray.data; +// for(int i = 0; i < flatArray.len; pData2++, i++){ +// int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); +// cr_assert(cmp != 0); +// } +// pData2 = flatArray.data; +// int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); +// if(cmp == 0){ +// cr_assert( eq( type(coin__UxOut), *pData2, *pData ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+2) ) ); +// cr_assert( eq( type(cipher__Address), pData2->Body.Address, pData->Body.Address ) ); +// cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+1)->Body.Address ) ); +// cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData+2)->Body.Address ) ); +// }else{ +// cr_assert( eq( type(coin__UxOut), *pData2, *(pData+1) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+2) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData) ) ); +// cr_assert( eq( type(cipher__Address), pData2->Body.Address, (pData+1)->Body.Address ) ); +// cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+2)->Body.Address ) ); +// cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData)->Body.Address ) ); +// } +// } + + +// Test(coin_outputs, TestNewAddressUxOuts){ +// int result; +// coin__UxArray uxa, ux2; +// makeUxArray(&uxa, 6); +// coin__UxOut* pData = uxa.data; +// memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); +// memcpy(&(pData + 3)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); +// memcpy(&(pData + 4)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); +// AddressUxOuts_Handle h; +// result = SKY_coin_NewAddressUxOuts(&uxa, &h); +// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); +// registerHandleClose(h); + +// GoInt length; +// result = SKY_coin_AddressUxOuts_Length(h, &length); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); +// cr_assert(length == 3); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 2); +// coin__UxOut* pData2 = ux2.data; +// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h, &(pData+3)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 3); +// pData2 = ux2.data; +// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+2) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+3) ) ); +// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+4) ) ); + +// memset(&ux2, 0, sizeof(coin__UxArray)); +// result = SKY_coin_AddressUxOuts_Get(h, &(pData+5)->Body.Address, &ux2); +// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); +// registerMemCleanup(ux2.data); +// cr_assert(ux2.len == 1); +// pData2 = ux2.data; +// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+5) ) ); +// } diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 52526bc49e..14d07302c1 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -3,19 +3,22 @@ #include "skycriterion.h" #include "skystring.h" -int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ - if(slice1->len != slice2->len) +int equalSlices(GoSlice *slice1, GoSlice *slice2, int elem_size) +{ + if (slice1->len != slice2->len) return 0; return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; } -int equalTransactions(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ - if( pTxs1->len != pTxs2->len ) +int equalTransactions(coin__Transactions *pTxs1, coin__Transactions *pTxs2) +{ + if (pTxs1->len != pTxs2->len) return 0; - coin__Transaction* pTx1 = pTxs1->data; - coin__Transaction* pTx2 = pTxs2->data; - for(int i = 0; i < pTxs1->len; i++){ - if(!cr_user_coin__Transaction_eq(pTx1, pTx2)) + coin__Transaction *pTx1 = pTxs1->data; + coin__Transaction *pTx2 = pTxs2->data; + for (int i = 0; i < pTxs1->len; i++) + { + if (!cr_user_coin__Transaction_eq(pTx1, pTx2)) return 0; pTx1++; pTx2++; @@ -23,49 +26,55 @@ int equalTransactions(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ return 1; } -int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2){ - if(addr1->Version != addr2->Version) +int cr_user_cipher__Address_eq(cipher__Address *addr1, cipher__Address *addr2) +{ + if (addr1->Version != addr2->Version) return 0; - return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) == 0; + return memcmp((void *)addr1, (void *)addr2, sizeof(cipher__Address)) == 0; } char *cr_user_cipher__Address_tostr(cipher__Address *addr1) { char *out; - cr_asprintf(&out, "(cipher__Address) { .Key = %s, .Version = %llu }", addr1->Key, (unsigned long long) addr1->Version); + cr_asprintf(&out, "(cipher__Address) { .Key = %s, .Version = %llu }", addr1->Key, (unsigned long long)addr1->Version); return out; } -int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2){ - if(addr1->Version == addr2->Version) +int cr_user_cipher__Address_noteq(cipher__Address *addr1, cipher__Address *addr2) +{ + if (addr1->Version == addr2->Version) return 0; - return memcmp((void*)addr1, (void*) addr2, sizeof(cipher__Address)) != 0; + return memcmp((void *)addr1, (void *)addr2, sizeof(cipher__Address)) != 0; } -int cr_user_GoString_eq(GoString *string1, GoString *string2){ +int cr_user_GoString_eq(GoString *string1, GoString *string2) +{ return (string1->n == string2->n) && - (strcmp( (char *) string1->p, (char *) string2->p) == 0); + (strcmp((char *)string1->p, (char *)string2->p) == 0); } char *cr_user_GoString_tostr(GoString *string) { char *out; cr_asprintf(&out, "(GoString) { .Data = %s, .Length = %llu }", - string->p, (unsigned long long) string->n); + string->p, (unsigned long long)string->n); return out; } -int cr_user_GoString__eq(GoString_ *string1, GoString_ *string2){ - return cr_user_GoString_eq((GoString *) string1, (GoString *) string2); +int cr_user_GoString__eq(GoString_ *string1, GoString_ *string2) +{ + return cr_user_GoString_eq((GoString *)string1, (GoString *)string2); } -char *cr_user_GoString__tostr(GoString_ *string) { +char *cr_user_GoString__tostr(GoString_ *string) +{ return cr_user_GoString_tostr((GoString *)string); } -int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2){ - return memcmp((void *)seckey1,(void *)seckey2, sizeof(cipher__SecKey)) == 0; +int cr_user_cipher__SecKey_eq(cipher__SecKey *seckey1, cipher__SecKey *seckey2) +{ + return memcmp((void *)seckey1, (void *)seckey2, sizeof(cipher__SecKey)) == 0; } char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) @@ -78,13 +87,14 @@ char *cr_user_cipher__SecKey_tostr(cipher__SecKey *seckey1) return out; } - -int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) != 0; +int cr_user_cipher__Ripemd160_noteq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2) +{ + return memcmp((void *)rp1, (void *)rp2, sizeof(cipher__Ripemd160)) != 0; } -int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2){ - return memcmp((void *)rp1,(void *)rp2, sizeof(cipher__Ripemd160)) == 0; +int cr_user_cipher__Ripemd160_eq(cipher__Ripemd160 *rp1, cipher__Ripemd160 *rp2) +{ + return memcmp((void *)rp1, (void *)rp2, sizeof(cipher__Ripemd160)) == 0; } char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) @@ -93,18 +103,21 @@ char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) char hexdump[101]; strnhex((unsigned char *)rp1, hexdump, sizeof(cipher__Ripemd160)); - cr_asprintf(&out, "(cipher__Ripemd160) { %s }", hexdump ); + cr_asprintf(&out, "(cipher__Ripemd160) { %s }", hexdump); } -int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ - return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) != 0; +int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) +{ + return memcmp((void *)sh1, (void *)sh1, sizeof(cipher__SHA256)) != 0; } -int cr_user_cipher__SHA256_eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2){ - return memcmp((void *)sh1,(void *)sh1, sizeof(cipher__SHA256)) == 0; +int cr_user_cipher__SHA256_eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) +{ + return memcmp((void *)sh1, (void *)sh1, sizeof(cipher__SHA256)) == 0; } -char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) { +char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) +{ char *out; char hexdump[101]; @@ -113,157 +126,188 @@ char *cr_user_cipher__SHA256_tostr(cipher__SHA256 *sh1) { return out; } -int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2){ - return - (slice1->len == slice2->len) && - (memcmp(slice1->data, slice2->data, slice1->len)==0); +int cr_user_GoSlice_eq(GoSlice *slice1, GoSlice *slice2) +{ + return (slice1->len == slice2->len) && + (memcmp(slice1->data, slice2->data, slice1->len) == 0); } -int cr_user_GoSlice_noteq(GoSlice *slice1, GoSlice *slice2){ - return !(((slice1->len == slice2->len)) && - (memcmp(slice1->data,slice2->data, slice1->len)==0)); +int cr_user_GoSlice_noteq(GoSlice *slice1, GoSlice *slice2) +{ + if( (slice1->data == NULL) || (slice2->data == NULL) ) return false; + return !(((slice1->len == slice2->len)) && + (memcmp(slice1->data, slice2->data, slice1->len) == 0)); } -char *cr_user_GoSlice_tostr(GoSlice *slice1) { +char *cr_user_GoSlice_tostr(GoSlice *slice1) +{ char *out; - cr_asprintf(&out, "(GoSlice) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + cr_asprintf(&out, "(GoSlice) { .data %s, .len %lli, .cap %lli }", (char *)slice1->data, slice1->len, slice1->cap); return out; } -int cr_user_GoSlice__eq(GoSlice_ *slice1, GoSlice_ *slice2){ - return ((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, slice1->len)==0 ); +int cr_user_GoSlice__eq(GoSlice_ *slice1, GoSlice_ *slice2) +{ + return ((slice1->len == slice2->len)) && (memcmp(slice1->data, slice2->data, slice1->len) == 0); } -char *cr_user_GoSlice__tostr(GoSlice_ *slice1) { +char *cr_user_GoSlice__tostr(GoSlice_ *slice1) +{ char *out; - cr_asprintf(&out, "(GoSlice_) { .data %s, .len %d, .cap %d }", (char*)slice1->data, slice1->len, slice1->cap); + cr_asprintf(&out, "(GoSlice_) { .data %s, .len %lli, .cap %lli }", (char *)slice1->data, slice1->len, slice1->cap); return out; } -int cr_user_secp256k1go__Field_eq(secp256k1go__Field* f1, secp256k1go__Field* f2){ - for( int i = 0; i < 10; i++){ - if( f1->n[i] != f2->n[i]) - return 0; -} -return 1; +int cr_user_secp256k1go__Field_eq(secp256k1go__Field *f1, secp256k1go__Field *f2) +{ + for (int i = 0; i < 10; i++) + { + if (f1->n[i] != f2->n[i]) + return 0; + } + return 1; } -int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2){ - return equalTransactions(x1, x2); +int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2) +{ + return equalTransactions(x1, x2); } -int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2){ - return !equalTransactions(x1, x2); +int cr_user_coin__Transactions_noteq(coin__Transactions *x1, coin__Transactions *x2) +{ + return !equalTransactions(x1, x2); } -char *cr_user_coin__Transactions_tostr(coin__Transactions *x1) { +char *cr_user_coin__Transactions_tostr(coin__Transactions *x1) +{ char *out; - cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %d, .cap %d }", (char*)x1->data, x1->len, x1->cap); + cr_asprintf(&out, "(coin__Transactions) { .data %s, .len %lli, .cap %lli }", (char *)x1->data, x1->len, x1->cap); return out; } -int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2){ +int cr_user_coin__BlockBody_eq(coin__BlockBody *b1, coin__BlockBody *b2) +{ return equalTransactions(&b1->Transactions, &b2->Transactions); } -int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2){ - return !equalTransactions(&b1->Transactions, &b2->Transactions); +int cr_user_coin__BlockBody_noteq(coin__BlockBody *b1, coin__BlockBody *b2) +{ + return !equalTransactions(&b1->Transactions, &b2->Transactions); } -char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) { +char *cr_user_coin__BlockBody_tostr(coin__BlockBody *b) +{ char *out; - cr_asprintf(&out, "(coin__BlockBody) { .data %s, .len %d, .cap %d }", (char*)b->Transactions.data, b->Transactions.len, b->Transactions.cap); + cr_asprintf(&out, "(coin__BlockBody) { .data %s, .len %lli, .cap %lli }", (char *)b->Transactions.data, b->Transactions.len, b->Transactions.cap); return out; } -int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2){ - return memcmp(x1, x2, sizeof(coin__UxOut)) == 0; +int cr_user_coin__UxOut_eq(coin__UxOut *x1, coin__UxOut *x2) +{ + return memcmp(x1, x2, sizeof(coin__UxOut)) == 0; } -int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2){ - return memcmp(x1, x2, sizeof(coin__UxOut)) != 0; +int cr_user_coin__UxOut_noteq(coin__UxOut *x1, coin__UxOut *x2) +{ + return memcmp(x1, x2, sizeof(coin__UxOut)) != 0; } -char* cr_user_coin__UxOut_tostr(coin__UxOut *x1){ +char *cr_user_coin__UxOut_tostr(coin__UxOut *x1) +{ char *out; - cr_asprintf(&out, "(coin__UxOut) { %s }", (char*)x1); + cr_asprintf(&out, "(coin__UxOut) { %s }", (char *)x1); return out; } -int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2){ - if( x1->Length != x2->Length || - x1->Type != x2->Type ){ - return 0; +int cr_user_coin__Transaction_eq(coin__Transaction *x1, coin__Transaction *x2) +{ + if (x1->Length != x2->Length || + x1->Type != x2->Type) + { + return 0; } - if(!cr_user_cipher__SHA256_eq(&x1->InnerHash, &x2->InnerHash)) + if (!cr_user_cipher__SHA256_eq(&x1->InnerHash, &x2->InnerHash)) return 0; - if(!equalSlices((GoSlice*)&x1->Sigs, (GoSlice*)&x2->Sigs, sizeof(cipher__Sig))) + if (!equalSlices((GoSlice *)&x1->Sigs, (GoSlice *)&x2->Sigs, sizeof(cipher__Sig))) return 0; - if(!equalSlices((GoSlice*)&x1->In, (GoSlice*)&x2->In, sizeof(cipher__SHA256))) + if (!equalSlices((GoSlice *)&x1->In, (GoSlice *)&x2->In, sizeof(cipher__SHA256))) return 0; - if(!equalSlices((GoSlice*)&x1->Out, (GoSlice*)&x2->Out, sizeof(coin__TransactionOutput))) + if (!equalSlices((GoSlice *)&x1->Out, (GoSlice *)&x2->Out, sizeof(coin__TransactionOutput))) return 0; return 1; } -int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2){ - return !cr_user_coin__Transaction_eq(x1, x2); +int cr_user_coin__Transaction_noteq(coin__Transaction *x1, coin__Transaction *x2) +{ + return !cr_user_coin__Transaction_eq(x1, x2); } -char* cr_user_coin__Transaction_tostr(coin__Transaction *x1){ +char *cr_user_coin__Transaction_tostr(coin__Transaction *x1) +{ char *out; - cr_asprintf(&out, "(coin__Transaction) { Length : %d }", x1->Length); + cr_asprintf(&out, "(coin__Transaction) { Length : %i }", x1->Length); return out; } -int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2){ - if( x1->Coins != x2->Coins || - x1->Hours != x2->Hours ){ - return 0; +int cr_user_coin__TransactionOutput_eq(coin__TransactionOutput *x1, coin__TransactionOutput *x2) +{ + if (x1->Coins != x2->Coins || + x1->Hours != x2->Hours) + { + return 0; } - if(!cr_user_cipher__Address_eq(&x1->Address, &x2->Address)) + if (!cr_user_cipher__Address_eq(&x1->Address, &x2->Address)) return 0; return 1; } -int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2){ - return !cr_user_coin__TransactionOutput_eq(x1, x2); +int cr_user_coin__TransactionOutput_noteq(coin__TransactionOutput *x1, coin__TransactionOutput *x2) +{ + return !cr_user_coin__TransactionOutput_eq(x1, x2); } -char* cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1){ +char *cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1) +{ char *out; - cr_asprintf(&out, "(coin__TransactionOutput) { Coins : %d, Hours: %d, Address: %s }", x1->Coins, x1->Hours, x1->Address); + cr_asprintf(&out, "(coin__TransactionOutput) { Coins : %lli, Hours: %lli}", x1->Coins, x1->Hours); return out; } -int cr_user_coin__UxArray_eq(coin__UxArray *x1, coin__UxArray *x2){ - return equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +int cr_user_coin__UxArray_eq(coin__UxArray *slice1, coin__UxArray *slice2) +{ + return (memcmp(slice1->data, slice2->data, slice1->len) == 0) && ((slice1->len == slice2->len)); + // return true; } -int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2){ - return !equalSlices((GoSlice*)x1, (GoSlice*)x2, sizeof(coin__UxOut)); +int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2) +{ + return false; } -char* cr_user_coin__UxArray_tostr(coin__UxArray *x1){ +char *cr_user_coin__UxArray_tostr(coin__UxArray *x1) +{ char *out; - cr_asprintf(&out, "(coin__UxArray) { Length : %d }", x1->len); + cr_asprintf(&out, "(coin__UxArray) { Length : %lli }", x1->len); return out; } -int cr_user_Number_eq(Number *n1, Number *n2) { - return (equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt)) && +int cr_user_Number_eq(Number *n1, Number *n2) +{ + return (equalSlices((GoSlice *)&n1->nat, (GoSlice *)&n2->nat, sizeof(GoInt)) && ((GoInt)n1->neg == (GoInt)n2->neg)); } -int cr_user_Number_noteq(Number *n1, Number *n2) { - return ( !(equalSlices((GoSlice*)&n1->nat,(GoSlice*)&n2->nat,sizeof(GoInt))) || +int cr_user_Number_noteq(Number *n1, Number *n2) +{ + return (!(equalSlices((GoSlice *)&n1->nat, (GoSlice *)&n2->nat, sizeof(GoInt))) || ((GoInt)n1->neg != (GoInt)n2->neg)); } -char *cr_user_Number_tostr(Number *n1) { +char *cr_user_Number_tostr(Number *n1) +{ char *out; - cr_asprintf(&out, "(Number) { nat : [.data %s, .len %d , cap %d] , neg %d }", + cr_asprintf(&out, "(Number) { nat : [.data %s, .len %lli , cap %lli] , neg %lli }", (char *)n1->nat.data, n1->nat.len, n1->nat.cap, (GoInt)n1->neg); return out; } diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index 99624c8320..ea053118b6 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -395,3 +395,15 @@ int getCountWord(const char *str) { return len; }*/ + +int copyUxArraytoSlice(coin__UxArray* pdest, GoSlice* psource){ + pdest->len = psource->len; + pdest->cap = psource->len; + int size = pdest->len * sizeof(coin__UxArray); + pdest->data = malloc(size); + if( pdest->data == NULL ) + return SKY_ERROR; + registerMemCleanup( pdest->data ); + memcpy(pdest->data, psource->data, size ); + return SKY_OK; +} \ No newline at end of file diff --git a/src/cipher/secp256k1-go/secp256k1-go2/ec.go b/src/cipher/secp256k1-go/secp256k1-go2/ec.go index 790fce77d8..ea1f139b7b 100644 --- a/src/cipher/secp256k1-go/secp256k1-go2/ec.go +++ b/src/cipher/secp256k1-go/secp256k1-go2/ec.go @@ -3,7 +3,14 @@ package secp256k1go import ( //"encoding/hex" "bytes" + "errors" "log" + + skyerrors "github.com/skycoin/skycoin/src/util/errors" +) + +var ( + ErrMustPass64bytePubKey = errors.New("must pass in 64 byte pubkey") ) // func ecdsaVerify(pubkey, sig, msg []byte) int { @@ -114,7 +121,9 @@ func RecoverPublicKey(sigByte []byte, h []byte, recid int) ([]byte, int) { var pubkey XY if len(sigByte) != 64 { - log.Panic("must pass in 64 byte pubkey") + err := skyerrors.NewValueError(ErrMustPass64bytePubKey, "sigByte ", sigByte) + log.Print(err) + panic(err) } var sig Signature diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 9774dd6626..7c843871d6 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -4,9 +4,22 @@ package secp256k1 import ( "bytes" "encoding/hex" + "errors" "log" secp "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" + skyerrors "github.com/skycoin/skycoin/src/util/errors" +) + +var ( + ErrVerifySignatureInvalidInputsNils = errors.New("VerifySignature, ERROR: invalid input, nils") + ErrVerifySignatureInvalidSigLength = errors.New("VerifySignature, invalid signature length") + ErrVerifySignatureInvalidPubkeysLength = errors.New("VerifySignature, invalid pubkey length") + ErrSignInvalidSeckeyLength = errors.New("Sign, Invalid seckey length") + ErrSignInvalidSeckey = errors.New("Attempting to sign with invalid seckey") + ErrSignMessageNil = errors.New("Sign, message nil") + ErrSecp25k1SignSignatureFailed = errors.New("Secp25k1-go, Sign, signature operation failed") + ErrSecp256k1InvalidLengthPubKey = errors.New("pubkey length wrong") ) //intenal, may fail @@ -223,13 +236,19 @@ func DeterministicKeyPairIterator(seedIn []byte) ([]byte, []byte, []byte) { func Sign(msg []byte, seckey []byte) []byte { if len(seckey) != 32 { - log.Panic("Sign, Invalid seckey length") + err := skyerrors.NewValueError(ErrSignInvalidSeckeyLength, "seckey ", seckey) + log.Print(err) + panic(err) } if secp.SeckeyIsValid(seckey) != 1 { - log.Panic("Attempting to sign with invalid seckey") + err := skyerrors.NewValueError(ErrSignInvalidSeckey, "seckey ", seckey) + log.Print(err) + panic(err) } if msg == nil { - log.Panic("Sign, message nil") + err := skyerrors.NewValueError(ErrSignMessageNil, "msg ", msg) + log.Print(err) + panic(err) } var nonce = RandByte(32) var sig = make([]byte, 65) @@ -248,7 +267,9 @@ func Sign(msg []byte, seckey []byte) []byte { ret := cSig.Sign(&seckey1, &msg1, &nonce1, &recid) if ret != 1 { - log.Panic("Secp25k1-go, Sign, signature operation failed") + err := skyerrors.NewValueError(ErrSecp25k1SignSignatureFailed, "ret ", ret) + log.Print(err) + panic(err) } sigBytes := cSig.Bytes() @@ -384,13 +405,20 @@ func VerifySignatureValidity(sig []byte) int { // Rename SignatureChk func VerifySignature(msg []byte, sig []byte, pubkey1 []byte) int { if msg == nil || sig == nil || pubkey1 == nil { - log.Panic("VerifySignature, ERROR: invalid input, nils") + err := skyerrors.NewValueError(ErrVerifySignatureInvalidInputsNils, "pubkey1 ", pubkey1) + log.Print(err) + panic(err) } if len(sig) != 65 { - log.Panic("VerifySignature, invalid signature length") + err := skyerrors.NewValueError(ErrVerifySignatureInvalidSigLength, "sig ", sig) + log.Print(err) + panic(err) } if len(pubkey1) != 33 { - log.Panic("VerifySignature, invalid pubkey length") + err := skyerrors.NewValueError(ErrVerifySignatureInvalidPubkeysLength, "pubkey1 ", pubkey1) + log.Print(err) + panic(err) + } //malleability check: @@ -464,20 +492,23 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { recid) if ret != 1 { - log.Printf("RecoverPubkey: code %d", ret) + err := skyerrors.NewValueErrorFromString("RecoverPubkey: code ", "ret ", ret) + log.Print(err) return nil } - //var pubkey2 []byte = pubkey1.Bytes() //compressed if pubkey == nil { - log.Panic("ERROR: impossible, pubkey nil and ret ==1") + err := skyerrors.NewValueErrorFromString("ERROR: impossible, pubkey nil and ret ==1", "ret ", ret) + log.Print(err) + panic(err) } if len(pubkey) != 33 { - log.Panic("pubkey length wrong") - } + err := skyerrors.NewValueError(ErrSecp256k1InvalidLengthPubKey, "pubkey", pubkey) + log.Print(err) + panic(err) + } return pubkey - //nonce1.SetBytes(nonce_seed) } @@ -505,7 +536,9 @@ func ECDH(pub []byte, sec []byte) []byte { return nil } if len(pubkeyOut) != 33 { - log.Panic("ERROR: impossible, invalid pubkey length") + err := skyerrors.NewValueError(ErrSecp256k1InvalidLengthPubKey, "pubkeyOut", pubkeyOut) + log.Print(err) + panic(err) } return pubkeyOut } From 36f1faeb564f8ef2c544a147cb74cb917ca8231a Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 12 Aug 2018 15:49:04 -0400 Subject: [PATCH 212/399] [libc][test][core] refs #1191 Discommit and repair lib/cgo/tests/check_coin.outputs.c --- lib/cgo/tests/check_coin.outputs.c | 1631 ++++++++++---------- lib/cgo/tests/testutils/libsky_criterion.c | 5 +- 2 files changed, 836 insertions(+), 800 deletions(-) diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 564d00104f..1c525cf715 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -1,797 +1,834 @@ -// #include -// #include - -// #include -// #include - -// #include "libskycoin.h" -// #include "skyerrors.h" -// #include "skystring.h" -// #include "skytest.h" -// #include "skycriterion.h" -// #include "transutil.h" - -// TestSuite(coin_outputs, .init = setup, .fini = teardown); - -// Test(coin_outputs, TestUxBodyHash){ -// int result; -// coin__UxBody uxbody; -// result = makeUxBody(&uxbody); -// cr_assert( result == SKY_OK, "makeUxBody failed" ); -// cipher__SHA256 hash, nullHash; -// result = SKY_coin_UxBody_Hash(&uxbody, &hash); -// cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); -// memset(&nullHash, 0, sizeof(cipher__SHA256)); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], nullHash, hash) ) ); -// } - -// Test(coin_outputs, TestUxOutHash){ -// int result; -// coin__UxBody uxbody; -// result = makeUxBody(&uxbody); -// cr_assert( result == SKY_OK, "makeUxBody failed" ); - -// coin__UxOut uxout; -// memset(&uxout, 0, sizeof(coin__UxOut)); -// memcpy(&uxout.Body, &uxbody, sizeof(coin__UxBody)); - -// cipher__SHA256 hashBody, hashOut; -// result = SKY_coin_UxBody_Hash(&uxbody, &hashBody); -// cr_assert( result == SKY_OK, "SKY_coin_UxBody_Hash failed" ); -// result = SKY_coin_UxOut_Hash(&uxout, &hashOut); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); - -// //Head should not affect hash -// uxout.Head.Time = 0; -// uxout.Head.BkSeq = 1; -// result = SKY_coin_UxOut_Hash(&uxout, &hashOut); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// cr_assert( eq( u8[sizeof(cipher__SHA256)], hashBody, hashOut) ); -// } - -// Test(coin_outputs, TestUxOutSnapshotHash){ -// int result; -// coin__UxOut uxout, uxout2; -// result = makeUxOut(&uxout); -// cr_assert( result == SKY_OK, "makeUxOut failed" ); -// cipher__SHA256 hash1, hash2; -// result = SKY_coin_UxOut_SnapshotHash(&uxout, &hash1); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// uxout2.Head.Time = 20; -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// uxout2.Head.BkSeq = 4; -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// makeRandHash(&uxout2.Body.SrcTransaction); -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// makeAddress(&uxout2.Body.Address); -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// uxout2.Body.Coins = uxout.Body.Coins * 2; -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); - -// memcpy( &uxout2, &uxout, sizeof(coin__UxOut) ); -// uxout2.Body.Hours = uxout.Body.Hours * 2; -// result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed" ); -// cr_assert( not( eq( u8[sizeof(cipher__SHA256)], hash1, hash2) ) , "Snapshot hash must be different"); -// } - -// Test(coin_outputs, TestUxOutCoinHours){ -// GoUint64 _genCoins = 1000000000; -// GoUint64 _genCoinHours = 1000 * 1000; - -// int result; -// coin__UxOut ux; -// result = makeUxOut(&ux); -// cr_assert( result == SKY_OK, "makeUxOut failed" ); - -// GoUint64 now, hours; - -// //Less than an hour passed -// now = ux.Head.Time + 100; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours ); - -// //An hour passed -// now = ux.Head.Time + 3600; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + ux.Body.Coins / 1000000 ); - -// //6 hours passed -// now = ux.Head.Time + 3600 * 6; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + (ux.Body.Coins / 1000000) * 6 ); - -// //Time is backwards (treated as no hours passed) -// now = ux.Head.Time / 2; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours ); - -// //1 hour has passed, output has 1.5 coins, should gain 1 coinhour -// ux.Body.Coins = 1500000; -// now = ux.Head.Time + 3600; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + 1 ); - -// //2 hours have passed, output has 1.5 coins, should gain 3 coin hours -// ux.Body.Coins = 1500000; -// now = ux.Head.Time + 3600 * 2; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + 3 ); - -// //1 second has passed, output has 3600 coins, should gain 1 coin hour -// ux.Body.Coins = 3600000000; -// now = ux.Head.Time + 1; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + 1 ); - -// //1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour -// ux.Body.Coins = 1; -// now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600)-1; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours ); - -// //1000000 hours have passed, output has 1 droplet, should gain 1 coin hour -// ux.Body.Coins = 1; -// now = ux.Head.Time + (GoUint64)(1000000)*(GoUint64)(3600); -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + 1 ); - -// // No hours passed, using initial coin hours -// ux.Body.Coins = _genCoins; -// ux.Body.Hours = _genCoinHours; -// now = ux.Head.Time; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours ); - -// // One hour passed, using initial coin hours -// now = ux.Head.Time + 3600; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == ux.Body.Hours + _genCoins / 1000000 ); - -// // No hours passed and no hours to begin with0 -// ux.Body.Hours = 0; -// now = ux.Head.Time; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( hours == 0 ); - -// // Centuries have passed, time-based calculation overflows uint64 -// // when calculating the whole coin seconds -// ux.Body.Coins = 2000000; -// now = 0xFFFFFFFFFFFFFFFF; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); - -// // Centuries have passed, time-based calculation overflows uint64 -// // when calculating the droplet seconds -// ux.Body.Coins = 1500000; -// now = 0xFFFFFFFFFFFFFFFF; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); - -// // Output would overflow if given more hours, has reached its limit -// ux.Body.Coins = 3600000000; -// now = 0xFFFFFFFFFFFFFFFE; -// result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); -// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail" ); -// } - -// Test(coin_outputs, TestUxArrayCoins){ -// coin__UxArray uxs; -// int result = makeUxArray(&uxs, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// GoUint64 coins; -// result = SKY_coin_UxArray_Coins( &uxs, &coins ); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Coins failed" ); -// cr_assert( coins == 4000000 ); -// coin__UxOut* p = (coin__UxOut*)uxs.data; -// p += 2; -// p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; -// result = SKY_coin_UxArray_Coins( &uxs, &coins ); -// cr_assert( result == SKY_ERROR, "SKY_coin_UxArray_Coins should fail with overflow" ); -// } - -// Test(coin_outputs, TestUxArrayCoinHours){ -// coin__UxArray uxs; -// int result = makeUxArray(&uxs, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// coin__UxOut* p = (coin__UxOut*)uxs.data; -// GoUint64 n; - -// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( n == 400 ); - -// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600, &n); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( n == 404 ); - -// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600 + 4600, &n); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_CoinHours failed" ); -// cr_assert( n == 408 ); - -// p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; -// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); -// cr_assert( result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); - -// result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); -// cr_assert( result == SKY_ErrAddEarnedCoinHoursAdditionOverflow, "SKY_coin_UxOut_CoinHours should have fail with overflow" ); -// } - -// Test(coin_outputs, TestUxArrayHashArray){ -// coin__UxArray uxs; -// int result = makeUxArray(&uxs, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// coin__UxOut* p = (coin__UxOut*)uxs.data; - -// GoSlice_ hashes = {NULL, 0, 0}; -// result = SKY_coin_UxArray_Hashes(&uxs, &hashes); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Hashes failed" ); -// registerMemCleanup( hashes.data ); -// cr_assert(hashes.len == uxs.len); -// coin__UxOut* pux = (coin__UxOut*)uxs.data; -// cipher__SHA256* ph = (cipher__SHA256*)hashes.data; -// cipher__SHA256 hash; -// for(int i = 0; i < hashes.len; i++){ -// result = SKY_coin_UxOut_Hash(pux, &hash); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// cr_assert( eq( u8[sizeof(cipher__SHA256)], hash, *ph) ); -// pux++; -// ph++; -// } -// } - -// Test(coin_outputs, TestUxArrayHasDupes){ -// coin__UxArray uxs; -// int result = makeUxArray(&uxs, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// GoUint8 hasDupes; -// result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); -// cr_assert( hasDupes == 0 ); -// coin__UxOut* p = (coin__UxOut*)uxs.data; -// p++; -// memcpy(uxs.data, p, sizeof(coin__UxOut)); -// result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_HasDupes failed" ); -// cr_assert( hasDupes != 0 ); -// } - -// Test(coin_outputs, TestUxArraySub){ - -// int result, equal; -// coin__UxArray uxa, uxb, uxc, uxd; -// coin__UxArray t1, t2, t3, t4; - -// int arraySize = sizeof(coin__UxArray); -// memset(&uxa, 0, arraySize); memset(&uxb, 0, arraySize); -// memset(&uxc, 0, arraySize); memset(&uxd, 0, arraySize); -// memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); -// memset(&t3, 0, arraySize); memset(&t4, 0, arraySize); - -// result = makeUxArray(&uxa, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// result = makeUxArray(&uxb, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); - -// int elems_size = sizeof(coin__UxOut); -// cutSlice(&uxa, 0, 1, elems_size, &t1); -// cr_assert( result == SKY_OK, "cutSlice failed" ); -// result = concatSlices( &t1, &uxb, elems_size, &t2 ); -// cr_assert( result == SKY_OK, "concatSlices failed" ); -// result = cutSlice(&uxa, 1, 2, elems_size, &t3); -// cr_assert( result == SKY_OK, "cutSlice failed" ); -// result = concatSlices( &t2, &t3, elems_size, &uxc ); -// cr_assert( result == SKY_OK, "concatSlices failed" ); -// //TODO: Fix comparision -// memset(&uxd, 0, arraySize); -// result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); -// registerMemCleanup( uxd.data ); -// cr_assert( eq( type(coin__UxArray), uxd, uxb ) ); - -// // memset(&uxd, 0, arraySize); -// // result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); -// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); -// // registerMemCleanup( uxd.data ); -// // cr_assert( uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len ); -// // cutSlice(&uxa, 0, 2, elems_size, &t1); -// // cr_assert( eq( type(coin__UxArray), uxd, t1 ) ); - -// // // No intersection -// // memset(&t1, 0, arraySize); memset(&t2, 0, arraySize); -// // result = SKY_coin_UxArray_Sub(&uxa, &uxb, &t1); -// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); -// // registerMemCleanup( t1.data ); -// // result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); -// // cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sub failed" ); -// // registerMemCleanup( t2.data ); -// // cr_assert( eq( type(coin__UxArray), uxa, t1 ) ); -// // cr_assert( eq( type(coin__UxArray), uxb, t2 ) ); -// } - -// int isUxArraySorted(coin__UxArray* uxa){ -// int n = uxa->len; -// coin__UxOut* prev = uxa->data; -// coin__UxOut* current = prev; -// current++; -// cipher__SHA256 hash1, hash2; -// cipher__SHA256* prevHash = NULL; -// cipher__SHA256* currentHash = NULL; - -// int result; -// for(int i = 1; i < n; i++){ -// if(prevHash == NULL){ -// result = SKY_coin_UxOut_Hash(prev, &hash1); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// prevHash = &hash1; -// } -// if(currentHash == NULL) -// currentHash = &hash2; -// result = SKY_coin_UxOut_Hash(current, currentHash); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// if( memcmp(prevHash, currentHash, sizeof(cipher__SHA256)) > 0) -// return 0; //Array is not sorted -// if(i % 2 != 0){ -// prevHash = &hash2; -// currentHash = &hash1; -// } else { -// prevHash = &hash1; -// currentHash = &hash2; -// } -// prev++; -// current++; -// } -// return 1; -// } - -// Test(coin_outputs, TestUxArraySorting){ - -// int result; -// coin__UxArray uxa; -// result = makeUxArray(&uxa, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// int isSorted = isUxArraySorted(&uxa); -// if( isSorted ){ //If already sorted then break the order -// coin__UxOut temp; -// coin__UxOut* p = uxa.data; -// memcpy(&temp, p, sizeof(coin__UxOut)); -// memcpy(p, p + 1, sizeof(coin__UxOut)); -// memcpy(p + 1, &temp, sizeof(coin__UxOut)); -// } -// isSorted = isUxArraySorted(&uxa); -// cr_assert( isSorted == 0); -// result = SKY_coin_UxArray_Sort( &uxa ); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Sort failed" ); -// isSorted = isUxArraySorted(&uxa); -// cr_assert( isSorted == 1); -// } - -// Test(coin_outputs, TestUxArrayLen){ -// int result; -// coin__UxArray uxa; -// result = makeUxArray(&uxa, 4); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// GoInt len; -// result = SKY_coin_UxArray_Len(&uxa, &len); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Len failed" ); -// cr_assert( len == uxa.len ); -// cr_assert( len == 4 ); -// } - -// Test(coin_outputs, TestUxArrayLess){ -// int result; -// coin__UxArray uxa; -// result = makeUxArray(&uxa, 2); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// cipher__SHA256 hashes[2]; -// coin__UxOut* p = uxa.data; -// result = SKY_coin_UxOut_Hash(p, &hashes[0]); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// p++; -// result = SKY_coin_UxOut_Hash(p, &hashes[1]); -// cr_assert( result == SKY_OK, "SKY_coin_UxOut_Hash failed" ); -// GoUint8 lessResult1, lessResult2; -// int memcmpResult; -// result = SKY_coin_UxArray_Less(&uxa, 0, 1, &lessResult1); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); -// result = SKY_coin_UxArray_Less(&uxa, 1, 0, &lessResult2); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Less failed" ); -// memcmpResult = memcmp( &hashes[0], &hashes[1], sizeof(cipher__SHA256) ); -// int r; -// r = (lessResult1 == 1) == (memcmpResult < 0); -// cr_assert(r != 0); -// r = (lessResult2 == 1) == (memcmpResult > 0); -// cr_assert(r != 0); -// } - -// Test(coin_outputs, TestUxArraySwap){ -// int result; -// coin__UxArray uxa; -// result = makeUxArray(&uxa, 2); -// cr_assert( result == SKY_OK, "makeUxArray failed" ); -// coin__UxOut uxx, uxy; -// coin__UxOut* p = uxa.data; -// memcpy(&uxx, p, sizeof(coin__UxOut)); -// memcpy(&uxy, p + 1, sizeof(coin__UxOut)); - -// result = SKY_coin_UxArray_Swap(&uxa, 0, 1); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); -// cr_assert( eq(type(coin__UxOut), uxy, *p) ); -// cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); - -// result = SKY_coin_UxArray_Swap(&uxa, 0, 1); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); -// cr_assert( eq(type(coin__UxOut), uxy, *(p+1)) ); -// cr_assert( eq(type(coin__UxOut), uxx, *p) ); - -// result = SKY_coin_UxArray_Swap(&uxa, 1, 0); -// cr_assert( result == SKY_OK, "SKY_coin_UxArray_Swap failed" ); -// cr_assert( eq(type(coin__UxOut), uxy, *p) ); -// cr_assert( eq(type(coin__UxOut), uxx, *(p+1)) ); -// } - -// Test(coin_outputs, TestAddressUxOutsKeys){ -// int result; -// int test_count = 3; -// coin__UxOut uxs[test_count]; -// for(int i = 0; i < 3; i++){ -// makeUxOut(&uxs[i]); -// } - -// coin__UxArray uxa = {uxs, test_count, test_count}; -// AddressUxOuts_Handle uxOutsHandle; -// result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// GoSlice_ keys = {NULL, 0, 0}; -// result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed" ); -// registerMemCleanup(keys.data); -// cr_assert(keys.len == test_count); -// cipher__Address* pKey = keys.data; -// for(int i = 0; i < test_count; i++){ -// //Check if every key matches uxout -// int found = 0; -// for(int j = 0; j < test_count; j++){ -// if(memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0){ -// found = 1; -// } -// } -// cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); -// found = 0; -// if( i < test_count - 1){ -// cipher__Address* pKey2 = pKey; -// for(int j = i + 1; j < test_count; j++){ -// pKey2++; -// if(memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0){ -// found = 1; -// } -// } -// } -// cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); -// pKey++; -// } -// } - -// Test(coin_outputs, TestAddressUxOutsSub){ -// int result; -// coin__UxArray uxa, empty; -// makeUxArray(&uxa, 4); -// coin__UxOut* pData = uxa.data; -// memset(&empty, 0, sizeof(coin__UxArray)); -// AddressUxOuts_Handle h1, h2, h3; -// result = SKY_coin_NewAddressUxOuts(&empty, &h1); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h1); -// result = SKY_coin_NewAddressUxOuts(&empty, &h2); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h2); -// memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); - -// coin__UxArray ux2 = {pData, 2, 2}; -// result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux3 = {pData + 2, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux4 = {pData + 3, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - -// coin__UxArray ux5 = {pData, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux6 = {pData + 2, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - -// result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed" ); -// registerHandleClose(h3); - -// GoInt length; -// result = SKY_coin_AddressUxOuts_Length(h3, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// // One address should have been removed, because no elements -// cr_assert(length == 2, "Invalid length %d", length); -// GoInt8_ hasKey; -// result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed" ); -// cr_assert(hasKey == 0); - -// memset(&ux3, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux3.data); -// cr_assert(ux3.len == 1); -// coin__UxOut* pData2 = ux3.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 1); -// pData2 = ux2.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 1)) ); - -// // Originals should be unmodified -// result = SKY_coin_AddressUxOuts_Length(h1, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 3, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 2, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); - -// result = SKY_coin_AddressUxOuts_Length(h2, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 2, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// } - -// Test(coin_outputs, TestAddressUxOutsAdd){ -// int result; -// coin__UxArray uxa, empty; -// makeUxArray(&uxa, 4); -// coin__UxOut* pData = uxa.data; -// memset(&empty, 0, sizeof(coin__UxArray)); -// AddressUxOuts_Handle h1, h2, h3; -// result = SKY_coin_NewAddressUxOuts(&empty, &h1); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h1); -// result = SKY_coin_NewAddressUxOuts(&empty, &h2); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h2); -// memcpy(&(pData+1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); - -// coin__UxArray ux2 = {pData, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux3 = {pData + 2, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux4 = {pData + 3, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - -// coin__UxArray ux5 = {pData + 1, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// coin__UxArray ux6 = {pData + 2, 1, 1}; -// result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - -// result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed" ); -// registerHandleClose(h3); - -// GoInt length; -// result = SKY_coin_AddressUxOuts_Length(h3, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// // One address should have been removed, because no elements -// cr_assert(length == 3, "Invalid length %d", length); - -// result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 2, "Invalid length %d", length); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 2); -// coin__UxOut* pData2 = ux2.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); -// cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+2)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 1); -// pData2 = ux2.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 2)) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+3)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 1); -// pData2 = ux2.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *(pData + 3)) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h3, &(pData+1)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 2); -// pData2 = ux2.data; -// cr_assert( eq(type(coin__UxOut), *pData2, *pData) ); -// cr_assert( eq(type(coin__UxOut), *(pData2+1), *(pData+1)) ); - -// // Originals should be unmodified -// result = SKY_coin_AddressUxOuts_Length(h1, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 3, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+2)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData+3)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_Length(h2, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 2, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData+2)->Body.Address, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 1, "Invalid length %d", length); -// } - -// Test(coin_outputs, TestAddressUxOutsFlatten){ -// int result; -// coin__UxArray uxa, emptyArray; -// makeUxArray(&uxa, 3); -// coin__UxOut* pData = uxa.data; -// memcpy(&(pData+2)->Body.Address, &(pData+1)->Body.Address, sizeof(cipher__Address)); -// memset(&emptyArray, 0, sizeof(coin__UxArray)); -// AddressUxOuts_Handle h; -// result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h); -// cipher__Address emptyAddr; -// makeAddress(&emptyAddr); -// coin__UxArray ux1 = {pData, 1, 1}; -// coin__UxArray ux2 = {pData+1, 2, 2}; -// result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); -// result = SKY_coin_AddressUxOuts_Set(h, &(pData+1)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOut_Set failed" ); - -// coin__UxArray flatArray; -// memset(&flatArray, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed" ); -// registerMemCleanup( flatArray.data ); -// cr_assert( flatArray.len == 3 ); -// // emptyAddr should not be in the array -// coin__UxOut* pData2 = flatArray.data; -// for(int i = 0; i < flatArray.len; pData2++, i++){ -// int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); -// cr_assert(cmp != 0); -// } -// pData2 = flatArray.data; -// int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); -// if(cmp == 0){ -// cr_assert( eq( type(coin__UxOut), *pData2, *pData ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+2) ) ); -// cr_assert( eq( type(cipher__Address), pData2->Body.Address, pData->Body.Address ) ); -// cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+1)->Body.Address ) ); -// cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData+2)->Body.Address ) ); -// }else{ -// cr_assert( eq( type(coin__UxOut), *pData2, *(pData+1) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+2) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData) ) ); -// cr_assert( eq( type(cipher__Address), pData2->Body.Address, (pData+1)->Body.Address ) ); -// cr_assert( eq( type(cipher__Address), (pData2+1)->Body.Address, (pData+2)->Body.Address ) ); -// cr_assert( eq( type(cipher__Address), (pData2+2)->Body.Address, (pData)->Body.Address ) ); -// } -// } - - -// Test(coin_outputs, TestNewAddressUxOuts){ -// int result; -// coin__UxArray uxa, ux2; -// makeUxArray(&uxa, 6); -// coin__UxOut* pData = uxa.data; -// memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); -// memcpy(&(pData + 3)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); -// memcpy(&(pData + 4)->Body.Address, &(pData+2)->Body.Address, sizeof(cipher__Address)); -// AddressUxOuts_Handle h; -// result = SKY_coin_NewAddressUxOuts(&uxa, &h); -// cr_assert( result == SKY_OK, "SKY_coin_NewAddressUxOuts failed" ); -// registerHandleClose(h); - -// GoInt length; -// result = SKY_coin_AddressUxOuts_Length(h, &length); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed" ); -// cr_assert(length == 3); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 2); -// coin__UxOut* pData2 = ux2.data; -// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+1) ) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h, &(pData+3)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 3); -// pData2 = ux2.data; -// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+2) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+1), *(pData+3) ) ); -// cr_assert( eq( type(coin__UxOut), *(pData2+2), *(pData+4) ) ); - -// memset(&ux2, 0, sizeof(coin__UxArray)); -// result = SKY_coin_AddressUxOuts_Get(h, &(pData+5)->Body.Address, &ux2); -// cr_assert( result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed" ); -// registerMemCleanup(ux2.data); -// cr_assert(ux2.len == 1); -// pData2 = ux2.data; -// cr_assert( eq( type(coin__UxOut), *(pData2), *(pData+5) ) ); -// } +#include +#include + +#include +#include + +#include "libskycoin.h" +#include "skyerrors.h" +#include "skystring.h" +#include "skytest.h" +#include "skycriterion.h" +#include "transutil.h" + +TestSuite(coin_outputs, .init = setup, .fini = teardown); + +Test(coin_outputs, TestUxBodyHash) +{ + int result; + coin__UxBody uxbody; + result = makeUxBody(&uxbody); + cr_assert(result == SKY_OK, "makeUxBody failed"); + cipher__SHA256 hash, nullHash; + result = SKY_coin_UxBody_Hash(&uxbody, &hash); + cr_assert(result == SKY_OK, "SKY_coin_UxBody_Hash failed"); + memset(&nullHash, 0, sizeof(cipher__SHA256)); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], nullHash, hash))); +} + +Test(coin_outputs, TestUxOutHash) +{ + int result; + coin__UxBody uxbody; + result = makeUxBody(&uxbody); + cr_assert(result == SKY_OK, "makeUxBody failed"); + + coin__UxOut uxout; + memset(&uxout, 0, sizeof(coin__UxOut)); + memcpy(&uxout.Body, &uxbody, sizeof(coin__UxBody)); + + cipher__SHA256 hashBody, hashOut; + result = SKY_coin_UxBody_Hash(&uxbody, &hashBody); + cr_assert(result == SKY_OK, "SKY_coin_UxBody_Hash failed"); + result = SKY_coin_UxOut_Hash(&uxout, &hashOut); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hashBody, hashOut)); + + //Head should not affect hash + uxout.Head.Time = 0; + uxout.Head.BkSeq = 1; + result = SKY_coin_UxOut_Hash(&uxout, &hashOut); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hashBody, hashOut)); +} + +Test(coin_outputs, TestUxOutSnapshotHash) +{ + int result; + coin__UxOut uxout, uxout2; + result = makeUxOut(&uxout); + cr_assert(result == SKY_OK, "makeUxOut failed"); + cipher__SHA256 hash1, hash2; + result = SKY_coin_UxOut_SnapshotHash(&uxout, &hash1); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + uxout2.Head.Time = 20; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + uxout2.Head.BkSeq = 4; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + makeRandHash(&uxout2.Body.SrcTransaction); + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + makeAddress(&uxout2.Body.Address); + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + uxout2.Body.Coins = uxout.Body.Coins * 2; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); + + memcpy(&uxout2, &uxout, sizeof(coin__UxOut)); + uxout2.Body.Hours = uxout.Body.Hours * 2; + result = SKY_coin_UxOut_SnapshotHash(&uxout2, &hash2); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_SnapshotHash failed"); + cr_assert(not(eq(u8[sizeof(cipher__SHA256)], hash1, hash2)), "Snapshot hash must be different"); +} + +Test(coin_outputs, TestUxOutCoinHours) +{ + GoUint64 _genCoins = 1000000000; + GoUint64 _genCoinHours = 1000 * 1000; + + int result; + coin__UxOut ux; + result = makeUxOut(&ux); + cr_assert(result == SKY_OK, "makeUxOut failed"); + + GoUint64 now, hours; + + //Less than an hour passed + now = ux.Head.Time + 100; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours); + + //An hour passed + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + ux.Body.Coins / 1000000); + + //6 hours passed + now = ux.Head.Time + 3600 * 6; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + (ux.Body.Coins / 1000000) * 6); + + //Time is backwards (treated as no hours passed) + now = ux.Head.Time / 2; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours); + + //1 hour has passed, output has 1.5 coins, should gain 1 coinhour + ux.Body.Coins = 1500000; + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + 1); + + //2 hours have passed, output has 1.5 coins, should gain 3 coin hours + ux.Body.Coins = 1500000; + now = ux.Head.Time + 3600 * 2; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + 3); + + //1 second has passed, output has 3600 coins, should gain 1 coin hour + ux.Body.Coins = 3600000000; + now = ux.Head.Time + 1; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + 1); + + //1000000 hours minus 1 second have passed, output has 1 droplet, should gain 0 coin hour + ux.Body.Coins = 1; + now = ux.Head.Time + (GoUint64)(1000000) * (GoUint64)(3600) - 1; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours); + + //1000000 hours have passed, output has 1 droplet, should gain 1 coin hour + ux.Body.Coins = 1; + now = ux.Head.Time + (GoUint64)(1000000) * (GoUint64)(3600); + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + 1); + + // No hours passed, using initial coin hours + ux.Body.Coins = _genCoins; + ux.Body.Hours = _genCoinHours; + now = ux.Head.Time; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours); + + // One hour passed, using initial coin hours + now = ux.Head.Time + 3600; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == ux.Body.Hours + _genCoins / 1000000); + + // No hours passed and no hours to begin with0 + ux.Body.Hours = 0; + now = ux.Head.Time; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(hours == 0); + + // Centuries have passed, time-based calculation overflows uint64 + // when calculating the whole coin seconds + ux.Body.Coins = 2000000; + now = 0xFFFFFFFFFFFFFFFF; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail"); + + // Centuries have passed, time-based calculation overflows uint64 + // when calculating the droplet seconds + ux.Body.Coins = 1500000; + now = 0xFFFFFFFFFFFFFFFF; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail"); + + // Output would overflow if given more hours, has reached its limit + ux.Body.Coins = 3600000000; + now = 0xFFFFFFFFFFFFFFFE; + result = SKY_coin_UxOut_CoinHours(&ux, now, &hours); + cr_assert(result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should fail"); +} + +Test(coin_outputs, TestUxArrayCoins) +{ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + GoUint64 coins; + result = SKY_coin_UxArray_Coins(&uxs, &coins); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Coins failed"); + cr_assert(coins == 4000000); + coin__UxOut *p = (coin__UxOut *)uxs.data; + p += 2; + p->Body.Coins = 0xFFFFFFFFFFFFFFFF - 1000000; + result = SKY_coin_UxArray_Coins(&uxs, &coins); + cr_assert(result == SKY_ERROR, "SKY_coin_UxArray_Coins should fail with overflow"); +} + +Test(coin_outputs, TestUxArrayCoinHours) +{ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + coin__UxOut *p = (coin__UxOut *)uxs.data; + GoUint64 n; + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(n == 400); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600, &n); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(n == 404); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time + 3600 + 4600, &n); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_CoinHours failed"); + cr_assert(n == 408); + + p[2].Body.Hours = 0xFFFFFFFFFFFFFFFF - 100; + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time, &n); + cr_assert(result == SKY_ERROR, "SKY_coin_UxOut_CoinHours should have fail with overflow"); + + result = SKY_coin_UxArray_CoinHours(&uxs, p->Head.Time * (GoUint64)1000000000000, &n); + cr_assert(result == SKY_ErrAddEarnedCoinHoursAdditionOverflow, "SKY_coin_UxOut_CoinHours should have fail with overflow"); +} + +Test(coin_outputs, TestUxArrayHashArray) +{ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + coin__UxOut *p = (coin__UxOut *)uxs.data; + + GoSlice_ hashes = {NULL, 0, 0}; + result = SKY_coin_UxArray_Hashes(&uxs, &hashes); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Hashes failed"); + registerMemCleanup(hashes.data); + cr_assert(hashes.len == uxs.len); + coin__UxOut *pux = (coin__UxOut *)uxs.data; + cipher__SHA256 *ph = (cipher__SHA256 *)hashes.data; + cipher__SHA256 hash; + for (int i = 0; i < hashes.len; i++) + { + result = SKY_coin_UxOut_Hash(pux, &hash); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + cr_assert(eq(u8[sizeof(cipher__SHA256)], hash, *ph)); + pux++; + ph++; + } +} + +Test(coin_outputs, TestUxArrayHasDupes) +{ + coin__UxArray uxs; + int result = makeUxArray(&uxs, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + GoUint8 hasDupes; + result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_HasDupes failed"); + cr_assert(hasDupes == 0); + coin__UxOut *p = (coin__UxOut *)uxs.data; + p++; + memcpy(uxs.data, p, sizeof(coin__UxOut)); + result = SKY_coin_UxArray_HasDupes(&uxs, &hasDupes); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_HasDupes failed"); + cr_assert(hasDupes != 0); +} + +Test(coin_outputs, TestUxArraySub) +{ + + int result, equal; + coin__UxArray uxa, uxb, uxc, uxd; + coin__UxArray t1, t2, t3, t4; + + int arraySize = sizeof(coin__UxArray); + memset(&uxa, 0, arraySize); + memset(&uxb, 0, arraySize); + memset(&uxc, 0, arraySize); + memset(&uxd, 0, arraySize); + memset(&t1, 0, arraySize); + memset(&t2, 0, arraySize); + memset(&t3, 0, arraySize); + memset(&t4, 0, arraySize); + + result = makeUxArray(&uxa, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + result = makeUxArray(&uxb, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + + int elems_size = sizeof(coin__UxOut); + cutSlice(&uxa, 0, 1, elems_size, &t1); + cr_assert(result == SKY_OK, "cutSlice failed"); + result = concatSlices(&t1, &uxb, elems_size, &t2); + cr_assert(result == SKY_OK, "concatSlices failed"); + result = cutSlice(&uxa, 1, 2, elems_size, &t3); + cr_assert(result == SKY_OK, "cutSlice failed"); + result = concatSlices(&t2, &t3, elems_size, &uxc); + cr_assert(result == SKY_OK, "concatSlices failed"); + // //TODO: Fix comparision + memset(&uxd, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxc, &uxa, &uxd); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Sub failed"); + cr_assert(eq(type(coin__UxArray), uxd, uxb)); + + memset(&uxd, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxc, &uxb, &uxd); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Sub failed"); + cr_assert(uxd.len == 2, "uxd length must be 2 and it is: %s", uxd.len); + cutSlice(&uxa, 0, 2, elems_size, &t1); + cr_assert(eq(type(coin__UxArray), uxd, t1)); + + // No intersection + memset(&t1, 0, arraySize); + memset(&t2, 0, arraySize); + result = SKY_coin_UxArray_Sub(&uxa, &uxb, &t1); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Sub failed"); + result = SKY_coin_UxArray_Sub(&uxb, &uxa, &t2); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Sub failed"); + cr_assert(eq(type(coin__UxArray), uxa, t1)); + cr_assert(eq(type(coin__UxArray), uxb, t2)); +} + +int isUxArraySorted(coin__UxArray *uxa) +{ + int n = uxa->len; + coin__UxOut *prev = uxa->data; + coin__UxOut *current = prev; + current++; + cipher__SHA256 hash1, hash2; + cipher__SHA256 *prevHash = NULL; + cipher__SHA256 *currentHash = NULL; + + int result; + for (int i = 1; i < n; i++) + { + if (prevHash == NULL) + { + result = SKY_coin_UxOut_Hash(prev, &hash1); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + prevHash = &hash1; + } + if (currentHash == NULL) + currentHash = &hash2; + result = SKY_coin_UxOut_Hash(current, currentHash); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + if (memcmp(prevHash, currentHash, sizeof(cipher__SHA256)) > 0) + return 0; //Array is not sorted + if (i % 2 != 0) + { + prevHash = &hash2; + currentHash = &hash1; + } + else + { + prevHash = &hash1; + currentHash = &hash2; + } + prev++; + current++; + } + return 1; +} + +Test(coin_outputs, TestUxArraySorting) +{ + + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + int isSorted = isUxArraySorted(&uxa); + if (isSorted) + { //If already sorted then break the order + coin__UxOut temp; + coin__UxOut *p = uxa.data; + memcpy(&temp, p, sizeof(coin__UxOut)); + memcpy(p, p + 1, sizeof(coin__UxOut)); + memcpy(p + 1, &temp, sizeof(coin__UxOut)); + } + isSorted = isUxArraySorted(&uxa); + cr_assert(isSorted == 0); + result = SKY_coin_UxArray_Sort(&uxa); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Sort failed"); + isSorted = isUxArraySorted(&uxa); + cr_assert(isSorted == 1); +} + +Test(coin_outputs, TestUxArrayLen) +{ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 4); + cr_assert(result == SKY_OK, "makeUxArray failed"); + GoInt len; + result = SKY_coin_UxArray_Len(&uxa, &len); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Len failed"); + cr_assert(len == uxa.len); + cr_assert(len == 4); +} + +Test(coin_outputs, TestUxArrayLess) +{ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 2); + cr_assert(result == SKY_OK, "makeUxArray failed"); + cipher__SHA256 hashes[2]; + coin__UxOut *p = uxa.data; + result = SKY_coin_UxOut_Hash(p, &hashes[0]); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + p++; + result = SKY_coin_UxOut_Hash(p, &hashes[1]); + cr_assert(result == SKY_OK, "SKY_coin_UxOut_Hash failed"); + GoUint8 lessResult1, lessResult2; + int memcmpResult; + result = SKY_coin_UxArray_Less(&uxa, 0, 1, &lessResult1); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Less failed"); + result = SKY_coin_UxArray_Less(&uxa, 1, 0, &lessResult2); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Less failed"); + memcmpResult = memcmp(&hashes[0], &hashes[1], sizeof(cipher__SHA256)); + int r; + r = (lessResult1 == 1) == (memcmpResult < 0); + cr_assert(r != 0); + r = (lessResult2 == 1) == (memcmpResult > 0); + cr_assert(r != 0); +} + +Test(coin_outputs, TestUxArraySwap) +{ + int result; + coin__UxArray uxa; + result = makeUxArray(&uxa, 2); + cr_assert(result == SKY_OK, "makeUxArray failed"); + coin__UxOut uxx, uxy; + coin__UxOut *p = uxa.data; + memcpy(&uxx, p, sizeof(coin__UxOut)); + memcpy(&uxy, p + 1, sizeof(coin__UxOut)); + + result = SKY_coin_UxArray_Swap(&uxa, 0, 1); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Swap failed"); + cr_assert(eq(type(coin__UxOut), uxy, *p)); + cr_assert(eq(type(coin__UxOut), uxx, *(p + 1))); + + result = SKY_coin_UxArray_Swap(&uxa, 0, 1); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Swap failed"); + cr_assert(eq(type(coin__UxOut), uxy, *(p + 1))); + cr_assert(eq(type(coin__UxOut), uxx, *p)); + + result = SKY_coin_UxArray_Swap(&uxa, 1, 0); + cr_assert(result == SKY_OK, "SKY_coin_UxArray_Swap failed"); + cr_assert(eq(type(coin__UxOut), uxy, *p)); + cr_assert(eq(type(coin__UxOut), uxx, *(p + 1))); +} + +Test(coin_outputs, TestAddressUxOutsKeys) +{ + int result; + int test_count = 3; + coin__UxOut uxs[test_count]; + for (int i = 0; i < 3; i++) + { + makeUxOut(&uxs[i]); + } + + coin__UxArray uxa = {uxs, test_count, test_count}; + AddressUxOuts_Handle uxOutsHandle; + result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + GoSlice_ keys = {NULL, 0, 0}; + result = SKY_coin_AddressUxOuts_Keys(uxOutsHandle, &keys); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Keys failed"); + registerMemCleanup(keys.data); + cr_assert(keys.len == test_count); + cipher__Address *pKey = keys.data; + for (int i = 0; i < test_count; i++) + { + //Check if every key matches uxout + int found = 0; + for (int j = 0; j < test_count; j++) + { + if (memcmp(pKey, &uxs[j].Body.Address, sizeof(cipher__Address)) == 0) + { + found = 1; + } + } + cr_assert(found == 1, "Invalid key received from SKY_coin_AddressUxOuts_Keys"); + found = 0; + if (i < test_count - 1) + { + cipher__Address *pKey2 = pKey; + for (int j = i + 1; j < test_count; j++) + { + pKey2++; + if (memcmp(pKey, pKey2, sizeof(cipher__Address)) == 0) + { + found = 1; + } + } + } + cr_assert(found == 0, "Duplicate keys received from SKY_coin_AddressUxOuts_Keys"); + pKey++; + } +} + +Test(coin_outputs, TestAddressUxOutsSub) +{ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut *pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h2); + memcpy(&(pData + 1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + + coin__UxArray ux5 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + + result = SKY_coin_AddressUxOuts_Sub(h1, h2, &h3); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Sub failed"); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + // One address should have been removed, because no elements + cr_assert(length == 2, "Invalid length %d", length); + GoInt8_ hasKey; + result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed"); + cr_assert(hasKey == 0); + + memset(&ux3, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux3); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux3.data); + cr_assert(ux3.len == 1); + coin__UxOut *pData2 = ux3.data; + cr_assert(eq(type(coin__UxOut), *pData2, *(pData + 3))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *pData2, *(pData + 1))); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData + 2)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData + 3)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData + 2)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsAdd) +{ + int result; + coin__UxArray uxa, empty; + makeUxArray(&uxa, 4); + coin__UxOut *pData = uxa.data; + memset(&empty, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h1, h2, h3; + result = SKY_coin_NewAddressUxOuts(&empty, &h1); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h1); + result = SKY_coin_NewAddressUxOuts(&empty, &h2); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h2); + memcpy(&(pData + 1)->Body.Address, &pData->Body.Address, sizeof(cipher__Address)); + + coin__UxArray ux2 = {pData, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &pData->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux3 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 2)->Body.Address, &ux3); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux4 = {pData + 3, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h1, &(pData + 3)->Body.Address, &ux4); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + + coin__UxArray ux5 = {pData + 1, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &pData->Body.Address, &ux5); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + coin__UxArray ux6 = {pData + 2, 1, 1}; + result = SKY_coin_AddressUxOuts_Set(h2, &(pData + 2)->Body.Address, &ux6); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + + result = SKY_coin_AddressUxOuts_Add(h1, h2, &h3); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Add failed"); + registerHandleClose(h3); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h3, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + // One address should have been removed, because no elements + cr_assert(length == 3, "Invalid length %d", length); + + result = SKY_coin_AddressUxOuts_GetOutputLength(h3, &pData->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 2, "Invalid length %d", length); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &pData->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut *pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *pData2, *pData)); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 1))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 2)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *pData2, *(pData + 2))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 3)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *pData2, *(pData + 3))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h3, &(pData + 1)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *pData2, *pData)); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 1))); + + // Originals should be unmodified + result = SKY_coin_AddressUxOuts_Length(h1, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 3, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &pData->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData + 2)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h1, &(pData + 3)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_Length(h2, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 2, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &pData->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); + result = SKY_coin_AddressUxOuts_GetOutputLength(h2, &(pData + 2)->Body.Address, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 1, "Invalid length %d", length); +} + +Test(coin_outputs, TestAddressUxOutsFlatten) +{ + int result; + coin__UxArray uxa, emptyArray; + makeUxArray(&uxa, 3); + coin__UxOut *pData = uxa.data; + memcpy(&(pData + 2)->Body.Address, &(pData + 1)->Body.Address, sizeof(cipher__Address)); + memset(&emptyArray, 0, sizeof(coin__UxArray)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&emptyArray, &h); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h); + cipher__Address emptyAddr; + makeAddress(&emptyAddr); + coin__UxArray ux1 = {pData, 1, 1}; + coin__UxArray ux2 = {pData + 1, 2, 2}; + result = SKY_coin_AddressUxOuts_Set(h, &emptyAddr, &emptyArray); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + result = SKY_coin_AddressUxOuts_Set(h, &pData->Body.Address, &ux1); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + result = SKY_coin_AddressUxOuts_Set(h, &(pData + 1)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOut_Set failed"); + + coin__UxArray flatArray; + memset(&flatArray, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Flatten(h, &flatArray); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Flatten failed"); + registerMemCleanup(flatArray.data); + cr_assert(flatArray.len == 3); + // emptyAddr should not be in the array + coin__UxOut *pData2 = flatArray.data; + for (int i = 0; i < flatArray.len; pData2++, i++) + { + int cmp = memcmp(&emptyAddr, &pData2->Body.Address, sizeof(cipher__Address)); + cr_assert(cmp != 0); + } + pData2 = flatArray.data; + int cmp = memcmp(&pData->Body.Address, &pData2->Body.Address, sizeof(cipher__Address)); + if (cmp == 0) + { + cr_assert(eq(type(coin__UxOut), *pData2, *pData)); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 1))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 2), *(pData + 2))); + cr_assert(eq(type(cipher__Address), pData2->Body.Address, pData->Body.Address)); + cr_assert(eq(type(cipher__Address), (pData2 + 1)->Body.Address, (pData + 1)->Body.Address)); + cr_assert(eq(type(cipher__Address), (pData2 + 2)->Body.Address, (pData + 2)->Body.Address)); + } + else + { + cr_assert(eq(type(coin__UxOut), *pData2, *(pData + 1))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 2))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 2), *(pData))); + cr_assert(eq(type(cipher__Address), pData2->Body.Address, (pData + 1)->Body.Address)); + cr_assert(eq(type(cipher__Address), (pData2 + 1)->Body.Address, (pData + 2)->Body.Address)); + cr_assert(eq(type(cipher__Address), (pData2 + 2)->Body.Address, (pData)->Body.Address)); + } +} + +Test(coin_outputs, TestNewAddressUxOuts) +{ + int result; + coin__UxArray uxa, ux2; + makeUxArray(&uxa, 6); + coin__UxOut *pData = uxa.data; + memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 3)->Body.Address, &(pData + 2)->Body.Address, sizeof(cipher__Address)); + memcpy(&(pData + 4)->Body.Address, &(pData + 2)->Body.Address, sizeof(cipher__Address)); + AddressUxOuts_Handle h; + result = SKY_coin_NewAddressUxOuts(&uxa, &h); + cr_assert(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed"); + registerHandleClose(h); + + GoInt length; + result = SKY_coin_AddressUxOuts_Length(h, &length); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); + cr_assert(length == 3); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 2); + coin__UxOut *pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *(pData2), *(pData))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 1))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData + 3)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 3); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *(pData2), *(pData + 2))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 1), *(pData + 3))); + cr_assert(eq(type(coin__UxOut), *(pData2 + 2), *(pData + 4))); + + memset(&ux2, 0, sizeof(coin__UxArray)); + result = SKY_coin_AddressUxOuts_Get(h, &(pData + 5)->Body.Address, &ux2); + cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Get failed"); + registerMemCleanup(ux2.data); + cr_assert(ux2.len == 1); + pData2 = ux2.data; + cr_assert(eq(type(coin__UxOut), *(pData2), *(pData + 5))); +} diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index 14d07302c1..cd802fea90 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -277,12 +277,11 @@ char *cr_user_coin__TransactionOutput_tostr(coin__TransactionOutput *x1) int cr_user_coin__UxArray_eq(coin__UxArray *slice1, coin__UxArray *slice2) { return (memcmp(slice1->data, slice2->data, slice1->len) == 0) && ((slice1->len == slice2->len)); - // return true; } -int cr_user_coin__UxArray_noteq(coin__UxArray *x1, coin__UxArray *x2) +int cr_user_coin__UxArray_noteq(coin__UxArray *slice1, coin__UxArray *slice2) { - return false; + return (memcmp(slice1->data, slice2->data, slice1->len) != 0) && ((slice1->len != slice2->len)); } char *cr_user_coin__UxArray_tostr(coin__UxArray *x1) From 4dc478555e8d7863af76be6ab970a4ff4ef06e19 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sun, 12 Aug 2018 16:03:34 -0400 Subject: [PATCH 213/399] [libc][test][core] refs #1191 reapir error in travis MAC --- lib/cgo/tests/check_coin.transactions.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 87ee4cd875..e0c071a094 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -168,7 +168,7 @@ Test(coin_transaction, TestTransactionVerify) cr_assert(result == SKY_OK); } -Test(coin_transaction, TestTransactionPushInput, .signal = SIGABRT) +Test(coin_transaction, TestTransactionPushInput, SKY_ABORT) { int result; Transaction__Handle handle; @@ -298,7 +298,7 @@ Test(coin_transaction, TestTransactionsSize) cr_assert(sizeTransactions == size); } -Test(coin_transactions, TestTransactionVerifyInput, .signal = SIGABRT) +Test(coin_transactions, TestTransactionVerifyInput, SKY_ABORT) { int result; Transaction__Handle handle; @@ -401,7 +401,7 @@ Test(coin_transactions, TestTransactionVerifyInput, .signal = SIGABRT) cr_assert(result == SKY_OK); } -Test(coin_transactions, TestTransactionSignInputs, .signal = SIGABRT) +Test(coin_transactions, TestTransactionSignInputs, SKY_ABORT) { int result; coin__Transaction *ptx; From c33eb0a3cb28ab1abe205124325d64c4ff4b235f Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Mon, 13 Aug 2018 09:46:08 -0400 Subject: [PATCH 214/399] [swig] refs #1191 correcting skycoin.mem.i --- lib/swig/skycoin.mem.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i index 0b1b283ca9..fa1a549b50 100644 --- a/lib/swig/skycoin.mem.i +++ b/lib/swig/skycoin.mem.i @@ -106,24 +106,24 @@ %rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; %inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys){ + GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys, GoInt* __out_Len){ GoSlice_ data; data.data = __in_pubKeys->data; data.len = __in_pubKeys->count; data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Len(&data); + GoUint32 result = SKY_cipher_PubKeySlice_Len(&data,__out_Len); return result; } } %rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; %inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ + GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2, GoUint8* __out_Less){ GoSlice_ data; data.data = __in_pubKeys->data; data.len = __in_pubKeys->count; data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2); + GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2,__out_Less); return result; } } From 49fa1f009f2a508f8825dd515669e6247137c475 Mon Sep 17 00:00:00 2001 From: stdevEclipse Date: Mon, 13 Aug 2018 14:33:33 +0000 Subject: [PATCH 215/399] [libc] refs #1191 - Fix bug in function SKY_coin_AddressUxOuts_Set, copy slice received as parameter, allocated in C, so it can be kept in Go --- lib/cgo/coin.outputs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 8fcc2bae02..84e0ddf39c 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -347,7 +347,13 @@ func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__A a, ok := lookupAddressUxOutHandle(handle) if ok { key := *(*cipher.Address)(unsafe.Pointer(_key)) - uxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) + //Copy the slice because it is going to be kept + //We can't hold memory allocated outside Go + tempUxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) + uxOuts := make(coin.UxArray, 0, len(tempUxOuts)) + for _, ux := range tempUxOuts { + uxOuts = append(uxOuts, ux) + } (*a)[key] = uxOuts return SKY_OK } From de2ae71981cde4bb6e4f285d16a9661c4c03d211 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Mon, 13 Aug 2018 19:23:29 -0400 Subject: [PATCH 216/399] [libc][core] Repair error in lib/cgo/coin.outputs.go [====] Synthesis: Tested: 144 | Passing: 144 | Failing: 0 | Crashing: 0 --- lib/cgo/coin.outputs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 80e06192fc..8bac865ce1 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -200,7 +200,7 @@ func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Sub(other) - *_arg1 = *(*C.coin__UxArray)(unsafe.Pointer(&__arg1)) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } From 4baa4d29529fd4f1b1fc1d5d90d5b368cd81374f Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Wed, 22 Aug 2018 20:05:07 +0000 Subject: [PATCH 217/399] [daemon] refs #735 - Check for the whole RJCT message prefix before creating RJCT messages --- src/daemon/messages.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 0502b56505..5f970a43ec 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -18,8 +18,8 @@ import ( ) var ( - // Every rejection message prefix must start with "RJC" prefix - rejectPrefix = [...]byte{82, 74, 67} + // Every rejection message prefix must start with "RJCT" prefix + rejectPrefix = [...]byte{82, 74, 67, 84} // ErrAckReject disconnect since peer sent RJCT message ErrAckReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") ) @@ -444,7 +444,7 @@ func NewRejectMessage(msg gnet.Message, err error, reason string) *RejectMessage if !exists { logger.Panicf("Rejecting unknown message type %s", t) } - if reflect.DeepEqual(prefix[:3], rejectPrefix[:]) { + if reflect.DeepEqual(prefix[:], rejectPrefix[:]) { logger.Panicf("Message type %s (prefix = %s) may not be rejected", t, prefix) } From 65109ce1dce01ae5df4fd15371db7e05fcaeb8b9 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 30 Aug 2018 08:02:43 -0400 Subject: [PATCH 218/399] [libc][test] refs # 1191 repair errors by review https://github.com/skycoin/skycoin/pull/1639\#pullrequestreview-150698295 [====] Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0 --- include/coin.transactions.go.h | 6 - include/skytypes.h | 4 + include/swig.h | 50 -- include/wallet.wallet.go.h | 10 - lib/cgo/api.client.go | 183 ++++---- lib/cgo/api.spend.go | 15 +- lib/cgo/api.wallet.go | 3 +- lib/cgo/api.webrpc.client.go | 61 +-- lib/cgo/cipher.address.go | 56 +-- lib/cgo/cipher.base58.base58.go | 30 +- lib/cgo/cipher.crypto.go | 40 -- lib/cgo/cipher.encoder.field.go | 6 +- .../cipher.encrypt.scrypt_chacha20poly1305.go | 4 +- lib/cgo/cipher.encrypt.sha256xor.go | 2 + lib/cgo/cipher.go-bip39.bip39.go | 15 +- lib/cgo/cipher.hash.go | 14 - lib/cgo/cipher.poly1305.poly1305.go | 3 +- lib/cgo/cipher.ripemd160.ripemd160.go | 7 +- lib/cgo/cipher.scrypt.scrypt.go | 3 +- lib/cgo/cipher.secp256k1-go.secp256_rand.go | 6 +- .../cipher.secp256k1-go.secp256k1-go2.ec.go | 24 +- ...cipher.secp256k1-go.secp256k1-go2.field.go | 19 + .../cipher.secp256k1-go.secp256k1-go2.num.go | 15 +- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 27 +- .../cipher.secp256k1-go.secp256k1-go2.xy.go | 33 +- .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 24 +- lib/cgo/cipher.secp256k1-go.secp256k1.go | 16 + lib/cgo/cli.add_private_key.go | 6 +- lib/cgo/cli.check_balance.go | 6 +- lib/cgo/cli.cli.go | 24 +- lib/cgo/cli.create_rawtx.go | 1 + lib/cgo/cli.generate_addrs.go | 12 +- lib/cgo/cli.generate_wallet.go | 6 +- lib/cgo/cli.outputs.go | 14 +- lib/cgo/cli_helper.go | 18 +- lib/cgo/coin.block.go | 70 ++- lib/cgo/coin.math.go | 9 +- lib/cgo/coin.outputs.go | 20 +- lib/cgo/coin.transactions.go | 156 ++++--- lib/cgo/libsky_error.go | 13 +- lib/cgo/libsky_handle.go | 46 +- lib/cgo/libsky_handle_helper.go | 56 +-- lib/cgo/libsky_mem.go | 12 - lib/cgo/tests/check_cipher.address.c | 101 ----- lib/cgo/tests/check_cipher.hash.c | 22 +- lib/cgo/testutil.testutil.go | 3 +- lib/cgo/util.apputil.apputil.go | 9 +- lib/cgo/util.browser.browser.go | 3 +- lib/cgo/util.cert.cert.go | 3 +- lib/cgo/util.droplet.droplet.go | 6 +- lib/cgo/util.fee.fee.go | 15 +- lib/cgo/util.file.file.go | 12 +- lib/cgo/util.http.json.go | 24 +- lib/cgo/util.iputil.iputil.go | 9 +- lib/cgo/util.logging.logging.go | 9 +- lib/cgo/util.utc.utc.go | 3 +- lib/cgo/wallet.addresses.go | 9 +- lib/cgo/wallet.balance.go | 18 +- lib/cgo/wallet.crypto.go | 3 +- lib/cgo/wallet.entry.go | 6 +- lib/cgo/wallet.notes.go | 226 --------- lib/cgo/wallet.readable.go | 24 +- lib/cgo/wallet.wallet.go | 45 +- lib/swig/README.md | 52 --- lib/swig/cmp.i | 47 -- lib/swig/golang.cgo.i | 111 ----- lib/swig/python_addresses.i | 53 --- lib/swig/python_pubkeys.i | 23 - lib/swig/python_seckeys.i | 50 -- lib/swig/python_sha256s.i | 53 --- lib/swig/python_skycoin.callback.i | 30 -- lib/swig/python_skycoin.cipher.crypto.i | 257 ----------- lib/swig/python_skycoin.coin.i | 88 ---- lib/swig/python_uxarray.i | 52 --- lib/swig/skycoin.cipher.crypto.i | 189 -------- lib/swig/skycoin.coin.i | 84 ---- lib/swig/skycoin.i | 34 -- lib/swig/skycoin.mem.i | 429 ------------------ lib/swig/structs.i | 26 -- lib/swig/structs_typemaps.i | 62 --- 80 files changed, 704 insertions(+), 2631 deletions(-) delete mode 100644 include/swig.h delete mode 100644 lib/cgo/wallet.notes.go delete mode 100644 lib/swig/README.md delete mode 100644 lib/swig/cmp.i delete mode 100644 lib/swig/golang.cgo.i delete mode 100644 lib/swig/python_addresses.i delete mode 100644 lib/swig/python_pubkeys.i delete mode 100644 lib/swig/python_seckeys.i delete mode 100644 lib/swig/python_sha256s.i delete mode 100644 lib/swig/python_skycoin.callback.i delete mode 100644 lib/swig/python_skycoin.cipher.crypto.i delete mode 100644 lib/swig/python_skycoin.coin.i delete mode 100644 lib/swig/python_uxarray.i delete mode 100644 lib/swig/skycoin.cipher.crypto.i delete mode 100644 lib/swig/skycoin.coin.i delete mode 100755 lib/swig/skycoin.i delete mode 100644 lib/swig/skycoin.mem.i delete mode 100644 lib/swig/structs.i delete mode 100644 lib/swig/structs_typemaps.i diff --git a/include/coin.transactions.go.h b/include/coin.transactions.go.h index 48efbba677..4e33ff1852 100644 --- a/include/coin.transactions.go.h +++ b/include/coin.transactions.go.h @@ -1,10 +1,4 @@ typedef GoSlice_ coin__Transactions; -typedef struct{ - coin__Transactions Txns; - GoSlice_ Fees; - GoSlice_ Hashes; -} coin__SortableTransactions; - /** * Skycoin transaction. * diff --git a/include/skytypes.h b/include/skytypes.h index fc1a424d9c..6b6821fff5 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -173,6 +173,10 @@ typedef Handle GoStringMap_; */ typedef Handle Wallets__Handle; +/** + * ReadableOutputSet Handle + * */ +typedef Handle ReadableOutputSet_Handle; /** * Instances of Go interface types. */ diff --git a/include/swig.h b/include/swig.h deleted file mode 100644 index add18857d6..0000000000 --- a/include/swig.h +++ /dev/null @@ -1,50 +0,0 @@ - -typedef struct{ - GoUint8 data[33]; -} cipher_PubKey; - -typedef struct{ - GoUint8 data[32]; -} cipher_SecKey; - -typedef struct{ - GoUint8 data[20]; -} cipher_Ripemd160; - -typedef struct{ - GoUint8 data[65]; -} cipher_Sig; - -typedef struct{ - GoUint8 data[32]; -} cipher_SHA256; - -typedef struct{ - GoUint8 data[4]; -} cipher_Checksum; - -typedef struct{ - cipher_SecKey* data; - int count; -} cipher_SecKeys; - -typedef struct{ - cipher_PubKey* data; - int count; -} cipher_PubKeys; - -typedef struct{ - cipher_SHA256* data; - int count; -} cipher_SHA256s; - -typedef struct{ - coin__UxOut* data; - int count; -} coin_UxOutArray; - -typedef struct{ - cipher__Address* data; - int count; -} cipher_Addresses; - diff --git a/include/wallet.wallet.go.h b/include/wallet.wallet.go.h index 59cef856f8..9a4006eaf5 100644 --- a/include/wallet.wallet.go.h +++ b/include/wallet.wallet.go.h @@ -1,14 +1,4 @@ -/** - * Internal representation of a Skycoin wallet. - */ -typedef struct { - GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. - GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. -} wallet__Wallet; - -typedef GoInterface_ wallet__Validator; - /** * Intermediate representation of a UxOut for sorting and spend choosing. */ diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 6d3e9e33b8..453d61cb54 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -17,10 +17,11 @@ import "C" //export SKY_api_NewClient func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addr := _addr __arg1 := api.NewClient(addr) *_arg1 = registerClientHandle(__arg1) @@ -29,10 +30,11 @@ func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code ui //export SKY_api_Client_CSRF func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -48,10 +50,11 @@ func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_cod //export SKY_api_Client_Version func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -67,10 +70,11 @@ func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod //export SKY_api_Client_Outputs func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -86,10 +90,11 @@ func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod //export SKY_api_Client_OutputsForAddresses func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -106,10 +111,11 @@ func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _a //export SKY_api_Client_OutputsForHashes func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -126,10 +132,11 @@ func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg //export SKY_api_Client_CoinSupply func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -145,10 +152,11 @@ func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_ //export SKY_api_Client_BlockByHash func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -165,10 +173,11 @@ func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Hand //export SKY_api_Client_BlockBySeq func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -184,19 +193,18 @@ func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle } //export SKY_api_Client_Blocks -func SKY_api_Client_Blocks(_c C.Client__Handle, _start, _end int, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 +func SKY_api_Client_Blocks(_c C.Client__Handle, _start uint64, _end uint64, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - start := _start - end := _end - __arg1, ____return_err := c.Blocks(start, end) + __arg1, ____return_err := c.Blocks(_start, _end) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg1 = registerHandle(__arg1) @@ -205,11 +213,12 @@ func SKY_api_Client_Blocks(_c C.Client__Handle, _start, _end int, _arg1 *C.Handl } //export SKY_api_Client_LastBlocks -func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n int, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 +func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n uint64, _arg1 *C.Handle) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -226,10 +235,11 @@ func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n int, _arg1 *C.Handle) (__ //export SKY_api_Client_BlockchainMetadata func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -245,10 +255,11 @@ func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_BlockchainProgress func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -264,10 +275,11 @@ func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_Balance func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -284,10 +296,11 @@ func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.walle //export SKY_api_Client_UxOut func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -304,10 +317,11 @@ func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (_ //export SKY_api_Client_AddressUxOuts func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -324,10 +338,11 @@ func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Ha //export SKY_api_Client_Wallet func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -344,10 +359,11 @@ func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletRespo //export SKY_api_Client_Wallets func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -356,17 +372,18 @@ func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____ __arg0, ____return_err := c.Wallets() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerWalletsHandle(__arg0) + *_arg0 = registerWalletsHandle(&__arg0) } return } //export SKY_api_Client_CreateUnencryptedWallet func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -385,10 +402,11 @@ func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label s //export SKY_api_Client_CreateEncryptedWallet func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _password string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -408,10 +426,11 @@ func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _p //export SKY_api_Client_NewWalletAddress func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _password string, _arg3 *C.Strings__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -430,10 +449,11 @@ func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _p //export SKY_api_Client_WalletBalance func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -450,10 +470,11 @@ func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wall //export SKY_api_Client_Spend func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.SpendResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -473,10 +494,11 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, //export SKY_api_Client_CreateTransaction func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.CreateTransactionResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -495,32 +517,13 @@ func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 return } -//export SKY_api_Client_WalletTransactions -func SKY_api_Client_WalletTransactions(_c C.Client__Handle, _id string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - c, okc := lookupClientHandle(_c) - if !okc { - ____error_code = SKY_BAD_HANDLE - return - } - id := _id - __arg1, ____return_err := c.WalletTransactions(id) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerHandle(__arg1) - } - return -} - //export SKY_api_Client_UpdateWallet func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -537,10 +540,11 @@ func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____e //export SKY_api_Client_WalletFolderName func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -556,10 +560,11 @@ func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____ //export SKY_api_Client_NewSeed func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -576,10 +581,11 @@ func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString //export SKY_api_Client_GetWalletSeed func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -597,10 +603,11 @@ func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password str //export SKY_api_Client_NetworkConnection func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -617,10 +624,11 @@ func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 * //export SKY_api_Client_NetworkConnections func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -636,10 +644,11 @@ func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_NetworkDefaultConnections func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -655,10 +664,11 @@ func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Hand //export SKY_api_Client_NetworkTrustedConnections func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -674,10 +684,11 @@ func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Hand //export SKY_api_Client_NetworkExchangeableConnections func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -693,10 +704,11 @@ func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C //export SKY_api_Client_PendingTransactions func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -712,10 +724,11 @@ func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (_ //export SKY_api_Client_Transaction func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -732,10 +745,11 @@ func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Hand //export SKY_api_Client_Transactions func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -752,10 +766,11 @@ func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C. //export SKY_api_Client_ConfirmedTransactions func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -772,10 +787,11 @@ func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, //export SKY_api_Client_UnconfirmedTransactions func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -791,17 +807,23 @@ func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string } //export SKY_api_Client_InjectTransaction -func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 +func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - rawTx := _rawTx + rawTx, okt := lookupTransactionHandle(_rawTx) + if !okt { + ____error_code = SKY_BAD_HANDLE + return + } + __arg1, ____return_err := c.InjectTransaction(rawTx) ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -812,10 +834,11 @@ func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx string, _arg1 //export SKY_api_Client_ResendUnconfirmedTransactions func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -831,10 +854,11 @@ func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C. //export SKY_api_Client_RawTransaction func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -851,10 +875,11 @@ func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.G //export SKY_api_Client_AddressTransactions func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -871,10 +896,11 @@ func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 //export SKY_api_Client_Richlist func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -891,10 +917,11 @@ func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams //export SKY_api_Client_AddressCount func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -910,10 +937,11 @@ func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_ //export SKY_api_Client_UnloadWallet func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -929,10 +957,11 @@ func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_cod //export SKY_api_Client_Health func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -948,10 +977,11 @@ func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code //export SKY_api_Client_EncryptWallet func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -969,10 +999,11 @@ func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password str //export SKY_api_Client_DecryptWallet func SKY_api_Client_DecryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index d230a697af..f3cf8db891 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -20,10 +20,11 @@ import "C" //export SKY_api_NewCreateTransactionResponse func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreateTransactionResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(_txn) if !ok { ____error_code = SKY_BAD_HANDLE @@ -40,10 +41,11 @@ func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs [] //export SKY_api_NewCreatedTransaction func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreatedTransaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(_txn) if !ok { ____error_code = SKY_BAD_HANDLE @@ -60,10 +62,11 @@ func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.walle //export SKY_api_CreatedTransaction_ToTransaction func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _arg0 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() r, ok := lookupCreatedTransactionHandle(_r) if !ok { ____error_code = SKY_BAD_HANDLE @@ -79,10 +82,11 @@ func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _ //export SKY_api_NewCreatedTransactionOutput func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.CreatedTransactionOutput__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() out := *(*coin.TransactionOutput)(unsafe.Pointer(_out)) txid := *(*cipher.SHA256)(unsafe.Pointer(_txid)) __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) @@ -95,10 +99,11 @@ func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid //export SKY_api_NewCreatedTransactionInput func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.CreatedTransactionInput__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() out := *(*wallet.UxBalance)(unsafe.Pointer(_out)) __arg1, ____return_err := api.NewCreatedTransactionInput(out) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/api.wallet.go b/lib/cgo/api.wallet.go index 7a0d44203d..726255d283 100644 --- a/lib/cgo/api.wallet.go +++ b/lib/cgo/api.wallet.go @@ -13,10 +13,11 @@ import "C" //export SKY_api_NewWalletResponse func SKY_api_NewWalletResponse(_w C.Wallet__Handle, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index d9a67305eb..25cc349430 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -54,52 +54,13 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ return } -//export SKY_webrpc_Client_GetUnspentOutputs -func SKY_webrpc_Client_GetUnspentOutputs(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.OutputsResult_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - c, okc := lookupWebRpcClientHandle(_c) - if !okc { - ____error_code = SKY_BAD_HANDLE - return - } - addrs := *(*[]string)(unsafe.Pointer(&_addrs)) - __arg1, ____return_err := c.GetUnspentOutputs(addrs) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerOutputsResultHandle(__arg1) - } - return -} - -//export SKY_webrpc_Client_InjectTransactionString -func SKY_webrpc_Client_InjectTransactionString(_c C.WebRpcClient__Handle, _rawtx string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - c, okc := lookupWebRpcClientHandle(_c) - if !okc { - ____error_code = SKY_BAD_HANDLE - return - } - rawtx := _rawtx - __arg1, ____return_err := c.InjectTransactionString(rawtx) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - copyString(__arg1, _arg1) - } - return -} - //export SKY_webrpc_Client_InjectTransaction func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -120,10 +81,11 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transa //export SKY_webrpc_Client_GetStatus func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -139,10 +101,11 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResul //export SKY_webrpc_Client_GetTransactionByID func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.TransactionResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -159,10 +122,11 @@ func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid strin //export SKY_webrpc_Client_GetAddressUxOuts func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -179,10 +143,11 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri //export SKY_webrpc_Client_GetBlocks func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -200,10 +165,11 @@ func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, //export SKY_webrpc_Client_GetBlocksBySeq func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -220,10 +186,11 @@ func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _ //export SKY_webrpc_Client_GetLastBlocks func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.address.go b/lib/cgo/cipher.address.go index 0232bf2c5f..cd6d2931e7 100644 --- a/lib/cgo/cipher.address.go +++ b/lib/cgo/cipher.address.go @@ -33,36 +33,13 @@ func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (___ return } -//export SKY_cipher_MustDecodeBase58Address -func SKY_cipher_MustDecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - addr := _addr - __arg1 := cipher.MustDecodeBase58Address(addr) - *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) - return -} - -//export SKY_cipher_BitcoinMustDecodeBase58Address -func SKY_cipher_BitcoinMustDecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - addr := _addr - __arg1 := cipher.BitcoinMustDecodeBase58Address(addr) - *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) - return -} - //export SKY_cipher_AddressFromBytes func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1, ____return_err := cipher.AddressFromBytes(b) ____error_code = libErrorCode(____return_err) @@ -118,23 +95,6 @@ func SKY_cipher_BitcoinDecodeBase58Address(_addr string, _arg1 *C.cipher__Addres return } -//export SKY_cipher_MustAddressFromBytes -func SKY_cipher_MustAddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - - b := *(*[]byte)(unsafe.Pointer(&_b)) - __arg1, ____return_err := cipher.MustAddressFromBytes(b) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) - } - return -} - //export SKY_cipher_Address_Null func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_code uint32) { ____error_code = SKY_OK @@ -309,15 +269,3 @@ func SKY_cipher_SecKeyFromWalletImportFormat(_input string, _arg1 *C.cipher__Sec ____error_code = errcode return } - -//export SKY_cipher_MustSecKeyFromWalletImportFormat -func SKY_cipher_MustSecKeyFromWalletImportFormat(_input string, _arg1 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - input := _input - __arg1 := cipher.MustSecKeyFromWalletImportFormat(input) - copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) - return -} diff --git a/lib/cgo/cipher.base58.base58.go b/lib/cgo/cipher.base58.base58.go index 0abcad2124..b7cbcad58a 100644 --- a/lib/cgo/cipher.base58.base58.go +++ b/lib/cgo/cipher.base58.base58.go @@ -18,10 +18,11 @@ import "C" //export SKY_base58_String2Hex func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := _s __arg1 := base58.String2Hex(s) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -30,10 +31,11 @@ func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) //export SKY_base58_Base58_ToInt func SKY_base58_Base58_ToInt(_b string, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.ToInt() ____error_code = libErrorCode(____return_err) @@ -45,10 +47,11 @@ func SKY_base58_Base58_ToInt(_b string, _arg0 *int) (____error_code uint32) { //export SKY_base58_Base58_ToHex func SKY_base58_Base58_ToHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.ToHex() ____error_code = libErrorCode(____return_err) @@ -60,10 +63,11 @@ func SKY_base58_Base58_ToHex(_b string, _arg0 *C.GoSlice_) (____error_code uint3 //export SKY_base58_Base58_Base582Int func SKY_base58_Base58_Base582Int(_b string, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.Base582Int() ____error_code = libErrorCode(____return_err) @@ -75,10 +79,11 @@ func SKY_base58_Base58_Base582Int(_b string, _arg0 *int) (____error_code uint32) //export SKY_base58_Base582Hex func SKY_base58_Base582Hex(_b string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := _b __arg1, ____return_err := base58.Base582Hex(b) ____error_code = libErrorCode(____return_err) @@ -90,10 +95,11 @@ func SKY_base58_Base582Hex(_b string, _arg1 *C.GoSlice_) (____error_code uint32) //export SKY_base58_Base58_BitHex func SKY_base58_Base58_BitHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.BitHex() ____error_code = libErrorCode(____return_err) @@ -105,10 +111,11 @@ func SKY_base58_Base58_BitHex(_b string, _arg0 *C.GoSlice_) (____error_code uint //export SKY_base58_Int2Base58 func SKY_base58_Int2Base58(_val int, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() val := _val __arg1 := base58.Int2Base58(val) copyString(string(__arg1), _arg1) @@ -117,10 +124,11 @@ func SKY_base58_Int2Base58(_val int, _arg1 *C.GoString_) (____error_code uint32) //export SKY_base58_Hex2Base58 func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58(val) copyString(string(__arg1), _arg1) @@ -129,10 +137,11 @@ func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint //export SKY_base58_Hex2Base58String func SKY_base58_Hex2Base58String(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58String(val) copyString(__arg1, _arg1) @@ -141,10 +150,11 @@ func SKY_base58_Hex2Base58String(_val []byte, _arg1 *C.GoString_) (____error_cod //export SKY_base58_Hex2Base58Str func SKY_base58_Hex2Base58Str(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58Str(val) copyString(__arg1, _arg1) diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index 19197361b6..ddd52078ae 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -81,19 +81,6 @@ func SKY_cipher_NewPubKey(_b []byte, _arg1 *C.cipher__PubKey) (____error_code ui return } -//export SKY_cipher_MustPubKeyFromHex -func SKY_cipher_MustPubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (errcode uint32) { - errcode = SKY_OK - defer func() { - errcode = catchApiPanic(errcode, recover()) - }() - checkAPIReady() - s := _s - __arg1 := cipher.MustPubKeyFromHex(s) - copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) - return -} - //export SKY_cipher_PubKeyFromHex func SKY_cipher_PubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (____error_code uint32) { ____error_code = SKY_OK @@ -205,20 +192,6 @@ func SKY_cipher_NewSecKey(_b []byte, _arg1 *C.cipher__SecKey) (____error_code ui return } -//export SKY_cipher_MustSecKeyFromHex -func SKY_cipher_MustSecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - s := _s - __arg1 := cipher.MustSecKeyFromHex(s) - copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) - ____error_code = SKY_OK - return -} - //export SKY_cipher_SecKeyFromHex func SKY_cipher_SecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_code uint32) { ____error_code = SKY_OK @@ -292,19 +265,6 @@ func SKY_cipher_NewSig(_b []byte, _arg1 *C.cipher__Sig) (____error_code uint32) return } -//export SKY_cipher_MustSigFromHex -func SKY_cipher_MustSigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - s := _s - __arg1 := cipher.MustSigFromHex(s) - copyToBuffer(reflect.ValueOf(__arg1[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) - return -} - //export SKY_cipher_SigFromHex func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint32) { ____error_code = SKY_OK diff --git a/lib/cgo/cipher.encoder.field.go b/lib/cgo/cipher.encoder.field.go index ba79c6687b..1ed66c5ebe 100644 --- a/lib/cgo/cipher.encoder.field.go +++ b/lib/cgo/cipher.encoder.field.go @@ -17,10 +17,11 @@ import "C" //export SKY_encoder_StructField_String func SKY_encoder_StructField_String(_s *C.encoder__StructField, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := (*encoder.StructField)(unsafe.Pointer(_s)) __arg0 := s.String() copyString(__arg0, _arg0) @@ -29,10 +30,11 @@ func SKY_encoder_StructField_String(_s *C.encoder__StructField, _arg0 *C.GoStrin //export SKY_encoder_ParseFields func SKY_encoder_ParseFields(_in []byte, _fields []C.encoder__StructField, _arg2 *C.GoStringMap_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() in := *(*[]byte)(unsafe.Pointer(&_in)) fields := *(*[]encoder.StructField)(unsafe.Pointer(&_fields)) __arg2 := encoder.ParseFields(in, fields) diff --git a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go index b9515ad20f..f76ce52886 100644 --- a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go +++ b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go @@ -18,10 +18,11 @@ import "C" //export SKY_encrypt_ScryptChacha20poly1305_Encrypt func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -39,6 +40,7 @@ func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20pol defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go index 6ee24cedda..5c8d334e1d 100644 --- a/lib/cgo/cipher.encrypt.sha256xor.go +++ b/lib/cgo/cipher.encrypt.sha256xor.go @@ -22,6 +22,7 @@ func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSl defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -39,6 +40,7 @@ func SKY_encrypt_Sha256Xor_Decrypt(_data []byte, _password []byte, _arg2 *C.GoSl defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) diff --git a/lib/cgo/cipher.go-bip39.bip39.go b/lib/cgo/cipher.go-bip39.bip39.go index d9531394ff..bceb6b4e34 100644 --- a/lib/cgo/cipher.go-bip39.bip39.go +++ b/lib/cgo/cipher.go-bip39.bip39.go @@ -18,10 +18,11 @@ import "C" //export SKY_bip39_NewDefaultMnemomic func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0, ____return_err := gobip39.NewDefaultMnemonic() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -32,10 +33,11 @@ func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_bip39_NewEntropy func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bitSize := _bitSize __arg1, ____return_err := gobip39.NewEntropy(bitSize) ____error_code = libErrorCode(____return_err) @@ -47,10 +49,11 @@ func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint3 //export SKY_bip39_NewMnemonic func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() entropy := *(*[]byte)(unsafe.Pointer(&_entropy)) __arg1, ____return_err := gobip39.NewMnemonic(entropy) ____error_code = libErrorCode(____return_err) @@ -62,10 +65,11 @@ func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code //export SKY_bip39_MnemonicToByteArray func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() mnemonic := _mnemonic __arg1, ____return_err := gobip39.MnemonicToByteArray(mnemonic) ____error_code = libErrorCode(____return_err) @@ -77,10 +81,11 @@ func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____err //export SKY_bip39_IsMnemonicValid func SKY_bip39_IsMnemonicValid(_mnemonic string, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() mnemonic := _mnemonic __arg1 := gobip39.IsMnemonicValid(mnemonic) *_arg1 = __arg1 diff --git a/lib/cgo/cipher.hash.go b/lib/cgo/cipher.hash.go index 523ff8d1f1..bf37a4aeaa 100644 --- a/lib/cgo/cipher.hash.go +++ b/lib/cgo/cipher.hash.go @@ -162,20 +162,6 @@ func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____er return } -//export SKY_cipher_MustSumSHA256 -func SKY_cipher_MustSumSHA256(_b []byte, _n int, _arg2 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - b := *(*[]byte)(unsafe.Pointer(&_b)) - n := _n - __arg2 := cipher.MustSumSHA256(b, n) - copyToBuffer(reflect.ValueOf(__arg2[:]), unsafe.Pointer(_arg2), uint(SizeofSHA256)) - return -} - //export SKY_cipher_SHA256_Null func SKY_cipher_SHA256_Null(_g *C.cipher__SHA256, _arg0 *bool) (____error_code uint32) { ____error_code = SKY_OK diff --git a/lib/cgo/cipher.poly1305.poly1305.go b/lib/cgo/cipher.poly1305.poly1305.go index c8aeb48b3d..70d2c60ce0 100644 --- a/lib/cgo/cipher.poly1305.poly1305.go +++ b/lib/cgo/cipher.poly1305.poly1305.go @@ -17,10 +17,11 @@ import "C" //export SKY_poly1305_Verify func SKY_poly1305_Verify(_mac *C.GoSlice_, _m []byte, _key *C.GoSlice_, _arg3 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() mac := (*[16]byte)(unsafe.Pointer(_mac)) m := *(*[]byte)(unsafe.Pointer(&_m)) key := (*[32]byte)(unsafe.Pointer(_key)) diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go index 89667f64c7..83c15f3cad 100644 --- a/lib/cgo/cipher.ripemd160.ripemd160.go +++ b/lib/cgo/cipher.ripemd160.ripemd160.go @@ -22,6 +22,7 @@ func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() hash := ripemd160.New() *handle = registerHashHandle(&hash) return @@ -29,10 +30,11 @@ func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { //export SKY_ripemd160_Write func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() h, ok := lookupHashHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -50,10 +52,11 @@ func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_c //export SKY_ripemd160_Sum func SKY_ripemd160_Sum(handle C.Hash_Handle, _p []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() h, ok := lookupHashHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.scrypt.scrypt.go b/lib/cgo/cipher.scrypt.scrypt.go index c1e4e7d8f2..5f6e2b5b0e 100644 --- a/lib/cgo/cipher.scrypt.scrypt.go +++ b/lib/cgo/cipher.scrypt.scrypt.go @@ -18,10 +18,11 @@ import "C" //export SKY_scrypt_Key func SKY_scrypt_Key(_password, _salt []byte, _N, _r, _p, _keyLen int, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() password := *(*[]byte)(unsafe.Pointer(&_password)) salt := *(*[]byte)(unsafe.Pointer(&_salt)) N := _N diff --git a/lib/cgo/cipher.secp256k1-go.secp256_rand.go b/lib/cgo/cipher.secp256k1-go.secp256_rand.go index 676171d64e..cf1521bf62 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256_rand.go +++ b/lib/cgo/cipher.secp256k1-go.secp256_rand.go @@ -18,10 +18,11 @@ import "C" //export SKY_secp256k1_SumSHA256 func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1 := secp256k1go.SumSHA256(b) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -30,10 +31,11 @@ func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint3 //export SKY_secp256k1_RandByte func SKY_secp256k1_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() n := _n __arg1 := secp256k1go.RandByte(n) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go index db1b66af74..dbfb3d9572 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go @@ -18,10 +18,11 @@ import "C" //export SKY_secp256k1go_DecompressPoint func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() X := *(*[]byte)(unsafe.Pointer(&_X)) off := _off Y := *(*[]byte)(unsafe.Pointer(&_Y)) @@ -31,10 +32,11 @@ func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error //export SKY_secp256k1go_RecoverPublicKey func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _arg3 *C.GoSlice_, _arg4 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sigByte := *(*[]byte)(unsafe.Pointer(&_sigByte)) h := *(*[]byte)(unsafe.Pointer(&_h)) recid := _recid @@ -46,10 +48,11 @@ func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _a //export SKY_secp256k1go_Multiply func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := *(*[]byte)(unsafe.Pointer(&_xy)) k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.Multiply(xy, k) @@ -59,10 +62,11 @@ func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code //export SKY_secp256k1go_BaseMultiply func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.BaseMultiply(k) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -71,10 +75,11 @@ func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code //export SKY_secp256k1go_BaseMultiplyAdd func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := *(*[]byte)(unsafe.Pointer(&_xy)) k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.BaseMultiplyAdd(xy, k) @@ -84,10 +89,11 @@ func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____err //export SKY_secp256k1go_GeneratePublicKey func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.GeneratePublicKey(k) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -96,10 +102,11 @@ func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_ //export SKY_secp256k1go_SeckeyIsValid func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go2.SeckeyIsValid(seckey) *_arg1 = __arg1 @@ -108,10 +115,11 @@ func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code u //export SKY_secp256k1go_PubkeyIsValid func SKY_secp256k1go_PubkeyIsValid(_pubkey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go2.PubkeyIsValid(pubkey) *_arg1 = __arg1 diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go index c65f7ad25a..bdafb1aa48 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go @@ -21,6 +21,7 @@ func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.String() copyString(__arg0, _arg0) @@ -33,6 +34,7 @@ func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____er defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) lab := _lab fd.Print(lab) @@ -45,6 +47,7 @@ func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := *(*[]byte)(unsafe.Pointer(&_a)) fd.SetB32(a) @@ -57,6 +60,7 @@ func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____e defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := *(*[]byte)(unsafe.Pointer(&_a)) fd.SetBytes(a) @@ -69,6 +73,7 @@ func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) s := _s fd.SetHex(s) @@ -81,6 +86,7 @@ func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____er defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.IsOdd() *_arg0 = __arg0 @@ -93,6 +99,7 @@ func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____e defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.IsZero() *_arg0 = __arg0 @@ -105,6 +112,7 @@ func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := _a fd.SetInt(a) @@ -117,6 +125,7 @@ func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) fd.Normalize() return @@ -128,6 +137,7 @@ func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := *(*[]byte)(unsafe.Pointer(&_r)) fd.GetB32(r) @@ -140,6 +150,7 @@ func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) __arg1 := fd.Equals(b) @@ -153,6 +164,7 @@ func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := (*secp256k1go2.Field)(unsafe.Pointer(_a)) fd.SetAdd(a) @@ -165,6 +177,7 @@ func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := _a fd.MulInt(a) @@ -177,6 +190,7 @@ func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) m := _m @@ -190,6 +204,7 @@ func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fie defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Inv(r) @@ -202,6 +217,7 @@ func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fi defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Sqrt(r) @@ -214,6 +230,7 @@ func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.InvVar(r) @@ -226,6 +243,7 @@ func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go_ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) @@ -239,6 +257,7 @@ func SKY_secp256k1go_Field_Sqr(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fie defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Sqr(r) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go index 0d151b091f..8cd908d0a7 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -17,10 +17,11 @@ import "C" //export SKY_secp256k1go_Number_Create func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() var num secp256k1go2.Number *handle = registerNumberHandle(&num) return @@ -28,10 +29,11 @@ func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint //export SKY_secp256k1go_Number_Print func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -43,10 +45,11 @@ func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____er //export SKY_secp256k1go_Number_SetHex func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -58,10 +61,11 @@ func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error //export SKY_secp256k1go_Number_IsOdd func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -74,10 +78,11 @@ func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____erro //export SKY_secp256k1go_Number_IsEqual func SKY_secp256k1go_Number_IsEqual(handle1 C.Number_Handle, handle2 C.Number_Handle, result *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() num1, ok := lookupNumberHandle(handle1) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go index c6e96f08f7..eb7e87d11b 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -18,10 +18,11 @@ import "C" //export SKY_secp256k1go_Signature_Create func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() var sig secp256k1go2.Signature *handle = registerSignatureHandle(&sig) return @@ -29,10 +30,11 @@ func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_cod //export SKY_secp256k1go_Signature_GetR func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -44,10 +46,11 @@ func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handl //export SKY_secp256k1go_Signature_GetS func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -59,10 +62,11 @@ func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handl //export SKY_secp256k1go_Signature_Print func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -74,10 +78,11 @@ func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (__ //export SKY_secp256k1go_Signature_Verify func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _arg2 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -96,10 +101,11 @@ func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp //export SKY_secp256k1go_Signature_Recover func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _recid int, _arg3 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -119,10 +125,11 @@ func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.sec //export SKY_secp256k1go_Signature_Sign func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message, _nonce C.Number_Handle, _recid *int, _arg2 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -151,10 +158,11 @@ func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message //export SKY_secp256k1go_Signature_ParseBytes func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -167,10 +175,11 @@ func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) //export SKY_secp256k1go_Signature_Bytes func SKY_secp256k1go_Signature_Bytes(handle C.Signature_Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go index 3d0c20cc50..5ec03f47ca 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go @@ -18,10 +18,11 @@ import "C" //export SKY_secp256k1go_XY_Print func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) lab := _lab xy.Print(lab) @@ -30,10 +31,11 @@ func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_co //export SKY_secp256k1go_XY_ParsePubkey func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) pub := *(*[]byte)(unsafe.Pointer(&_pub)) __arg1 := xy.ParsePubkey(pub) @@ -43,10 +45,11 @@ func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 * //export SKY_secp256k1go_XY_Bytes func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := *(*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -55,10 +58,11 @@ func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____er //export SKY_secp256k1go_XY_BytesUncompressed func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.BytesUncompressed() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -67,10 +71,11 @@ func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSli //export SKY_secp256k1go_XY_SetXY func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) Y := (*secp256k1go2.Field)(unsafe.Pointer(_Y)) @@ -80,10 +85,11 @@ func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Fie //export SKY_secp256k1go_XY_IsValid func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.IsValid() *_arg0 = __arg0 @@ -92,10 +98,11 @@ func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_ //export SKY_secp256k1go_XY_SetXYZ func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) a := (*secp256k1go2.XYZ)(unsafe.Pointer(_a)) xy.SetXYZ(a) @@ -104,10 +111,11 @@ func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) ( //export SKY_secp256k1go_XY_Neg func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) r := (*secp256k1go2.XY)(unsafe.Pointer(_r)) xy.Neg(r) @@ -116,10 +124,11 @@ func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____ //export SKY_secp256k1go_XY_SetXO func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, _odd bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) odd := _odd @@ -129,10 +138,11 @@ func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, //export SKY_secp256k1go_XY_AddXY func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) xy.AddXY(a) @@ -141,10 +151,11 @@ func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (__ //export SKY_secp256k1go_XY_GetPublicKey func SKY_secp256k1go_XY_GetPublicKey(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.GetPublicKey() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go index 200b40d572..f89430016c 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go @@ -17,7 +17,7 @@ import "C" //export SKY_secp256k1go_XYZ_Print func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -29,7 +29,7 @@ func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error //export SKY_secp256k1go_XYZ_SetXY func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -41,7 +41,7 @@ func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) //export SKY_secp256k1go_XYZ_IsInfinity func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -53,7 +53,7 @@ func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____ //export SKY_secp256k1go_XYZ_IsValid func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -65,7 +65,7 @@ func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____err //export SKY_secp256k1go_XYZ_Normalize func SKY_secp256k1go_XYZ_Normalize(_xyz *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -76,7 +76,7 @@ func SKY_secp256k1go_XYZ_Normalize(_xyz *C.secp256k1go__XYZ) (____error_code uin //export SKY_secp256k1go_XYZ_Equals func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -89,7 +89,7 @@ func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_ECmult func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng C.Number_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -111,7 +111,7 @@ func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_Neg func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -123,7 +123,7 @@ func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) ( //export SKY_secp256k1go_XYZ_Double func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -135,7 +135,7 @@ func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_AddXY func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _b *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -148,7 +148,7 @@ func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, //export SKY_secp256k1go_XYZ_Add func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -161,7 +161,7 @@ func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XY //export SKY_secp256k1go_ECmultGen func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a C.Number_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go index 9236ffa50d..9ade652646 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1.go @@ -22,6 +22,7 @@ func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____er defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0, __arg1 := secp256k1go.GenerateKeyPair() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -34,6 +35,7 @@ func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____erro defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.PubkeyFromSeckey(seckey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -46,6 +48,7 @@ func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____erro defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go.UncompressPubkey(pubkey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -58,6 +61,7 @@ func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.UncompressedPubkeyFromSeckey(seckey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -70,6 +74,7 @@ func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_cod defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() hash := *(*[]byte)(unsafe.Pointer(&_hash)) __arg1 := secp256k1go.Secp256k1Hash(hash) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -82,6 +87,7 @@ func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seed := *(*[]byte)(unsafe.Pointer(&_seed)) __arg1, __arg2 := secp256k1go.GenerateDeterministicKeyPair(seed) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -95,6 +101,7 @@ func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seedIn := *(*[]byte)(unsafe.Pointer(&_seedIn)) __arg1, __arg2, __arg3 := secp256k1go.DeterministicKeyPairIterator(seedIn) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -109,6 +116,7 @@ func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____err defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg2 := secp256k1go.Sign(msg, seckey) @@ -122,6 +130,7 @@ func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []b defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) nonceSeed := *(*[]byte)(unsafe.Pointer(&_nonceSeed)) @@ -136,6 +145,7 @@ func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.VerifySeckey(seckey) *_arg1 = __arg1 @@ -148,6 +158,7 @@ func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go.VerifyPubkey(pubkey) *_arg1 = __arg1 @@ -160,6 +171,7 @@ func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_c defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() sig := *(*[]byte)(unsafe.Pointer(&_sig)) __arg1 := secp256k1go.VerifySignatureValidity(sig) *_arg1 = __arg1 @@ -172,6 +184,7 @@ func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _a defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) sig := *(*[]byte)(unsafe.Pointer(&_sig)) pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) @@ -186,6 +199,7 @@ func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byt defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) sig := *(*[]byte)(unsafe.Pointer(&_sig)) pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) @@ -200,6 +214,7 @@ func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (_ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) sig := *(*[]byte)(unsafe.Pointer(&_sig)) __arg2 := secp256k1go.RecoverPubkey(msg, sig) @@ -213,6 +228,7 @@ func SKY_secp256k1_ECDH(_pub []byte, _sec []byte, _arg2 *C.GoSlice_) (____error_ defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pub := *(*[]byte)(unsafe.Pointer(&_pub)) sec := *(*[]byte)(unsafe.Pointer(&_sec)) __arg2 := secp256k1go.ECDH(pub, sec) diff --git a/lib/cgo/cli.add_private_key.go b/lib/cgo/cli.add_private_key.go index f5ee27bb72..1f96caaa30 100644 --- a/lib/cgo/cli.add_private_key.go +++ b/lib/cgo/cli.add_private_key.go @@ -15,10 +15,11 @@ import "C" //export SKY_cli_AddPrivateKey func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() wlt, okwlt := lookupWalletHandle(_wlt) if !okwlt { ____error_code = SKY_BAD_HANDLE @@ -34,10 +35,11 @@ func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code u //export SKY_cli_AddPrivateKeyToFile func SKY_cli_AddPrivateKeyToFile(_walletFile, _key string, pwd C.PasswordReader__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() walletFile := _walletFile key := _key pr, okc := lookupPasswordReaderHandle(pwd) diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go index c1543ddf17..9a511d7142 100644 --- a/lib/cgo/cli.check_balance.go +++ b/lib/cgo/cli.check_balance.go @@ -17,10 +17,11 @@ import "C" //export SKY_cli_CheckWalletBalance func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -37,10 +38,11 @@ func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _ //export SKY_cli_GetBalanceOfAddresses func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cli.cli.go b/lib/cgo/cli.cli.go index a237f7b717..1eaab60ca6 100644 --- a/lib/cgo/cli.cli.go +++ b/lib/cgo/cli.cli.go @@ -19,10 +19,11 @@ import "C" //export SKY_cli_LoadConfig func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0, ____return_err := cli.LoadConfig() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -33,10 +34,11 @@ func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { //export SKY_cli_Config_FullWalletPath func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -50,10 +52,11 @@ func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (___ //export SKY_cli_Config_FullDBPath func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -67,10 +70,11 @@ func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____err //export SKY_cli_NewApp func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __cfg, okcfg := lookupConfigHandle(_cfg) if !okcfg { ____error_code = SKY_BAD_HANDLE @@ -87,10 +91,11 @@ func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code //export SKY_cli_RPCClientFromContext func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupContextHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -103,10 +108,11 @@ func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__H //export SKY_cli_ConfigFromContext func SKY_cli_ConfigFromContext(_c C.Context__Handle, _arg1 *C.Config__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupContextHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -125,10 +131,11 @@ func SKY_cli_NewPasswordReader(_password []byte, passwordReader *C.PasswordReade //export SKY_cli_PasswordFromBytes_Password func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() p := *(*cli.PasswordFromBytes)(unsafe.Pointer(_p)) __arg0, ____return_err := p.Password() ____error_code = libErrorCode(____return_err) @@ -140,10 +147,11 @@ func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.G //export SKY_cli_PasswordFromTerm_Password func SKY_cli_PasswordFromTerm_Password(_arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() p := cli.PasswordFromTerm{} __arg0, ____return_err := p.Password() ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index bf3f62c7b8..9fed72f8ac 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -84,6 +84,7 @@ func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAd defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go index f2117f0c60..8c962fa196 100644 --- a/lib/cgo/cli.generate_addrs.go +++ b/lib/cgo/cli.generate_addrs.go @@ -19,10 +19,11 @@ import "C" //export SKY_cli_GenerateAddressesInFile func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.PasswordReader__Handle, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() walletFile := _walletFile num := _num pr, okc := lookupPasswordReaderHandle(pwd) @@ -40,10 +41,11 @@ func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.Pass //export SKY_cli_FormatAddressesAsJSON func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1, ____return_err := cli.FormatAddressesAsJSON(addrs) ____error_code = libErrorCode(____return_err) @@ -55,10 +57,11 @@ func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString //export SKY_cli_FormatAddressesAsJoinedArray func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1 := cli.FormatAddressesAsJoinedArray(addrs) copyString(__arg1, _arg1) @@ -67,10 +70,11 @@ func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.G //export SKY_cli_AddressesToStrings func SKY_cli_AddressesToStrings(_addrs []C.cipher__Address, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1 := cli.AddressesToStrings(addrs) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) diff --git a/lib/cgo/cli.generate_wallet.go b/lib/cgo/cli.generate_wallet.go index e9537f07ad..86cf1f461f 100644 --- a/lib/cgo/cli.generate_wallet.go +++ b/lib/cgo/cli.generate_wallet.go @@ -15,10 +15,11 @@ import "C" //export SKY_cli_GenerateWallet func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAddrs uint64, _arg3 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() walletFile := _walletFile __opts, okopts := lookupOptionsHandle(*_opts) if !okopts { @@ -37,10 +38,11 @@ func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAd //export SKY_cli_MakeAlphanumericSeed func SKY_cli_MakeAlphanumericSeed(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0 := cli.MakeAlphanumericSeed() copyString(__arg0, _arg0) return diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index 463c664ee8..8aedb5c504 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -14,11 +14,12 @@ import ( import "C" //export SKY_cli_GetWalletOutputsFromFile -func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { - ____error_code = 0 +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.ReadableOutputSet_Handle) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -28,17 +29,18 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = registerOutputsResultHandle(__arg2) + *_arg2 = registerReadableOutputSetHandle(__arg2) } return } //export SKY_cli_GetWalletOutputs -func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.OutputsResult_Handle) (____error_code uint32) { - ____error_code = 0 +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.ReadableOutputSet_Handle) (____error_code uint32) { + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -52,7 +54,7 @@ func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = registerOutputsResultHandle(__arg2) + *_arg2 = registerReadableOutputSetHandle(__arg2) } return } diff --git a/lib/cgo/cli_helper.go b/lib/cgo/cli_helper.go index 6e8b7709be..e1dd28f65a 100644 --- a/lib/cgo/cli_helper.go +++ b/lib/cgo/cli_helper.go @@ -17,10 +17,11 @@ import "C" //export SKY_cli_App_Run func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() app, okapp := lookupAppHandle(_app) if !okapp { ____error_code = SKY_BAD_HANDLE @@ -36,10 +37,11 @@ func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { //export SKY_cli_Config_GetCoin func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -53,10 +55,11 @@ func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_ //export SKY_cli_Config_GetRPCAddress func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -70,10 +73,11 @@ func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____ //export SKY_cli_RPCClientFromApp func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() app, okapp := lookupAppHandle(_app) if !okapp { ____error_code = SKY_BAD_HANDLE @@ -86,10 +90,11 @@ func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) //export SKY_cli_Getenv func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0 := os.Getenv(varname) copyString(__arg0, _arg0) return @@ -97,10 +102,11 @@ func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) //export SKY_cli_Setenv func SKY_cli_Setenv(varname string, value string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() os.Setenv(varname, value) return } diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index 697a76d12a..b60c307a2a 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -33,10 +33,11 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ } } - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -58,10 +59,11 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ //export SKY_coin_SignedBlock_VerifySignature func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.cipher__PubKey) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := *(*coin.SignedBlock)(unsafe.Pointer(_b)) pubkey := *(*cipher.PubKey)(unsafe.Pointer(_pubkey)) ____return_err := b.VerifySignature(pubkey) @@ -73,10 +75,11 @@ func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.ci //export SKY_coin_NewGenesisBlock func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.Block__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() genesisAddr := *(*cipher.Address)(unsafe.Pointer(_genesisAddr)) genesisCoins := _genesisCoins timestamp := _timestamp @@ -90,10 +93,11 @@ func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _t //export SKY_coin_Block_HashHeader func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -106,10 +110,12 @@ func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (___ //export SKY_coin_Block_PreHashHeader func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -122,10 +128,11 @@ func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) ( //export SKY_coin_Block_Time func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -138,10 +145,11 @@ func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint //export SKY_coin_Block_Seq func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -154,10 +162,11 @@ func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint3 //export SKY_coin_Block_HashBody func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -170,10 +179,11 @@ func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____e //export SKY_coin_Block_Size func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -186,10 +196,11 @@ func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) //export SKY_coin_Block_String func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -202,10 +213,11 @@ func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_co //export SKY_coin_Block_GetTransaction func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256, _arg1 *C.Transaction__Handle, _arg2 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -220,10 +232,11 @@ func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256 //export SKY_coin_NewBlockHeader func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body C.BlockBody__Handle, _arg4 *C.coin__BlockHeader) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() prev := *(*coin.BlockHeader)(unsafe.Pointer(_prev)) uxHash := *(*cipher.SHA256)(unsafe.Pointer(_uxHash)) currentTime := _currentTime @@ -240,10 +253,11 @@ func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA2 //export SKY_coin_BlockHeader_Hash func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) @@ -252,10 +266,11 @@ func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256 //export SKY_coin_BlockHeader_Bytes func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -264,10 +279,11 @@ func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (__ //export SKY_coin_BlockHeader_String func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.String() copyString(__arg0, _arg0) @@ -276,10 +292,11 @@ func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) ( //export SKY_coin_BlockBody_Hash func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() body, ok := lookupBlockBodyHandle(_body) if !ok { ____error_code = SKY_BAD_HANDLE @@ -292,10 +309,11 @@ func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) //export SKY_coin_BlockBody_Size func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bb, ok := lookupBlockBodyHandle(*_bb) if !ok { ____error_code = SKY_BAD_HANDLE @@ -308,10 +326,11 @@ func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_co //export SKY_coin_BlockBody_Bytes func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bb, ok := lookupBlockBodyHandle(_bb) if !ok { ____error_code = SKY_BAD_HANDLE @@ -324,10 +343,11 @@ func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____e //export SKY_coin_CreateUnspents func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _arg2 *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { @@ -341,10 +361,11 @@ func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle //export SKY_coin_CreateUnspent func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { @@ -362,10 +383,11 @@ func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, //export SKY_coin_GetBlockObject func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -377,10 +399,11 @@ func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_ //export SKY_coin_GetBlockBody func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -392,10 +415,11 @@ func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____err //export SKY_coin_NewEmptyBlock func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle, handle *C.Block__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/coin.math.go b/lib/cgo/coin.math.go index 6d2eb7a520..519efc3ed6 100644 --- a/lib/cgo/coin.math.go +++ b/lib/cgo/coin.math.go @@ -13,10 +13,11 @@ import "C" //export SKY_coin_AddUint64 func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() a := _a b := _b __arg1, ____return_err := coin.AddUint64(a, b) @@ -29,10 +30,11 @@ func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { //export SKY_coin_Uint64ToInt64 func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() a := _a __arg1, ____return_err := coin.Uint64ToInt64(a) ____error_code = libErrorCode(____return_err) @@ -44,10 +46,11 @@ func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { //export SKY_coin_Int64ToUint64 func SKY_coin_Int64ToUint64(_a int64, _arg1 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() a := _a __arg1, ____return_err := coin.Int64ToUint64(a) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 8bac865ce1..500c88ec92 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -220,7 +220,7 @@ func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * //export SKY_coin_NewAddressUxOuts func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -233,7 +233,7 @@ func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxO //export SKY_coin_AddressUxOuts_Keys func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -250,7 +250,7 @@ func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C. //export SKY_coin_AddressUxOuts_Flatten func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -267,7 +267,7 @@ func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C //export SKY_coin_AddressUxOuts_Sub func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -289,7 +289,7 @@ func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO //export SKY_coin_AddressUxOuts_Add func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -311,7 +311,7 @@ func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO //export SKY_coin_AddressUxOuts_Get func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -332,7 +332,7 @@ func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__A //export SKY_coin_AddressUxOuts_HasKey func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _hasKey *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -351,7 +351,7 @@ func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher //export SKY_coin_AddressUxOuts_GetOutputLength func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -372,7 +372,7 @@ func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key //export SKY_coin_AddressUxOuts_Length func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -389,7 +389,7 @@ func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) //export SKY_coin_AddressUxOuts_Set func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 8399520857..1efb3ac166 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -21,10 +21,11 @@ import "C" //export SKY_coin_Create_Transaction func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() tx := coin.Transaction{} *handle = registerTransactionHandle(&tx) return @@ -32,10 +33,11 @@ func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code //export SKY_coin_Transaction_Copy func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() tx, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -57,10 +59,11 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact //export SKY_coin_GetTransactionObject func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() ptx, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -72,10 +75,11 @@ func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin_ //export SKY_coin_Transaction_ResetInputs func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -87,10 +91,11 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( //export SKY_coin_Transaction_GetInputsCount func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -102,10 +107,11 @@ func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *i //export SKY_coin_Transaction_GetInputAt func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -121,10 +127,11 @@ func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input //export SKY_coin_Transaction_SetInputAt func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -140,10 +147,11 @@ func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input //export SKY_coin_Transaction_GetOutputsCount func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -155,10 +163,11 @@ func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length * //export SKY_coin_Transaction_GetOutputAt func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -174,10 +183,11 @@ func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, outpu //export SKY_coin_Transaction_SetOutputAt func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -193,10 +203,11 @@ func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, outpu //export SKY_coin_Transaction_GetSignaturesCount func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -208,10 +219,11 @@ func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, lengt //export SKY_coin_Transaction_GetSignatureAt func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -227,10 +239,11 @@ func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, si //export SKY_coin_Transaction_SetSignatureAt func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -246,10 +259,11 @@ func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, si //export SKY_coin_Transaction_PushSignature func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -262,10 +276,11 @@ func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.ci //export SKY_coin_Transaction_ResetOutputs func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -277,10 +292,11 @@ func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) //export SKY_coin_Transaction_ResetSignatures func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -292,10 +308,11 @@ func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count in //export SKY_coin_Transaction_Verify func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -310,10 +327,11 @@ func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code u //export SKY_coin_Transaction_VerifyInput func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -329,10 +347,11 @@ func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coi //export SKY_coin_Transaction_PushInput func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -346,10 +365,11 @@ func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.ciph //export SKY_coin_TransactionOutput_UxID func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txOut := *(*coin.TransactionOutput)(unsafe.Pointer(_txOut)) txID := *(*cipher.SHA256)(unsafe.Pointer(_txID)) __arg1 := txOut.UxID(txID) @@ -359,10 +379,11 @@ func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C //export SKY_coin_Transaction_PushOutput func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -377,10 +398,11 @@ func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.ciphe //export SKY_coin_Transaction_SignInputs func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -393,10 +415,11 @@ func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cip //export SKY_coin_Transaction_Size func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -409,10 +432,11 @@ func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____er //export SKY_coin_Transaction_Hash func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -425,10 +449,11 @@ func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SH //export SKY_coin_Transaction_SizeHash func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -442,10 +467,11 @@ func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _ar //export SKY_coin_Transaction_TxID func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -458,10 +484,11 @@ func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) //export SKY_coin_Transaction_TxIDHex func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -474,10 +501,11 @@ func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoStrin //export SKY_coin_Transaction_UpdateHeader func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -489,10 +517,11 @@ func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_ //export SKY_coin_Transaction_HashInner func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -505,10 +534,11 @@ func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.ciphe //export SKY_coin_Transaction_Serialize func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -519,24 +549,13 @@ func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSli return } -//export SKY_coin_MustTransactionDeserialize -func SKY_coin_MustTransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - b := *(*[]byte)(unsafe.Pointer(&_b)) - __arg1 := coin.MustTransactionDeserialize(b) - *_arg1 = registerTransactionHandle(&__arg1) - return -} - //export SKY_coin_TransactionDeserialize func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1, ____return_err := coin.TransactionDeserialize(b) ____error_code = libErrorCode(____return_err) @@ -548,10 +567,11 @@ func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (_ //export SKY_coin_Transaction_OutputHours func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -574,10 +594,11 @@ func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_cod //export SKY_coin_GetTransactionsObject func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() ptx, ok := lookupTransactionsHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -589,10 +610,11 @@ func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coi //export SKY_coin_Transactions_Length func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -604,10 +626,11 @@ func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) ( //export SKY_coin_Transactions_Add func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -639,10 +662,11 @@ func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcu return 0, errors.New("Error calculating fee") } } - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -659,10 +683,11 @@ func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcu //export SKY_coin_Transactions_GetAt func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -679,10 +704,11 @@ func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transa //export SKY_coin_Transactions_Hashes func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -695,10 +721,11 @@ func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) //export SKY_coin_Transactions_Size func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -711,10 +738,11 @@ func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____err //export SKY_coin_Transactions_TruncateBytesTo func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int, _arg1 *C.Transactions__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -739,10 +767,11 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcul return 0, errors.New("Error calculating fee") } } - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -766,10 +795,11 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.Fe return 0, errors.New("Error calculating fee") } } - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -782,10 +812,11 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.Fe //export SKY_coin_SortableTransactions_Sort func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -797,10 +828,11 @@ func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle //export SKY_coin_SortableTransactions_Len func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, _arg0 *int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -813,10 +845,11 @@ func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, //export SKY_coin_SortableTransactions_Less func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle, _i, _j int, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -831,10 +864,11 @@ func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle //export SKY_coin_SortableTransactions_Swap func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle, _i, _j int) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -848,10 +882,11 @@ func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle //export SKY_coin_VerifyTransactionCoinsSpending func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) ____return_err := coin.VerifyTransactionCoinsSpending(uxIn, uxOut) @@ -863,10 +898,11 @@ func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.c //export SKY_coin_VerifyTransactionHoursSpending func SKY_coin_VerifyTransactionHoursSpending(_headTime uint64, _uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() headTime := _headTime uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 9696029035..7206663cae 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -36,9 +36,10 @@ const ( ) // Package prefixes for error codes +//nolint megacheck const ( // Error code prefix for api package - SKY_PKG_API = (1 + iota) << 24 + SKY_PKG_API = (1 + iota) << 24 //nolint megacheck // Error code prefix for cipher package and subpackages SKY_PKG_CIPHER // Error code prefix for cli package @@ -61,12 +62,14 @@ const ( SKY_PKG_WALLET ) +//nolint megacheck const ( // SKY_PKG_LIBCGO package prefix for internal API errors SKY_PKG_LIBCGO = 0x7F000000 ) // Error codes defined in cipher package +//nolint megacheck const ( // SKY_ErrAddressInvalidLength Unexpected size of address bytes buffer SKY_ErrAddressInvalidLength = SKY_PKG_CIPHER + iota @@ -145,6 +148,7 @@ const ( ) // Error codes defined in cli package +// nolint megacheck const ( // SKY_ErrTemporaryInsufficientBalance is returned if a wallet does not have // enough balance for a spend, but will have enough after unconfirmed transactions confirm @@ -162,6 +166,7 @@ const ( ) // Error codes defined in coin package +// nolint megacheck const ( // ErrAddEarnedCoinHoursAdditionOverflow is returned by UxOut.CoinHours() // if during the addition of base coin @@ -182,6 +187,7 @@ const ( ) // Error codes defined in daemon package +// nolint megacheck const ( // SKY_ErrPeerlistFull is returned when the Pex is at a maximum SKY_ErrPeerlistFull = SKY_PKG_DAEMON + iota @@ -246,6 +252,7 @@ const ( ) // Error codes defined in util package +// nolint megacheck const ( // ErrTxnNoFee is returned if a transaction has no coinhour fee SKY_ErrTxnNoFee = SKY_PKG_UTIL + iota @@ -266,6 +273,7 @@ const ( ) // Error codes defined in visor package +// nolint megacheck const ( // SKY_ErrHistoryDBCorrupted Internal format error in HistoryDB database SKY_ErrHistoryDBCorrupted = SKY_PKG_VISOR + iota @@ -292,6 +300,7 @@ const ( ) // Error codes defined in wallet package +// nolint megacheck const ( // SKY_ErrInsufficientBalance is returned if a wallet does not have enough balance for a spend SKY_ErrInsufficientBalance = SKY_PKG_WALLET + iota @@ -617,6 +626,7 @@ var ( haltOnPanic = true ) +// nolint megacheck const ( // SKY_OPT_HALTONPANIC controls API behavior on panic // Supported values: @@ -626,6 +636,7 @@ const ( ) // SKY_libcgo_ConfigApiOptions set values for configurable API settings +// nolint megacheck func SKY_libcgo_ConfigApiOption(optionID uint32, optionValue uint64) { if optionID == SKY_OPT_HALTONPANIC { haltOnPanic = optionValue != 0 diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index aee0f024dd..09a454df59 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -178,7 +178,7 @@ func lookupClientHandle(handle C.Client__Handle) (*api.Client, bool) { return nil, false } -func registerWalletsHandle(obj []*api.WalletResponse) C.Wallets__Handle { +func registerWalletsHandle(obj *[]api.WalletResponse) C.Wallets__Handle { return (C.Wallets__Handle)(registerHandle(obj)) } @@ -416,34 +416,6 @@ func lookupSortableTransactionHandle(handle C.SortableTransactionResult_Handle) return nil, false } -func registerWalletNotesHandle(obj *wallet.Notes) C.WalletNotes_Handle { - return (C.WalletNotes_Handle)(registerHandle(obj)) -} - -func lookupWalletNotesHandle(handle C.WalletNotes_Handle) (*wallet.Notes, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*wallet.Notes); isOK { - return obj, true - } - } - return nil, false -} - -func registerWalletReadableNotesHandle(obj *wallet.ReadableNotes) C.WalletReadableNotes_Handle { - return (C.WalletReadableNotes_Handle)(registerHandle(obj)) -} - -func lookupWalletReadableNotesHandle(handle C.WalletReadableNotes_Handle) (*wallet.ReadableNotes, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*wallet.ReadableNotes); isOK { - return obj, true - } - } - return nil, false -} - func registerOutputsResultHandle(obj *webrpc.OutputsResult) C.OutputsResult_Handle { return (C.OutputsResult_Handle)(registerHandle(obj)) } @@ -556,8 +528,22 @@ func SKY_handle_copy(handle C.Handle, copy *C.Handle) uint32 { obj, ok := lookupHandle(handle) if ok { *copy = registerHandle(obj) - return 0 + return SKY_OK } else { return SKY_BAD_HANDLE } } + +func registerReadableOutputSetHandle(obj *visor.ReadableOutputSet) C.ReadableOutputSet_Handle { + return (C.ReadableOutputSet_Handle)(registerHandle(obj)) +} + +func lookupReadableOutputSetHandle(handle C.ReadableOutputSet_Handle) (*visor.ReadableOutputSet, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*visor.ReadableOutputSet); isOK { + return obj, true + } + } + return nil, false +} diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index 0aa551bf3b..b730dafda1 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -31,7 +31,7 @@ func SKY_JsonEncode_Handle(handle C.Handle, json_string *C.GoString_) uint32 { return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Progress_GetCurrent @@ -43,7 +43,7 @@ func SKY_Handle_Progress_GetCurrent(handle C.Handle, current *uint64) uint32 { return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Block_GetHeadSeq @@ -55,7 +55,7 @@ func SKY_Handle_Block_GetHeadSeq(handle C.Handle, seq *uint64) uint32 { return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Block_GetHeadHash @@ -67,7 +67,7 @@ func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Block_GetPreviousBlockHash @@ -79,7 +79,7 @@ func SKY_Handle_Block_GetPreviousBlockHash(handle C.Handle, hash *C.GoString_) u return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Blocks_GetAt @@ -92,7 +92,7 @@ func SKY_Handle_Blocks_GetAt(handle C.Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Blocks_GetCount @@ -105,7 +105,7 @@ func SKY_Handle_Blocks_GetCount(handle C.Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Connections_GetCount @@ -118,7 +118,7 @@ func SKY_Handle_Connections_GetCount(handle C.Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Strings_GetCount @@ -131,7 +131,7 @@ func SKY_Handle_Strings_GetCount(handle C.Strings__Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Strings_Sort @@ -143,7 +143,7 @@ func SKY_Handle_Strings_Sort(handle C.Strings__Handle) uint32 { return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_Handle_Strings_GetAt @@ -157,7 +157,7 @@ func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_Client_GetWalletDir @@ -171,7 +171,7 @@ func SKY_api_Handle_Client_GetWalletDir(handle C.Client__Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_Client_GetWalletFileName @@ -182,7 +182,7 @@ func SKY_api_Handle_Client_GetWalletFileName(handle C.WalletResponse__Handle, copyString(w.Meta.Filename, walletFileName) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_Client_GetWalletLabel @@ -193,7 +193,7 @@ func SKY_api_Handle_Client_GetWalletLabel(handle C.WalletResponse__Handle, copyString(w.Meta.Label, walletLabel) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_Client_GetWalletFullPath @@ -213,7 +213,7 @@ func SKY_api_Handle_Client_GetWalletFullPath( } } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetWalletMeta @@ -224,7 +224,7 @@ func SKY_api_Handle_GetWalletMeta(handle C.Wallet__Handle, copyToStringMap(w.Meta, gomap) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetWalletEntriesCount @@ -235,7 +235,7 @@ func SKY_api_Handle_GetWalletEntriesCount(handle C.Wallet__Handle, *count = uint32(len(w.Entries)) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_Client_GetWalletResponseEntriesCount @@ -247,7 +247,7 @@ func SKY_api_Handle_Client_GetWalletResponseEntriesCount( *count = uint32(len(w.Entries)) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletGetEntry @@ -263,7 +263,7 @@ func SKY_api_Handle_WalletGetEntry(handle C.Wallet__Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletResponseGetEntry @@ -279,7 +279,7 @@ func SKY_api_Handle_WalletResponseGetEntry(handle C.WalletResponse__Handle, return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletResponseIsEncrypted @@ -291,7 +291,7 @@ func SKY_api_Handle_WalletResponseIsEncrypted( *isEncrypted = w.Meta.Encrypted return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletResponseGetCryptoType @@ -303,7 +303,7 @@ func SKY_api_Handle_WalletResponseGetCryptoType( copyString(w.Meta.CryptoType, cryptoType) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletsResponseGetCount @@ -315,7 +315,7 @@ func SKY_api_Handle_WalletsResponseGetCount( *count = uint32(len(w)) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_WalletsResponseGetAt @@ -330,7 +330,7 @@ func SKY_api_Handle_WalletsResponseGetAt( } return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetWalletFolderAddress @@ -344,7 +344,7 @@ func SKY_api_Handle_GetWalletFolderAddress( return SKY_OK } } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetWalletSeed @@ -355,7 +355,7 @@ func SKY_api_Handle_GetWalletSeed(handle C.Wallet__Handle, copyString(w.Meta["seed"], seed) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetWalletLastSeed @@ -366,7 +366,7 @@ func SKY_api_Handle_GetWalletLastSeed(handle C.Wallet__Handle, copyString(w.Meta["lastSeed"], lastSeed) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } //export SKY_api_Handle_GetBuildInfoData @@ -379,5 +379,5 @@ func SKY_api_Handle_GetBuildInfoData(handle C.BuildInfo_Handle, copyString(bi.Branch, branch) return SKY_OK } - return SKY_ERROR + return SKY_BAD_HANDLE } diff --git a/lib/cgo/libsky_mem.go b/lib/cgo/libsky_mem.go index 10f4a17e84..79440f54d8 100644 --- a/lib/cgo/libsky_mem.go +++ b/lib/cgo/libsky_mem.go @@ -1,7 +1,6 @@ package main import ( - "hash" "reflect" "unsafe" @@ -33,7 +32,6 @@ const ( SizeofSHA256 = unsafe.Sizeof(C.cipher__SHA256{}) SizeofTransactionOutput = unsafe.Sizeof(C.coin__TransactionOutput{}) SizeofTransaction = unsafe.Sizeof(C.coin__Transaction{}) - SizeofWallet = unsafe.Sizeof(C.wallet__Wallet{}) SizeofEntry = unsafe.Sizeof(C.wallet__Entry{}) SizeofUxBalance = unsafe.Sizeof(C.wallet__UxBalance{}) ) @@ -126,16 +124,6 @@ func copyToGoSlice(src reflect.Value, dest *C.GoSlice_) { } } -func convertToInterface(a *C.GoInterface_) interface{} { - //TODO: Implement - return nil -} - -func copyToFunc(f C.Handle) func() hash.Hash { - //TODO: Implement - return nil -} - func copyToStringMap(gomap map[string]string, dest *C.GoStringMap_) { *dest = (C.GoStringMap_)(registerHandle(gomap)) } diff --git a/lib/cgo/tests/check_cipher.address.c b/lib/cgo/tests/check_cipher.address.c index e73e2fcb7a..183d8dbd24 100644 --- a/lib/cgo/tests/check_cipher.address.c +++ b/lib/cgo/tests/check_cipher.address.c @@ -430,107 +430,6 @@ Test(cipher_address, TestBitcoinAddressFromBytes) { cr_assert(result == SKY_ErrAddressInvalidVersion, "Invalid version"); } -Test(cipher_address, TestMustDecodeBase58Address, SKY_ABORT) { - cipher__PubKey p; - cipher__SecKey s; - GoInt result; - result = SKY_cipher_GenerateKeyPair(&p, &s); - cr_assert(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed"); - cipher__Address a; - result = SKY_cipher_AddressFromPubKey(&p, &a); - cr_assert(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed"); - - result = SKY_cipher_Address_Verify(&a, &p); - cr_assert(result == SKY_OK); - GoString str = {"", 0}; - cipher__Address addr; - result = SKY_cipher_MustDecodeBase58Address(str, &addr); - cr_assert(result == SKY_ERROR); - str.p = "cascs"; - str.n = 5; - result = SKY_cipher_MustDecodeBase58Address(str, &addr); - cr_assert(result == SKY_ERROR); - - char *buff_pks[1024]; - cipher__PubKeySlice b = {buff_pks, 0, 1024}; - result = SKY_cipher_Address_Bytes(&a, &b); - cr_assert(result == SKY_OK, "SKY_cipher_Address_Bytes failed"); - int b_len = b.len; - b.len = (int)(b_len / 2); - GoSlice bConvert = {&b.data, b.len, b.cap}; - char buffer_h[1024]; - GoString_ h = {buffer_h, 0}; - result = SKY_base58_Hex2Base58String(bConvert, &h); - cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); - char buffer_hConvert[1024]; - GoString hConvert = {buffer_hConvert, 0}; - toGoString(&h, &hConvert); - result = SKY_cipher_MustDecodeBase58Address(hConvert, &addr); - cr_assert(result == SKY_ERROR); - - b.len = b_len; - GoSlice b2Convert = {b.data, b.len, b.cap}; - char buffer_h2[1024]; - GoString_ h2 = {buffer_h2, 0}; - result = SKY_base58_Hex2Base58String(b2Convert, &h2); - cr_assert(result == SKY_OK, "SKY_base58_Hex2Base58String failed"); - char buffer_h2Convert[1024]; - GoString h2Convert = {buffer_h2, 0}; - toGoString(&h2, &h2Convert); - result = SKY_cipher_MustDecodeBase58Address(h2Convert, &addr); - cr_assert(result == SKY_OK); - - cipher__Address a2; - - result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); - cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); - cr_assert(eq(type(cipher__Address), a, a2)); - - result = SKY_cipher_Address_String(&a, &h2); - cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); - toGoString(&h2, &h2Convert); - result = SKY_cipher_MustDecodeBase58Address(h2Convert, &a2); - cr_assert(result == SKY_OK, "SKY_cipher_MustDecodeBase58Address failed"); - cr_assert(eq(type(cipher__Address), a, a2)); - - char strbadAddr[1024]; - char buffer_addrStr[1024]; - GoString_ addStr = {buffer_addrStr, 0}; - result = SKY_cipher_Address_String(&a, &addStr); - cr_assert(result == SKY_OK, "SKY_cipher_Address_String failed"); - - // preceding whitespace is invalid - strcpy(strbadAddr, " "); - strncat(strbadAddr, addStr.p, addStr.n); - GoString badAddr = {strbadAddr, strlen(strbadAddr)}; - result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); - cr_assert(result == SKY_ERROR); - - // preceding zeroes are invalid - strcpy(strbadAddr, "000"); - strncat(strbadAddr, addStr.p, addStr.n); - badAddr.p = strbadAddr; - badAddr.n = strlen(strbadAddr); - result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); - cr_assert(result == SKY_ERROR); - - // trailing whitespace is invalid - strcpy(strbadAddr, addStr.p); - strcat(strbadAddr, " "); - badAddr.p = strbadAddr; - badAddr.n = strlen(strbadAddr); - result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); - cr_assert(result == SKY_ERROR); - - // trailing zeroes are invalid - strcpy(strbadAddr, addStr.p); - strcat(strbadAddr, "000"); - badAddr.p = strbadAddr; - badAddr.n = strlen(strbadAddr); - result = SKY_cipher_MustDecodeBase58Address(badAddr, &addr); - cr_assert(result == SKY_ERROR); -} - Test(cipher_address, TestAddressRoundtrip) { cipher__PubKey p; cipher__SecKey s; diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index ce72796bb5..5dac066d51 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -368,24 +368,4 @@ Test(cipher_hash, TestSHA256Null) cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); cr_assert(not(isNull)); -} - -Test(cipher_hash, TestMustSumSHA256, SKY_ABORT ){ - char buffer_b[1024]; - GoSlice b = {buffer_b, 0, 1024}; - randBytes(&b, 128); - GoUint32 result; - cipher__SHA256 h; - memset(&h, 0, sizeof(cipher__SHA256)); - result = SKY_cipher_MustSumSHA256(b, 127, &h); - cr_assert(result == SKY_ERROR); - result = SKY_cipher_MustSumSHA256(b, 129, &h); - cr_assert(result == SKY_ERROR); - result = SKY_cipher_MustSumSHA256(b, 128, &h); - cr_assert(result == SKY_OK); - cipher__SHA256 sha; - cr_assert(not(eq(u8[32], h, sha))); - memset(&sha, 0, sizeof(cipher__SHA256)); - freshSumSHA256(b, &sha); - cr_assert(eq(u8[32], h, sha)); -} +} \ No newline at end of file diff --git a/lib/cgo/testutil.testutil.go b/lib/cgo/testutil.testutil.go index 081543f75e..55a518a3d9 100644 --- a/lib/cgo/testutil.testutil.go +++ b/lib/cgo/testutil.testutil.go @@ -17,10 +17,11 @@ import "C" //export SKY_testutil_MakeAddress func SKY_testutil_MakeAddress(_arg0 *C.cipher__Address) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0 := testutil.MakeAddress() *_arg0 = *(*C.cipher__Address)(unsafe.Pointer(&__arg0)) return diff --git a/lib/cgo/util.apputil.apputil.go b/lib/cgo/util.apputil.apputil.go index ef72046d7c..62c5875c0c 100644 --- a/lib/cgo/util.apputil.apputil.go +++ b/lib/cgo/util.apputil.apputil.go @@ -13,30 +13,33 @@ import "C" //export SKY_apputil_CatchInterruptPanic func SKY_apputil_CatchInterruptPanic() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() apputil.CatchInterruptPanic() return } //export SKY_apputil_CatchDebug func SKY_apputil_CatchDebug() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() apputil.CatchDebug() return } //export SKY_apputil_PrintProgramStatus func SKY_apputil_PrintProgramStatus() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() apputil.PrintProgramStatus() return } diff --git a/lib/cgo/util.browser.browser.go b/lib/cgo/util.browser.browser.go index 579e18dfaf..f37318525d 100644 --- a/lib/cgo/util.browser.browser.go +++ b/lib/cgo/util.browser.browser.go @@ -13,10 +13,11 @@ import "C" //export SKY_browser_Open func SKY_browser_Open(_url string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() url := _url ____return_err := browser.Open(url) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/util.cert.cert.go b/lib/cgo/util.cert.cert.go index 19edececba..8f5b8f0036 100644 --- a/lib/cgo/util.cert.cert.go +++ b/lib/cgo/util.cert.cert.go @@ -13,10 +13,11 @@ import "C" //export SKY_cert_CreateCertIfNotExists func SKY_cert_CreateCertIfNotExists(_host, _certFile, _keyFile string, _appName string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() host := _host certFile := _certFile keyFile := _keyFile diff --git a/lib/cgo/util.droplet.droplet.go b/lib/cgo/util.droplet.droplet.go index 26d194bf1a..74bebc86ec 100644 --- a/lib/cgo/util.droplet.droplet.go +++ b/lib/cgo/util.droplet.droplet.go @@ -13,10 +13,11 @@ import "C" //export SKY_droplet_FromString func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() b := _b __arg1, ____return_err := droplet.FromString(b) ____error_code = libErrorCode(____return_err) @@ -28,10 +29,11 @@ func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { //export SKY_droplet_ToString func SKY_droplet_ToString(_n uint64, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() n := _n __arg1, ____return_err := droplet.ToString(n) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go index 473af09711..1586f336e5 100644 --- a/lib/cgo/util.fee.fee.go +++ b/lib/cgo/util.fee.fee.go @@ -18,10 +18,11 @@ import "C" //export SKY_fee_VerifyTransactionFee func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() t, ok := lookupTransactionHandle(_t) if !ok { ____error_code = SKY_BAD_HANDLE @@ -36,10 +37,11 @@ func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____er //export SKY_fee_VerifyTransactionFeeForHours func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() hours := _hours ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee) ____error_code = libErrorCode(____return_err) @@ -50,10 +52,11 @@ func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code u //export SKY_fee_RequiredFee func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() hours := _hours __arg1 := fee.RequiredFee(hours) *_arg1 = __arg1 @@ -62,10 +65,11 @@ func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { //export SKY_fee_RemainingHours func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() hours := _hours __arg1 := fee.RemainingHours(hours) *_arg1 = __arg1 @@ -74,10 +78,11 @@ func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32 //export SKY_fee_TransactionFee func SKY_fee_TransactionFee(_tx C.Transaction__Handle, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() tx, ok := lookupTransactionHandle(_tx) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/util.file.file.go b/lib/cgo/util.file.file.go index 4b3e608b34..5c7d27070d 100644 --- a/lib/cgo/util.file.file.go +++ b/lib/cgo/util.file.file.go @@ -13,10 +13,11 @@ import "C" //export SKY_file_InitDataDir func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() dir := _dir __arg1, ____return_err := file.InitDataDir(dir) ____error_code = libErrorCode(____return_err) @@ -28,10 +29,11 @@ func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint3 //export SKY_file_UserHome func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0 := file.UserHome() copyString(__arg0, _arg0) return @@ -39,10 +41,11 @@ func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_file_ResolveResourceDirectory func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() path := _path __arg1 := file.ResolveResourceDirectory(path) copyString(__arg1, _arg1) @@ -51,10 +54,11 @@ func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____er //export SKY_file_DetermineResourcePath func SKY_file_DetermineResourcePath(_staticDir string, _resourceDir string, _devDir string, _arg3 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() staticDir := _staticDir resourceDir := _resourceDir devDir := _devDir diff --git a/lib/cgo/util.http.json.go b/lib/cgo/util.http.json.go index 6be88017c7..5ce5e11ea6 100644 --- a/lib/cgo/util.http.json.go +++ b/lib/cgo/util.http.json.go @@ -18,10 +18,11 @@ import "C" //export SKY_httphelper_Address_UnmarshalJSON func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() a := inplaceHttpHelperAddress(_a) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := a.UnmarshalJSON(b) @@ -33,10 +34,11 @@ func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) //export SKY_httphelper_Address_MarshalJSON func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() a := *inplaceHttpHelperAddress(_a) __arg0, ____return_err := a.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -48,10 +50,11 @@ func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSl //export SKY_httphelper_Coins_UnmarshalJSON func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c := (*http.Coins)(unsafe.Pointer(_c)) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := c.UnmarshalJSON(b) @@ -63,10 +66,11 @@ func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (___ //export SKY_httphelper_Coins_MarshalJSON func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c := *(*http.Coins)(unsafe.Pointer(_c)) __arg0, ____return_err := c.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -78,10 +82,11 @@ func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_ //export SKY_httphelper_Coins_Value func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() c := *(*http.Coins)(unsafe.Pointer(_c)) __arg0 := c.Value() *_arg0 = __arg0 @@ -90,10 +95,11 @@ func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____err //export SKY_httphelper_Hours_UnmarshalJSON func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() h := (*http.Hours)(unsafe.Pointer(_h)) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := h.UnmarshalJSON(b) @@ -105,10 +111,11 @@ func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (___ //export SKY_httphelper_Hours_MarshalJSON func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() h := *(*http.Hours)(unsafe.Pointer(_h)) __arg0, ____return_err := h.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -120,10 +127,11 @@ func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_ //export SKY_httphelper_Hours_Value func SKY_httphelper_Hours_Value(_h *C.httphelper__Hours, _arg0 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() h := *(*http.Hours)(unsafe.Pointer(_h)) __arg0 := h.Value() *_arg0 = __arg0 diff --git a/lib/cgo/util.iputil.iputil.go b/lib/cgo/util.iputil.iputil.go index b42ea95cc0..8d93a99491 100644 --- a/lib/cgo/util.iputil.iputil.go +++ b/lib/cgo/util.iputil.iputil.go @@ -13,10 +13,11 @@ import "C" //export SKY_iputil_LocalhostIP func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0, ____return_err := iputil.LocalhostIP() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -27,10 +28,11 @@ func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_iputil_IsLocalhost func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addr := _addr __arg1 := iputil.IsLocalhost(addr) *_arg1 = __arg1 @@ -39,10 +41,11 @@ func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { //export SKY_iputil_SplitAddr func SKY_iputil_SplitAddr(_addr string, _arg1 *C.GoString_, _arg2 *uint16) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() addr := _addr __arg1, __arg2, ____return_err := iputil.SplitAddr(addr) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/util.logging.logging.go b/lib/cgo/util.logging.logging.go index 07260b286e..f46f804a8d 100644 --- a/lib/cgo/util.logging.logging.go +++ b/lib/cgo/util.logging.logging.go @@ -13,30 +13,33 @@ import "C" //export SKY_logging_EnableColors func SKY_logging_EnableColors() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() logging.EnableColors() return } //export SKY_logging_DisableColors func SKY_logging_DisableColors() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() logging.DisableColors() return } //export SKY_logging_Disable func SKY_logging_Disable() (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() logging.Disable() return } diff --git a/lib/cgo/util.utc.utc.go b/lib/cgo/util.utc.utc.go index 03dbc8034a..aaf33620eb 100644 --- a/lib/cgo/util.utc.utc.go +++ b/lib/cgo/util.utc.utc.go @@ -13,10 +13,11 @@ import "C" //export SKY_utc_UnixNow func SKY_utc_UnixNow(_arg0 *int64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() __arg0 := utc.UnixNow() *_arg0 = __arg0 return diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go index 64e457cffe..252fdb4493 100644 --- a/lib/cgo/wallet.addresses.go +++ b/lib/cgo/wallet.addresses.go @@ -18,10 +18,11 @@ import "C" //export SKY_wallet_CreateAddresses func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _hideSecretKey bool, _arg4 *C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() coinType := _coinType seed := _seed genCount := _genCount @@ -36,10 +37,11 @@ func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _ //export SKY_wallet_GetSkycoinWalletEntry func SKY_wallet_GetSkycoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) __arg2 := wallet.GetSkycoinWalletEntry(pub, sec) @@ -49,10 +51,11 @@ func SKY_wallet_GetSkycoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__Se //export SKY_wallet_GetBitcoinWalletEntry func SKY_wallet_GetBitcoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) __arg2 := wallet.GetBitcoinWalletEntry(pub, sec) diff --git a/lib/cgo/wallet.balance.go b/lib/cgo/wallet.balance.go index 45c4d1f093..f80390bf89 100644 --- a/lib/cgo/wallet.balance.go +++ b/lib/cgo/wallet.balance.go @@ -18,10 +18,11 @@ import "C" //export SKY_wallet_NewBalance func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() coins := _coins hours := _hours __arg1 := wallet.NewBalance(coins, hours) @@ -31,10 +32,11 @@ func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (___ //export SKY_wallet_NewBalanceFromUxOut func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__Balance) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() headTime := _headTime ux := (*coin.UxOut)(unsafe.Pointer(_ux)) __arg2, ____return_err := wallet.NewBalanceFromUxOut(headTime, ux) @@ -47,10 +49,11 @@ func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 //export SKY_wallet_Balance_Add func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1, ____return_err := bal.Add(other) @@ -63,10 +66,11 @@ func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, //export SKY_wallet_Balance_Sub func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1 := bal.Sub(other) @@ -76,10 +80,11 @@ func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, //export SKY_wallet_Balance_Equals func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1 := bal.Equals(other) @@ -89,10 +94,11 @@ func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balanc //export SKY_wallet_Balance_IsZero func SKY_wallet_Balance_IsZero(_bal *C.wallet__Balance, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) __arg0 := bal.IsZero() *_arg0 = __arg0 diff --git a/lib/cgo/wallet.crypto.go b/lib/cgo/wallet.crypto.go index f0ef2fddac..58b317e0b9 100644 --- a/lib/cgo/wallet.crypto.go +++ b/lib/cgo/wallet.crypto.go @@ -15,10 +15,11 @@ import "C" //export SKY_wallet_CryptoTypeFromString func SKY_wallet_CryptoTypeFromString(_s string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() s := _s __arg1, ____return_err := wallet.CryptoTypeFromString(s) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/wallet.entry.go b/lib/cgo/wallet.entry.go index 11137bb74c..03edc08b85 100644 --- a/lib/cgo/wallet.entry.go +++ b/lib/cgo/wallet.entry.go @@ -17,10 +17,11 @@ import "C" //export SKY_wallet_Entry_Verify func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() we := (*wallet.Entry)(unsafe.Pointer(_we)) ____return_err := we.Verify() ____error_code = libErrorCode(____return_err) @@ -31,10 +32,11 @@ func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { //export SKY_wallet_Entry_VerifyPublic func SKY_wallet_Entry_VerifyPublic(_we *C.wallet__Entry) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() we := (*wallet.Entry)(unsafe.Pointer(_we)) ____return_err := we.VerifyPublic() ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go deleted file mode 100644 index 3936afe5b3..0000000000 --- a/lib/cgo/wallet.notes.go +++ /dev/null @@ -1,226 +0,0 @@ -package main - -import ( - "unsafe" - - wallet "github.com/skycoin/skycoin/src/wallet" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_wallet_NewNotesFilename -func SKY_wallet_NewNotesFilename(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - __arg0 := wallet.NewNotesFilename() - copyString(__arg0, _arg0) - return -} - -//export SKY_wallet_LoadNotes -func SKY_wallet_LoadNotes(_dir string, _arg1 *C.WalletNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - __arg1, ____return_err := wallet.LoadNotes(dir) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerWalletNotesHandle(&__arg1) - } - return -} - -//export SKY_wallet_LoadReadableNotes -func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - filename := _filename - __arg1, ____return_err := wallet.LoadReadableNotes(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerWalletReadableNotesHandle(__arg1) - } - return -} - -//export SKY_wallet_ReadableNotes_Load -func SKY_wallet_ReadableNotes_Load(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - filename := _filename - ____return_err := rns.Load(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_ReadableNotes_ToNotes -func SKY_wallet_ReadableNotes_ToNotes(_rns C.WalletReadableNotes_Handle, _arg0 *C.WalletNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0, ____return_err := rns.ToNotes() - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - notes := wallet.Notes(__arg0) - *_arg0 = registerWalletNotesHandle(¬es) - } - return -} - -//export SKY_wallet_ReadableNotes_Save -func SKY_wallet_ReadableNotes_Save(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - filename := _filename - ____return_err := rns.Save(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_NewReadableNote -func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__ReadableNote) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - note := *(*wallet.Note)(unsafe.Pointer(_note)) - __arg1 := wallet.NewReadableNote(note) - copyString(__arg1.TransactionID, &_arg1.TransactionID) - copyString(__arg1.ActualNote, &_arg1.ActualNote) - return -} - -//export SKY_wallet_NewReadableNotesFromNotes -func SKY_wallet_NewReadableNotesFromNotes(_w C.WalletNotes_Handle, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - w, ok := lookupWalletNotesHandle(_w) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg1 := wallet.NewReadableNotesFromNotes(*w) - *_arg1 = registerWalletReadableNotesHandle(&__arg1) - return -} - -//export SKY_wallet_Notes_Save -func SKY_wallet_Notes_Save(_notes C.WalletNotes_Handle, _dir string, _fileName string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - dir := _dir - fileName := _fileName - ____return_err := notes.Save(dir, fileName) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_Notes_SaveNote -func SKY_wallet_Notes_SaveNote(_notes C.WalletNotes_Handle, _dir string, _note *C.wallet__Note) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - dir := _dir - note := *(*wallet.Note)(unsafe.Pointer(_note)) - ____return_err := notes.SaveNote(dir, note) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_Notes_ToReadable -func SKY_wallet_Notes_ToReadable(_notes C.WalletNotes_Handle, _arg0 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0 := notes.ToReadable() - *_arg0 = registerWalletReadableNotesHandle(&__arg0) - return -} - -//export SKY_wallet_NotesFileExist -func SKY_wallet_NotesFileExist(_dir string, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - __arg1, ____return_err := wallet.NotesFileExist(dir) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = __arg1 - } - return -} - -//export SKY_wallet_CreateNoteFileIfNotExist -func SKY_wallet_CreateNoteFileIfNotExist(_dir string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - wallet.CreateNoteFileIfNotExist(dir) - return -} diff --git a/lib/cgo/wallet.readable.go b/lib/cgo/wallet.readable.go index 2f6a07a4dc..d026baf776 100644 --- a/lib/cgo/wallet.readable.go +++ b/lib/cgo/wallet.readable.go @@ -17,10 +17,11 @@ import "C" //export SKY_wallet_NewReadableEntry func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() w := *(*wallet.Entry)(unsafe.Pointer(_w)) __arg1 := wallet.NewReadableEntry(w) *_arg1 = registerReadableEntryHandle(&__arg1) @@ -29,10 +30,11 @@ func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Ha //export SKY_wallet_LoadReadableEntry func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() filename := _filename __arg1, ____return_err := wallet.LoadReadableEntry(filename) ____error_code = libErrorCode(____return_err) @@ -44,10 +46,11 @@ func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Hand //export SKY_wallet_NewReadableEntryFromPubkey func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() pub := _pub __arg1 := wallet.NewReadableEntryFromPubkey(pub) *_arg1 = registerReadableEntryHandle(&__arg1) @@ -56,10 +59,11 @@ func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__ //export SKY_wallet_ReadableEntry_Save func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() re, okre := lookupReadableEntryHandle(_re) if !okre { ____error_code = SKY_BAD_HANDLE @@ -75,10 +79,11 @@ func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string //export SKY_wallet_LoadReadableWallet func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() filename := _filename __arg1, ____return_err := wallet.LoadReadableWallet(filename) ____error_code = libErrorCode(____return_err) @@ -90,10 +95,11 @@ func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Ha //export SKY_wallet_ReadableWallet_Save func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE @@ -109,10 +115,11 @@ func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename stri //export SKY_wallet_ReadableWallet_Load func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE @@ -128,10 +135,11 @@ func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename stri //export SKY_wallet_ReadableWallet_Erase func SKY_wallet_ReadableWallet_Erase(_rw C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/wallet.wallet.go b/lib/cgo/wallet.wallet.go index ae894abda7..e72042710e 100644 --- a/lib/cgo/wallet.wallet.go +++ b/lib/cgo/wallet.wallet.go @@ -20,10 +20,11 @@ import "C" //export SKY_wallet_NewError func SKY_wallet_NewError(_err error) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() + checkAPIReady() err := _err ____return_err := wallet.NewError(err) ____error_code = libErrorCode(____return_err) @@ -34,7 +35,7 @@ func SKY_wallet_NewError(_err error) (____error_code uint32) { //export SKY_wallet_NewWallet func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -57,7 +58,7 @@ func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wal //export SKY_wallet_Wallet_Lock func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -79,7 +80,7 @@ func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType s //export SKY_wallet_Wallet_Unlock func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -101,7 +102,7 @@ func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wa //export SKY_wallet_Load func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -118,7 +119,7 @@ func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code u //export SKY_wallet_Wallet_Save func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -139,7 +140,7 @@ func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code ui //export SKY_wallet_Wallet_Validate func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -159,7 +160,7 @@ func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { //export SKY_wallet_Wallet_Type func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -177,7 +178,7 @@ func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_ //export SKY_wallet_Wallet_Version func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -195,7 +196,7 @@ func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____err //export SKY_wallet_Wallet_Filename func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -213,7 +214,7 @@ func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____er //export SKY_wallet_Wallet_Label func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -231,7 +232,7 @@ func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error //export SKY_wallet_Wallet_IsEncrypted func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -249,7 +250,7 @@ func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_ //export SKY_wallet_Wallet_GenerateAddresses func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -271,7 +272,7 @@ func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 //export SKY_wallet_Wallet_GetAddresses func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -289,7 +290,7 @@ func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (___ //export SKY_wallet_Wallet_GetEntry func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg1 *C.wallet__Entry, _arg2 *bool) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -309,7 +310,7 @@ func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg //export SKY_wallet_Wallet_AddEntry func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -330,7 +331,7 @@ func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (_ //export SKY_wallet_DistributeSpendHours func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bool, _arg2 *uint64, _arg3 *C.GoSlice_, _arg4 *uint64) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -348,7 +349,7 @@ func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bo //export SKY_wallet_DistributeCoinHoursProportional func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -366,7 +367,7 @@ func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, //export SKY_wallet_NewUxBalances func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -384,7 +385,7 @@ func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C. //export SKY_wallet_NewUxBalance func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__UxBalance) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -402,7 +403,7 @@ func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wall //export SKY_wallet_ChooseSpendsMinimizeUxOuts func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() @@ -421,7 +422,7 @@ func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _ //export SKY_wallet_ChooseSpendsMaximizeUxOuts func SKY_wallet_ChooseSpendsMaximizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = 0 + ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) }() diff --git a/lib/swig/README.md b/lib/swig/README.md deleted file mode 100644 index 868bba4999..0000000000 --- a/lib/swig/README.md +++ /dev/null @@ -1,52 +0,0 @@ -#SWIG files - -SWIG interface files for generating skycoin libraries in different languages. - -##Table of Contents - - -- [Requirements] (#requirements) -- [Usage] (#usage) - - [Tips] (#tips) - - -## Requirements - Requires Swig installed. It has been tested with 3.0.10, so that would be the preferred version. - These swig interface files has been tested with Python2.7, and in other languages may not work as expected. It is very important to read SWIG documentation for the specific target language being used, http://www.swig.org/Doc3.0/SWIGDocumentation.html -## Usage - First step would be to apply SWIG to the main interface file (skycoin.i). For example if it is going to be generated for Python it would be like this: - swig -python skycoin.i -Or in the case of C#: - swig -csharp skycoin.i - You will also need to add to this command the include paths where to search for required header files. This path would be skycoin include path. For example if skycoin include path is skycoin/include, then the swig command would be: - swig -csharp -Iskycoin/include skycoin.i - However, doing this will raise an error because SWIG doesn't fully understand a specific line in libksycoin.h. The solution is making a copy of libskycoin and removing the conflicting line. Like this: - grep -v _Complex skycoin/include/libskycoin.h > swig/include/libskycoin.h - swig -csharp -I swig/include -Iskycoin/include skycoin.i - The above command lines will make a copy of libskycoin.h removing lines containing string "_Complex" and execute swig specifying first as include path the path containing the modified copy of libskycoin. -## Tips - It is also important to notice that file structs.i contains inclusions of header files containing type definitions of libskycoin. This file is very similar to skytypes.gen.h but replacing character # with %. - For example skytypes.gen.h being something like this: - - #include "file1.h" - #include "file2.h" - - Then, structs.i would be: - %include "file1.h" - %include "file2.h" - - And this is something that swig can understand. - So, a good idea would be to update structs.i from skytypes.gen.h, just in case there have been modifications to skycoin source code. - Like this: - cp skycoin/include/skytypes.gen.h structs.i - sed -i 's/#/%/g' structs.i - grep -v _Complex skycoin/include/libskycoin.h > swig/include/libskycoin.h - swig -csharp -I swig/include -Iskycoin/include skycoin.i - - Use https://github.com/simelo/pyskycoin/ as a reference. Check Makefile rule build-swig. - This project is used to create a Python extension to access skycoin API from Python. This project contains skycoin repository as git submodule, which is a good idea to make libraries for other languages. - - - - - diff --git a/lib/swig/cmp.i b/lib/swig/cmp.i deleted file mode 100644 index 8a85c4bb50..0000000000 --- a/lib/swig/cmp.i +++ /dev/null @@ -1,47 +0,0 @@ -%inline { - int equalSlices(GoSlice* slice1, GoSlice* slice2, int elem_size){ - if(slice1->len != slice2->len) - return 0; - return memcmp(slice1->data, slice2->data, slice1->len * elem_size) == 0; - } - int equalTransactions(coin__Transaction* t1, coin__Transaction* t2){ - if( t1->Length != t2->Length || t1->Type != t2->Type ){ - return 0; - } - if( memcmp(&t1->InnerHash, &t2->InnerHash, sizeof(cipher__SHA256)) != 0 ) - return 0; - if(!equalSlices((GoSlice*)&t1->Sigs, (GoSlice*)&t2->Sigs, sizeof(cipher__Sig))) - return 0; - if(!equalSlices((GoSlice*)&t1->In, (GoSlice*)&t2->In, sizeof(cipher__SHA256))) - return 0; - if(!equalSlices((GoSlice*)&t1->Out, (GoSlice*)&t2->Out, sizeof(coin__TransactionOutput))) - return 0; - return 1; - } - int equalTransactionsArrays(coin__Transactions* pTxs1, coin__Transactions* pTxs2){ - if( pTxs1->len != pTxs2->len ) - return 0; - coin__Transaction* pTx1 = pTxs1->data; - coin__Transaction* pTx2 = pTxs2->data; - int i; - for(i = 0; i < pTxs1->len; i++){ - if(!equalTransactions(pTx1, pTx2)) - return 0; - pTx1++; - pTx2++; - } - return 1; - } - int equalBlockHeaders(coin__BlockHeader* bh1, coin__BlockHeader* bh2){ - if( bh1->Version != bh2->Version || bh1->Time != bh2->Time || - bh1->BkSeq != bh2->BkSeq || bh1->Fee != bh2->Fee) - return 0; - if( memcmp( &bh1->PrevHash, bh2->PrevHash, sizeof(bh2->PrevHash) ) != 0 ) - return 0; - if( memcmp( &bh1->BodyHash, bh2->PrevHash, sizeof(bh2->BodyHash) ) != 0 ) - return 0; - if( memcmp( &bh1->UxHash, bh2->PrevHash, sizeof(bh2->UxHash) ) != 0 ) - return 0; - return 1; - } -} diff --git a/lib/swig/golang.cgo.i b/lib/swig/golang.cgo.i deleted file mode 100644 index 5fe2b9d95b..0000000000 --- a/lib/swig/golang.cgo.i +++ /dev/null @@ -1,111 +0,0 @@ -%begin %{ -#define SWIG_PYTHON_STRICT_BYTE_CHAR -%} - -/*GoSlice in typemap*/ -%typemap(in) GoSlice { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); - } - $1.data = buffer; - $1.len = size - 1; - $1.cap = size; -} - - -%typecheck(SWIG_TYPECHECK_STRING) GoSlice { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - $1 = SWIG_IsOK(res) ? 1 : 0; -} - -/*GoSlice_* parameter as reference */ -%typemap(in, numinputs=0) GoSlice_* (GoSlice_ temp) { - temp.data = NULL; - temp.len = 0; - temp.cap = 0; - $1 = ($1_type)&temp; -} - -/*GoSlice_* as function return typemap*/ -%typemap(argout) GoSlice_* { - %append_output( SWIG_FromCharPtrAndSize( $1->data, $1->len ) ); - free( (void*)$1->data ); -} - -%apply GoSlice_* {coin__UxArray*} - - -/*GoString in typemap*/ -%typemap(in) GoString { - char* buffer = 0; - size_t size = 0; - int res = SWIG_AsCharPtrAndSize( $input, &buffer, &size, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting string"); - } - $1.p = buffer; - $1.n = size - 1; -} - -/*GoString* parameter as reference */ -%typemap(in, numinputs=0) GoString* (GoString temp) { - temp.p = NULL; - temp.n = 0; - $1 = ($1_type)&temp; -} - -/*GoString* as function return typemap*/ -%typemap(argout) GoString* { - %append_output( SWIG_FromCharPtrAndSize( $1->p, $1->n ) ); - free( (void*)$1->p ); -} - -/*GoUint64* parameter as reference */ -%typemap(in, numinputs=0) GoUint64* (GoUint64 temp) { - temp = 0; - $1 = &temp; -} - -/*GoUint64* as function return typemap*/ -%typemap(argout) GoUint64* { - %append_output( SWIG_From_long( *$1 ) ); -} - -/*GoInt64* parameter as reference */ -%typemap(in, numinputs=0) GoInt64* (GoInt64 temp) { - temp = 0; - $1 = &temp; -} - -/*GoInt64* as function return typemap*/ -%typemap(argout) GoInt64* { - %append_output( SWIG_From_long( *$1 ) ); -} - -%apply GoString {GoString_} -%apply GoString* {GoString_*} - -%apply int* OUTPUT {GoInt*} -%apply int* OUTPUT {GoUint*} -%apply int* OUTPUT {GoUint8*} -%apply int* OUTPUT {GoInt8*} -%apply int* OUTPUT {GoUint16*} -%apply int* OUTPUT {GoInt16*} -%apply int* OUTPUT {GoUint32*} -%apply int* OUTPUT {GoInt32*} - -typedef GoInt GoInt_; -typedef GoUint GoUint_; -typedef GoInt8 GoInt8_; -typedef GoUint8 GoUint8_; -typedef GoInt16 GoInt16_; -typedef GoUint16 GoUint16_; -typedef GoInt32 GoInt32_; -typedef GoUint32 GoUint32_; -typedef GoInt64 GoInt64_; -typedef GoUint64 GoUint64_; diff --git a/lib/swig/python_addresses.i b/lib/swig/python_addresses.i deleted file mode 100644 index 2383ca2414..0000000000 --- a/lib/swig/python_addresses.i +++ /dev/null @@ -1,53 +0,0 @@ -%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_Addresses* { - $1 = PyList_Check($input) ? 1 : 0; -} - -/*cipher_Addresses* input parameter */ -%typemap(in) (cipher_Addresses* __in_addresses) (cipher_Addresses temp) { - int i; - $1 = &temp; - $1->count = PyList_Size($input); - $1->data = malloc(sizeof(cipher__Address) * $1->count); - cipher__Address* pdata = $1->data; - for(i = 0; i < $1->count; i++){ - PyObject *o = PyList_GetItem($input, i); - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher__Address, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type cipher__Address"); - cipher__Address* p = (cipher__Address*)argp; - memcpy(pdata, p, sizeof(cipher__Address)); - pdata++; - } -} - -%typemap(freearg) (cipher_Addresses* __in_addresses) { - if ($1->data) free($1->data); -} - -/*cipher_Addresses* parameter to return as a list */ -%typemap(in, numinputs=0) (cipher_Addresses* __out_addresses) (cipher_Addresses temp) { - temp.data = NULL; - temp.count = 0; - $1 = &temp; -} - -/*cipher_Addresses* as function return typemap*/ -%typemap(argout) (cipher_Addresses* __out_addresses) { - int i; - PyObject *list = PyList_New(0); - for (i = 0; i < $1->count; i++) { - cipher__Address* key = &($1->data[i]); - cipher__Address* newKey = malloc(sizeof(cipher__Address)); - memcpy(newKey, key, sizeof(cipher__Address)); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher__Address, SWIG_POINTER_OWN ); - PyList_Append(list, o); - Py_DECREF(o); - } - if( $1->data != NULL) - free( (void*)$1->data ); - %append_output( list ); -} - - - diff --git a/lib/swig/python_pubkeys.i b/lib/swig/python_pubkeys.i deleted file mode 100644 index 174eaa15e5..0000000000 --- a/lib/swig/python_pubkeys.i +++ /dev/null @@ -1,23 +0,0 @@ -/*cipher_PubKeys* input parameter */ -%typemap(in) (cipher_PubKeys* __in_pubKeys) (cipher_PubKeys temp) { - int i; - $1 = &temp; - $1->count = PyList_Size($input); - $1->data = malloc(sizeof(cipher_PubKey) * $1->count); - cipher_PubKey* pdata = $1->data; - for(i = 0; i < $1->count; i++){ - PyObject *o = PyList_GetItem($input, i); - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_PubKey, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type PubKey"); - cipher_PubKey* p = (cipher_PubKey*)argp; - memcpy(pdata, p, sizeof(cipher_PubKey)); - pdata++; - } -} - -%typemap(freearg) (cipher_PubKeys* __in_pubKeys) { - if ($1->data) free($1->data); -} - diff --git a/lib/swig/python_seckeys.i b/lib/swig/python_seckeys.i deleted file mode 100644 index 3808de7716..0000000000 --- a/lib/swig/python_seckeys.i +++ /dev/null @@ -1,50 +0,0 @@ -%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_SecKeys* { - $1 = PyList_Check($input) ? 1 : 0; -} - -/*cipher_SecKeys* input parameter */ -%typemap(in) (cipher_SecKeys* __in_secKeys) (cipher_SecKeys temp) { - int i; - $1 = &temp; - $1->count = PyList_Size($input); - $1->data = malloc(sizeof(cipher_SecKey) * $1->count); - cipher_SecKey* pdata = $1->data; - for(i = 0; i < $1->count; i++){ - PyObject *o = PyList_GetItem($input, i); - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SecKey, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type SecKey"); - cipher_SecKey* p = (cipher_SecKey*)argp; - memcpy(pdata, p, sizeof(cipher_SecKey)); - pdata++; - } -} - -%typemap(freearg) (cipher_SecKeys* __in_secKeys) { - if ($1->data) free($1->data); -} - -/*cipher_SecKeys* parameter to return as a list */ -%typemap(in, numinputs=0) (cipher_SecKeys* __out_secKeys) (cipher_SecKeys temp) { - temp.data = NULL; - temp.count = 0; - $1 = &temp; -} - -/*cipher_SecKeys* as function return typemap*/ -%typemap(argout) (cipher_SecKeys* __out_secKeys) { - int i; - PyObject *list = PyList_New(0); - for (i = 0; i < $1->count; i++) { - cipher_SecKey* key = &($1->data[i]); - cipher_SecKey* newKey = malloc(sizeof(cipher_SecKey)); - memcpy(newKey, key, sizeof(cipher_SecKey)); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher_SecKey, SWIG_POINTER_OWN ); - PyList_Append(list, o); - Py_DECREF(o); - } - if( $1->data != NULL) - free( (void*)$1->data ); - %append_output( list ); -} diff --git a/lib/swig/python_sha256s.i b/lib/swig/python_sha256s.i deleted file mode 100644 index 88a53efe03..0000000000 --- a/lib/swig/python_sha256s.i +++ /dev/null @@ -1,53 +0,0 @@ -%typecheck(SWIG_TYPECHECK_STRING_ARRAY) cipher_SHA256s* { - $1 = PyList_Check($input) ? 1 : 0; -} - -/*cipher_SHA256s* input parameter */ -%typemap(in) (cipher_SHA256s* __in_hashes) (cipher_SHA256s temp) { - int i; - $1 = &temp; - $1->count = PyList_Size($input); - $1->data = malloc(sizeof(cipher_SHA256) * $1->count); - cipher_SHA256* pdata = $1->data; - for(i = 0; i < $1->count; i++){ - PyObject *o = PyList_GetItem($input, i); - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type cipher_SHA256"); - cipher_SHA256* p = (cipher_SHA256*)argp; - memcpy(pdata, p, sizeof(cipher_SHA256)); - pdata++; - } -} - -%typemap(freearg) (cipher_SHA256s* __in_hashes) { - if ($1->data) free($1->data); -} - -/*cipher_SHA256s* parameter to return as a list */ -%typemap(in, numinputs=0) (cipher_SHA256s* __out_hashes) (cipher_SHA256s temp) { - temp.data = NULL; - temp.count = 0; - $1 = &temp; -} - -/*cipher_SHA256s* as function return typemap*/ -%typemap(argout) (cipher_SHA256s* __out_hashes) { - int i; - PyObject *list = PyList_New(0); - for (i = 0; i < $1->count; i++) { - cipher_SHA256* key = &($1->data[i]); - cipher_SHA256* newKey = malloc(sizeof(cipher_SHA256)); - memcpy(newKey, key, sizeof(cipher_SHA256)); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_cipher_SHA256, SWIG_POINTER_OWN ); - PyList_Append(list, o); - Py_DECREF(o); - } - if( $1->data != NULL) - free( (void*)$1->data ); - %append_output( list ); -} - - - diff --git a/lib/swig/python_skycoin.callback.i b/lib/swig/python_skycoin.callback.i deleted file mode 100644 index 8bc1e9a722..0000000000 --- a/lib/swig/python_skycoin.callback.i +++ /dev/null @@ -1,30 +0,0 @@ -%{ - -GoUint32_ _WrapperFeeCalculator(Transaction__Handle handle, GoUint64_* pFee, void* context){ - PyObject* feeCalc = (PyObject*)context; - PyObject *result = PyObject_CallFunctionObjArgs(feeCalc, PyLong_FromLong(handle), NULL); - GoUint32_ error = 0; - if(PyTuple_Check(result)){ - PyObject* objerror = PyTuple_GetItem(result, 0); - error = PyLong_AsLong(objerror); - result = PyTuple_GetItem(result, 1); - } - if(error != 0) - return error; - GoUint64_ ret = PyLong_AsLong(result); - Py_DECREF(result); - if(pFee){ - *pFee = ret; - return 0; - } - else - return 1; -} -%} - -%typemap(in) FeeCalculator* (FeeCalculator temp) { - if (!PyCallable_Check($input)) SWIG_fail; - temp.callback = _WrapperFeeCalculator; - temp.context = $input; - $1 = &temp; -} diff --git a/lib/swig/python_skycoin.cipher.crypto.i b/lib/swig/python_skycoin.cipher.crypto.i deleted file mode 100644 index 359744d07c..0000000000 --- a/lib/swig/python_skycoin.cipher.crypto.i +++ /dev/null @@ -1,257 +0,0 @@ - - -%extend cipher__Address{ - int __eq__(cipher__Address* a){ - if( $self->Version == a->Version ){ - return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; - } - return 0; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->Key, sizeof($self->Key)); - } -} - -%extend cipher_PubKey { - int __eq__(cipher_PubKey* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_SecKey { - int __eq__(cipher_SecKey* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Ripemd160 { - int __eq__(cipher_Ripemd160* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Sig { - int __eq__(cipher_Sig* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_SHA256 { - int __eq__(cipher_SHA256* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Checksum { - int __eq__(cipher_Checksum* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - int compareToString(PyObject * str){ - char* s = SWIG_Python_str_AsChar(str); - int result = memcmp(s, $self->data, sizeof($self->data)); - SWIG_Python_str_DelForPy3(s); - return result; - } - PyObject* toStr(){ - return PyBytes_FromStringAndSize((const char*)$self->data, sizeof($self->data)); - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - - -%extend cipher_SecKeys { - cipher_SecKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_SecKey* seckey){ - if( i < $self->count){ - memcpy(&$self->data[i], seckey, sizeof(*seckey)); - return i; - } else { - return -1; - } - } - - int __eq__(cipher_SecKeys* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SecKey) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - destroy_cipher_SecKeys($self); - } -} - -%inline{ - void destroy_cipher_SecKeys(cipher_SecKeys* p){ - if( p != NULL ){ - if( p->data != NULL ){ - free( p->data ); - } - } - } -} - -%extend cipher_PubKeys { - cipher_PubKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_PubKey* pubkey){ - if( i < $self->count){ - memcpy(&self->data[i], pubkey, sizeof(*pubkey)); - return i; - } else { - return -1; - } - } - - int __eq__(cipher_PubKeys* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_PubKey) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - destroy_cipher_PubKeys($self); - } -} - -%extend cipher_SHA256s { - cipher_SHA256* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_SHA256* hash){ - if( i < $self->count){ - memcpy(&self->data[i], hash, sizeof(*hash)); - return i; - } else { - return -1; - } - } - - int __eq__(cipher_SHA256s* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SHA256) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - if($self->data != NULL) free($self->data); - } -} - -%inline{ - void destroy_cipher_PubKeys(cipher_PubKeys* p){ - if( p != NULL ){ - if( p->data != NULL ){ - free( p->data ); - } - } - } -} - diff --git a/lib/swig/python_skycoin.coin.i b/lib/swig/python_skycoin.coin.i deleted file mode 100644 index 40068a285f..0000000000 --- a/lib/swig/python_skycoin.coin.i +++ /dev/null @@ -1,88 +0,0 @@ -%include "cmp.i" - -%extend coin__BlockHeader { - int __eq__(coin__BlockHeader* bh){ - return equalBlockHeaders($self, bh); - } -} - -%extend coin__Transaction { - int __eq__(coin__Transaction* t){ - return equalTransactions($self, t); - } -} - -%extend coin__BlockBody { - int __eq__(coin__BlockBody* b){ - return equalTransactionsArrays(&$self->Transactions, &b->Transactions); - } -} - -%extend coin__UxOut { - int __eq__(coin__UxOut* u){ - if($self->Head.Time != u->Head.Time) - return 0; - if($self->Head.BkSeq != u->Head.BkSeq) - return 0; - if($self->Body.Coins != u->Body.Coins) - return 0; - if($self->Body.Hours != u->Body.Hours) - return 0; - if(memcmp(&$self->Body.Address, &u->Body.Address, sizeof(cipher__Address)) != 0) - return 0; - if(memcmp(&$self->Body.SrcTransaction, &u->Body.SrcTransaction, sizeof(cipher__SHA256)) != 0) - return 0; - return 1; - } -} - -%extend coin__TransactionOutput { - int __eq__(coin__TransactionOutput* t){ - if( $self->Coins != t->Coins || - $self->Hours != t->Hours ){ - return 0; - } - - if(memcmp(&$self->Address, &t->Address, sizeof(cipher__Address)) != 0) - return 0; - return 1; - } -} - -%typemap(in, numinputs=0) (coin__Transaction**) (coin__Transaction* temp) { - temp = NULL; - $1 = &temp; -} - -/*Return a pointer created with own = 0 because -Python will not own the object - */ -%typemap(argout) (coin__Transaction**) { - %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Transaction, 0 ) ); -} - -%typemap(in, numinputs=0) (coin__Block**) (coin__Block* temp) { - temp = NULL; - $1 = &temp; -} - -/*Return a pointer created with own = 0 because -Python will not own the object - */ -%typemap(argout) (coin__Block**) { - %append_output( SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_coin__Block, 0 ) ); -} - -%extend coin__UxBody { - PyObject* GetSrcTransaction(){ - return SWIG_NewPointerObj(SWIG_as_voidptr(&$self->SrcTransaction), SWIGTYPE_p_cipher_SHA256, 0 ); - } - void SetSrcTransaction(PyObject* o){ - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); - if (SWIG_IsOK(res)){ - cipher_SHA256* p = (cipher_SHA256*)argp; - memcpy( &$self->SrcTransaction, &p->data, sizeof(cipher__SHA256)); - } - } -} diff --git a/lib/swig/python_uxarray.i b/lib/swig/python_uxarray.i deleted file mode 100644 index 5d35da7bcd..0000000000 --- a/lib/swig/python_uxarray.i +++ /dev/null @@ -1,52 +0,0 @@ -%typecheck(SWIG_TYPECHECK_STRING_ARRAY) coin_UxOutArray* { - $1 = PyList_Check($input) ? 1 : 0; -} - -/*coin_UxOutArray* input parameter */ -%typemap(in) (coin_UxOutArray* __uxIn) (coin_UxOutArray temp) { - int i; - $1 = &temp; - $1->count = PyList_Size($input); - $1->data = malloc(sizeof(coin__UxOut) * $1->count); - coin__UxOut* pdata = $1->data; - for(i = 0; i < $1->count; i++){ - PyObject *o = PyList_GetItem($input, i); - void *argp = 0; - int res = SWIG_ConvertPtr(o, &argp, SWIGTYPE_p_coin__UxOut, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type UxOut"); - coin__UxOut* p = (coin__UxOut*)argp; - memcpy(pdata, p, sizeof(coin__UxOut)); - pdata++; - } -} - -%typemap(freearg) (coin_UxOutArray* __uxIn) { - if ($1->data) free($1->data); -} - -%apply (coin_UxOutArray* __uxIn) {(coin_UxOutArray* __uxOut), (coin_UxOutArray* __uxIn2)} - -/*coin_UxOutArray* parameter to return as a list */ -%typemap(in, numinputs=0) (coin_UxOutArray* __return_Ux) (coin_UxOutArray temp) { - temp.data = NULL; - temp.count = 0; - $1 = &temp; -} - -/*coin_UxOutArray* as function return typemap*/ -%typemap(argout) (coin_UxOutArray* __return_Ux) { - int i; - PyObject *list = PyList_New(0); - for (i = 0; i < $1->count; i++) { - coin__UxOut* key = &($1->data[i]); - coin__UxOut* newKey = malloc(sizeof(coin__UxOut)); - memcpy(newKey, key, sizeof(coin__UxOut)); - PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(newKey), SWIGTYPE_p_coin__UxOut, SWIG_POINTER_OWN ); - PyList_Append(list, o); - Py_DECREF(o); - } - if( $1->data != NULL) - free( (void*)$1->data ); - %append_output( list ); -} diff --git a/lib/swig/skycoin.cipher.crypto.i b/lib/swig/skycoin.cipher.crypto.i deleted file mode 100644 index 06ac4dcf27..0000000000 --- a/lib/swig/skycoin.cipher.crypto.i +++ /dev/null @@ -1,189 +0,0 @@ -%extend cipher__Address { - int isEqual(cipher__Address* a){ - if( $self->Version == a->Version ){ - return memcmp($self->Key, a->Key, sizeof(a->Key)) == 0; - } - return 0; - } -} - -%extend cipher_PubKey { - int isEqual(cipher_PubKey* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_SecKey { - int isEqual(cipher_SecKey* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Ripemd160 { - int isEqual(cipher_Ripemd160* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Sig { - int isEqual(cipher_Sig* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_SHA256 { - int isEqual(cipher_SHA256* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - -%extend cipher_Checksum { - int isEqual(cipher_Checksum* a){ - return memcmp($self->data, a->data, sizeof(a->data)) == 0; - } - void assignFrom(void* data){ - memcpy(&$self->data, data, sizeof($self->data)); - } - void assignTo(void* data){ - memcpy(data, &$self->data, sizeof($self->data)); - } -} - - -%extend cipher_SecKeys { - cipher_SecKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_SecKey* seckey){ - if( i < $self->count){ - memcpy(&self->data[i], seckey, sizeof(*seckey)); - return i; - } else { - return -1; - } - } - - int isEqual(cipher_SecKeys* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SecKey) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - destroy_cipher_SecKeys($self); - } -} - -%extend cipher_SHA256s { - cipher_SHA256* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_SHA256* hash){ - if( i < $self->count){ - memcpy(&self->data[i], hash, sizeof(*hash)); - return i; - } else { - return -1; - } - } - - int isEqual(cipher_SHA256s* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_SHA256) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - if($self->data != NULL) free($self->data); - } -} - -%inline{ - void destroy_cipher_SecKeys(cipher_SecKeys* p){ - if( p != NULL ){ - if( p->data != NULL ){ - free( p->data ); - } - } - } -} - -%extend cipher_PubKeys { - cipher_PubKey* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, cipher_PubKey* pubkey){ - if( i < $self->count){ - memcpy(&self->data[i], pubkey, sizeof(*pubkey)); - return i; - } else { - return -1; - } - } - - int isEqual(cipher_PubKeys* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(cipher_PubKey) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - if($self->data != NULL) - free($self->data); - } -} - diff --git a/lib/swig/skycoin.coin.i b/lib/swig/skycoin.coin.i deleted file mode 100644 index 0759fd524f..0000000000 --- a/lib/swig/skycoin.coin.i +++ /dev/null @@ -1,84 +0,0 @@ -%include "cmp.i" - -%extend coin__BlockHeader { - int isEqual(coin__BlockHeader* bh){ - return equalBlockHeaders($self, bh); - } -} - -%extend coin__Transaction { - int isEqual(coin__Transaction* t){ - return equalTransactions($self, t); - } -} - -%extend coin__BlockBody { - int isEqual(coin__BlockBody* b){ - return equalTransactionsArrays(&$self->Transactions, &b->Transactions); - } -} - -%extend coin__UxOut { - int isEqual(coin__UxOut* u){ - if($self->Head.Time != u->Head.Time) - return 0; - if($self->Head.BkSeq != u->Head.BkSeq) - return 0; - if($self->Body.Coins != u->Body.Coins) - return 0; - if($self->Body.Hours != u->Body.Hours) - return 0; - if(memcmp(&$self->Body.Address, &u->Body.Address, sizeof(cipher__Address)) != 0) - return 0; - if(memcmp(&$self->Body.SrcTransaction, &u->Body.SrcTransaction, sizeof(cipher__SHA256)) != 0) - return 0; - return 1; - } -} - -%extend coin_UxOutArray { - coin__UxOut* getAt(int i){ - if( i < $self->count ){ - return &$self->data[i]; - } - else - return NULL; - } - - int setAt(int i, coin__UxOut* uxout){ - if( i < $self->count){ - memcpy(&self->data[i], uxout, sizeof(*uxout)); - return i; - } else { - return -1; - } - } - - int isEqual(coin_UxOutArray* a){ - return $self->count == a->count && memcmp($self->data, a->data, sizeof(coin__UxOut) * $self->count) == 0; - } - - void allocate(int n){ - $self->data = malloc(n * sizeof(*($self->data))); - $self->count = n; - } - - void release(){ - if($self->data != NULL) - free($self->data); - } -} - -%extend coin__TransactionOutput { - int isEqual(coin__TransactionOutput* t){ - if( $self->Coins != t->Coins || - $self->Hours != t->Hours ){ - return 0; - } - - if(memcmp(&$self->Address, &t->Address, sizeof(cipher__Address)) != 0) - return 0; - return 1; - } -} - diff --git a/lib/swig/skycoin.i b/lib/swig/skycoin.i deleted file mode 100755 index 511341b16e..0000000000 --- a/lib/swig/skycoin.i +++ /dev/null @@ -1,34 +0,0 @@ -%module skycoin -%include "typemaps.i" -%{ - #define SWIG_FILE_WITH_INIT - #include "libskycoin.h" - #include "swig.h" -%} - -//Apply strictly to python -//Not for other languages -#if defined(SWIGPYTHON) -%include "python_skycoin.cipher.crypto.i" -%include "python_uxarray.i" -%include "python_sha256s.i" -%include "python_skycoin.coin.i" -%include "python_skycoin.callback.i" -#else -%include "skycoin.cipher.crypto.i" -%include "skycoin.coin.i" -#endif - -//Apply typemaps for Python for now -//It can be applied to other languages that fit in -//Not languages can't return multiple values -#if defined(SWIGPYTHON) -%include "golang.cgo.i" -%include "structs_typemaps.i" -%include "skycoin.mem.i" -#endif - -%include "swig.h" -/* Find the modified copy of libskycoin */ -%include "libskycoin.h" -%include "structs.i" diff --git a/lib/swig/skycoin.mem.i b/lib/swig/skycoin.mem.i deleted file mode 100644 index fa1a549b50..0000000000 --- a/lib/swig/skycoin.mem.i +++ /dev/null @@ -1,429 +0,0 @@ -/** -* -* typemaps for Handles -* -**/ - -/* Handle reference typemap. */ -%typemap(in, numinputs=0) Handle* (Handle temp) { - $1 = &temp; -} - -/* Handle out typemap. */ -%typemap(argout) Handle* { - %append_output( SWIG_From_long(*$1) ); -} - -/* Handle not as pointer is input. */ -%typemap(in) Handle { - SWIG_AsVal_long($input, (long*)&$1); -} - - -%apply Handle { Wallet__Handle, Options__Handle, ReadableEntry__Handle, ReadableWallet__Handle, WebRpcClient__Handle, - WalletResponse__Handle, Client__Handle, Strings__Handle, Wallets__Handle, Config__Handle, App__Handle, Context__Handle, - GoStringMap, PasswordReader__Handle_, - Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, - CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle, AddressUxOuts_Handle - } - -%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, - WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*, - App__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, - Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, - CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*, AddressUxOuts_Handle* - } - -#if defined(SWIGPYTHON) - -%typecheck(SWIG_TYPECHECK_INTEGER) Transaction__Handle { - $1 = PyInt_Check($input) ? 1 : 0; -} - -%typecheck(SWIG_TYPECHECK_INTEGER) Transactions__Handle { - $1 = PyInt_Check($input) ? 1 : 0; -} - -%typecheck(SWIG_TYPECHECK_INTEGER) AddressUxOuts_Handle { - $1 = PyInt_Check($input) ? 1 : 0; -} - -%include "python_seckeys.i" -%include "python_pubkeys.i" -%include "python_uxarray.i" -%include "python_addresses.i" -#endif - -%rename(SKY_coin_Transaction_SignInputs) wrap_SKY_coin_Transaction_SignInputs; -%inline{ - GoUint32 wrap_SKY_coin_Transaction_SignInputs(Transaction__Handle handle, cipher_SecKeys* __in_secKeys){ - GoSlice data; - data.data = __in_secKeys->data; - data.len = __in_secKeys->count; - data.cap = __in_secKeys->count; - return SKY_coin_Transaction_SignInputs(handle, data); - } -} - - -%rename(SKY_cipher_GenerateDeterministicKeyPairs) wrap_SKY_cipher_GenerateDeterministicKeyPairs; -%inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairs(GoSlice seed, GoInt n, cipher_SecKeys* __out_secKeys){ - __out_secKeys->data = NULL; - __out_secKeys->count = 0; - GoSlice_ data; - data.data = malloc(sizeof(cipher_SecKey) * n); - data.len = n; - data.cap = n; - GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairs(seed, n, &data); - if( result == 0){ - __out_secKeys->data = data.data; - __out_secKeys->count = data.len; - } - return result; - } -} - -%rename(SKY_cipher_GenerateDeterministicKeyPairsSeed) wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed; -%inline { - GoUint32 wrap_SKY_cipher_GenerateDeterministicKeyPairsSeed(GoSlice seed, GoInt n, coin__UxArray* newSeed, cipher_SecKeys* __out_secKeys){ - __out_secKeys->data = NULL; - __out_secKeys->count = 0; - GoSlice_ data; - data.data = malloc(sizeof(cipher_SecKey) * n); - data.len = n; - data.cap = n; - GoUint32 result = SKY_cipher_GenerateDeterministicKeyPairsSeed(seed, n, newSeed, &data); - if( result == 0){ - __out_secKeys->data = data.data; - __out_secKeys->count = data.len; - } - return result; - } -} - -%rename(SKY_cipher_PubKeySlice_Len) wrap_SKY_cipher_PubKeySlice_Len; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Len(cipher_PubKeys* __in_pubKeys, GoInt* __out_Len){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Len(&data,__out_Len); - return result; - } -} - -%rename(SKY_cipher_PubKeySlice_Less) wrap_SKY_cipher_PubKeySlice_Less; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Less(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2, GoUint8* __out_Less){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Less(&data, p1, p2,__out_Less); - return result; - } -} - -%rename(SKY_cipher_PubKeySlice_Swap) wrap_SKY_cipher_PubKeySlice_Swap; -%inline { - GoUint32 wrap_SKY_cipher_PubKeySlice_Swap(cipher_PubKeys* __in_pubKeys, GoInt p1, GoInt p2){ - GoSlice_ data; - data.data = __in_pubKeys->data; - data.len = __in_pubKeys->count; - data.cap = __in_pubKeys->count; - GoUint32 result = SKY_cipher_PubKeySlice_Swap(&data, p1, p2); - return result; - } -} - -%rename(SKY_coin_VerifyTransactionCoinsSpending) wrap_SKY_coin_VerifyTransactionCoinsSpending; -%inline { - GoUint32 wrap_SKY_coin_VerifyTransactionCoinsSpending(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxOut){ - GoSlice_ dataIn; - dataIn.data = __uxIn->data; - dataIn.len = __uxIn->count; - dataIn.cap = __uxIn->count; - GoSlice_ dataOut; - dataOut.data = __uxOut->data; - dataOut.len = __uxOut->count; - dataOut.cap = __uxOut->count; - GoUint32 result = SKY_coin_VerifyTransactionCoinsSpending(&dataIn, &dataOut); - return result; - }; -} - -%rename(SKY_coin_VerifyTransactionHoursSpending) wrap_SKY_coin_VerifyTransactionHoursSpending; -%inline { - GoUint32 wrap_SKY_coin_VerifyTransactionHoursSpending(GoUint64 _headTime , coin_UxOutArray* __uxIn, coin_UxOutArray* __uxOut){ - GoSlice_ dataIn; - dataIn.data = __uxIn->data; - dataIn.len = __uxIn->count; - dataIn.cap = __uxIn->count; - GoSlice_ dataOut; - dataOut.data = __uxOut->data; - dataOut.len = __uxOut->count; - dataOut.cap = __uxOut->count; - GoUint32 result = SKY_coin_VerifyTransactionHoursSpending(_headTime, &dataIn, &dataOut); - return result; - }; -} - -%rename(SKY_coin_CreateUnspents) wrap_SKY_coin_CreateUnspents; -%inline { - GoUint32 wrap_SKY_coin_CreateUnspents(coin__BlockHeader* bh, Transaction__Handle t, coin_UxOutArray* __return_Ux){ - __return_Ux->data = NULL; - __return_Ux->count = 0; - GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; - GoUint32 result = SKY_coin_CreateUnspents(bh, t, &data); - if( result == 0){ - __return_Ux->data = data.data; - __return_Ux->count = data.len; - } - return result; - } -} - -%rename(SKY_coin_Transaction_VerifyInput) wrap_SKY_coin_Transaction_VerifyInput; -%inline{ - GoUint32 wrap_SKY_coin_Transaction_VerifyInput(Transaction__Handle handle, coin_UxOutArray* __uxIn){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_Transaction_VerifyInput(handle, &data); - } -} - -%rename(SKY_coin_UxArray_HasDupes) wrap_SKY_coin_UxArray_HasDupes; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_HasDupes(coin_UxOutArray* __uxIn, GoUint8* p1){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_UxArray_HasDupes(&data, p1); - } -} - -%rename(SKY_coin_UxArray_Coins) wrap_SKY_coin_UxArray_Coins; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Coins(coin_UxOutArray* __uxIn, GoUint64* p1){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_UxArray_Coins(&data, p1); - } -} - -%rename(SKY_coin_UxArray_CoinHours) wrap_SKY_coin_UxArray_CoinHours; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_CoinHours(coin_UxOutArray* __uxIn, GoUint64 p1, GoUint64* p2){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_UxArray_CoinHours(&data, p1, p2); - } -} - -%rename(SKY_coin_UxArray_Less) wrap_SKY_coin_UxArray_Less; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Less(coin_UxOutArray* __uxIn, GoInt p1, GoInt p2, GoUint8* p3){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_UxArray_Less(&data, p1, p2, p3); - } -} - -%rename(SKY_coin_UxArray_Swap) wrap_SKY_coin_UxArray_Swap; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Swap(coin_UxOutArray* __uxIn, GoInt p1, GoInt p2){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_UxArray_Swap(&data, p1, p2); - } -} - -%rename(SKY_coin_UxArray_Sub) wrap_SKY_coin_UxArray_Sub; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Sub(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxIn2, coin_UxOutArray* __return_Ux){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - GoSlice_ data2; - data2.data = __uxIn2->data; - data2.len = __uxIn2->count; - data2.cap = __uxIn2->count; - GoSlice_ data3; - data3.data = NULL; - data3.len = 0; - data3.cap = 0; - GoUint32 result = SKY_coin_UxArray_Sub(&data, &data2, &data3); - if( result == 0){ - __return_Ux->data = data3.data; - __return_Ux->count = data3.len; - } - return result; - } -} - -%rename(SKY_coin_UxArray_Add) wrap_SKY_coin_UxArray_Add; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Add(coin_UxOutArray* __uxIn, coin_UxOutArray* __uxIn2, coin_UxOutArray* __return_Ux){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - GoSlice_ data2; - data2.data = __uxIn2->data; - data2.len = __uxIn2->count; - data2.cap = __uxIn2->count; - GoSlice_ data3; - data3.data = NULL; - data3.len = 0; - data3.cap = 0; - GoUint32 result = SKY_coin_UxArray_Add(&data, &data2, &data3); - if( result == 0){ - __return_Ux->data = data3.data; - __return_Ux->count = data3.len; - } - return result; - } -} - -%rename(SKY_coin_NewAddressUxOuts) wrap_SKY_coin_NewAddressUxOuts; -%inline{ - GoUint32 wrap_SKY_coin_NewAddressUxOuts(coin_UxOutArray* __uxIn, AddressUxOuts_Handle* p1){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_NewAddressUxOuts(&data, p1); - } -} - -%rename(SKY_coin_UxArray_Hashes) wrap_SKY_coin_UxArray_Hashes; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Hashes(coin_UxOutArray* __uxIn, cipher_SHA256s* __out_hashes){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - GoSlice_ dataOut; - dataOut.data = NULL; - dataOut.len = 0; - dataOut.cap = 0; - GoUint32 result = SKY_coin_UxArray_Hashes(&data, &dataOut); - if(result == 0){ - __out_hashes->data = dataOut.data; - __out_hashes->count = dataOut.len; - } - return result; - } -} - -%rename(SKY_coin_AddressUxOuts_Flatten) wrap_SKY_coin_AddressUxOuts_Flatten; -%inline{ - GoUint32 wrap_SKY_coin_AddressUxOuts_Flatten(AddressUxOuts_Handle p0, coin_UxOutArray* __return_Ux){ - GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; - GoUint32 result = SKY_coin_AddressUxOuts_Flatten(p0, &data); - if( result == 0 ){ - __return_Ux->data = data.data; - __return_Ux->count = data.len; - } - return result; - } -} - -%rename(SKY_coin_AddressUxOuts_Get) wrap_SKY_coin_AddressUxOuts_Get; -%inline{ - GoUint32 wrap_SKY_coin_AddressUxOuts_Get(AddressUxOuts_Handle p0, cipher__Address* p1, coin_UxOutArray* __return_Ux){ - GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; - GoUint32 result = SKY_coin_AddressUxOuts_Get(p0, p1, &data); - if( result == 0 ){ - __return_Ux->data = data.data; - __return_Ux->count = data.len; - } - return result; - } -} - -%rename(SKY_coin_AddressUxOuts_Set) wrap_SKY_coin_AddressUxOuts_Set; -%inline{ - GoUint32 wrap_SKY_coin_AddressUxOuts_Set(AddressUxOuts_Handle p0, cipher__Address* p1, coin_UxOutArray* __uxIn){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - return SKY_coin_AddressUxOuts_Set(p0, p1, &data); - } -} - -%rename(SKY_coin_AddressUxOuts_Keys) wrap_SKY_coin_AddressUxOuts_Keys; -%inline{ - GoUint32 wrap_SKY_coin_AddressUxOuts_Keys(AddressUxOuts_Handle p0, cipher_Addresses* __out_addresses){ - GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; - GoUint32 result = SKY_coin_AddressUxOuts_Keys(p0, &data); - if( result == 0){ - __out_addresses->data = data.data; - __out_addresses->count = data.len; - } - return result; - } -} - -%rename(SKY_coin_Transactions_Hashes) wrap_SKY_coin_Transactions_Hashes; -%inline{ - GoUint32 wrap_SKY_coin_Transactions_Hashes(Transactions__Handle p0, cipher_SHA256s* __out_hashes){ - GoSlice_ data; - data.data = NULL; - data.len = 0; - data.cap = 0; - GoUint32 result = SKY_coin_Transactions_Hashes(p0, &data); - if( result == 0){ - __out_hashes->data = data.data; - __out_hashes->count = data.len; - } - return result; - } -} - -%rename(SKY_coin_UxArray_Sort) wrap_SKY_coin_UxArray_Sort; -%inline{ - GoUint32 wrap_SKY_coin_UxArray_Sort(coin_UxOutArray* __uxIn, coin_UxOutArray* __return_Ux){ - GoSlice_ data; - data.data = __uxIn->data; - data.len = __uxIn->count; - data.cap = __uxIn->count; - GoUint32 result = SKY_coin_UxArray_Sort(&data); - if( result == 0){ - __return_Ux->data = malloc(data.len * sizeof(coin__UxOut)); - __return_Ux->count = data.len; - memcpy(__return_Ux->data, data.data, data.len * sizeof(coin__UxOut)); - } - return result; - } -} - diff --git a/lib/swig/structs.i b/lib/swig/structs.i deleted file mode 100644 index bdc6984bc8..0000000000 --- a/lib/swig/structs.i +++ /dev/null @@ -1,26 +0,0 @@ -%include "cipher.hash.go.h" -%include "cipher.address.go.h" -%include "cipher.crypto.go.h" -%include "cipher.encoder.field.go.h" -%include "cipher.encrypt.scrypt_chacha20poly1305.go.h" - -%include "cipher.secp256k1-go.secp256k1-go2.field.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" -%include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" -%include "coin.transactions.go.h" -%include "coin.block.go.h" -%include "coin.outputs.go.h" - - -%include "visor.readable.go.h" - - -%include "wallet.balance.go.h" -%include "wallet.entry.go.h" -%include "wallet.notes.go.h" -%include "wallet.wallet.go.h" - -%include "api.client.go.h" -%include "cli.cli.go.h" -%include "cli.create_rawtx.go.h" -%include "util.http.json.go.h" diff --git a/lib/swig/structs_typemaps.i b/lib/swig/structs_typemaps.i deleted file mode 100644 index 394ddbde9d..0000000000 --- a/lib/swig/structs_typemaps.i +++ /dev/null @@ -1,62 +0,0 @@ -/* -cipher__PubKey* input typemap -*/ -%typemap(in) cipher__PubKey* { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_PubKey, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type PubKey"); - cipher_PubKey* p = (cipher_PubKey*)argp; - $1 = &p->data; -} - - -/* -cipher__SecKey* input typemap -*/ -%typemap(in) cipher__SecKey*{ - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_SecKey, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type SecKey"); - cipher_SecKey* p = (cipher_SecKey*)argp; - $1 = &p->data; -} - -%typemap(in) cipher__Ripemd160* { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Ripemd160, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type Ripemd160"); - cipher_Ripemd160* p = (cipher_Ripemd160*)argp; - $1 = &p->data; -} - -%typemap(in) cipher__Sig* { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Sig, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type Sig"); - cipher_Sig* p = (cipher_Sig*)argp; - $1 = &p->data; -} - - - -%typemap(in) cipher__SHA256* { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_SHA256, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type SHA256"); - cipher_SHA256* p = (cipher_SHA256*)argp; - $1 = &p->data; -} - -%typemap(in) cipher__Checksum* { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_cipher_Checksum, 0 | 0); - if (!SWIG_IsOK(res)) - SWIG_exception_fail(SWIG_TypeError, "expecting type Checksum"); - cipher_Checksum* p = (cipher_Checksum*)argp; - $1 = &p->data; -} From 75d6d997a53467e0b66796676e91879dfe280434 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Wed, 5 Sep 2018 20:51:26 -0400 Subject: [PATCH 219/399] [cgo][libc][cipher] refs #1191 Changes in the file cipher.base58.base58.go && cli_helper.go && src/cipher/secp256k1-go/secp256k1-go2/ec.go && src/cipher/encrypt/sha256xor.go [====] Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0 --- lib/cgo/cipher.base58.base58.go | 9 +++++++-- lib/cgo/cli_helper.go | 5 ++++- src/cipher/encrypt/sha256xor.go | 1 + src/cipher/secp256k1-go/secp256k1-go2/ec.go | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/cgo/cipher.base58.base58.go b/lib/cgo/cipher.base58.base58.go index b7cbcad58a..73663ec001 100644 --- a/lib/cgo/cipher.base58.base58.go +++ b/lib/cgo/cipher.base58.base58.go @@ -1,6 +1,7 @@ package main import ( + "encoding/hex" "reflect" "unsafe" @@ -24,8 +25,12 @@ func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) }() checkAPIReady() s := _s - __arg1 := base58.String2Hex(s) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + __arg1, ____return_err := hex.DecodeString(s) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return } diff --git a/lib/cgo/cli_helper.go b/lib/cgo/cli_helper.go index e1dd28f65a..f589db3eee 100644 --- a/lib/cgo/cli_helper.go +++ b/lib/cgo/cli_helper.go @@ -107,6 +107,9 @@ func SKY_cli_Setenv(varname string, value string) (____error_code uint32) { ____error_code = catchApiPanic(____error_code, recover()) }() checkAPIReady() - os.Setenv(varname, value) + ____return_err := os.Setenv(varname, value) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } return } diff --git a/src/cipher/encrypt/sha256xor.go b/src/cipher/encrypt/sha256xor.go index 18c92231e9..181a7f94ab 100644 --- a/src/cipher/encrypt/sha256xor.go +++ b/src/cipher/encrypt/sha256xor.go @@ -27,6 +27,7 @@ const ( ) +// Error definition var ( ErrSHA256orMissingPassword = errors.New("missing password") ErrLenghtDataOverflowMaxUint32 = errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") diff --git a/src/cipher/secp256k1-go/secp256k1-go2/ec.go b/src/cipher/secp256k1-go/secp256k1-go2/ec.go index f63d3896b4..379216b012 100644 --- a/src/cipher/secp256k1-go/secp256k1-go2/ec.go +++ b/src/cipher/secp256k1-go/secp256k1-go2/ec.go @@ -9,6 +9,7 @@ import ( skyerrors "github.com/skycoin/skycoin/src/util/errors" ) +// Error definition var ( ErrMustPass64bytePubKey = errors.New("must pass in 64 byte pubkey") ) From 3f4cce6bbe9fed185f26feb8ca2a8cc1135889c5 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 16 Sep 2018 13:14:00 -0400 Subject: [PATCH 220/399] [lib] [cipher] refs #1191 - Move to new package ValueError and related functions make test fails --- lib/cgo/libsky_error.go | 3 +- lib/cgo/libsky_handle.go | 42 ---- lib/cgo/util.utc.utc.go | 23 -- lib/cgo/wallet.notes.go | 226 -------------------- src/cipher/crypto.go | 17 +- src/cipher/{ => errors}/errors.go | 2 +- src/cipher/hash.go | 6 +- src/cipher/secp256k1-go/secp256k1-go2/ec.go | 2 +- src/cipher/secp256k1-go/secp256k1.go | 2 +- 9 files changed, 18 insertions(+), 305 deletions(-) delete mode 100644 lib/cgo/util.utc.utc.go delete mode 100644 lib/cgo/wallet.notes.go rename src/cipher/{ => errors}/errors.go (98%) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index a62daa063e..21bf5c4551 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -7,6 +7,7 @@ import ( "github.com/skycoin/skycoin/src/cipher/base58" "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/cipher/encrypt" + skyerrors "github.com/skycoin/skycoin/src/cipher/errors" "github.com/skycoin/skycoin/src/cipher/secp256k1-go" "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" @@ -661,7 +662,7 @@ func catchApiPanic(errcode uint32, err interface{}) uint32 { return SKY_API_LOCKED } if err != nil { - if valueErr, isValueError := err.(cipher.ValueError); isValueError { + if valueErr, isValueError := err.(skyerrors.ValueError); isValueError { return libErrorCode(valueErr.ErrorData) } else { // Setting flag every time (i.e. even when haltOnPanic is active diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index aee0f024dd..0ebfcbf0d6 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -416,34 +416,6 @@ func lookupSortableTransactionHandle(handle C.SortableTransactionResult_Handle) return nil, false } -func registerWalletNotesHandle(obj *wallet.Notes) C.WalletNotes_Handle { - return (C.WalletNotes_Handle)(registerHandle(obj)) -} - -func lookupWalletNotesHandle(handle C.WalletNotes_Handle) (*wallet.Notes, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*wallet.Notes); isOK { - return obj, true - } - } - return nil, false -} - -func registerWalletReadableNotesHandle(obj *wallet.ReadableNotes) C.WalletReadableNotes_Handle { - return (C.WalletReadableNotes_Handle)(registerHandle(obj)) -} - -func lookupWalletReadableNotesHandle(handle C.WalletReadableNotes_Handle) (*wallet.ReadableNotes, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*wallet.ReadableNotes); isOK { - return obj, true - } - } - return nil, false -} - func registerOutputsResultHandle(obj *webrpc.OutputsResult) C.OutputsResult_Handle { return (C.OutputsResult_Handle)(registerHandle(obj)) } @@ -486,20 +458,6 @@ func lookupAddressUxOutHandle(handle C.AddressUxOuts_Handle) (*coin.AddressUxOut return nil, false } -func registerBuildInfoHandle(obj *visor.BuildInfo) C.BuildInfo_Handle { - return (C.BuildInfo_Handle)(registerHandle(obj)) -} - -func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*visor.BuildInfo, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*visor.BuildInfo); isOK { - return obj, true - } - } - return nil, false -} - func registerHashHandle(obj *hash.Hash) C.Hash_Handle { return (C.Hash_Handle)(registerHandle(obj)) } diff --git a/lib/cgo/util.utc.utc.go b/lib/cgo/util.utc.utc.go deleted file mode 100644 index 03dbc8034a..0000000000 --- a/lib/cgo/util.utc.utc.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import utc "github.com/skycoin/skycoin/src/util/utc" - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_utc_UnixNow -func SKY_utc_UnixNow(_arg0 *int64) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - __arg0 := utc.UnixNow() - *_arg0 = __arg0 - return -} diff --git a/lib/cgo/wallet.notes.go b/lib/cgo/wallet.notes.go deleted file mode 100644 index 3936afe5b3..0000000000 --- a/lib/cgo/wallet.notes.go +++ /dev/null @@ -1,226 +0,0 @@ -package main - -import ( - "unsafe" - - wallet "github.com/skycoin/skycoin/src/wallet" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_wallet_NewNotesFilename -func SKY_wallet_NewNotesFilename(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - __arg0 := wallet.NewNotesFilename() - copyString(__arg0, _arg0) - return -} - -//export SKY_wallet_LoadNotes -func SKY_wallet_LoadNotes(_dir string, _arg1 *C.WalletNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - __arg1, ____return_err := wallet.LoadNotes(dir) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerWalletNotesHandle(&__arg1) - } - return -} - -//export SKY_wallet_LoadReadableNotes -func SKY_wallet_LoadReadableNotes(_filename string, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - filename := _filename - __arg1, ____return_err := wallet.LoadReadableNotes(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerWalletReadableNotesHandle(__arg1) - } - return -} - -//export SKY_wallet_ReadableNotes_Load -func SKY_wallet_ReadableNotes_Load(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - filename := _filename - ____return_err := rns.Load(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_ReadableNotes_ToNotes -func SKY_wallet_ReadableNotes_ToNotes(_rns C.WalletReadableNotes_Handle, _arg0 *C.WalletNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0, ____return_err := rns.ToNotes() - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - notes := wallet.Notes(__arg0) - *_arg0 = registerWalletNotesHandle(¬es) - } - return -} - -//export SKY_wallet_ReadableNotes_Save -func SKY_wallet_ReadableNotes_Save(_rns C.WalletReadableNotes_Handle, _filename string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - rns, ok := lookupWalletReadableNotesHandle(_rns) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - filename := _filename - ____return_err := rns.Save(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_NewReadableNote -func SKY_wallet_NewReadableNote(_note *C.wallet__Note, _arg1 *C.wallet__ReadableNote) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - note := *(*wallet.Note)(unsafe.Pointer(_note)) - __arg1 := wallet.NewReadableNote(note) - copyString(__arg1.TransactionID, &_arg1.TransactionID) - copyString(__arg1.ActualNote, &_arg1.ActualNote) - return -} - -//export SKY_wallet_NewReadableNotesFromNotes -func SKY_wallet_NewReadableNotesFromNotes(_w C.WalletNotes_Handle, _arg1 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - w, ok := lookupWalletNotesHandle(_w) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg1 := wallet.NewReadableNotesFromNotes(*w) - *_arg1 = registerWalletReadableNotesHandle(&__arg1) - return -} - -//export SKY_wallet_Notes_Save -func SKY_wallet_Notes_Save(_notes C.WalletNotes_Handle, _dir string, _fileName string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - dir := _dir - fileName := _fileName - ____return_err := notes.Save(dir, fileName) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_Notes_SaveNote -func SKY_wallet_Notes_SaveNote(_notes C.WalletNotes_Handle, _dir string, _note *C.wallet__Note) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - dir := _dir - note := *(*wallet.Note)(unsafe.Pointer(_note)) - ____return_err := notes.SaveNote(dir, note) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - -//export SKY_wallet_Notes_ToReadable -func SKY_wallet_Notes_ToReadable(_notes C.WalletNotes_Handle, _arg0 *C.WalletReadableNotes_Handle) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - notes, ok := lookupWalletNotesHandle(_notes) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0 := notes.ToReadable() - *_arg0 = registerWalletReadableNotesHandle(&__arg0) - return -} - -//export SKY_wallet_NotesFileExist -func SKY_wallet_NotesFileExist(_dir string, _arg1 *bool) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - __arg1, ____return_err := wallet.NotesFileExist(dir) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = __arg1 - } - return -} - -//export SKY_wallet_CreateNoteFileIfNotExist -func SKY_wallet_CreateNoteFileIfNotExist(_dir string) (____error_code uint32) { - ____error_code = 0 - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - dir := _dir - wallet.CreateNoteFileIfNotExist(dir) - return -} diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index 7cea37bb26..cb6fffbfb3 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -10,6 +10,7 @@ import ( "log" "time" + skyerrors "github.com/skycoin/skycoin/src/cipher/errors" "github.com/skycoin/skycoin/src/cipher/ripemd160" "github.com/skycoin/skycoin/src/cipher/secp256k1-go" ) @@ -97,7 +98,7 @@ func RandByte(n int) []byte { func NewPubKey(b []byte) PubKey { p := PubKey{} if len(b) != len(p) { - err := NewValueError(ErrInvalidLengthPubKey, "b", b) + err := skyerrors.NewValueError(ErrInvalidLengthPubKey, "b", b) log.Print(err) panic(err) } @@ -129,13 +130,13 @@ func PubKeyFromHex(s string) (PubKey, error) { // PubKeyFromSecKey recovers the public key for a secret key func PubKeyFromSecKey(seckey SecKey) PubKey { if seckey == (SecKey{}) { - err := NewValueError(ErrPubKeyFromNullSecKey, "seckey", seckey) + err := skyerrors.NewValueError(ErrPubKeyFromNullSecKey, "seckey", seckey) log.Print(err) panic(err) } b := secp256k1.PubkeyFromSeckey(seckey[:]) if b == nil { - err := NewValueError(ErrPubKeyFromBadSecKey, "seckey", seckey) + err := skyerrors.NewValueError(ErrPubKeyFromBadSecKey, "seckey", seckey) log.Print(err) panic(err) } @@ -178,7 +179,7 @@ type SecKey [32]byte func NewSecKey(b []byte) SecKey { p := SecKey{} if len(b) != len(p) { - err := NewValueError(ErrInvalidLengthSecKey, "b", b) + err := skyerrors.NewValueError(ErrInvalidLengthSecKey, "b", b) log.Print(err) panic(err) } @@ -239,7 +240,7 @@ func (sk SecKey) Hex() string { func ECDH(pub PubKey, sec SecKey) []byte { if err := pub.Verify(); err != nil { - err := NewValueError(ErrECHDInvalidPubKey, "pub", pub) + err := skyerrors.NewValueError(ErrECHDInvalidPubKey, "pub", pub) log.Print(err) panic(err) } @@ -247,7 +248,7 @@ func ECDH(pub PubKey, sec SecKey) []byte { // WARNING: This calls TestSecKey if DebugLevel2 is set to true. // TestSecKey is extremely slow and will kill performance if ECDH is called frequently if err := sec.Verify(); err != nil { - err := NewValueError(ErrECHDInvalidSecKey, "sec", sec) + err := skyerrors.NewValueError(ErrECHDInvalidSecKey, "sec", sec) log.Print(err) panic(err) } @@ -265,7 +266,7 @@ type Sig [64 + 1]byte //64 byte signature with 1 byte for key recovery func NewSig(b []byte) Sig { s := Sig{} if len(b) != len(s) { - err := NewValueError(ErrInvalidLengthSig, "b", b) + err := skyerrors.NewValueError(ErrInvalidLengthSig, "b", b) log.Print(err) panic(err) } @@ -280,7 +281,7 @@ func MustSigFromHex(s string) Sig { log.Panic(err) } if len(b) != 65 { - err := NewValueError(ErrInvalidLengthSig, "s", s) + err := skyerrors.NewValueError(ErrInvalidLengthSig, "s", s) log.Print(err) panic(err) } diff --git a/src/cipher/errors.go b/src/cipher/errors/errors.go similarity index 98% rename from src/cipher/errors.go rename to src/cipher/errors/errors.go index 9fd616ca4d..a7a4699d73 100644 --- a/src/cipher/errors.go +++ b/src/cipher/errors/errors.go @@ -1,4 +1,4 @@ -package cipher +package errors import ( "errors" diff --git a/src/cipher/hash.go b/src/cipher/hash.go index 9784acb429..0434160cb1 100644 --- a/src/cipher/hash.go +++ b/src/cipher/hash.go @@ -5,6 +5,8 @@ import ( "errors" "hash" "log" + + skyerrors "github.com/skycoin/skycoin/src/cipher/errors" ) var ( @@ -32,7 +34,7 @@ type Ripemd160 [20]byte // Set sets value func (rd *Ripemd160) Set(b []byte) { if len(b) != 20 { - err := NewValueError( + err := skyerrors.NewValueError( ErrInvalidLengthRipemd160, "b", b, ) log.Print(err) @@ -62,7 +64,7 @@ type SHA256 [32]byte // Set sets value func (g *SHA256) Set(b []byte) { if len(b) != 32 { - err := NewValueError( + err := skyerrors.NewValueError( ErrInvalidLengthSHA256, "b", b, ) log.Print(err) diff --git a/src/cipher/secp256k1-go/secp256k1-go2/ec.go b/src/cipher/secp256k1-go/secp256k1-go2/ec.go index f63d3896b4..41100a31c0 100644 --- a/src/cipher/secp256k1-go/secp256k1-go2/ec.go +++ b/src/cipher/secp256k1-go/secp256k1-go2/ec.go @@ -6,7 +6,7 @@ import ( "errors" "log" - skyerrors "github.com/skycoin/skycoin/src/util/errors" + skyerrors "github.com/skycoin/skycoin/src/cipher/errors" ) var ( diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index c80f2a0be3..4317826bef 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -7,8 +7,8 @@ import ( "errors" "log" + skyerrors "github.com/skycoin/skycoin/src/cipher/errors" secp "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" - skyerrors "github.com/skycoin/skycoin/src/util/errors" ) var ( From 03cb3a8324baf3d01f58aac21f91fd3c311ef5aa Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 16 Sep 2018 19:12:36 +0000 Subject: [PATCH 221/399] [lib] [include] refs #1191 - Structs in readable package. Rename API functions ... - SKY_api_Client_GetWalletSeed => SKY_api_Client_WalletSeed - SKY_webrpc_Client_GetBlocks => SKY_webrpc_Client_GetBlocksInRange - ReadableOutputSet_Handle => ReadableUnspentOutputsSummary_Handle Synthesis: Tested: 142 | Passing: 142 | Failing: 0 | Crashing: 0 --- include/skytypes.h | 8 +++++++- lib/cgo/api.client.go | 6 +++--- lib/cgo/api.webrpc.client.go | 6 +++--- lib/cgo/cli.outputs.go | 8 ++++---- lib/cgo/libsky_handle.go | 24 +++++++++++++++++++----- lib/cgo/libsky_handle_helper.go | 12 ++++++------ 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/skytypes.h b/include/skytypes.h index 6b6821fff5..c3251fb840 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -348,11 +348,17 @@ typedef Handle StatusResult_Handle; typedef Handle AddressUxOuts_Handle; /** - * Memory handle to access to visor.BuildInfo (BuildInfo) + * Memory handle to access to readable.BuildInfo (BuildInfo) */ typedef Handle BuildInfo_Handle; +/** + * Memory handle to access to readable.UnspentOutputsSummary (UnspentOutputsSummary) + */ + +typedef Handle ReadableUnspentOutputsSummary_Handle; + /** * Memory handle for hash (ripemd160.digest) */ diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 453d61cb54..9fda5f0e71 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -579,8 +579,8 @@ func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString return } -//export SKY_api_Client_GetWalletSeed -func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { +//export SKY_api_Client_WalletSeed +func SKY_api_Client_WalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -593,7 +593,7 @@ func SKY_api_Client_GetWalletSeed(_c C.Client__Handle, _id string, _password str } id := _id password := _password - __arg2, ____return_err := c.GetWalletSeed(id, password) + __arg2, ____return_err := c.WalletSeed(id, password) ____error_code = libErrorCode(____return_err) if ____return_err == nil { copyString(__arg2, _arg2) diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 25cc349430..6448aa354d 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -141,8 +141,8 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri return } -//export SKY_webrpc_Client_GetBlocks -func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { +//export SKY_webrpc_Client_GetBlocksInRange +func SKY_webrpc_Client_GetBlocksInRange(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -155,7 +155,7 @@ func SKY_webrpc_Client_GetBlocks(_c C.WebRpcClient__Handle, _start, _end uint64, } start := _start end := _end - __arg1, ____return_err := c.GetBlocks(start, end) + __arg1, ____return_err := c.GetBlocksInRange(start, end) ____error_code = libErrorCode(____return_err) if ____return_err == nil { copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index 8aedb5c504..3668ea836d 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -14,7 +14,7 @@ import ( import "C" //export SKY_cli_GetWalletOutputsFromFile -func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.ReadableOutputSet_Handle) (____error_code uint32) { +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -29,13 +29,13 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = registerReadableOutputSetHandle(__arg2) + *_arg2 = registerReadableUnspentOutputsSummaryHandle(__arg2) } return } //export SKY_cli_GetWalletOutputs -func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.ReadableOutputSet_Handle) (____error_code uint32) { +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -54,7 +54,7 @@ func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg2 = registerReadableOutputSetHandle(__arg2) + *_arg2 = registerReadableUnspentOutputsSummaryHandle(__arg2) } return } diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index eb5ccedc07..58835afc89 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -18,7 +18,7 @@ import ( secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" cli "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" - "github.com/skycoin/skycoin/src/visor" + "github.com/skycoin/skycoin/src/readable" wallet "github.com/skycoin/skycoin/src/wallet" gcli "github.com/urfave/cli" ) @@ -520,14 +520,28 @@ func SKY_handle_copy(handle C.Handle, copy *C.Handle) uint32 { } } -func registerReadableOutputSetHandle(obj *visor.ReadableOutputSet) C.ReadableOutputSet_Handle { - return (C.ReadableOutputSet_Handle)(registerHandle(obj)) +func registerReadableUnspentOutputsSummaryHandle(obj *readable.UnspentOutputsSummary) C.ReadableUnspentOutputsSummary_Handle { + return (C.ReadableUnspentOutputsSummary_Handle)(registerHandle(obj)) } -func lookupReadableOutputSetHandle(handle C.ReadableOutputSet_Handle) (*visor.ReadableOutputSet, bool) { +func lookupReadableUnspentOutputsSummaryHandle(handle C.ReadableUnspentOutputsSummary_Handle) (*readable.UnspentOutputsSummary, bool) { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableOutputSet); isOK { + if obj, isOK := (obj).(*readable.UnspentOutputsSummary); isOK { + return obj, true + } + } + return nil, false +} + +func registerBuildInfoHandle(obj *readable.BuildInfo) C.BuildInfo_Handle { + return (C.BuildInfo_Handle)(registerHandle(obj)) +} + +func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*readable.BuildInfo, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.BuildInfo); isOK { return obj, true } } diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index b730dafda1..738d63767a 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -18,7 +18,7 @@ import ( api "github.com/skycoin/skycoin/src/api" "github.com/skycoin/skycoin/src/daemon" - "github.com/skycoin/skycoin/src/visor" + "github.com/skycoin/skycoin/src/readable" ) //export SKY_JsonEncode_Handle @@ -50,7 +50,7 @@ func SKY_Handle_Progress_GetCurrent(handle C.Handle, current *uint64) uint32 { func SKY_Handle_Block_GetHeadSeq(handle C.Handle, seq *uint64) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + if obj, isOK := (obj).(*readable.Block); isOK { *seq = obj.Head.BkSeq return SKY_OK } @@ -62,7 +62,7 @@ func SKY_Handle_Block_GetHeadSeq(handle C.Handle, seq *uint64) uint32 { func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + if obj, isOK := (obj).(*readable.Block); isOK { copyString(obj.Head.BlockHash, hash) return SKY_OK } @@ -74,7 +74,7 @@ func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { func SKY_Handle_Block_GetPreviousBlockHash(handle C.Handle, hash *C.GoString_) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableBlock); isOK { + if obj, isOK := (obj).(*readable.Block); isOK { copyString(obj.Head.PreviousBlockHash, hash) return SKY_OK } @@ -87,7 +87,7 @@ func SKY_Handle_Blocks_GetAt(handle C.Handle, index uint64, blockHandle *C.Handle) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableBlocks); isOK { + if obj, isOK := (obj).(*readable.Blocks); isOK { *blockHandle = registerHandle(&obj.Blocks[index]) return SKY_OK } @@ -100,7 +100,7 @@ func SKY_Handle_Blocks_GetCount(handle C.Handle, count *uint64) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { - if obj, isOK := (obj).(*visor.ReadableBlocks); isOK { + if obj, isOK := (obj).(*readable.Blocks); isOK { *count = uint64(len(obj.Blocks)) return SKY_OK } From 5814d741886d50b57e9a17d4149d1bcf13f4503a Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 17 Sep 2018 03:27:42 -0400 Subject: [PATCH 222/399] [lib] refs #1191 - No race conditions (read/writ)ing isAPILocked --- lib/cgo/libsky_error.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 10867de90f..3f36bb5429 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -2,6 +2,7 @@ package main import ( "errors" + "sync" "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/base58" @@ -623,6 +624,10 @@ var ( // isApiLocked flag set when previous unrecoverable panic is detected // subsequent use of the API leads to SKY_API_LOCKED returned isAPILocked = false + // apiWriteLock locks write access to isAPILocked + apiWriteLock = &sync.RWMutex{} + // apiReadLock locks read access to isAPILocked + apiReadLock = apiWriteLock.RLocker() // haltOnPanic is enabled by default to halt process on unhandled panic // if disabled then locking is activated instead. // Subsequent use of the API leads to SKY_API_LOCKED error code returned @@ -638,6 +643,18 @@ const ( SKY_OPT_HALTONPANIC = 1 + iota // nolint megacheck ) +func getIsAPILocked() bool { + defer apiReadLock.Unlock() + apiReadLock.Lock() + return isAPILocked +} + +func lockAPI() { + defer apiWriteLock.Unlock() + apiWriteLock.Lock() + isAPILocked = true +} + // SKY_libcgo_ConfigApiOptions set values for configurable API settings //export SKY_libcgo_ConfigApiOption func SKY_libcgo_ConfigApiOption(optionID uint32, optionValue uint64) { // nolint megacheck @@ -649,7 +666,7 @@ func SKY_libcgo_ConfigApiOption(optionID uint32, optionValue uint64) { // nolint // checkAPIReady ensure preconditions are met for API functions to be invoked // and lock API otherwise func checkAPIReady() { - if isAPILocked { + if getIsAPILocked() { panic(ErrorLockApi) } } @@ -667,8 +684,8 @@ func catchApiPanic(errcode uint32, err interface{}) uint32 { // Return right away return errcode } - if isAPILocked || err == ErrorLockApi { - isAPILocked = true + if getIsAPILocked() || err == ErrorLockApi { + lockAPI() return SKY_API_LOCKED } if err != nil { @@ -678,7 +695,7 @@ func catchApiPanic(errcode uint32, err interface{}) uint32 { // Setting flag every time (i.e. even when haltOnPanic is active // protects against hypothetical situations in which panic() // does not abort the current process. - isAPILocked = true + lockAPI() if haltOnPanic { // FIXME: Set process exit code on panic /* From 7be5ea7a3a7169df74bd9240a611e644796f7be3 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 4 Oct 2018 20:14:45 -0400 Subject: [PATCH 223/399] [cipher] refs #1191 - Fix typos in cipher crypto after merge --- src/cipher/crypto.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index 93fe2acd18..1b58fc87d3 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -24,7 +24,6 @@ import ( "log" "time" - skyerrors "github.com/skycoin/skycoin/src/cipher/errors" "github.com/skycoin/skycoin/src/cipher/ripemd160" "github.com/skycoin/skycoin/src/cipher/secp256k1-go" ) From bed7a2e9657cd394ec301e65bebe40b1f00420c9 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 4 Oct 2018 20:23:21 -0400 Subject: [PATCH 224/399] [lib] refs #1191 - Remove libskycoin bindings for removed ./util/browser package No references to SWIG in docs --- README.md | 1 - lib/cgo/util.browser.browser.go | 27 --------------------------- 2 files changed, 28 deletions(-) delete mode 100644 lib/cgo/util.browser.browser.go diff --git a/README.md b/README.md index ca4ac0de3d..72689933bf 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,6 @@ Skycoin implements client libraries which export core functionality for usage fr other programming languages. * `lib/cgo/` - libskycoin C client library ( [overview](lib/cgo/README.md), [API reference](docs/libc/API.md) ) -* `Swig` - Skycoin contains Swig interface files to generate libraries in different languages. ( Python library [Pyskycoin] (https://github.com/skycoin/pyskycoin)) For further details run `make docs` to generate documetation and read the corresponding README and API references. diff --git a/lib/cgo/util.browser.browser.go b/lib/cgo/util.browser.browser.go deleted file mode 100644 index f37318525d..0000000000 --- a/lib/cgo/util.browser.browser.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import browser "github.com/skycoin/skycoin/src/util/browser" - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_browser_Open -func SKY_browser_Open(_url string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - url := _url - ____return_err := browser.Open(url) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} From 4d121b2723ef2bc29bcb32393a6453443c5ddab6 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 4 Oct 2018 20:54:07 -0400 Subject: [PATCH 225/399] [lib] refs #1191 - No bindings for ciper/encoder in libskycoin API --- lib/cgo/cipher.encoder.field.go | 43 --------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 lib/cgo/cipher.encoder.field.go diff --git a/lib/cgo/cipher.encoder.field.go b/lib/cgo/cipher.encoder.field.go deleted file mode 100644 index 1ed66c5ebe..0000000000 --- a/lib/cgo/cipher.encoder.field.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "unsafe" - - encoder "github.com/skycoin/skycoin/src/cipher/encoder" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_encoder_StructField_String -func SKY_encoder_StructField_String(_s *C.encoder__StructField, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - s := (*encoder.StructField)(unsafe.Pointer(_s)) - __arg0 := s.String() - copyString(__arg0, _arg0) - return -} - -//export SKY_encoder_ParseFields -func SKY_encoder_ParseFields(_in []byte, _fields []C.encoder__StructField, _arg2 *C.GoStringMap_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - in := *(*[]byte)(unsafe.Pointer(&_in)) - fields := *(*[]encoder.StructField)(unsafe.Pointer(&_fields)) - __arg2 := encoder.ParseFields(in, fields) - copyToStringMap(__arg2, _arg2) - return -} From e071241ba96961b6698042c9ae44bff023c8d3a3 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 4 Oct 2018 20:57:10 -0400 Subject: [PATCH 226/399] [lib] refs #1191 - No header files for ciper/encoder in libskycoin API --- include/cipher.encoder.field.go.h | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 include/cipher.encoder.field.go.h diff --git a/include/cipher.encoder.field.go.h b/include/cipher.encoder.field.go.h deleted file mode 100644 index 6e58de2c1e..0000000000 --- a/include/cipher.encoder.field.go.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef struct{ - GoString_ Name; - GoUint32_ Kind; - GoString_ Type; - GoString_ Tag; -} encoder__StructField; From 2ecf8fea4f8186e6292a47435945059a69df8dab Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 4 Oct 2018 21:02:13 -0400 Subject: [PATCH 227/399] [lib] refs #1191 - remove duplicate code for SKY_cipher_AddressFromBytes Bug introduced by previous merge --- lib/cgo/cipher.address.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/cgo/cipher.address.go b/lib/cgo/cipher.address.go index 56b9bdcad7..517e7aaf9f 100644 --- a/lib/cgo/cipher.address.go +++ b/lib/cgo/cipher.address.go @@ -40,20 +40,6 @@ func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error ____error_code = catchApiPanic(____error_code, recover()) }() checkAPIReady() - b := *(*[]byte)(unsafe.Pointer(&_b)) - __arg1, ____return_err := cipher.AddressFromBytes(b) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&__arg1)) - } - return -} - - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr, err := cipher.AddressFromBytes(_b) ____error_code = libErrorCode(err) From 71ee24a8ea9bce9e3cfa660d6f27296a7d889f65 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 5 Oct 2018 00:36:39 -0400 Subject: [PATCH 228/399] [lib] refs #1191 - Successful compilation of libskycoin C lib - Remove SKY_wallet_GetBitcoinWalletEntry . - Remove SKY_wallet_GetSkycoinWalletEntry . --- include/skytypes.gen.h | 15 +++++++++------ include/skytypes.h | 10 ---------- lib/cgo/wallet.addresses.go | 31 ------------------------------- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/include/skytypes.gen.h b/include/skytypes.gen.h index d2e7706c94..0e38a3865c 100644 --- a/include/skytypes.gen.h +++ b/include/skytypes.gen.h @@ -1,26 +1,29 @@ + +#include "api.client.go.h" + #include "cipher.hash.go.h" #include "cipher.address.go.h" +#include "cipher.bitcoin.go.h" #include "cipher.crypto.go.h" -#include "cipher.encoder.field.go.h" #include "cipher.encrypt.scrypt_chacha20poly1305.go.h" #include "cipher.secp256k1-go.secp256k1-go2.field.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xy.go.h" #include "cipher.secp256k1-go.secp256k1-go2.xyz.go.h" + +#include "cli.cli.go.h" +#include "cli.create_rawtx.go.h" + #include "coin.transactions.go.h" #include "coin.block.go.h" #include "coin.outputs.go.h" +#include "util.http.json.go.h" #include "visor.readable.go.h" - #include "wallet.balance.go.h" #include "wallet.entry.go.h" #include "wallet.notes.go.h" #include "wallet.wallet.go.h" -#include "api.client.go.h" -#include "cli.cli.go.h" -#include "cli.create_rawtx.go.h" -#include "util.http.json.go.h" diff --git a/include/skytypes.h b/include/skytypes.h index fff33a75c8..c3251fb840 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -384,14 +384,4 @@ typedef struct { void* context; } FeeCalculator ; -#include "cipher.hash.go.h" -#include "cipher.crypto.go.h" -#include "cipher.address.go.h" -#include "cipher.bitcoin.go.h" -#include "cli.create_rawtx.go.h" -#include "coin.outputs.go.h" -#include "coin.transactions.go.h" -#include "wallet.entry.go.h" -#include "wallet.wallet.go.h" - #endif diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go index 252fdb4493..ea02b54f4a 100644 --- a/lib/cgo/wallet.addresses.go +++ b/lib/cgo/wallet.addresses.go @@ -1,9 +1,6 @@ package main import ( - "unsafe" - - cipher "github.com/skycoin/skycoin/src/cipher" wallet "github.com/skycoin/skycoin/src/wallet" ) @@ -34,31 +31,3 @@ func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _ } return } - -//export SKY_wallet_GetSkycoinWalletEntry -func SKY_wallet_GetSkycoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) - sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) - __arg2 := wallet.GetSkycoinWalletEntry(pub, sec) - *_arg2 = registerReadableEntryHandle(&__arg2) - return -} - -//export SKY_wallet_GetBitcoinWalletEntry -func SKY_wallet_GetBitcoinWalletEntry(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - pub := *(*cipher.PubKey)(unsafe.Pointer(_pub)) - sec := *(*cipher.SecKey)(unsafe.Pointer(_sec)) - __arg2 := wallet.GetBitcoinWalletEntry(pub, sec) - *_arg2 = registerReadableEntryHandle(&__arg2) - return -} From 1b9717e8c0786b3f7d449aa7eada8ade2d426d15 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 12:44:49 -0400 Subject: [PATCH 229/399] [cipher] refs #1191 - Remove ValueError --- src/cipher/errors/errors.go | 44 ------------------- src/cipher/hash.go | 14 +----- src/cipher/secp256k1-go/secp256k1-go2/ec.go | 6 +-- src/cipher/secp256k1-go/secp256k1.go | 48 +++++---------------- 4 files changed, 14 insertions(+), 98 deletions(-) delete mode 100644 src/cipher/errors/errors.go diff --git a/src/cipher/errors/errors.go b/src/cipher/errors/errors.go deleted file mode 100644 index a7a4699d73..0000000000 --- a/src/cipher/errors/errors.go +++ /dev/null @@ -1,44 +0,0 @@ -package errors - -import ( - "errors" - "fmt" -) - -// ValueError an operation or function receives an argument -// that has the right type but an inappropriate value -type ValueError struct { - ErrorData error - ParamName string - ParamValue interface{} -} - -func (err ValueError) Error() string { - return fmt.Sprintf("Invalid value for '%s' : %s", - err.ParamName, err.ErrorData.Error()) -} - -// NewValueError instantiate value error from concrete error -func NewValueError(err error, paramName string, paramValue interface{}) ValueError { - return ValueError{ - ErrorData: err, - ParamName: paramName, - ParamValue: paramValue, - } -} - -// NewValueErrorFromString shortcut for new value errors given an error message -func NewValueErrorFromString(errorMessage string, paramName string, paramValue interface{}) ValueError { - return NewValueError(errors.New(errorMessage), paramName, paramValue) -} - -// SameError check for identical error conditions -func SameError(err1, err2 error) bool { - if _err, isOfType := err1.(ValueError); isOfType { - err1 = _err - } - if _err, isOfType := err2.(ValueError); isOfType { - err2 = _err - } - return err1 == err2 -} diff --git a/src/cipher/hash.go b/src/cipher/hash.go index 5bdeb08441..a853f974b6 100644 --- a/src/cipher/hash.go +++ b/src/cipher/hash.go @@ -5,8 +5,6 @@ import ( "errors" "hash" "log" - - skyerrors "github.com/skycoin/skycoin/src/cipher/errors" ) var ( @@ -34,11 +32,7 @@ type Ripemd160 [20]byte // MustSet sets value, panics on error func (rd *Ripemd160) MustSet(b []byte) { if len(b) != 20 { - err := skyerrors.NewValueError( - ErrInvalidLengthRipemd160, "b", b, - ) - log.Print(err) - panic(err) + log.Panic(ErrInvalidLengthRipemd160) } copy(rd[:], b[:]) } @@ -72,11 +66,7 @@ type SHA256 [32]byte // MustSet sets value, panics on error func (g *SHA256) MustSet(b []byte) { if len(b) != 32 { - err := skyerrors.NewValueError( - ErrInvalidLengthSHA256, "b", b, - ) - log.Print(err) - panic(err) + panic(ErrInvalidLengthSHA256) } copy(g[:], b[:]) } diff --git a/src/cipher/secp256k1-go/secp256k1-go2/ec.go b/src/cipher/secp256k1-go/secp256k1-go2/ec.go index 6b1a5163a8..a38aff0b4c 100644 --- a/src/cipher/secp256k1-go/secp256k1-go2/ec.go +++ b/src/cipher/secp256k1-go/secp256k1-go2/ec.go @@ -5,8 +5,6 @@ import ( "bytes" "errors" "log" - - skyerrors "github.com/skycoin/skycoin/src/cipher/errors" ) // Error definition @@ -121,9 +119,7 @@ func RecoverPublicKey(sigByte []byte, h []byte, recid int) ([]byte, int) { var pubkey XY if len(sigByte) != 64 { - err := skyerrors.NewValueError(ErrMustPass64bytePubKey, "sigByte ", sigByte) - log.Print(err) - panic(err) + log.Panic(ErrMustPass64bytePubKey) } var sig Signature diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 11b560d53c..340d11e5a8 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -10,7 +10,6 @@ import ( "errors" "log" - skyerrors "github.com/skycoin/skycoin/src/cipher/errors" secp "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) @@ -34,7 +33,6 @@ func pubkeyFromSeckey(seckey []byte) []byte { if secp.SeckeyIsValid(seckey) != 1 { log.Panic("always ensure seckey is valid") - return nil } var pubkey = secp.GeneratePublicKey(seckey) //always returns true @@ -239,19 +237,13 @@ func DeterministicKeyPairIterator(seedIn []byte) ([]byte, []byte, []byte) { func Sign(msg []byte, seckey []byte) []byte { if len(seckey) != 32 { - err := skyerrors.NewValueError(ErrSignInvalidSeckeyLength, "seckey ", seckey) - log.Print(err) - panic(err) + log.Panic(ErrSignInvalidSeckeyLength) } if secp.SeckeyIsValid(seckey) != 1 { - err := skyerrors.NewValueError(ErrSignInvalidSeckey, "seckey ", seckey) - log.Print(err) - panic(err) + log.Panic(ErrSignInvalidSeckey) } if len(msg) == 0 { - err := skyerrors.NewValueError(ErrSignMessageNil, "msg ", msg) - log.Print(err) - panic(err) + log.Panic(ErrSignMessageNil) } var nonce = RandByte(32) var sig = make([]byte, 65) @@ -270,9 +262,7 @@ func Sign(msg []byte, seckey []byte) []byte { ret := cSig.Sign(&seckey1, &msg1, &nonce1, &recid) if ret != 1 { - err := skyerrors.NewValueError(ErrSecp25k1SignSignatureFailed, "ret ", ret) - log.Print(err) - panic(err) + log.Panic(ErrSecp25k1SignSignatureFailed) } sigBytes := cSig.Bytes() @@ -408,20 +398,13 @@ func VerifySignatureValidity(sig []byte) int { // Rename SignatureChk func VerifySignature(msg []byte, sig []byte, pubkey1 []byte) int { if msg == nil || sig == nil || pubkey1 == nil { - err := skyerrors.NewValueError(ErrVerifySignatureInvalidInputsNils, "pubkey1 ", pubkey1) - log.Print(err) - panic(err) + log.Panic("VerifySignature, ERROR: invalid input, nils") } if len(sig) != 65 { - err := skyerrors.NewValueError(ErrVerifySignatureInvalidSigLength, "sig ", sig) - log.Print(err) - panic(err) + log.Panic("VerifySignature, invalid signature length") } if len(pubkey1) != 33 { - err := skyerrors.NewValueError(ErrVerifySignatureInvalidPubkeysLength, "pubkey1 ", pubkey1) - log.Print(err) - panic(err) - + log.Panic("VerifySignature, invalid pubkey length") } //malleability check: @@ -495,21 +478,14 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { recid) if ret != 1 { - err := skyerrors.NewValueErrorFromString("RecoverPubkey: code ", "ret ", ret) - log.Print(err) - return nil + log.Printf("RecoverPubkey: code %d", ret) } if pubkey == nil { - err := skyerrors.NewValueErrorFromString("ERROR: impossible, pubkey nil and ret ==1", "ret ", ret) - log.Print(err) - panic(err) + log.Panic("ERROR: impossible, pubkey nil and ret ==1") } if len(pubkey) != 33 { - err := skyerrors.NewValueError(ErrSecp256k1InvalidLengthPubKey, "pubkey", pubkey) - log.Print(err) - panic(err) - + log.Panic("pubkey length wrong") } return pubkey @@ -539,9 +515,7 @@ func ECDH(pub []byte, sec []byte) []byte { return nil } if len(pubkeyOut) != 33 { - err := skyerrors.NewValueError(ErrSecp256k1InvalidLengthPubKey, "pubkeyOut", pubkeyOut) - log.Print(err) - panic(err) + log.Panic("ERROR: impossible, invalid pubkey length") } return pubkeyOut } From d0892a0afab704ada9cd8ee74605927d7acfd345 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 12:46:55 -0400 Subject: [PATCH 230/399] [lib] refs #1191 - Error codes. Do not consider ValueError when locking API. Use GoSlice to fix type errors. --- lib/cgo/libsky_error.go | 136 +++++++++--------- lib/cgo/tests/check_cipher.crypto.c | 2 +- .../tests/check_cipher.secp256k1.secp256.c | 2 +- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 4 +- lib/cgo/tests/check_coin.coin.c | 6 +- lib/cgo/tests/check_coin.transactions.c | 12 +- 6 files changed, 79 insertions(+), 83 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 9ed0376118..4c95efeb5a 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -8,7 +8,6 @@ import ( "github.com/skycoin/skycoin/src/cipher/base58" "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/cipher/encrypt" - skyerrors "github.com/skycoin/skycoin/src/cipher/errors" "github.com/skycoin/skycoin/src/cipher/secp256k1-go" "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" @@ -158,6 +157,26 @@ const ( SKY_ErrEmptySeed // SKY_ErrInvalidSig Invalid signature SKY_ErrInvalidSig + // SKY_ErrSHA256orMissingPassword missing password + SKY_ErrSHA256orMissingPassword + // SKY_ErrSHA256LenghtDataOverflowMaxUint32 data length overflowed, it must <= math.MaxUint32(4294967295) + SKY_ErrLenghtDataOverflowMaxUint32 + // SKY_ErrInvalidChecksumLength invalid checksum length + SKY_ErrInvalidChecksumLength + // SKY_ErrInvalidDataChecksumNotMatched invalid data, checksum is not matched + SKY_ErrInvalidDataChecksumNotMatched + // SKY_ErrInvalidNonceLength invalid nonce length + SKY_ErrInvalidNonceLength + // SKY_ErrInvalidBlockSizeMultiple32Bytes invalid block size, must be multiple of 32 bytes + SKY_ErrInvalidBlockSizeMultiple32Bytes + // SKY_ErrReadDataHashFailedLength read data hash failed: read length != 32 + SKY_ErrReadDataHashFailedLength + // SKY_ErrSHA256orInvalidPassword invalid password SHA256or + SKY_ErrSHA256orInvalidPassword + // SKY_ErrReadDataLengthFailed read data length failed + SKY_ErrReadDataLengthFailed + // SKY_ErrInvalidDataLength invalid data length + SKY_ErrInvalidDataLength ) // Error codes defined in cli package @@ -399,26 +418,6 @@ const ( SKY_ErrDuplicateUxOuts // SKY_ErrUnknownWalletID params.Wallet.ID does not match wallet SKY_ErrUnknownWalletID - // SKY_ErrSHA256orMissingPassword missing password - SKY_ErrSHA256orMissingPassword - // SKY_ErrSHA256LenghtDataOverflowMaxUint32 data length overflowed, it must <= math.MaxUint32(4294967295) - SKY_ErrLenghtDataOverflowMaxUint32 - // SKY_ErrInvalidChecksumLength invalid checksum length - SKY_ErrInvalidChecksumLength - // SKY_ErrInvalidDataChecksumNotMatched invalid data, checksum is not matched - SKY_ErrInvalidDataChecksumNotMatched - // SKY_ErrInvalidNonceLength invalid nonce length - SKY_ErrInvalidNonceLength - // SKY_ErrInvalidBlockSizeMultiple32Bytes invalid block size, must be multiple of 32 bytes - SKY_ErrInvalidBlockSizeMultiple32Bytes - // SKY_ErrReadDataHashFailedLength read data hash failed: read length != 32 - SKY_ErrReadDataHashFailedLength - // SKY_ErrSHA256orInvalidPassword invalid password SHA256or - SKY_ErrSHA256orInvalidPassword - // SKY_ErrReadDataLengthFailed read data length failed - SKY_ErrReadDataLengthFailed - // SKY_ErrInvalidDataLength invalid data length - SKY_ErrInvalidDataLength // SKY_ErrVerifySignatureInvalidInputsNils VerifySignature, ERROR: invalid input, nils SKY_ErrVerifySignatureInvalidInputsNils // SKY_ErrVerifySignatureInvalidSigLength @@ -469,23 +468,34 @@ var ( cipher.ErrInvalidSigForPubKey: SKY_ErrInvalidSigForPubKey, // Removed in ea0aafbffb76 // cipher.ErrInvalidSecKeyHex: SKY_ErrInvalidSecKeyHex, - cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, - cipher.ErrInvalidHashForSig: SKY_ErrInvalidHashForSig, - cipher.ErrPubKeyRecoverMismatch: SKY_ErrPubKeyRecoverMismatch, - cipher.ErrInvalidSigInvalidPubKey: SKY_ErrInvalidSigInvalidPubKey, - cipher.ErrInvalidSigValidity: SKY_ErrInvalidSigValidity, - cipher.ErrInvalidSigForMessage: SKY_ErrInvalidSigForMessage, - cipher.ErrInvalidSecKyVerification: SKY_ErrInvalidSecKyVerification, - cipher.ErrNullPubKeyFromSecKey: SKY_ErrNullPubKeyFromSecKey, - cipher.ErrInvalidDerivedPubKeyFromSecKey: SKY_ErrInvalidDerivedPubKeyFromSecKey, - cipher.ErrInvalidPubKeyFromHash: SKY_ErrInvalidPubKeyFromHash, - cipher.ErrPubKeyFromSecKeyMismatch: SKY_ErrPubKeyFromSecKeyMismatch, - cipher.ErrInvalidLength: SKY_ErrInvalidLength, - cipher.ErrBitcoinWIFInvalidFirstByte: SKY_ErrBitcoinWIFInvalidFirstByte, - cipher.ErrBitcoinWIFInvalidSuffix: SKY_ErrBitcoinWIFInvalidSuffix, - cipher.ErrBitcoinWIFInvalidChecksum: SKY_ErrBitcoinWIFInvalidChecksum, - cipher.ErrEmptySeed: SKY_ErrEmptySeed, - cipher.ErrInvalidSig: SKY_ErrInvalidSig, + cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, + cipher.ErrInvalidHashForSig: SKY_ErrInvalidHashForSig, + cipher.ErrPubKeyRecoverMismatch: SKY_ErrPubKeyRecoverMismatch, + cipher.ErrInvalidSigInvalidPubKey: SKY_ErrInvalidSigInvalidPubKey, + cipher.ErrInvalidSigValidity: SKY_ErrInvalidSigValidity, + cipher.ErrInvalidSigForMessage: SKY_ErrInvalidSigForMessage, + cipher.ErrInvalidSecKyVerification: SKY_ErrInvalidSecKyVerification, + cipher.ErrNullPubKeyFromSecKey: SKY_ErrNullPubKeyFromSecKey, + cipher.ErrInvalidDerivedPubKeyFromSecKey: SKY_ErrInvalidDerivedPubKeyFromSecKey, + cipher.ErrInvalidPubKeyFromHash: SKY_ErrInvalidPubKeyFromHash, + cipher.ErrPubKeyFromSecKeyMismatch: SKY_ErrPubKeyFromSecKeyMismatch, + cipher.ErrInvalidLength: SKY_ErrInvalidLength, + cipher.ErrBitcoinWIFInvalidFirstByte: SKY_ErrBitcoinWIFInvalidFirstByte, + cipher.ErrBitcoinWIFInvalidSuffix: SKY_ErrBitcoinWIFInvalidSuffix, + cipher.ErrBitcoinWIFInvalidChecksum: SKY_ErrBitcoinWIFInvalidChecksum, + cipher.ErrEmptySeed: SKY_ErrEmptySeed, + cipher.ErrInvalidSig: SKY_ErrInvalidSig, + encrypt.ErrSHA256orMissingPassword: SKY_ErrSHA256orMissingPassword, + encrypt.ErrLenghtDataOverflowMaxUint32: SKY_ErrLenghtDataOverflowMaxUint32, + encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, + encrypt.ErrInvalidDataChecksumNotMatched: SKY_ErrInvalidDataChecksumNotMatched, + encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, + encrypt.ErrInvalidBlockSizeMultiple32Bytes: SKY_ErrInvalidBlockSizeMultiple32Bytes, + encrypt.ErrReadDataHashFailedLength: SKY_ErrReadDataHashFailedLength, + encrypt.ErrSHA256orInvalidPassword: SKY_ErrSHA256orInvalidPassword, + encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, + encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, + // cli cli.ErrTemporaryInsufficientBalance: SKY_ErrTemporaryInsufficientBalance, cli.ErrAddress: SKY_ErrAddress, @@ -586,17 +596,6 @@ var ( wallet.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts, wallet.ErrUnknownWalletID: SKY_ErrUnknownWalletID, - encrypt.ErrSHA256orMissingPassword: SKY_ErrSHA256orMissingPassword, - encrypt.ErrLenghtDataOverflowMaxUint32: SKY_ErrLenghtDataOverflowMaxUint32, - encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, - encrypt.ErrInvalidDataChecksumNotMatched: SKY_ErrInvalidDataChecksumNotMatched, - encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, - encrypt.ErrInvalidBlockSizeMultiple32Bytes: SKY_ErrInvalidBlockSizeMultiple32Bytes, - encrypt.ErrReadDataHashFailedLength: SKY_ErrReadDataHashFailedLength, - encrypt.ErrSHA256orInvalidPassword: SKY_ErrSHA256orInvalidPassword, - encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, - encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, - secp256k1.ErrVerifySignatureInvalidInputsNils: SKY_ErrVerifySignatureInvalidInputsNils, secp256k1.ErrVerifySignatureInvalidSigLength: SKY_ErrVerifySignatureInvalidSigLength, secp256k1.ErrVerifySignatureInvalidPubkeysLength: SKY_ErrVerifySignatureInvalidPubkeysLength, @@ -708,28 +707,27 @@ func catchApiPanic(errcode uint32, err interface{}) uint32 { return SKY_API_LOCKED } if err != nil { - if valueErr, isValueError := err.(skyerrors.ValueError); isValueError { - return libErrorCode(valueErr.ErrorData) + // Setting flag every time (i.e. even when haltOnPanic is active + // protects against hypothetical situations in which panic() + // does not abort the current process. + lockAPI() + if haltOnPanic { + // FIXME: Set process exit code on panic + /* + var exitCode int + if _err, isError := err.(error); isError { + exitCode = int(libErrorCode(_err)) + } else { + exitCode = SKY_ERROR + } + */ + panic(err) } else { - // Setting flag every time (i.e. even when haltOnPanic is active - // protects against hypothetical situations in which panic() - // does not abort the current process. - lockAPI() - if haltOnPanic { - // FIXME: Set process exit code on panic - /* - var exitCode int - if _err, isError := err.(error); isError { - exitCode = int(libErrorCode(_err)) - } else { - exitCode = SKY_ERROR - } - */ - panic(err) - } else { - // Let the caller know specific error that locked the API - return libErrorCode(valueErr.ErrorData) + // Let the caller know specific error that locked the API + if _err, isError := err.error; isError { + return libErrorCode(_err) } + return SKY_ERROR } } return SKY_OK diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index b2b08f6899..df731ec050 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -174,7 +174,7 @@ Test(cipher_crypto, TestPubKeyVerifyDefault2) Test(cipher_crypto, TestPubKeyRipemd160) { cipher__PubKey p; cipher__SecKey s; - Ripemd160 h; + cipher__Ripemd160 h; SKY_cipher_GenerateKeyPair(&p, &s); SKY_cipher_PubKeyRipemd160(&p, &h); diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index 3e98fdf4d6..3878fe8356 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -353,7 +353,7 @@ Test(cipher_secp256k1, Test_Secp256_04) GoInt randSig(GoSlice *sig) { GoInt error_code; - error_code = SKY_secp256k1_RandByte(65, sig); + error_code = SKY_secp256k1_RandByte(65, (GoSlice_ *) sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", sig->len); diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index 2ab3287d41..7cfcb0ab07 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -176,10 +176,10 @@ Test(cipher_secp256k1_sig, TestSigVerify) { result = SKY_secp256k1go_Number_SetHex(s, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); char buffer_xy[1024]; - cipher__PubKeySlice xy = {buffer_xy, 0, 1024}; + GoSlice xy = {buffer_xy, 0, 1024}; str.p = "02a60d70cfba37177d8239d018185d864b2bdd0caf5e175fd4454cc006fd2d75ac"; str.n = 66; - result = SKY_base58_String2Hex(str, &xy); + result = SKY_base58_String2Hex(str, (GoSlice_ *) &xy); cr_assert(result == SKY_OK, "SKY_base58_String2Hex"); GoSlice xyConvert = {xy.data, xy.len, xy.cap}; result = SKY_secp256k1go_XY_ParsePubkey(&key, xyConvert, &valid); diff --git a/lib/cgo/tests/check_coin.coin.c b/lib/cgo/tests/check_coin.coin.c index 188c85a75f..d5b92b2dee 100644 --- a/lib/cgo/tests/check_coin.coin.c +++ b/lib/cgo/tests/check_coin.coin.c @@ -54,7 +54,7 @@ Test(coin_coin, TestCrypto1){ for(int i = 0; i < 10; i ++){ result = SKY_cipher_GenerateKeyPair( &pubkey, &seckey ); cr_assert( result == SKY_OK, "SKY_cipher_GenerateKeyPair failed" ); - result = SKY_cipher_TestSecKey( &seckey ); + result = SKY_cipher_CheckSecKey( &seckey ); cr_assert( result == SKY_OK, "CRYPTOGRAPHIC INTEGRITY CHECK FAILED" ); } } @@ -83,6 +83,6 @@ Test(coin_coin, TestCrypto2){ cipher__SHA256 hash; result = SKY_cipher_SumSHA256(textslice, &hash); cr_assert( result == SKY_OK, "SKY_cipher_SumSHA256 failed" ); - result = SKY_cipher_TestSecKeyHash( &seckey, &hash ); - cr_assert( result == SKY_OK, "SKY_cipher_TestSecKeyHash failed" ); + result = SKY_cipher_CheckSecKeyHash( &seckey, &hash ); + cr_assert( result == SKY_OK, "SKY_cipher_CheckSecKeyHash failed" ); } diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index e0c071a094..b8d7235147 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -279,18 +279,16 @@ Test(coin_transaction, TestTransactionsSize) result = makeTransactions(10, &txns); cr_assert(result == SKY_OK); GoInt size = 0; - for (size_t i = 0; i < 10; i++) - { + for (size_t i = 0; i < 10; i++) { Transaction__Handle handle; result = SKY_coin_Transactions_GetAt(txns, i, &handle); registerHandleClose(handle); cr_assert(result == SKY_OK); - cipher__PubKeySlice p1 = {NULL, 0, 0}; - result = SKY_coin_Transaction_Serialize(handle, &p1); - cr_assert(result == SKY_OK, "SKY_coin_Transaction_Serialize failed"); - GoInt count; + GoSlice p1 = {NULL, 0, 0}; + result = SKY_coin_Transaction_Serialize(handle, (GoSlice_ *) &p1); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Serialize"); size += p1.len; - cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size failed"); + cr_assert(result == SKY_OK, "SKY_coin_Transaction_Size"); } GoInt sizeTransactions; result = SKY_coin_Transactions_Size(txns, &sizeTransactions); From dd959124b23da34e1c88d07a5c2ac09bcd993a4a Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 14:40:48 -0400 Subject: [PATCH 231/399] [lib] [cipher] refs #1191 - Fix make libc after merge - Error codes in C headers. - Return nil in secp256k1 RecoverPubkey (regression). - Remove duplicate libsky_string . [====] Synthesis: Tested: 138 | Passing: 136 | Failing: 2 | Crashing: 1 --- include/skyerrors.h | 100 ++++++++------ lib/cgo/libsky_error.go | 2 +- lib/cgo/tests/libsky_string.c | 41 ------ lib/cgo/tests/testutils/libsky_string.c | 173 +++++++++++++----------- src/cipher/secp256k1-go/secp256k1.go | 1 + 5 files changed, 152 insertions(+), 165 deletions(-) delete mode 100644 lib/cgo/tests/libsky_string.c diff --git a/include/skyerrors.h b/include/skyerrors.h index e41e595376..1276fb95aa 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -17,6 +17,8 @@ #define SKY_OK 0 #define SKY_ERROR 0x7FFFFFFF +#define SKY_BAD_HANDLE 0x7F000001 +#define SKY_API_LOCKED 0x7F000002 #define SKY_PKG_API 0x01000000 #define SKY_PKG_CIPHER 0x02000000 @@ -29,6 +31,7 @@ #define SKY_PKG_UTIL 0x09000000 #define SKY_PKG_VISOR 0x0A000000 #define SKY_PKG_WALLET 0x0B000000 +#define SKY_PKG_LIBCGO 0x7F000000 #define SKY_ErrAddressInvalidLength 0x02000000 #define SKY_ErrAddressInvalidChecksum 0x02000001 @@ -73,6 +76,16 @@ #define SKY_ErrBitcoinWIFInvalidChecksum 0x02000028 #define SKY_ErrEmptySeed 0x02000029 #define SKY_ErrInvalidSig 0x0200002A +#define SKY_ErrSHA256orMissingPassword 0x0200002A +#define SKY_ErrLenghtDataOverflowMaxUint32 0x02000029 +#define SKY_ErrInvalidChecksumLength 0x0200002B +#define SKY_ErrInvalidDataChecksumNotMatched 0x0200002C +#define SKY_ErrInvalidNonceLength 0x0200002D +#define SKY_ErrInvalidBlockSizeMultiple32Bytes 0x0200002E +#define SKY_ErrReadDataHashFailedLength 0x0200002F +#define SKY_ErrSHA256orInvalidPassword 0x02000030 +#define SKY_ErrReadDataLengthFailed 0x02000031 +#define SKY_ErrInvalidDataLength 0x02000032 #define SKY_ErrTemporaryInsufficientBalance 0x03000000 #define SKY_ErrAddress 0x03000001 @@ -140,47 +153,50 @@ #define SKY_ErrTxnViolatesSoftConstraint 0x0A000008 #define SKY_ErrTxnViolatesUserConstraint 0x0A000009 -#define SKY_ErrInsufficientBalance 0x0B000000 -#define SKY_ErrInsufficientHours 0x0B000001 -#define SKY_ErrZeroSpend 0x0B000002 -#define SKY_ErrSpendingUnconfirmed 0x0B000003 -#define SKY_ErrInvalidEncryptedField 0x0B000004 -#define SKY_ErrWalletEncrypted 0x0B000005 -#define SKY_ErrWalletNotEncrypted 0x0B000006 -#define SKY_ErrMissingPassword 0x0B000007 -#define SKY_ErrMissingEncrypt 0x0B000008 -#define SKY_ErrInvalidPassword 0x0B000009 -#define SKY_ErrMissingSeed 0x0B00000A -#define SKY_ErrMissingAuthenticated 0x0B00000B -#define SKY_ErrWrongCryptoType 0x0B00000C -#define SKY_ErrWalletNotExist 0x0B00000D -#define SKY_ErrSeedUsed 0x0B00000E -#define SKY_ErrWalletAPIDisabled 0x0B00000F -#define SKY_ErrSeedAPIDisabled 0x0B000010 -#define SKY_ErrWalletNameConflict 0x0B000011 -#define SKY_ErrInvalidHoursSelectionMode 0x0B000012 -#define SKY_ErrInvalidHoursSelectionType 0x0B000013 -#define SKY_ErrUnknownAddress 0x0B000014 -#define SKY_ErrUnknownUxOut 0x0B000015 -#define SKY_ErrNoUnspents 0x0B000016 -#define SKY_ErrNullChangeAddress 0x0B000017 -#define SKY_ErrMissingTo 0x0B000018 -#define SKY_ErrZeroCoinsTo 0x0B000019 -#define SKY_ErrNullAddressTo 0x0B00001A -#define SKY_ErrDuplicateTo 0x0B00001B -#define SKY_ErrMissingWalletID 0x0B00001C -#define SKY_ErrIncludesNullAddress 0x0B00001D -#define SKY_ErrDuplicateAddresses 0x0B00001E -#define SKY_ErrZeroToHoursAuto 0x0B00001F -#define SKY_ErrMissingModeAuto 0x0B000020 -#define SKY_ErrInvalidHoursSelMode 0x0B000021 -#define SKY_ErrInvalidModeManual 0x0B000022 -#define SKY_ErrInvalidHoursSelType 0x0B000023 -#define SKY_ErrMissingShareFactor 0x0B000024 -#define SKY_ErrInvalidShareFactor 0x0B000025 -#define SKY_ErrShareFactorOutOfRange 0x0B000026 -#define SKY_ErrWalletConstraint 0x0B000027 -#define SKY_ErrDuplicateUxOuts 0x0B000028 -#define SKY_ErrUnknownWalletID 0x0B000029 +#define SKY_ErrInsufficientBalance 0x0B000000 +#define SKY_ErrInsufficientHours 0x0B000001 +#define SKY_ErrZeroSpend 0x0B000002 +#define SKY_ErrSpendingUnconfirmed 0x0B000003 +#define SKY_ErrInvalidEncryptedField 0x0B000004 +#define SKY_ErrWalletEncrypted 0x0B000005 +#define SKY_ErrWalletNotEncrypted 0x0B000006 +#define SKY_ErrMissingPassword 0x0B000007 +#define SKY_ErrMissingEncrypt 0x0B000008 +#define SKY_ErrInvalidPassword 0x0B000009 +#define SKY_ErrMissingSeed 0x0B00000A +#define SKY_ErrMissingAuthenticated 0x0B00000B +#define SKY_ErrWrongCryptoType 0x0B00000C +#define SKY_ErrWalletNotExist 0x0B00000D +#define SKY_ErrSeedUsed 0x0B00000E +#define SKY_ErrWalletAPIDisabled 0x0B00000F +#define SKY_ErrSeedAPIDisabled 0x0B000010 +#define SKY_ErrWalletNameConflict 0x0B000011 +#define SKY_ErrInvalidHoursSelectionMode 0x0B000012 +#define SKY_ErrInvalidHoursSelectionType 0x0B000013 +#define SKY_ErrUnknownAddress 0x0B000014 +#define SKY_ErrUnknownUxOut 0x0B000015 +#define SKY_ErrNoUnspents 0x0B000016 +#define SKY_ErrNullChangeAddress 0x0B000017 +#define SKY_ErrMissingTo 0x0B000018 +#define SKY_ErrZeroCoinsTo 0x0B000019 +#define SKY_ErrNullAddressTo 0x0B00001A +#define SKY_ErrDuplicateTo 0x0B00001B +#define SKY_ErrMissingWalletID 0x0B00001C +#define SKY_ErrIncludesNullAddress 0x0B00001D +#define SKY_ErrDuplicateAddresses 0x0B00001E +#define SKY_ErrZeroToHoursAuto 0x0B00001F +#define SKY_ErrMissingModeAuto 0x0B000020 +#define SKY_ErrInvalidHoursSelMode 0x0B000021 +#define SKY_ErrInvalidModeManual 0x0B000022 +#define SKY_ErrInvalidHoursSelType 0x0B000023 +#define SKY_ErrMissingShareFactor 0x0B000024 +#define SKY_ErrInvalidShareFactor 0x0B000025 +#define SKY_ErrShareFactorOutOfRange 0x0B000026 +#define SKY_ErrWalletConstraint 0x0B000027 +#define SKY_ErrDuplicateUxOuts 0x0B000028 +#define SKY_ErrUnknownWalletID 0x0B000029 +#define SKY_ErrVerifySignatureInvalidInputsNils 0x0B000033 +#define SKY_ErrVerifySignatureInvalidSigLength 0x0B000034 +#define SKY_ErrVerifySignatureInvalidPubkeysLength 0x0B000035 #endif diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 4c95efeb5a..4627a656d9 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -724,7 +724,7 @@ func catchApiPanic(errcode uint32, err interface{}) uint32 { panic(err) } else { // Let the caller know specific error that locked the API - if _err, isError := err.error; isError { + if _err, isError := err.(error); isError { return libErrorCode(_err) } return SKY_ERROR diff --git a/lib/cgo/tests/libsky_string.c b/lib/cgo/tests/libsky_string.c deleted file mode 100644 index 06e0f62b13..0000000000 --- a/lib/cgo/tests/libsky_string.c +++ /dev/null @@ -1,41 +0,0 @@ - -#include "skystring.h" - -#define ALPHANUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define ALPHANUM_LEN 62 -#define SIZE_ALL -1 - -void randBytes(GoSlice *bytes, size_t n) { - size_t i = 0; - unsigned char *ptr = (unsigned char *) bytes->data; - for (; i < n; ++i, ++ptr) { - *ptr = ALPHANUM[rand() % ALPHANUM_LEN]; - } - bytes->len = (GoInt) n; -} - -void bytesnhex(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789ABCDEF"; - char * pout = str; - for(; n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; -} - -void strnhex(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789ABCDEF"; - char * pout = str; - for(; *pin && n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; -} - -void strhex(unsigned char* buf, char *str){ - strnhex(buf, str, SIZE_ALL); -} diff --git a/lib/cgo/tests/testutils/libsky_string.c b/lib/cgo/tests/testutils/libsky_string.c index 130761eb9c..2a170f1995 100644 --- a/lib/cgo/tests/testutils/libsky_string.c +++ b/lib/cgo/tests/testutils/libsky_string.c @@ -6,110 +6,121 @@ #define SIZE_ALL -1 void randBytes(GoSlice *bytes, size_t n) { - size_t i = 0; - unsigned char *ptr = (unsigned char *) bytes->data; - for (; i < n; ++i, ++ptr) { - *ptr = ALPHANUM[rand() % ALPHANUM_LEN]; - } - bytes->len = (GoInt) n; + size_t i = 0; + unsigned char *ptr = (unsigned char *) bytes->data; + for (; i < n; ++i, ++ptr) { + *ptr = ALPHANUM[rand() % ALPHANUM_LEN]; + } + bytes->len = (GoInt) n; +} + +void bytesnhex(unsigned char* buf, char *str, int n){ + unsigned char * pin = buf; + const char * hex = "0123456789ABCDEF"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; } void strnhex(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789ABCDEF"; - char * pout = str; - for(; n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; + unsigned char * pin = buf; + const char * hex = "0123456789ABCDEF"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; } void strnhexlower(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789abcdef"; - char * pout = str; - for(; n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; + unsigned char * pin = buf; + const char * hex = "0123456789abcdef"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; } int hexnstr(const char* hex, unsigned char* str, int n){ - const char * pin = hex; - unsigned char * pout = str; - unsigned char c; - int odd = 0; - int size = 0; - for(; *pin && size < n; pin++){ - if(*pin >= '0' && *pin <= '9'){ - c = *pin - '0'; - } else if(*pin >= 'A' && *pin <= 'F'){ - c = 10 + (*pin - 'A'); - } else if(*pin >= 'a' && *pin <= 'f'){ - c = 10 + (*pin - 'a'); - } else { //Invalid hex string - return -1; - } - if(odd){ - *pout = (*pout << 4) | c; - pout++; - size++; - } else { - *pout = c; - } - odd = !odd; - } - if( odd ) - return -1; - if( size < n ) - *pout = 0; - return size; + const char * pin = hex; + unsigned char * pout = str; + unsigned char c; + int odd = 0; + int size = 0; + for(; *pin && size < n; pin++){ + if(*pin >= '0' && *pin <= '9'){ + c = *pin - '0'; + } else if(*pin >= 'A' && *pin <= 'F'){ + c = 10 + (*pin - 'A'); + } else if(*pin >= 'a' && *pin <= 'f'){ + c = 10 + (*pin - 'a'); + } else { //Invalid hex string + return -1; + } + if(odd){ + *pout = (*pout << 4) | c; + pout++; + size++; + } else { + *pout = c; + } + odd = !odd; + } + if( odd ) + return -1; + if( size < n ) + *pout = 0; + return size; } int cmpGoSlice_GoSlice(GoSlice *slice1, GoSlice_ *slice2){ - return ((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, sizeof(GoSlice_))==0 ); + return ((slice1->len == slice2->len)) && (memcmp(slice1->data,slice2->data, sizeof(GoSlice_))==0 ); } void bin2hex(unsigned char* buf, char *str, int n){ - unsigned char * pin = buf; - const char * hex = "0123456789ABCDEF"; - char * pout = str; - for(; n; --n){ - *pout++ = hex[(*pin>>4)&0xF]; - *pout++ = hex[(*pin++)&0xF]; - } - *pout = 0; + unsigned char * pin = buf; + const char * hex = "0123456789ABCDEF"; + char * pout = str; + for(; n; --n){ + *pout++ = hex[(*pin>>4)&0xF]; + *pout++ = hex[(*pin++)&0xF]; + } + *pout = 0; } int string_has_suffix(const char* str, const char* suffix){ - int string_len = strlen(str); - int suffix_len = strlen(suffix); - if(string_len >= suffix_len){ - char* p = (char*)str + (string_len - suffix_len); - return strcmp(p, suffix) == 0; - } - return 0; + int string_len = strlen(str); + int suffix_len = strlen(suffix); + if(string_len >= suffix_len){ + char* p = (char*)str + (string_len - suffix_len); + return strcmp(p, suffix) == 0; + } + return 0; } int string_has_prefix(const char* str, const char* prefix){ - int string_len = strlen(str); - int prefix_len = strlen(prefix); - if(string_len >= prefix_len){ - return strncmp(str, prefix, prefix_len) == 0; - } - return 0; + int string_len = strlen(str); + int prefix_len = strlen(prefix); + if(string_len >= prefix_len){ + return strncmp(str, prefix, prefix_len) == 0; + } + return 0; } extern int count_words(const char* str, int length){ - int words = 1; - char prevChar = 0; - for(int i = 0; i < length; i++){ - char c = str[i]; - if( c == ' ' && prevChar != ' ' ) words++; - prevChar = c; - } - return words; + int words = 1; + char prevChar = 0; + for(int i = 0; i < length; i++){ + char c = str[i]; + if( c == ' ' && prevChar != ' ' ) words++; + prevChar = c; + } + return words; } diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 340d11e5a8..86e8b3ecc6 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -479,6 +479,7 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { if ret != 1 { log.Printf("RecoverPubkey: code %d", ret) + return nil } if pubkey == nil { From a1e17b123dda8a3b144adfb270acf58663691330 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 16:56:07 -0400 Subject: [PATCH 232/399] [lib] refs #1191 - Correct sequence of cipher errors [====] Synthesis: Tested: 138 | Passing: 137 | Failing: 1 | Crashing: 1 --- include/skyerrors.h | 20 +++++++++---------- .../tests/check_cipher.encrypt.sha256xor.c | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 1276fb95aa..e44ace1e0d 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -76,16 +76,16 @@ #define SKY_ErrBitcoinWIFInvalidChecksum 0x02000028 #define SKY_ErrEmptySeed 0x02000029 #define SKY_ErrInvalidSig 0x0200002A -#define SKY_ErrSHA256orMissingPassword 0x0200002A -#define SKY_ErrLenghtDataOverflowMaxUint32 0x02000029 -#define SKY_ErrInvalidChecksumLength 0x0200002B -#define SKY_ErrInvalidDataChecksumNotMatched 0x0200002C -#define SKY_ErrInvalidNonceLength 0x0200002D -#define SKY_ErrInvalidBlockSizeMultiple32Bytes 0x0200002E -#define SKY_ErrReadDataHashFailedLength 0x0200002F -#define SKY_ErrSHA256orInvalidPassword 0x02000030 -#define SKY_ErrReadDataLengthFailed 0x02000031 -#define SKY_ErrInvalidDataLength 0x02000032 +#define SKY_ErrSHA256orMissingPassword 0x0200002B +#define SKY_ErrLenghtDataOverflowMaxUint32 0x0200002C +#define SKY_ErrInvalidChecksumLength 0x0200002D +#define SKY_ErrInvalidDataChecksumNotMatched 0x0200002E +#define SKY_ErrInvalidNonceLength 0x0200002F +#define SKY_ErrInvalidBlockSizeMultiple32Bytes 0x02000030 +#define SKY_ErrReadDataHashFailedLength 0x02000031 +#define SKY_ErrSHA256orInvalidPassword 0x02000032 +#define SKY_ErrReadDataLengthFailed 0x02000033 +#define SKY_ErrInvalidDataLength 0x02000034 #define SKY_ErrTemporaryInsufficientBalance 0x03000000 #define SKY_ErrAddress 0x03000001 diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 9f92d5e39e..4a89b11636 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -169,6 +169,7 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); } else { + fprintf(stderr, "Errorcode %d\n", errcode); cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); } if( errcode == SKY_OK ){ From 1da94cece242cc2c2cf67fa592558d7972334144 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 18:36:25 -0400 Subject: [PATCH 233/399] [lib] refs #1191 - Fix previous crash running Test_Secp256_06a_alt0 [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- lib/cgo/cipher.secp256k1-go.secp256k1.go | 5 +---- lib/cgo/tests/check_cipher.secp256k1.secp256.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go index 9ade652646..53e12d6335 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1.go @@ -185,10 +185,7 @@ func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _a ____error_code = catchApiPanic(____error_code, recover()) }() checkAPIReady() - msg := *(*[]byte)(unsafe.Pointer(&_msg)) - sig := *(*[]byte)(unsafe.Pointer(&_sig)) - pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) - __arg3 := secp256k1go.VerifySignature(msg, sig, pubkey1) + __arg3 := secp256k1go.VerifySignature(_msg, _sig, _pubkey1) *_arg3 = __arg3 return } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index 3878fe8356..44722a9a0e 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -356,7 +356,7 @@ GoInt randSig(GoSlice *sig) error_code = SKY_secp256k1_RandByte(65, (GoSlice_ *) sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", - sig->len); + sig->len); ((unsigned char *)sig->data)[32] = ((unsigned char *)sig->data)[32] & 0x70; ((unsigned char *)sig->data)[64] = ((unsigned char *)sig->data)[64] % 4; return error_code; @@ -376,8 +376,7 @@ Test(cipher_secp256k1, Test_Secp256_06a_alt0) GoSlice sig2 = {bufferSig2, 0, BUFFER_SIZE}; GoSlice msg = {buff, 0, 32}; - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); + error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); GoInt code; error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); @@ -392,13 +391,15 @@ Test(cipher_secp256k1, Test_Secp256_06a_alt0) GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; GoInt result; randSig(&sig2); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (coin__UxArray *)&pub2); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (GoSlice_ *)&pub2); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); - error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); - cr_assert(pub2.len == 0 || result, "Public key is not valid"); + if (pub2.len != 0) { + error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); + cr_assert(result == 1); + } error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub1, &result); - cr_assert(result == 0, "Public key should not be valid"); + cr_assert(result != 1); } } From 0639e47407ebe5bf475f32d70066dff7afed7a9a Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 8 Oct 2018 20:45:03 -0400 Subject: [PATCH 234/399] [lib] refs #1191 - (coin__UxArray *) => (GoSlice_ *) --- include/cipher.address.go.h | 2 +- include/cipher.bitcoin.go.h | 4 +- include/cipher.testsuite.testsuite.go.h | 2 +- include/cli.create_rawtx.go.h | 4 +- include/coin.transactions.go.h | 14 +- include/skytest.h | 10 +- include/skytypes.h | 14 +- include/wallet.entry.go.h | 6 +- include/wallet.wallet.go.h | 10 +- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 332 ++-- .../tests/check_cipher.encrypt.sha256xor.c | 484 ++--- lib/cgo/tests/check_cipher.hash.c | 2 +- lib/cgo/tests/check_cipher.scrypt.c | 286 +-- .../tests/check_cipher.secp256k1.secp256.c | 1606 ++++++++--------- .../check_cipher.secp256k1.secp256k1-go2.ec.c | 226 +-- ...eck_cipher.secp256k1.secp256k1-go2.field.c | 44 +- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 264 +-- ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 80 +- lib/cgo/tests/cipher.testsuite.c | 16 +- lib/cgo/tests/testutils/base64.c | 308 ++-- lib/cgo/tests/testutils/json_util.c | 226 +-- lib/cgo/tests/testutils/libsky_testutil.c | 416 ++--- vendor/golang.org/x/sys/unix/gccgo_c.c | 16 +- 23 files changed, 2186 insertions(+), 2186 deletions(-) diff --git a/include/cipher.address.go.h b/include/cipher.address.go.h index 082ce600d8..902592057d 100644 --- a/include/cipher.address.go.h +++ b/include/cipher.address.go.h @@ -1,7 +1,7 @@ typedef GoUint8_ cipher__Checksum[4]; typedef struct{ GoUint8_ Version; ///< Address version identifier. - ///< Used to differentiate testnet + ///< Used to differentiate testnet ///< vs mainnet addresses, for ins cipher__Ripemd160 Key; ///< Address hash identifier. } cipher__Address; diff --git a/include/cipher.bitcoin.go.h b/include/cipher.bitcoin.go.h index 0cb3b6ffc4..fd55b071af 100644 --- a/include/cipher.bitcoin.go.h +++ b/include/cipher.bitcoin.go.h @@ -2,8 +2,8 @@ * Addresses of Bitcoin accounts */ typedef struct { - unsigned char Version; ///< Address version identifier. + unsigned char Version; ///< Address version identifier. ///< Used to differentiate testnet ///< vs mainnet addresses, for instance. - cipher__Ripemd160 Key; ///< Address hash identifier. + cipher__Ripemd160 Key; ///< Address hash identifier. } cipher__BitcoinAddress; diff --git a/include/cipher.testsuite.testsuite.go.h b/include/cipher.testsuite.testsuite.go.h index 0802f980dc..c56c207748 100644 --- a/include/cipher.testsuite.testsuite.go.h +++ b/include/cipher.testsuite.testsuite.go.h @@ -21,7 +21,7 @@ #define FILEPATH_SEPARATOR "/" #define TEST_DATA_DIR "src/cipher/testsuite/testdata/" #define MANY_ADDRESSES_FILENAME "many-addresses.golden" -#define INPUT_HASHES_FILENAME "input-hashes.golden" +#define INPUT_HASHES_FILENAME "input-hashes.golden" #define SEED_FILE_REGEX "seed-\d+.golden" //------------------------------------------------------------------------------ diff --git a/include/cli.create_rawtx.go.h b/include/cli.create_rawtx.go.h index 48dfa5c9b4..5d41be93df 100644 --- a/include/cli.create_rawtx.go.h +++ b/include/cli.create_rawtx.go.h @@ -2,6 +2,6 @@ * Structure used to specify amounts transferred in a transaction. */ typedef struct { - GoString_ Addr; ///< Sender / receipient address. - GoInt64_ Coins; ///< Amount transferred (e.g. measured in SKY) + GoString_ Addr; ///< Sender / receipient address. + GoInt64_ Coins; ///< Amount transferred (e.g. measured in SKY) } cli__SendAmount; diff --git a/include/coin.transactions.go.h b/include/coin.transactions.go.h index 4e33ff1852..2eed03ea26 100644 --- a/include/coin.transactions.go.h +++ b/include/coin.transactions.go.h @@ -5,13 +5,13 @@ typedef GoSlice_ coin__Transactions; * Instances of this struct are included in blocks. */ typedef struct { - GoInt32_ Length; ///< Current transaction's length expressed in bytes. - GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. - cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. + GoInt32_ Length; ///< Current transaction's length expressed in bytes. + GoInt8_ Type; ///< Transaction's version. When a node tries to process a transaction, it must verify whether it supports the transaction's type. This is intended to provide a way to update skycoin clients and servers without crashing the network. If the transaction is not compatible with the node, it should not process it. + cipher__SHA256 InnerHash; ///< It's a SHA256 hash of the inputs and outputs of the transaction. It is used to protect against transaction mutability. This means that the transaction cannot be altered after its creation. - GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. - GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. - GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. + GoSlice_ Sigs; ///< A list of digital signiatures generated by the skycoin client using the private key. It is used by Skycoin servers to verify the authenticy of the transaction. Each input requires a different signature. + GoSlice_ In; ///< A list of references to unspent transaction outputs. Unlike other cryptocurrencies, such as Bitcoin, Skycoin unspent transaction outputs (UX) and Skycoin transactions (TX) are separated in the blockchain protocol, allowing for lighter transactions, thus reducing the broadcasting costs across the network. + GoSlice_ Out; ///< Outputs: A list of outputs created by the client, that will be recorded in the blockchain if transactions are confirmed. An output consists of a data structure representing an UTXT, which is composed by a Skycoin address to be sent to, the amount in Skycoin to be sent, and the amount of Coin Hours to be sent, and the SHA256 hash of the previous fields. } coin__Transaction; /** @@ -21,6 +21,6 @@ typedef struct { */ typedef struct{ cipher__Address Address; ///< Receipient address. - GoUint64_ Coins; ///< Amount sent to the receipient address. + GoUint64_ Coins; ///< Amount sent to the receipient address. GoUint64_ Hours; ///< Amount of Coin Hours sent to the receipient address. } coin__TransactionOutput; diff --git a/include/skytest.h b/include/skytest.h index abdc4e0b7b..6bfeda6e70 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -26,21 +26,21 @@ void closeRegisteredHandle(Handle handle); void freeRegisteredMemCleanup(void *p); int registerWalletClean(Client__Handle clientHandle, - WalletResponse__Handle walletHandle); + WalletResponse__Handle walletHandle); void cleanRegisteredWallet( - Client__Handle client, - WalletResponse__Handle wallet); + Client__Handle client, + WalletResponse__Handle wallet); json_value* loadJsonFile(const char* filename); int compareJsonValues(json_value* value1, json_value* value2); json_value* get_json_value(json_value* node, const char* path, - json_type type); + json_type type); json_value* get_json_value_not_strict(json_value* node, const char* path, - json_type type, int allow_null); + json_type type, int allow_null); int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, const char* ignoreList); diff --git a/include/skytypes.h b/include/skytypes.h index c3251fb840..1b55b7056b 100644 --- a/include/skytypes.h +++ b/include/skytypes.h @@ -198,14 +198,14 @@ typedef struct { } GoSlice_; typedef struct { - BOOL neg; - GoSlice_ nat; + BOOL neg; + GoSlice_ nat; } Number; typedef struct { - //TODO: stdevEclipse Define Signature - Number R; - Number S; + //TODO: stdevEclipse Define Signature + Number R; + Number S; } Signature; #include "skytypes.gen.h" @@ -214,8 +214,8 @@ typedef struct { * Internal representation of a Skycoin wallet. */ typedef struct { - GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. - GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. + GoMap_ Meta; ///< Records items that are not deterministic, like filename, lable, wallet type, secrets, etc. + GoSlice_ Entries; ///< Entries field stores the address entries that are deterministically generated from seed. } Wallet; typedef GoUint8_ poly1305__Mac[16]; diff --git a/include/wallet.entry.go.h b/include/wallet.entry.go.h index 362bb76494..fa43ea31d3 100644 --- a/include/wallet.entry.go.h +++ b/include/wallet.entry.go.h @@ -2,7 +2,7 @@ * Wallet entry. */ typedef struct { - cipher__Address Address; ///< Wallet address. - cipher__PubKey Public; ///< Public key used to generate address. - cipher__SecKey Secret; ///< Secret key used to generate address. + cipher__Address Address; ///< Wallet address. + cipher__PubKey Public; ///< Public key used to generate address. + cipher__SecKey Secret; ///< Secret key used to generate address. } wallet__Entry; diff --git a/include/wallet.wallet.go.h b/include/wallet.wallet.go.h index 9a4006eaf5..1aef1b164a 100644 --- a/include/wallet.wallet.go.h +++ b/include/wallet.wallet.go.h @@ -3,10 +3,10 @@ * Intermediate representation of a UxOut for sorting and spend choosing. */ typedef struct { - cipher__SHA256 Hash; ///< Hash of underlying UxOut. - GoInt64_ BkSeq; ///< Block height corresponding to the + cipher__SHA256 Hash; ///< Hash of underlying UxOut. + GoInt64_ BkSeq; ///< Block height corresponding to the ///< moment balance calculation is performed at. - cipher__Address Address; ///< Account holder address. - GoInt64_ Coins; ///< Coins amount (e.g. in SKY). - GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. + cipher__Address Address; ///< Account holder address. + GoInt64_ Coins; ///< Coins amount (e.g. in SKY). + GoInt64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time. } wallet__UxBalance; diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c index 58589fbea6..93f208fad0 100644 --- a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -23,185 +23,185 @@ TestSuite(cipher_encrypt_scrypt_chacha20poly1305, .init = setup, .fini = teardow void parseJsonMetaData(char *metadata, int *n, int *r, int *p, int *keyLen) { - *n = *r = *p = *keyLen = 0; - int length = strlen(metadata); - int openingQuote = -1; - const char *keys[] = {"n", "r", "p", "keyLen"}; - int keysCount = 4; - int keyIndex = -1; - int startNumber = -1; - for (int i = 0; i < length; i++) - { - if (metadata[i] == '\"') - { - startNumber = -1; - if (openingQuote >= 0) - { - keyIndex = -1; - metadata[i] = 0; - for (int k = 0; k < keysCount; k++) - { - if (strcmp(metadata + openingQuote + 1, keys[k]) == 0) - { - keyIndex = k; - } - } - openingQuote = -1; - } - else - { - openingQuote = i; - } - } - else if (metadata[i] >= '0' && metadata[i] <= '9') - { - if (startNumber < 0) - startNumber = i; - } - else if (metadata[i] == ',') - { - if (startNumber >= 0) - { - metadata[i] = 0; - int number = atoi(metadata + startNumber); - startNumber = -1; - if (keyIndex == 0) - *n = number; - else if (keyIndex == 1) - *r = number; - else if (keyIndex == 2) - *p = number; - else if (keyIndex == 3) - *keyLen = number; - } - } - else - { - startNumber = -1; - } - } + *n = *r = *p = *keyLen = 0; + int length = strlen(metadata); + int openingQuote = -1; + const char *keys[] = {"n", "r", "p", "keyLen"}; + int keysCount = 4; + int keyIndex = -1; + int startNumber = -1; + for (int i = 0; i < length; i++) + { + if (metadata[i] == '\"') + { + startNumber = -1; + if (openingQuote >= 0) + { + keyIndex = -1; + metadata[i] = 0; + for (int k = 0; k < keysCount; k++) + { + if (strcmp(metadata + openingQuote + 1, keys[k]) == 0) + { + keyIndex = k; + } + } + openingQuote = -1; + } + else + { + openingQuote = i; + } + } + else if (metadata[i] >= '0' && metadata[i] <= '9') + { + if (startNumber < 0) + startNumber = i; + } + else if (metadata[i] == ',') + { + if (startNumber >= 0) + { + metadata[i] = 0; + int number = atoi(metadata + startNumber); + startNumber = -1; + if (keyIndex == 0) + *n = number; + else if (keyIndex == 1) + *r = number; + else if (keyIndex == 2) + *p = number; + else if (keyIndex == 3) + *keyLen = number; + } + } + else + { + startNumber = -1; + } + } } Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt) { - GoSlice result; - GoSlice nullData; - GoSlice nullPassword; - char str[BUFFER_SIZE]; - GoSlice text; - GoSlice password; - GoSlice password2; - GoSlice wrong_password; - GoSlice encrypted; + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + char str[BUFFER_SIZE]; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; - memset(&text, 0, sizeof(GoSlice)); - memset(&password, 0, sizeof(GoSlice)); - memset(&password2, 0, sizeof(GoSlice)); - memset(&wrong_password, 0, sizeof(GoSlice)); - memset(&encrypted, 0, sizeof(GoSlice)); - memset(&nullData, 0, sizeof(GoSlice)); - memset(&nullPassword, 0, sizeof(GoSlice)); - memset(str, 0, BUFFER_SIZE); + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(str, 0, BUFFER_SIZE); - text.data = PLAINTEXT; - text.len = strlen(PLAINTEXT); - text.cap = text.len; - password.data = PASSWORD; - password.len = strlen(PASSWORD); - password.cap = password.len; - password2.data = PASSWORD2; - password2.len = strlen(PASSWORD2); - password2.cap = password2.len; - wrong_password.data = WRONG_PASSWORD; - wrong_password.len = strlen(WRONG_PASSWORD); - wrong_password.cap = wrong_password.len; - encrypted.data = ENCRYPTED; - encrypted.len = strlen(ENCRYPTED); - encrypted.cap = encrypted.len; + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; - GoUint32 errcode; - unsigned int metalength; - encrypt__ScryptChacha20poly1305 encrypt = {1, 8, 1, 32}; - for (int i = 1; i <= 20; i++) - { - memset(&result, 0, sizeof(GoSlice)); - encrypt.N = 1 << i; - errcode = SKY_encrypt_ScryptChacha20poly1305_Encrypt( - &encrypt, text, password, (coin__UxArray *)&result); - cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed"); - registerMemCleanup((void *)result.data); - cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); - int decode_len = b64_decode((const unsigned char *)result.data, - result.len, str); - cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); - cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); - metalength = (unsigned int)str[0]; - for (int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++) - { - if (str[m] > 0) - { - metalength += (((unsigned int)str[m]) << (m * 8)); - } - } - cr_assert(metalength + SCRYPTCHACHA20METALENGTHSIZE < decode_len, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata length greater than result lentgh."); - char *meta = str + SCRYPTCHACHA20METALENGTHSIZE; - meta[metalength] = 0; - int n, r, p, keyLen; - parseJsonMetaData(meta, &n, &r, &p, &keyLen); + GoUint32 errcode; + unsigned int metalength; + encrypt__ScryptChacha20poly1305 encrypt = {1, 8, 1, 32}; + for (int i = 1; i <= 20; i++) + { + memset(&result, 0, sizeof(GoSlice)); + encrypt.N = 1 << i; + errcode = SKY_encrypt_ScryptChacha20poly1305_Encrypt( + &encrypt, text, password, (GoSlice_ *)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed"); + registerMemCleanup((void *)result.data); + cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); + int decode_len = b64_decode((const unsigned char *)result.data, + result.len, str); + cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); + cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); + metalength = (unsigned int)str[0]; + for (int m = 1; m < SCRYPTCHACHA20METALENGTHSIZE; m++) + { + if (str[m] > 0) + { + metalength += (((unsigned int)str[m]) << (m * 8)); + } + } + cr_assert(metalength + SCRYPTCHACHA20METALENGTHSIZE < decode_len, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata length greater than result lentgh."); + char *meta = str + SCRYPTCHACHA20METALENGTHSIZE; + meta[metalength] = 0; + int n, r, p, keyLen; + parseJsonMetaData(meta, &n, &r, &p, &keyLen); - cr_assert(n == encrypt.N, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value N incorrect."); - cr_assert(r == encrypt.R, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value R incorrect."); - cr_assert(p == encrypt.P, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value P incorrect."); - cr_assert(keyLen == encrypt.KeyLen, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value KeyLen incorrect."); - } + cr_assert(n == encrypt.N, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value N incorrect."); + cr_assert(r == encrypt.R, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value R incorrect."); + cr_assert(p == encrypt.P, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value P incorrect."); + cr_assert(keyLen == encrypt.KeyLen, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed. Metadata value KeyLen incorrect."); + } } Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Decrypt) { - GoSlice result; - GoSlice nullData; - GoSlice nullPassword; - GoSlice text; - GoSlice password; - GoSlice password2; - GoSlice wrong_password; - GoSlice encrypted; + GoSlice result; + GoSlice nullData; + GoSlice nullPassword; + GoSlice text; + GoSlice password; + GoSlice password2; + GoSlice wrong_password; + GoSlice encrypted; - memset(&text, 0, sizeof(GoSlice)); - memset(&password, 0, sizeof(GoSlice)); - memset(&password2, 0, sizeof(GoSlice)); - memset(&wrong_password, 0, sizeof(GoSlice)); - memset(&encrypted, 0, sizeof(GoSlice)); - memset(&nullData, 0, sizeof(GoSlice)); - memset(&nullPassword, 0, sizeof(GoSlice)); - memset(&result, 0, sizeof(coin__UxArray)); + memset(&text, 0, sizeof(GoSlice)); + memset(&password, 0, sizeof(GoSlice)); + memset(&password2, 0, sizeof(GoSlice)); + memset(&wrong_password, 0, sizeof(GoSlice)); + memset(&encrypted, 0, sizeof(GoSlice)); + memset(&nullData, 0, sizeof(GoSlice)); + memset(&nullPassword, 0, sizeof(GoSlice)); + memset(&result, 0, sizeof(coin__UxArray)); - text.data = PLAINTEXT; - text.len = strlen(PLAINTEXT); - text.cap = text.len; - password.data = PASSWORD; - password.len = strlen(PASSWORD); - password.cap = password.len; - password2.data = PASSWORD2; - password2.len = strlen(PASSWORD2); - password2.cap = password2.len; - wrong_password.data = WRONG_PASSWORD; - wrong_password.len = strlen(WRONG_PASSWORD); - wrong_password.cap = wrong_password.len; - encrypted.data = ENCRYPTED; - encrypted.len = strlen(ENCRYPTED); - encrypted.cap = encrypted.len; + text.data = PLAINTEXT; + text.len = strlen(PLAINTEXT); + text.cap = text.len; + password.data = PASSWORD; + password.len = strlen(PASSWORD); + password.cap = password.len; + password2.data = PASSWORD2; + password2.len = strlen(PASSWORD2); + password2.cap = password2.len; + wrong_password.data = WRONG_PASSWORD; + wrong_password.len = strlen(WRONG_PASSWORD); + wrong_password.cap = wrong_password.len; + encrypted.data = ENCRYPTED; + encrypted.len = strlen(ENCRYPTED); + encrypted.cap = encrypted.len; - GoUint32 errcode; - encrypt__ScryptChacha20poly1305 encrypt = {0, 0, 0, 0}; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (coin__UxArray *)&result); - cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt failed"); - registerMemCleanup((void *)result.data); - cr_assert(eq(type(GoSlice), text, result)); - result.cap = result.len = 0; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (coin__UxArray *)&result); - cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); - result.cap = result.len = 0; - errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (coin__UxArray *)&result); - cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); + GoUint32 errcode; + encrypt__ScryptChacha20poly1305 encrypt = {0, 0, 0, 0}; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, password2, (GoSlice_ *)&result); + cr_assert(errcode == SKY_OK, "SKY_encrypt_ScryptChacha20poly1305_Decrypt failed"); + registerMemCleanup((void *)result.data); + cr_assert(eq(type(GoSlice), text, result)); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, wrong_password, (GoSlice_ *)&result); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with wrong password."); + result.cap = result.len = 0; + errcode = SKY_encrypt_ScryptChacha20poly1305_Decrypt(&encrypt, encrypted, nullPassword, (GoSlice_ *)&result); + cr_assert(errcode == SKY_ERROR, "SKY_encrypt_ScryptChacha20poly1305_Decrypt decrypted with null password."); } diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 4a89b11636..94e5d159e3 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -24,280 +24,280 @@ TestSuite(cipher_encrypt_sha256xor, .init = setup, .fini = teardown); typedef struct{ - int dataLength; - GoSlice* pwd; - GoSlice* decryptPwd; - int success; - int tampered; + int dataLength; + GoSlice* pwd; + GoSlice* decryptPwd; + int success; + int tampered; } TEST_DATA; int putUvarint(GoSlice* buf , GoUint64 x){ - int i = 0; - while( x >= 0x80 && i < buf->cap) { - ((unsigned char*)buf->data)[i] = ((GoUint8)x) | 0x80; - x >>= 7; - i++; - } - if( i < buf->cap ){ - ((unsigned char*)buf->data)[i] = (GoUint8)(x); - buf->len = i + 1; - } else { - buf->len = i; - } - return buf->len; + int i = 0; + while( x >= 0x80 && i < buf->cap) { + ((unsigned char*)buf->data)[i] = ((GoUint8)x) | 0x80; + x >>= 7; + i++; + } + if( i < buf->cap ){ + ((unsigned char*)buf->data)[i] = (GoUint8)(x); + buf->len = i + 1; + } else { + buf->len = i; + } + return buf->len; } int putVarint(GoSlice* buf , GoInt64 x){ - GoUint64 ux = (GoUint64)x << 1; - if ( x < 0 ) { - ux = ~ux; - } - return putUvarint(buf, ux); + GoUint64 ux = (GoUint64)x << 1; + if ( x < 0 ) { + ux = ~ux; + } + return putUvarint(buf, ux); } void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, - cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ - GoUint32 errcode; - int length = 32 + sizeof(cipher__SHA256); - unsigned char buff[length]; - GoSlice slice = {buff, 0, length}; - memset(buff, 0, length * sizeof(char)); - putVarint( &slice, index ); - memcpy(buff + 32, *nonceHash, sizeof(cipher__SHA256)); - slice.len = length; - cipher__SHA256 indexNonceHash; - errcode = SKY_cipher_SumSHA256(slice, &indexNonceHash); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); - SKY_cipher_AddSHA256(key.data, &indexNonceHash, resultHash); - cr_assert(errcode == SKY_OK, "SKY_cipher_AddSHA256 failed. Error adding hashes"); + cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ + GoUint32 errcode; + int length = 32 + sizeof(cipher__SHA256); + unsigned char buff[length]; + GoSlice slice = {buff, 0, length}; + memset(buff, 0, length * sizeof(char)); + putVarint( &slice, index ); + memcpy(buff + 32, *nonceHash, sizeof(cipher__SHA256)); + slice.len = length; + cipher__SHA256 indexNonceHash; + errcode = SKY_cipher_SumSHA256(slice, &indexNonceHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + SKY_cipher_AddSHA256(key.data, &indexNonceHash, resultHash); + cr_assert(errcode == SKY_OK, "SKY_cipher_AddSHA256 failed. Error adding hashes"); } void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxArray* encrypted){ - GoUint32 fullLength = dataLength + SHA256XORDATALENGTHSIZE; - GoUint32 n = fullLength / SHA256XORBLOCKSIZE; - GoUint32 m = fullLength % SHA256XORBLOCKSIZE; - GoUint32 errcode; + GoUint32 fullLength = dataLength + SHA256XORDATALENGTHSIZE; + GoUint32 n = fullLength / SHA256XORBLOCKSIZE; + GoUint32 m = fullLength % SHA256XORBLOCKSIZE; + GoUint32 errcode; - if( m > 0 ){ - fullLength += SHA256XORBLOCKSIZE - m; - } - cr_assert(SHA256XORBLOCKSIZE == sizeof(cipher__SHA256), "Size of SHA256 block size different that cipher.SHA256 struct"); - fullLength += SHA256XORBLOCKSIZE; - char* buffer = malloc(fullLength); - cr_assert(buffer != NULL, "Couldn\'t allocate buffer"); - //Add data length to the beginning, saving space for the checksum - for(int i = 0; i < SHA256XORDATALENGTHSIZE; i++){ - int shift = i * 8; - buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; - } - //Add the data - memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, - data.data, dataLength); - //Add padding - for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ - buffer[i] = 0; - } - //Buffer with space for the checksum, then data length, then data, and then padding - GoSlice _data = {buffer + SHA256XORBLOCKSIZE, - fullLength - SHA256XORBLOCKSIZE, - fullLength - SHA256XORBLOCKSIZE}; - //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; - errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); - char bufferNonce[SHA256XORNONCESIZE]; - GoSlice sliceNonce = {bufferNonce, 0, SHA256XORNONCESIZE}; - randBytes(&sliceNonce, SHA256XORNONCESIZE); - cipher__SHA256 hashNonce; - errcode = SKY_cipher_SumSHA256(sliceNonce, &hashNonce); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash for nonce"); - char bufferHash[BUFFER_SIZE]; - coin__UxArray hashPassword = {bufferHash, 0, BUFFER_SIZE}; - errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); - cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); - cipher__SHA256 h; + if( m > 0 ){ + fullLength += SHA256XORBLOCKSIZE - m; + } + cr_assert(SHA256XORBLOCKSIZE == sizeof(cipher__SHA256), "Size of SHA256 block size different that cipher.SHA256 struct"); + fullLength += SHA256XORBLOCKSIZE; + char* buffer = malloc(fullLength); + cr_assert(buffer != NULL, "Couldn\'t allocate buffer"); + //Add data length to the beginning, saving space for the checksum + for(int i = 0; i < SHA256XORDATALENGTHSIZE; i++){ + int shift = i * 8; + buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; + } + //Add the data + memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, + data.data, dataLength); + //Add padding + for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ + buffer[i] = 0; + } + //Buffer with space for the checksum, then data length, then data, and then padding + GoSlice _data = {buffer + SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE, + fullLength - SHA256XORBLOCKSIZE}; + //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; + errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); + char bufferNonce[SHA256XORNONCESIZE]; + GoSlice sliceNonce = {bufferNonce, 0, SHA256XORNONCESIZE}; + randBytes(&sliceNonce, SHA256XORNONCESIZE); + cipher__SHA256 hashNonce; + errcode = SKY_cipher_SumSHA256(sliceNonce, &hashNonce); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash for nonce"); + char bufferHash[BUFFER_SIZE]; + coin__UxArray hashPassword = {bufferHash, 0, BUFFER_SIZE}; + errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); + cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); + cipher__SHA256 h; - int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; - int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; - unsigned char* dest_buffer = malloc(fullDestLength); - cr_assert(dest_buffer != NULL, "Couldn\'t allocate result buffer"); - for(int i = 0; i < n; i++){ - hashKeyIndexNonce(hashPassword, i, &hashNonce, &h); - cipher__SHA256* pBuffer = (cipher__SHA256*)(buffer + i *SHA256XORBLOCKSIZE); - cipher__SHA256* xorResult = (cipher__SHA256*)(dest_buffer + destBufferStart + i *SHA256XORBLOCKSIZE); - SKY_cipher_SHA256_Xor(pBuffer, &h, xorResult); - } - // Prefix the nonce - memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); - // Calculates the checksum - GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), - fullLength + SHA256XORNONCESIZE, - fullLength + SHA256XORNONCESIZE - }; - cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; - errcode = SKY_cipher_SumSHA256(nonceAndDataBytes, checksum); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating final checksum"); - unsigned char bufferb64[BUFFER_SIZE]; - unsigned int size = b64_encode((const unsigned char*)dest_buffer, fullDestLength, encrypted->data); - encrypted->len = size; + int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; + unsigned char* dest_buffer = malloc(fullDestLength); + cr_assert(dest_buffer != NULL, "Couldn\'t allocate result buffer"); + for(int i = 0; i < n; i++){ + hashKeyIndexNonce(hashPassword, i, &hashNonce, &h); + cipher__SHA256* pBuffer = (cipher__SHA256*)(buffer + i *SHA256XORBLOCKSIZE); + cipher__SHA256* xorResult = (cipher__SHA256*)(dest_buffer + destBufferStart + i *SHA256XORBLOCKSIZE); + SKY_cipher_SHA256_Xor(pBuffer, &h, xorResult); + } + // Prefix the nonce + memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); + // Calculates the checksum + GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), + fullLength + SHA256XORNONCESIZE, + fullLength + SHA256XORNONCESIZE + }; + cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; + errcode = SKY_cipher_SumSHA256(nonceAndDataBytes, checksum); + cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating final checksum"); + unsigned char bufferb64[BUFFER_SIZE]; + unsigned int size = b64_encode((const unsigned char*)dest_buffer, fullDestLength, encrypted->data); + encrypted->len = size; } Test(cipher_encrypt_sha256xor, TestEncrypt){ - unsigned char buff[BUFFER_SIZE]; - unsigned char encryptedBuffer[BUFFER_SIZE]; - unsigned char encryptedText[BUFFER_SIZE]; - GoSlice data = { buff, 0, BUFFER_SIZE }; - coin__UxArray encrypted = { encryptedBuffer, 0, BUFFER_SIZE }; - GoSlice pwd1 = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; - GoSlice pwd2 = { PASSWORD2, strlen(PASSWORD2), strlen(PASSWORD2) }; - GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; - GoSlice nullPwd = {NULL, 0, 0}; - GoUint32 errcode; + unsigned char buff[BUFFER_SIZE]; + unsigned char encryptedBuffer[BUFFER_SIZE]; + unsigned char encryptedText[BUFFER_SIZE]; + GoSlice data = { buff, 0, BUFFER_SIZE }; + coin__UxArray encrypted = { encryptedBuffer, 0, BUFFER_SIZE }; + GoSlice pwd1 = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice pwd2 = { PASSWORD2, strlen(PASSWORD2), strlen(PASSWORD2) }; + GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; - TEST_DATA test_data[] = { - {1, &nullPwd, &nullPwd, 0, 0}, - {1, &pwd2, &nullPwd, 1, 0}, - {2, &pwd1, &nullPwd, 1, 0}, - {32, &pwd1, &nullPwd, 1, 0}, - {64, &pwd3, &nullPwd, 1, 0}, - {65, &pwd3, &nullPwd, 1, 0}, - }; + TEST_DATA test_data[] = { + {1, &nullPwd, &nullPwd, 0, 0}, + {1, &pwd2, &nullPwd, 1, 0}, + {2, &pwd1, &nullPwd, 1, 0}, + {32, &pwd1, &nullPwd, 1, 0}, + {64, &pwd3, &nullPwd, 1, 0}, + {65, &pwd3, &nullPwd, 1, 0}, + }; - for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ - randBytes(&data, test_data[i].dataLength); - errcode = SKY_encrypt_Sha256Xor_Encrypt(data, *(test_data[i].pwd), &encrypted); - if( test_data[i].success ){ - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); - } else { + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, test_data[i].dataLength); + errcode = SKY_encrypt_Sha256Xor_Encrypt(data, *(test_data[i].pwd), &encrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + } else { fprintf(stderr, "Errorcode %d\n", errcode); - cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); - } - if( errcode == SKY_OK ){ - cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); - cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); - ((char*)encrypted.data)[encrypted.len] = 0; + cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); + } + if( errcode == SKY_OK ){ + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; - int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; - int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; - if ( m > 0 ) { - n++; - } + int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } - int decode_length = b64_decode((const unsigned char*)encrypted.data, - encrypted.len, encryptedText); - cr_assert(decode_length >= 0, "base64_decode_string failed."); - int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert(decode_length >= 0, "base64_decode_string failed."); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); - cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); - cipher__SHA256 enc_hash; - cipher__SHA256 cal_hash; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - enc_hash[j] = (GoUint8_)encryptedText[j]; - } - int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; - GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; - SKY_cipher_SumSHA256(slice, &cal_hash); - int equal = 1; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - if(enc_hash[j] != cal_hash[j]){ - equal = 0; - break; - } - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); - } - } + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + } + } - for(int i = 33; i <= 64; i++){ - randBytes(&data, i); - errcode = SKY_encrypt_Sha256Xor_Encrypt(data, pwd1, &encrypted); - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); - cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); - cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); - ((char*)encrypted.data)[encrypted.len] = 0; + for(int i = 33; i <= 64; i++){ + randBytes(&data, i); + errcode = SKY_encrypt_Sha256Xor_Encrypt(data, pwd1, &encrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); + cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); + cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); + ((char*)encrypted.data)[encrypted.len] = 0; - int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; - int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; - if ( m > 0 ) { - n++; - } + int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; + int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; + if ( m > 0 ) { + n++; + } - int decode_length = b64_decode((const unsigned char*)encrypted.data, - encrypted.len, encryptedText); - cr_assert( decode_length >= 0, "base64_decode failed" ); - int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length + int decode_length = b64_decode((const unsigned char*)encrypted.data, + encrypted.len, encryptedText); + cr_assert( decode_length >= 0, "base64_decode failed" ); + int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); - cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); - cipher__SHA256 enc_hash; - cipher__SHA256 cal_hash; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - enc_hash[j] = (GoUint8_)encryptedText[j]; - } - int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; - GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; - SKY_cipher_SumSHA256(slice, &cal_hash); - int equal = 1; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - if(enc_hash[j] != cal_hash[j]){ - equal = 0; - break; - } - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); + cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); + cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); + cipher__SHA256 enc_hash; + cipher__SHA256 cal_hash; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + enc_hash[j] = (GoUint8_)encryptedText[j]; + } + int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; + GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; + SKY_cipher_SumSHA256(slice, &cal_hash); + int equal = 1; + for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ + if(enc_hash[j] != cal_hash[j]){ + equal = 0; + break; + } + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); - } + } } Test(cipher_encrypt_sha256xor, TestDecrypt){ - unsigned char buff[BUFFER_SIZE]; - unsigned char encrypted_buffer[BUFFER_SIZE]; - unsigned char decrypted_buffer[BUFFER_SIZE]; - GoSlice data = {buff, 0, BUFFER_SIZE}; - GoSlice pwd = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; - GoSlice wrong_pwd = { WRONGPASSWORD, strlen(WRONGPASSWORD), strlen(WRONGPASSWORD) }; - coin__UxArray encrypted = {encrypted_buffer, 0, BUFFER_SIZE}; - coin__UxArray decrypted = {decrypted_buffer, 0, BUFFER_SIZE}; - GoSlice emptyPwd = {"", 1, 1}; - GoSlice nullPwd = {NULL, 0, 0}; - GoUint32 errcode; + unsigned char buff[BUFFER_SIZE]; + unsigned char encrypted_buffer[BUFFER_SIZE]; + unsigned char decrypted_buffer[BUFFER_SIZE]; + GoSlice data = {buff, 0, BUFFER_SIZE}; + GoSlice pwd = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; + GoSlice wrong_pwd = { WRONGPASSWORD, strlen(WRONGPASSWORD), strlen(WRONGPASSWORD) }; + coin__UxArray encrypted = {encrypted_buffer, 0, BUFFER_SIZE}; + coin__UxArray decrypted = {decrypted_buffer, 0, BUFFER_SIZE}; + GoSlice emptyPwd = {"", 1, 1}; + GoSlice nullPwd = {NULL, 0, 0}; + GoUint32 errcode; - TEST_DATA test_data[] = { - {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum - {32, &pwd, &emptyPwd, 0, 0}, //Empty password - {32, &pwd, &nullPwd, 0, 0}, //Null password - {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password - }; - for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ - randBytes(&data, 32); - makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); - //SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); - cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - if( test_data[i].tampered ){ - ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; - } - errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); - if( test_data[i].success ){ - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); - } else { - cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful. %x\n",errcode); - } - } + TEST_DATA test_data[] = { + {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum + {32, &pwd, &emptyPwd, 0, 0}, //Empty password + {32, &pwd, &nullPwd, 0, 0}, //Null password + {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password + }; + for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ + randBytes(&data, 32); + makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); + //SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + if( test_data[i].tampered ){ + ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; + } + errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); + if( test_data[i].success ){ + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + } else { + cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful. %x\n",errcode); + } + } - for(int i = 0; i <= 64; i++){ - randBytes(&data, i); - //makeEncryptedData(data, i, pwd, &encrypted); - SKY_encrypt_Sha256Xor_Encrypt(data, pwd, &encrypted); - cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, pwd, &decrypted); - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); - cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); - int equal = 1; - for(int j = 0; j < data.len; j++){ - if( ((unsigned char*)data.data)[j] != ((unsigned char*)decrypted.data)[j] ) - equal = 0; - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); - } + for(int i = 0; i <= 64; i++){ + randBytes(&data, i); + //makeEncryptedData(data, i, pwd, &encrypted); + SKY_encrypt_Sha256Xor_Encrypt(data, pwd, &encrypted); + cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); + errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, pwd, &decrypted); + cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); + cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); + int equal = 1; + for(int j = 0; j < data.len; j++){ + if( ((unsigned char*)data.data)[j] != ((unsigned char*)decrypted.data)[j] ) + equal = 0; + } + cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); + } } diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 48dc17b491..cb0cb14741 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -367,4 +367,4 @@ Test(cipher_hash, TestSHA256Null) cr_assert(SKY_cipher_SumSHA256(b, &x) == SKY_OK); cr_assert(SKY_cipher_SHA256_Null(&x, &isNull) == SKY_OK); cr_assert(not(isNull)); -} \ No newline at end of file +} diff --git a/lib/cgo/tests/check_cipher.scrypt.c b/lib/cgo/tests/check_cipher.scrypt.c index 4d825c4108..fface05b85 100644 --- a/lib/cgo/tests/check_cipher.scrypt.c +++ b/lib/cgo/tests/check_cipher.scrypt.c @@ -16,149 +16,149 @@ TestSuite(cipher_scrypt, .init = setup, .fini = teardown); typedef struct { - char* password; - char* salt; - GoInt N, r, p; - GoUint8* output; - GoInt keyLength; - GoInt passwordLength; - GoInt saltLength; + char* password; + char* salt; + GoInt N, r, p; + GoUint8* output; + GoInt keyLength; + GoInt passwordLength; + GoInt saltLength; } TESTVECTOR; Test(cipher_scrypt, TestKey){ - GoUint8 g1[] = { - 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f, - 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb, - 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a, - 0xc5, 0xe5, 0xa, 0xa1, 0x5f, - }; - GoUint8 g2[] = { - 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18, - 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e, - 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5, - 0x7f, 0x91, 0x96, 0x3c, 0x37, - }; - GoUint8 g3[] = { - 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70, - 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09, - 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f, - 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98, - 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50, - 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa, - 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11, - 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40, - 0x18, 0x79, 0xe6, 0x41, 0xae, - }; - GoUint8 g4[] = { - 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98, - 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52, - }; - GoUint8 g5[] = { - 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b, - 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b, - 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa, - 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d, - 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f, - 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d, - 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89, - 0x06, - }; - GoUint8 g6[] = { - 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78, - 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a, - 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76, - 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9, - 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d, - 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, - 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, - 0x40, - }; - GoUint8 g7[] = { - 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46, - 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8, - 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43, - 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55, - 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24, - 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65, - 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58, - 0x87, - }; - TESTVECTOR good_ones[] = { - {"password", "salt", 2, 10, 10, g1, sizeof(g1) / sizeof(GoUint8), -1, -1}, - {"password", "salt", 16, 100, 100, g2, sizeof(g2) / sizeof(GoUint8), -1, -1}, - {"this is a long \000 password", - "and this is a long \000 salt", - 16384, 8, 1, g3, sizeof(g3) / sizeof(GoUint8), 25, 25}, - {"p", "s", 2, 1, 1, g4, sizeof(g4) / sizeof(GoUint8), -1, -1}, - {"", "", 16, 1, 1, g5, sizeof(g5) / sizeof(GoUint8), -1, -1}, - {"password", "NaCl", 1024, 8, 16, g6, sizeof(g6) / sizeof(GoUint8), -1, -1}, - {"pleaseletmein", "SodiumChloride", 16384, 8, 1, g7, sizeof(g7) / sizeof(GoUint8), -1, -1}, - }; - - GoInt32 maxInt = (GoInt32)(~((GoUint32)0) >> 1); - - TESTVECTOR bad_ones[] = { - {"p", "s", 0, 1, 1, NULL, -1, -1}, // N == 0 - {"p", "s", 1, 1, 1, NULL, -1, -1}, // N == 1 - {"p", "s", 7, 8, 1, NULL, -1, -1}, // N is not power of 2 - {"p", "s", 16, maxInt / 2, maxInt / 2, NULL, -1, -1}, // p * r too large - }; - - GoUint32 errcode; - GoSlice password; - GoSlice salt; - GoUint8 buffer[BUFFER_SIZE]; - coin__UxArray key = {buffer, 0, BUFFER_SIZE}; - - int good_ones_count = sizeof(good_ones) / sizeof(good_ones[0]); - int bad_ones_count = sizeof(bad_ones) / sizeof(bad_ones[0]); - for(int i = 0; i < good_ones_count; i++){ - password.data = good_ones[i].password; - if( good_ones[i].passwordLength < 0) - password.len = strlen(good_ones[i].password); - else - password.len = good_ones[i].passwordLength; - password.cap = password.len; - - salt.data = good_ones[i].salt; - if( good_ones[i].saltLength < 0) - salt.len = strlen(good_ones[i].salt); - else - salt.len = good_ones[i].saltLength; - salt.cap = salt.len; - - errcode = SKY_scrypt_Key(password, salt, - good_ones[i].N, good_ones[i].r, good_ones[i].p, - good_ones[i].keyLength, &key); - cr_assert(errcode == SKY_OK, "SKY_scrypt_Key failed"); - cr_assert(good_ones[i].keyLength == key.len, "SKY_scrypt_Key failed, incorrect generated key length."); - int equal = 1; - for(int j = 0; j < key.len; j++){ - if( ((GoUint8*)key.data)[j] != good_ones[i].output[j]){ - equal = 0; - } - } - cr_assert(equal == 1, "SKY_scrypt_Key failed. Invalid key generated."); - } - - for(int i = 0; i < bad_ones_count; i++){ - password.data = bad_ones[i].password; - if( bad_ones[i].passwordLength < 0) - password.len = strlen(bad_ones[i].password); - else - password.len = bad_ones[i].passwordLength; - password.cap = password.len; - - salt.data = bad_ones[i].salt; - if( bad_ones[i].saltLength < 0) - salt.len = strlen(bad_ones[i].salt); - else - salt.len = bad_ones[i].saltLength; - salt.cap = salt.len; - - errcode = SKY_scrypt_Key(password, salt, - bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, - bad_ones[i].keyLength, &key); - cr_assert(errcode == SKY_ERROR, "SKY_scrypt_Key didn\'t failed"); - } -} \ No newline at end of file + GoUint8 g1[] = { + 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f, + 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb, + 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a, + 0xc5, 0xe5, 0xa, 0xa1, 0x5f, + }; + GoUint8 g2[] = { + 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18, + 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e, + 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5, + 0x7f, 0x91, 0x96, 0x3c, 0x37, + }; + GoUint8 g3[] = { + 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70, + 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09, + 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f, + 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98, + 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50, + 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa, + 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11, + 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40, + 0x18, 0x79, 0xe6, 0x41, 0xae, + }; + GoUint8 g4[] = { + 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98, + 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52, + }; + GoUint8 g5[] = { + 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b, + 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b, + 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa, + 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d, + 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f, + 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d, + 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89, + 0x06, + }; + GoUint8 g6[] = { + 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78, + 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a, + 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76, + 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9, + 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d, + 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, + 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, + 0x40, + }; + GoUint8 g7[] = { + 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46, + 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8, + 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43, + 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55, + 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24, + 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65, + 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58, + 0x87, + }; + TESTVECTOR good_ones[] = { + {"password", "salt", 2, 10, 10, g1, sizeof(g1) / sizeof(GoUint8), -1, -1}, + {"password", "salt", 16, 100, 100, g2, sizeof(g2) / sizeof(GoUint8), -1, -1}, + {"this is a long \000 password", + "and this is a long \000 salt", + 16384, 8, 1, g3, sizeof(g3) / sizeof(GoUint8), 25, 25}, + {"p", "s", 2, 1, 1, g4, sizeof(g4) / sizeof(GoUint8), -1, -1}, + {"", "", 16, 1, 1, g5, sizeof(g5) / sizeof(GoUint8), -1, -1}, + {"password", "NaCl", 1024, 8, 16, g6, sizeof(g6) / sizeof(GoUint8), -1, -1}, + {"pleaseletmein", "SodiumChloride", 16384, 8, 1, g7, sizeof(g7) / sizeof(GoUint8), -1, -1}, + }; + + GoInt32 maxInt = (GoInt32)(~((GoUint32)0) >> 1); + + TESTVECTOR bad_ones[] = { + {"p", "s", 0, 1, 1, NULL, -1, -1}, // N == 0 + {"p", "s", 1, 1, 1, NULL, -1, -1}, // N == 1 + {"p", "s", 7, 8, 1, NULL, -1, -1}, // N is not power of 2 + {"p", "s", 16, maxInt / 2, maxInt / 2, NULL, -1, -1}, // p * r too large + }; + + GoUint32 errcode; + GoSlice password; + GoSlice salt; + GoUint8 buffer[BUFFER_SIZE]; + coin__UxArray key = {buffer, 0, BUFFER_SIZE}; + + int good_ones_count = sizeof(good_ones) / sizeof(good_ones[0]); + int bad_ones_count = sizeof(bad_ones) / sizeof(bad_ones[0]); + for(int i = 0; i < good_ones_count; i++){ + password.data = good_ones[i].password; + if( good_ones[i].passwordLength < 0) + password.len = strlen(good_ones[i].password); + else + password.len = good_ones[i].passwordLength; + password.cap = password.len; + + salt.data = good_ones[i].salt; + if( good_ones[i].saltLength < 0) + salt.len = strlen(good_ones[i].salt); + else + salt.len = good_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + good_ones[i].N, good_ones[i].r, good_ones[i].p, + good_ones[i].keyLength, &key); + cr_assert(errcode == SKY_OK, "SKY_scrypt_Key failed"); + cr_assert(good_ones[i].keyLength == key.len, "SKY_scrypt_Key failed, incorrect generated key length."); + int equal = 1; + for(int j = 0; j < key.len; j++){ + if( ((GoUint8*)key.data)[j] != good_ones[i].output[j]){ + equal = 0; + } + } + cr_assert(equal == 1, "SKY_scrypt_Key failed. Invalid key generated."); + } + + for(int i = 0; i < bad_ones_count; i++){ + password.data = bad_ones[i].password; + if( bad_ones[i].passwordLength < 0) + password.len = strlen(bad_ones[i].password); + else + password.len = bad_ones[i].passwordLength; + password.cap = password.len; + + salt.data = bad_ones[i].salt; + if( bad_ones[i].saltLength < 0) + salt.len = strlen(bad_ones[i].salt); + else + salt.len = bad_ones[i].saltLength; + salt.cap = salt.len; + + errcode = SKY_scrypt_Key(password, salt, + bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, + bad_ones[i].keyLength, &key); + cr_assert(errcode == SKY_ERROR, "SKY_scrypt_Key didn\'t failed"); + } +} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index 44722a9a0e..a136350245 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -18,939 +18,939 @@ TestSuite(cipher_secp256k1, .init = setup, .fini = teardown); int keys_count = 4; const char *test_keys[] = { - "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", - "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", - "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", - "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", + "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", + "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", + "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", + "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", }; Test(cipher_secp256k1, Test_Secp256_00) { - unsigned char buff[SigSize]; - visor__ReadableOutputs nonce = {buff, 0, 64}; - SKY_secp256k1_RandByte(32, &nonce); - if (nonce.len != 32) - cr_fatal(); + unsigned char buff[SigSize]; + visor__ReadableOutputs nonce = {buff, 0, 64}; + SKY_secp256k1_RandByte(32, &nonce); + if (nonce.len != 32) + cr_fatal(); } Test(cipher_secp256k1, Test_Secp256_01) { - cipher__PubKey pubkey; - cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - GoInt errorSecKey; - char bufferSecKey[101]; - strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; - SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); - if (!errorSecKey) - cr_fatal(); - - GoInt errorPubKey; - GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); - if (!errorPubKey) - cr_fatal(); + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; + SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); + if (!errorSecKey) + cr_fatal(); + + GoInt errorPubKey; + GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); + if (!errorPubKey) + cr_fatal(); } Test(cipher_secp256k1, TestPubkeyFromSeckey) { - unsigned char bufferPrivkey[BUFFER_SIZE]; - unsigned char bufferDesiredPubKey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; - const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char *hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; + const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char *hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; - int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); - int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; - GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; + GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; + GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; - visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; + visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey, &pubkey); - if (errocode) - cr_fatal(); + GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey, &pubkey); + if (errocode) + cr_fatal(); - cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); + cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); } Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) { - unsigned char bufferPrivkey[BUFFER_SIZE]; - unsigned char bufferDesiredPubKey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; + unsigned char bufferPrivkey[BUFFER_SIZE]; + unsigned char bufferDesiredPubKey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; - const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char *hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; + const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; + const char *hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; - int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); - int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); + int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); + int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; - GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; + GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; + GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; - visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; + visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey, &pubkey); - if (errocode) - cr_fatal(); + GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey, &pubkey); + if (errocode) + cr_fatal(); - cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); + cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); } Test(cipher_secp256k1, Test_SignatureVerifyPubkey) { - unsigned char buff[SigSize]; - char sigBuffer[BUFFER_SIZE]; - cipher__PubKey pubkey; - cipher__SecKey seckey; - cipher__PubKey recoveredPubkey; - GoInt32 error_code; - GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pubKeySlice, (coin__UxArray *)&secKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - - GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); - GoInt result = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); - cr_assert(result == 1, "Public key not verified"); - SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&recoveredPubKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pubKeySlice, (GoSlice_ *)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + + GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); + GoInt result = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&recoveredPubKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); } Test(cipher_secp256k1, Test_verify_functions) { - unsigned char buff[SigSize]; - char sigBuffer[BUFFER_SIZE]; - cipher__PubKey pubkey; - cipher__SecKey seckey; - cipher__PubKey recoveredPubkey; - GoInt32 error_code; - GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pubKeySlice, (coin__UxArray *)&secKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); - GoInt result = 0; - - error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySeckey failed"); - cr_assert(result == 1, "Sec key not verified"); - - error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); - cr_assert(result == 1, "Public key not verified"); - - error_code = SKY_secp256k1_VerifySignature(msg, sig, pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result == 1, "Signature not verified"); + unsigned char buff[SigSize]; + char sigBuffer[BUFFER_SIZE]; + cipher__PubKey pubkey; + cipher__SecKey seckey; + cipher__PubKey recoveredPubkey; + GoInt32 error_code; + GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + + error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pubKeySlice, (GoSlice_ *)&secKeySlice); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + GoSlice msg = {buff, 0, SigSize}; + SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + + GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; + SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); + GoInt result = 0; + + error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySeckey failed"); + cr_assert(result == 1, "Sec key not verified"); + + error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); + cr_assert(result == 1, "Public key not verified"); + + error_code = SKY_secp256k1_VerifySignature(msg, sig, pubKeySlice, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result == 1, "Signature not verified"); } Test(cipher_secp256k1, Test_SignatureVerifySecKey) { - cipher__PubKey pubkey; - cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - GoInt errorSecKey; - char bufferSecKey[101]; - strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; - SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); - cr_assert(errorSecKey == 1); - GoInt errorPubKey; - GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); - cr_assert(errorPubKey == 1); + cipher__PubKey pubkey; + cipher__SecKey seckey; + SKY_cipher_GenerateKeyPair(&pubkey, &seckey); + GoInt errorSecKey; + char bufferSecKey[101]; + strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; + SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); + cr_assert(errorSecKey == 1); + GoInt errorPubKey; + GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); + cr_assert(errorPubKey == 1); } //test size of messages Test(cipher_secp256k1, Test_Secp256_02s) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); - cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last <= 4); + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); + cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last <= 4); } //test signing message Test(cipher_secp256k1, Test_Secp256_02) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); } //test pubkey recovery Test(cipher_secp256k1, Test_Secp256_02a) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + GoInt result; + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); + cr_assert(result, "Signature invalid"); + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); } //test random messages for the same pub/private key Test(cipher_secp256k1, Test_Secp256_03) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - } + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; + + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + } } //test random messages for different pub/private keys Test(cipher_secp256k1, Test_Secp256_04) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last < 4); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - } + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + unsigned char last = ((unsigned char *)sig.data)[64]; + cr_assert(last < 4); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(pub2.len > 0, "Invalid public key"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + } } GoInt randSig(GoSlice *sig) { - GoInt error_code; - error_code = SKY_secp256k1_RandByte(65, (GoSlice_ *) sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", - sig->len); - ((unsigned char *)sig->data)[32] = ((unsigned char *)sig->data)[32] & 0x70; - ((unsigned char *)sig->data)[64] = ((unsigned char *)sig->data)[64] % 4; - return error_code; + GoInt error_code; + error_code = SKY_secp256k1_RandByte(65, (GoSlice_ *) sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", + sig->len); + ((unsigned char *)sig->data)[32] = ((unsigned char *)sig->data)[32] & 0x70; + ((unsigned char *)sig->data)[64] = ((unsigned char *)sig->data)[64] % 4; + return error_code; } Test(cipher_secp256k1, Test_Secp256_06a_alt0) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - char bufferSig2[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice sig2 = {bufferSig2, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - GoInt code; - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - for (int i = 0; i < TESTS; i++) - { - char bufferPub2[BUFFER_SIZE]; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoInt result; - randSig(&sig2); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); - if (pub2.len != 0) { - error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); - cr_assert(result == 1); - } - error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub1, &result); - cr_assert(result != 1); - } + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + char bufferSig2[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice sig2 = {bufferSig2, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + GoInt code; + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + cr_assert(sig.len == 65, "Signature should be 65 bytes long."); + + for (int i = 0; i < TESTS; i++) + { + char bufferPub2[BUFFER_SIZE]; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoInt result; + randSig(&sig2); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); + if (pub2.len != 0) { + error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); + cr_assert(result == 1); + } + error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub1, &result); + cr_assert(result != 1); + } } Test(cipher_secp256k1, Test_Secp256_06b) { - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair((coin__UxArray *)&pub1, (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - - GoInt result; - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (coin__UxArray *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); - cr_assert(pub2.len == 0 || result, "Public key is not valid"); - SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(result == 0, "Public key should not be valid"); - } + GoInt32 error_code; + char bufferPub1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSig1[BUFFER_SIZE]; + unsigned char buff[32]; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; + GoSlice msg = {buff, 0, 32}; + + error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); + + GoInt result; + for (int i = 0; i < TESTS; i++) + { + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); + cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); + error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); + cr_assert(pub2.len == 0 || result, "Public key is not valid"); + SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); + cr_assert(result == 0, "Public key should not be valid"); + } } Test(cipher_secp256k1, Test_Deterministic_Keypairs_00) { - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&hash, + (GoSlice_ *)&pub1, + (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (GoSlice_ *)&pub2, + (GoSlice_ *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } } Test(cipher_secp256k1, Test_Deterministic_Keypairs_01) { - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&hash, + (GoSlice_ *)&pub1, + (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (GoSlice_ *)&pub2, + (GoSlice_ *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } } Test(cipher_secp256k1, Test_Deterministic_Keypairs_02) { - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash, - (coin__UxArray *)&pub1, - (coin__UxArray *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&pub2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } + char bufferSeed[BUFFER_SIZE]; + char bufferHash[BUFFER_SIZE]; + char bufferPub1[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferPub2[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; + GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&hash, + (GoSlice_ *)&pub1, + (GoSlice_ *)&sec1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (GoSlice_ *)&pub2, + (GoSlice_ *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); + cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); + } } Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) { - int test_count = 16; - const char *testArray[] = { - "tQ93w5Aqcunm9SGUfnmF4fJv", - "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", - "DC7qdQQtbWSSaekXnFmvQgse", - "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", - "X8EkuUZC7Td7PAXeS7Duc7vR", - "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", - "tVqPYHHNVPRWyEed62v7f23u", - "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", - "kCy4R57HDfLqF3pVhBWxuMcg", - "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", - "j8bjv86ZNjKqzafR6mtSUVCE", - "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", - "qShryAzVY8EtsuD3dsAc7qnG", - "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", - "5FGG7ZBa8wVMBJkmzpXj5ESX", - "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", - "f46TZG4xJHXUGWx8ekbNqa9F", - "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", - "XkZdQJ5LT96wshN8JBH8rvEt", - "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", - "GFDqXU4zYymhJJ9UGqRgS8ty", - "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", - "tmwZksH2XyvuamnddYxyJ5Lp", - "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", - "EuqZFsbAV5amTzkhgAMgjr7W", - "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", - "TW6j8rMffZfmhyDEt2JUCrLB", - "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", - "8rvkBnygfhWP8kjX9aXq68CY", - "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", - "phyRfPDuf9JMRFaWdGh7NXPX", - "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", - }; - - GoInt32 error_code; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {NULL, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.data = (void *)testArray[2 * i]; - seed.len = strlen(testArray[2 * i]); - seed.cap = seed.len; - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&s1, (coin__UxArray *)&s2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } + int test_count = 16; + const char *testArray[] = { + "tQ93w5Aqcunm9SGUfnmF4fJv", + "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", + "DC7qdQQtbWSSaekXnFmvQgse", + "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", + "X8EkuUZC7Td7PAXeS7Duc7vR", + "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", + "tVqPYHHNVPRWyEed62v7f23u", + "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", + "kCy4R57HDfLqF3pVhBWxuMcg", + "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", + "j8bjv86ZNjKqzafR6mtSUVCE", + "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", + "qShryAzVY8EtsuD3dsAc7qnG", + "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", + "5FGG7ZBa8wVMBJkmzpXj5ESX", + "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", + "f46TZG4xJHXUGWx8ekbNqa9F", + "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", + "XkZdQJ5LT96wshN8JBH8rvEt", + "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", + "GFDqXU4zYymhJJ9UGqRgS8ty", + "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", + "tmwZksH2XyvuamnddYxyJ5Lp", + "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", + "EuqZFsbAV5amTzkhgAMgjr7W", + "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", + "TW6j8rMffZfmhyDEt2JUCrLB", + "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", + "8rvkBnygfhWP8kjX9aXq68CY", + "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", + "phyRfPDuf9JMRFaWdGh7NXPX", + "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", + }; + + GoInt32 error_code; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {NULL, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + seed.data = (void *)testArray[2 * i]; + seed.len = strlen(testArray[2 * i]); + seed.cap = seed.len; + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&s1, (GoSlice_ *)&s2, + (GoSlice_ *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } } Test(cipher_secp256k1, Test_DeterministicWallets1) { - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", - }; - GoInt32 error_code; - char bufferSeed[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&s1, (coin__UxArray *)&s2, - (coin__UxArray *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } + int test_count = 16; + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", + }; + GoInt32 error_code; + char bufferSeed[BUFFER_SIZE]; + char bufferSec1[BUFFER_SIZE]; + char bufferSec2[BUFFER_SIZE]; + char buffer1[BUFFER_SIZE]; + char buffer2[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; + GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; + GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; + GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&s1, (GoSlice_ *)&s2, + (GoSlice_ *)&sec2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); + } } Test(cipher_secp256k1, Test_Secp256k1_Hash) { - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", - }; - GoInt32 error_code; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferHash3[BUFFER_SIZE]; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); - hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); - error_code = SKY_secp256k1_Secp256k1Hash(hash1, (coin__UxArray *)&hash3); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); - } + int test_count = 16; + const char *testArray[] = { + "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", + "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", + "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", + "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", + "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", + "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", + "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", + "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", + "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", + "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", + "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", + "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", + "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", + "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", + "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", + "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", + "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", + "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", + "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", + "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", + "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", + "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", + "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", + "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", + "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", + "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", + "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", + "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", + "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", + "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", + "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", + "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", + }; + GoInt32 error_code; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferHash3[BUFFER_SIZE]; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; + + for (int i = 0; i < test_count; i++) + { + hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); + hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); + error_code = SKY_secp256k1_Secp256k1Hash(hash1, (GoSlice_ *)&hash3); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); + } } Test(cipher_secp256k1, Test_Secp256k1_Equal) { - char bufferSeed[BUFFER_SIZE]; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(128, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Secp256k1Hash(seed, (coin__UxArray *)&hash1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&hash2, - (coin__UxArray *)&public, - (coin__UxArray *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); - } + char bufferSeed[BUFFER_SIZE]; + char bufferHash1[BUFFER_SIZE]; + char bufferHash2[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; + GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 64; i++) + { + error_code = SKY_secp256k1_RandByte(128, (GoSlice_ *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); + error_code = SKY_secp256k1_Secp256k1Hash(seed, (GoSlice_ *)&hash1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&hash2, + (GoSlice_ *)&public, + (GoSlice_ *)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); + } } Test(cipher_secp256k1, Test_DeterministicWalletGeneration) { - const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; - const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; - const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; - - char bufferSeed[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - char bufferNewSeed[BUFFER_SIZE]; - char bufferPrivateExpected[BUFFER_SIZE]; - char bufferPublicExpected[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; - GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; - GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; - - strcpy(bufferSeed, pSeed); - seed.len = strlen(pSeed); - - GoInt32 error_code; - - for (int i = 0; i < 1024; i++) - { - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (coin__UxArray *)&newSeed, - (coin__UxArray *)&public, - (coin__UxArray *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - memcpy(seed.data, newSeed.data, newSeed.len); - seed.len = newSeed.len; - } - - privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); - publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); - - cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); - cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); + const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; + const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; + const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; + + char bufferSeed[BUFFER_SIZE]; + char bufferPrivate[BUFFER_SIZE]; + char bufferPublic[BUFFER_SIZE]; + char bufferNewSeed[BUFFER_SIZE]; + char bufferPrivateExpected[BUFFER_SIZE]; + char bufferPublicExpected[BUFFER_SIZE]; + + GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; + GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; + GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; + GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; + GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; + GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; + + strcpy(bufferSeed, pSeed); + seed.len = strlen(pSeed); + + GoInt32 error_code; + + for (int i = 0; i < 1024; i++) + { + error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, + (GoSlice_ *)&newSeed, + (GoSlice_ *)&public, + (GoSlice_ *)&private); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); + memcpy(seed.data, newSeed.data, newSeed.len); + seed.len = newSeed.len; + } + + privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); + publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); + + cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); + cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); } Test(cipher_secp256k1, Test_ECDH) { - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pubKeySlice1, (GoSlice_ *)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pubKeySlice2, (GoSlice_ *)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (GoSlice_ *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (GoSlice_ *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); } Test(cipher_secp256k1, Test_ECDH2) { - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice1, (coin__UxArray *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (coin__UxArray *)&pubKeySlice2, (coin__UxArray *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } + cipher__PubKey pubkey1; + cipher__SecKey seckey1; + cipher__PubKey pubkey2; + cipher__SecKey seckey2; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + GoInt32 error_code; + GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; + GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + + for (int i = 0; i < 32; i++) + { + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pubKeySlice1, (GoSlice_ *)&secKeySlice1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + error_code = SKY_secp256k1_GenerateKeyPair( + (GoSlice_ *)&pubKeySlice2, (GoSlice_ *)&secKeySlice2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); + + SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (GoSlice_ *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (GoSlice_ *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } } Test(cipher_secp256k1, Test_Abnormal_Keys) { - char seedBuffer[64]; - GoSlice seed = {seedBuffer, 0, 64}; - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_RandByte(32, (coin__UxArray *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (coin__UxArray *)&privatekey, (coin__UxArray *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } + char seedBuffer[64]; + GoSlice seed = {seedBuffer, 0, 64}; + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < 32; i++) + { + error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); + error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, + (GoSlice_ *)&privatekey, (GoSlice_ *)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } } Test(cipher_secp256k1, Test_Abnormal_Keys2) { - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); - privatekey.len = sizePrivatekey; - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (coin__UxArray *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } + unsigned char bufferPrivatekey[BUFFER_SIZE]; + unsigned char bufferPubKey[BUFFER_SIZE]; + + GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; + GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < keys_count; i++) + { + int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); + privatekey.len = sizePrivatekey; + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (GoSlice_ *)&pubKey); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + GoInt verified = 0; + error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); + cr_assert(verified != 0, "Failed verifying key"); + } } Test(cipher_secp256k1, Test_Abnormal_Keys3) { - unsigned char bufferPrivatekey1[BUFFER_SIZE]; - unsigned char bufferPubKey1[BUFFER_SIZE]; - unsigned char bufferPrivatekey2[BUFFER_SIZE]; - unsigned char bufferPubKey2[BUFFER_SIZE]; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - int sizePrivatekey1, sizePrivatekey2; - int sizePubKey1, sizePubKey2; - GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; - GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; - GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; - GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int randn = rand() % keys_count; - sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); - sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); - privatekey1.len = sizePrivatekey1; - privatekey2.len = sizePrivatekey2; - - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (coin__UxArray *)&pubKey1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (coin__UxArray *)&pubKey2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - - SKY_secp256k1_ECDH(pubKey1, privatekey2, (coin__UxArray *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKey2, privatekey1, (coin__UxArray *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } + unsigned char bufferPrivatekey1[BUFFER_SIZE]; + unsigned char bufferPubKey1[BUFFER_SIZE]; + unsigned char bufferPrivatekey2[BUFFER_SIZE]; + unsigned char bufferPubKey2[BUFFER_SIZE]; + unsigned char bufferECDH1[BUFFER_SIZE]; + unsigned char bufferECDH2[BUFFER_SIZE]; + + int sizePrivatekey1, sizePrivatekey2; + int sizePubKey1, sizePubKey2; + GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; + GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; + GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; + GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; + GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; + GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; + GoInt32 error_code; + + for (int i = 0; i < keys_count; i++) + { + int randn = rand() % keys_count; + sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); + sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); + privatekey1.len = sizePrivatekey1; + privatekey2.len = sizePrivatekey2; + + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (GoSlice_ *)&pubKey1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (GoSlice_ *)&pubKey2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); + cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); + + SKY_secp256k1_ECDH(pubKey1, privatekey2, (GoSlice_ *)&ecdh1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + SKY_secp256k1_ECDH(pubKey2, privatekey1, (GoSlice_ *)&ecdh2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); + + cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); + } } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c index 396425e90a..0d997a2e99 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c @@ -32,120 +32,120 @@ TestSuite(cipher_secp256k1_xyz, .init = setup, .fini = teardown); Test(cipher_secp256k1_xyz, TestXYZECMult){ - secp256k1go__XYZ pubkey; //pubkey - secp256k1go__XYZ pr; //result of ECmult - secp256k1go__XYZ e; //expected - Number_Handle u1, u2; - secp256k1go__Field x, y, z; - - GoInt32 error_code; - memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); - memset(&pr, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - u1 = 0; - u2 = 0; - memset(&x, 0, sizeof(secp256k1go__Field)); - memset(&y, 0, sizeof(secp256k1go__Field)); - memset(&z, 0, sizeof(secp256k1go__Field)); - - GoString strAx = {AX, strlen(AX)}; - GoString strAy = {AY, strlen(AY)}; - GoString strAz = {AZ, strlen(AZ)}; - - GoString strEx = {EX, strlen(EX)}; - GoString strEy = {EY, strlen(EY)}; - GoString strEz = {EZ, strlen(EZ)}; - - GoString strU1 = {U1, strlen(U1)}; - GoString strU2 = {U2, strlen(U2)}; - - error_code = SKY_secp256k1go_Number_Create(&u1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(u1); - - error_code = SKY_secp256k1go_Number_Create(&u2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(u2); - - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Number_SetHex(u1, strU1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - error_code = SKY_secp256k1go_Number_SetHex(u2, strU2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, u2, u1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); - - GoInt8 equal = 0; - error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number_Handle u1, u2; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + u1 = 0; + u2 = 0; + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + GoString strU1 = {U1, strlen(U1)}; + GoString strU2 = {U2, strlen(U2)}; + + error_code = SKY_secp256k1go_Number_Create(&u1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(u1); + + error_code = SKY_secp256k1go_Number_Create(&u2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(u2); + + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Number_SetHex(u1, strU1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + error_code = SKY_secp256k1go_Number_SetHex(u2, strU2); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, u2, u1); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); } Test(cipher_secp256k1_xyz, TestXYZECMultGen){ - secp256k1go__XYZ pubkey; //pubkey - secp256k1go__XYZ pr; //result of ECmult - secp256k1go__XYZ e; //expected - Number_Handle nonce; - secp256k1go__Field x, y, z; - - GoInt32 error_code; - memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); - memset(&pr, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - nonce = 0; - memset(&x, 0, sizeof(secp256k1go__Field)); - memset(&y, 0, sizeof(secp256k1go__Field)); - memset(&z, 0, sizeof(secp256k1go__Field)); - - GoString strNonce = {NONCE, strlen(NONCE)}; - GoString strEx = {E2X, strlen(E2X)}; - GoString strEy = {E2Y, strlen(E2Y)}; - GoString strEz = {E2Z, strlen(E2Z)}; - - error_code = SKY_secp256k1go_Number_Create(&nonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(nonce); - - error_code = SKY_secp256k1go_Number_SetHex(nonce, strNonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - - error_code = SKY_secp256k1go_ECmultGen(&pr, nonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - - GoInt8 equal = 0; - error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); - error_code = SKY_secp256k1go_Field_Equals(&pr.Y, &y, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Y is different than expected"); - error_code = SKY_secp256k1go_Field_Equals(&pr.Z, &z, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); + secp256k1go__XYZ pubkey; //pubkey + secp256k1go__XYZ pr; //result of ECmult + secp256k1go__XYZ e; //expected + Number_Handle nonce; + secp256k1go__Field x, y, z; + + GoInt32 error_code; + memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); + memset(&pr, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + nonce = 0; + memset(&x, 0, sizeof(secp256k1go__Field)); + memset(&y, 0, sizeof(secp256k1go__Field)); + memset(&z, 0, sizeof(secp256k1go__Field)); + + GoString strNonce = {NONCE, strlen(NONCE)}; + GoString strEx = {E2X, strlen(E2X)}; + GoString strEy = {E2Y, strlen(E2Y)}; + GoString strEz = {E2Z, strlen(E2Z)}; + + error_code = SKY_secp256k1go_Number_Create(&nonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(nonce); + + error_code = SKY_secp256k1go_Number_SetHex(nonce, strNonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); + + error_code = SKY_secp256k1go_ECmultGen(&pr, nonce); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Y, &y, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Y is different than expected"); + error_code = SKY_secp256k1go_Field_Equals(&pr.Z, &z, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c index e271c36c42..4b64688262 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c @@ -17,25 +17,25 @@ TestSuite(cipher_secp256k1_field, .init = setup, .fini = teardown); Test(cipher_secp256k1_field, TestFieldInv){ - secp256k1go__Field in; - secp256k1go__Field out; - secp256k1go__Field expected; - - memset(&in, 0, sizeof(secp256k1go__Field)); - memset(&out, 0, sizeof(secp256k1go__Field)); - memset(&expected, 0, sizeof(secp256k1go__Field)); - - GoUint32 error_code; - GoInt8 equal = 0; - - GoString InStr = {INHEX, strlen(INHEX)}; - GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; - error_code = SKY_secp256k1go_Field_SetHex(&in, InStr); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected, ExpStr); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_Inv(&in, &out); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Inv failed"); - error_code = SKY_secp256k1go_Field_Equals(&out, &expected, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Field_Inv failed, result is different than expected."); -} \ No newline at end of file + secp256k1go__Field in; + secp256k1go__Field out; + secp256k1go__Field expected; + + memset(&in, 0, sizeof(secp256k1go__Field)); + memset(&out, 0, sizeof(secp256k1go__Field)); + memset(&expected, 0, sizeof(secp256k1go__Field)); + + GoUint32 error_code; + GoInt8 equal = 0; + + GoString InStr = {INHEX, strlen(INHEX)}; + GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; + error_code = SKY_secp256k1go_Field_SetHex(&in, InStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected, ExpStr); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_Inv(&in, &out); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Inv failed"); + error_code = SKY_secp256k1go_Field_Equals(&out, &expected, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Field_Inv failed, result is different than expected."); +} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index 7cfcb0ab07..4f62dea557 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -14,104 +14,104 @@ #define BUFFER_SIZE 1024 #define R1 "6028b9e3a31c9e725fcbd7d5d16736aaaafcc9bf157dfb4be62bcbcf0969d488" -#define S1 "036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a" +#define S1 "036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a" #define MSG1 "9cff3da1a4f86caf3683f865232c64992b5ed002af42b321b8d8a48420680487" #define X1 "56dc5df245955302893d8dda0677cc9865d8011bc678c7803a18b5f6faafec08" -#define Y1 "54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6" +#define Y1 "54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6" #define R2 "b470e02f834a3aaafa27bd2b49e07269e962a51410f364e9e195c31351a05e50" -#define S2 "560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09" +#define S2 "560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09" #define MSG2 "9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6" #define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" -#define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" +#define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" #define forceLowS true TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); Test(cipher_secp256k1_sig, TestSigRecover){ - GoUint32 error_code; - Signature_Handle sig; - Number_Handle msg; - secp256k1go__XY pubKey; - secp256k1go__XY expected; - - memset(&pubKey, 0, sizeof(secp256k1go__XY)); - memset(&expected, 0, sizeof(secp256k1go__XY)); - sig = 0; - msg = 0; - - GoString R = {R1, strlen(R1)}; - GoString S = {S1, strlen(S1)}; - GoString MSG = {MSG1, strlen(MSG1)}; - GoString X = {X1, strlen(X1)}; - GoString Y = {Y1, strlen(Y1)}; - GoInt rid = 0; - GoInt8 result; - - error_code = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); - Number_Handle r; - error_code = SKY_secp256k1go_Signature_GetR(sig, &r); - registerHandleClose(r); - Number_Handle s; - error_code = SKY_secp256k1go_Signature_GetS(sig, &s); - registerHandleClose(s); - error_code = SKY_secp256k1go_Number_Create(&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - error_code = SKY_secp256k1go_Number_SetHex(r, R); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(s, S); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - - error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); - cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - - cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); - cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); - - R.p = R2; - R.n = strlen(R2); - S.p = S2; - S.n = strlen(S2); - MSG.p = MSG2; - MSG.n = strlen(MSG2); - X.p = X2; - X.n = strlen(X2); - Y.p = Y2; - Y.n = strlen(Y2); - rid = 1; - - error_code = SKY_secp256k1go_Number_SetHex(r, R); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(s, S); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - - error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); - cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - - GoInt8 equal; - error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); - SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); + GoUint32 error_code; + Signature_Handle sig; + Number_Handle msg; + secp256k1go__XY pubKey; + secp256k1go__XY expected; + + memset(&pubKey, 0, sizeof(secp256k1go__XY)); + memset(&expected, 0, sizeof(secp256k1go__XY)); + sig = 0; + msg = 0; + + GoString R = {R1, strlen(R1)}; + GoString S = {S1, strlen(S1)}; + GoString MSG = {MSG1, strlen(MSG1)}; + GoString X = {X1, strlen(X1)}; + GoString Y = {Y1, strlen(Y1)}; + GoInt rid = 0; + GoInt8 result; + + error_code = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); + Number_Handle r; + error_code = SKY_secp256k1go_Signature_GetR(sig, &r); + registerHandleClose(r); + Number_Handle s; + error_code = SKY_secp256k1go_Signature_GetS(sig, &s); + registerHandleClose(s); + error_code = SKY_secp256k1go_Number_Create(&msg); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); + + error_code = SKY_secp256k1go_Number_SetHex(r, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(s, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); + cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); + + R.p = R2; + R.n = strlen(R2); + S.p = S2; + S.n = strlen(S2); + MSG.p = MSG2; + MSG.n = strlen(MSG2); + X.p = X2; + X.n = strlen(X2); + Y.p = Y2; + Y.n = strlen(Y2); + rid = 1; + + error_code = SKY_secp256k1go_Number_SetHex(r, R); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); + error_code = SKY_secp256k1go_Number_SetHex(s, S); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); + error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); + error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); + + error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); + cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); + + GoInt8 equal; + error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); + SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); + cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); } Test(cipher_secp256k1_sig, TestSigVerify) { @@ -123,20 +123,20 @@ Test(cipher_secp256k1_sig, TestSigVerify) { msg = 0; sig = 0; memset(&key, 0, sizeof(secp256k1go__XY)); - GoUint32 result; - - result = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); - Number_Handle r; - result = SKY_secp256k1go_Signature_GetR(sig, &r); - registerHandleClose(r); - Number_Handle s; - result = SKY_secp256k1go_Signature_GetS(sig, &s); - registerHandleClose(s); - result = SKY_secp256k1go_Number_Create(&msg); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); + GoUint32 result; + + result = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); + Number_Handle r; + result = SKY_secp256k1go_Signature_GetR(sig, &r); + registerHandleClose(r); + Number_Handle s; + result = SKY_secp256k1go_Signature_GetS(sig, &s); + registerHandleClose(s); + result = SKY_secp256k1go_Number_Create(&msg); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); GoString str = { "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA", 64}; @@ -196,24 +196,24 @@ Test(cipher_secp256k1_sig, TestSigSign) { Number_Handle non; Signature_Handle sig; GoInt recid; - GoUint32 result; + GoUint32 result; sec = 0; - msg = 0; - non = 0; - sig = 0; + msg = 0; + non = 0; + sig = 0; - result = SKY_secp256k1go_Number_Create(&sec); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); + result = SKY_secp256k1go_Number_Create(&sec); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); - result = SKY_secp256k1go_Number_Create(&msg); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); + result = SKY_secp256k1go_Number_Create(&msg); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); - result = SKY_secp256k1go_Number_Create(&non); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); + result = SKY_secp256k1go_Number_Create(&non); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); + registerHandleClose(msg); GoString str = { "73641C99F7719F57D8F4BEB11A303AFCD190243A51CED8782CA6D3DBE014D146", 64}; @@ -230,12 +230,12 @@ Test(cipher_secp256k1_sig, TestSigSign) { result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - result = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); + result = SKY_secp256k1go_Signature_Create(&sig); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); + registerHandleClose(sig); GoInt res; - GoInt8 equal; + GoInt8 equal; result = SKY_secp256k1go_Signature_Sign(sig, sec, msg, non, &recid, &res); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); @@ -251,14 +251,14 @@ Test(cipher_secp256k1_sig, TestSigSign) { result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - Number_Handle r; - result = SKY_secp256k1go_Signature_GetR(sig, &r); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetR failed"); - registerHandleClose(r); + Number_Handle r; + result = SKY_secp256k1go_Signature_GetR(sig, &r); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetR failed"); + registerHandleClose(r); - equal = 0; - result = SKY_secp256k1go_Number_IsEqual(r, non, &equal); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_IsEqual failed"); + equal = 0; + result = SKY_secp256k1go_Number_IsEqual(r, non, &equal); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_IsEqual failed"); cr_assert(equal != 0); if (forceLowS) { @@ -272,13 +272,13 @@ Test(cipher_secp256k1_sig, TestSigSign) { result = SKY_secp256k1go_Number_SetHex(non, str); cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); } - Number_Handle s; - result = SKY_secp256k1go_Signature_GetS(sig, &s); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); - registerHandleClose(s); - - equal = 0; - result = SKY_secp256k1go_Number_IsEqual(s, non, &equal); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); + Number_Handle s; + result = SKY_secp256k1go_Signature_GetS(sig, &s); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); + registerHandleClose(s); + + equal = 0; + result = SKY_secp256k1go_Number_IsEqual(s, non, &equal); + cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); cr_assert(equal != 0); } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c index 9bd664993c..270e6bec57 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c @@ -20,45 +20,45 @@ -Test(cipher_secp256k1_xyz, TestXYZDouble){ - GoInt32 error_code; - secp256k1go__XYZ a; //sample data - secp256k1go__XYZ r; //result of double - secp256k1go__XYZ e; //expected - - memset(&a, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - memset(&r, 0, sizeof(secp256k1go__XYZ)); - - GoString strAx = {AX, strlen(AX)}; - GoString strAy = {AY, strlen(AY)}; - GoString strAz = {AZ, strlen(AZ)}; - - GoString strEx = {EX, strlen(EX)}; - GoString strEy = {EY, strlen(EY)}; - GoString strEz = {EZ, strlen(EZ)}; - - error_code = SKY_secp256k1go_Field_SetHex(&a.X, strAx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&a.Y, strAy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&a.Z, strAz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_XYZ_Double(&a, &r); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); - - GoInt8 equal = 0; - error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); +Test(cipher_secp256k1_xyz, TestXYZDouble){ + GoInt32 error_code; + secp256k1go__XYZ a; //sample data + secp256k1go__XYZ r; //result of double + secp256k1go__XYZ e; //expected + + memset(&a, 0, sizeof(secp256k1go__XYZ)); + memset(&e, 0, sizeof(secp256k1go__XYZ)); + memset(&r, 0, sizeof(secp256k1go__XYZ)); + + GoString strAx = {AX, strlen(AX)}; + GoString strAy = {AY, strlen(AY)}; + GoString strAz = {AZ, strlen(AZ)}; + + GoString strEx = {EX, strlen(EX)}; + GoString strEy = {EY, strlen(EY)}; + GoString strEz = {EZ, strlen(EZ)}; + + error_code = SKY_secp256k1go_Field_SetHex(&a.X, strAx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Y, strAy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&a.Z, strAz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); + + error_code = SKY_secp256k1go_XYZ_Double(&a, &r); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); + + GoInt8 equal = 0; + error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); + cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); + cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); } @@ -103,4 +103,4 @@ Test(cipher_secp256k1_xyz, TestGejGetX) { result = SKY_secp256k1go_Field_Equals(&X, &exp, &valid); cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Equals failed"); cr_assert(valid, "get.get_x() fail"); -} \ No newline at end of file +} diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 0319fdaf03..f935e9dbb1 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -432,16 +432,16 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { // TODO : Translate once secp256k1 be part of libskycoin GoInt validSec; - char bufferSecKey[101]; - strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),65 }; - SKY_secp256k1_VerifySeckey(slseckey,&validSec); + char bufferSecKey[101]; + strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),65 }; + SKY_secp256k1_VerifySeckey(slseckey,&validSec); cr_assert(validSec ==1 ,"SKY_secp256k1_VerifySeckey failed"); - GoInt validPub; - GoSlice slpubkey = { &p,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; - SKY_secp256k1_VerifyPubkey(slpubkey,&validPub); - cr_assert(validPub ==1 ,"SKY_secp256k1_VerifyPubkey failed"); + GoInt validPub; + GoSlice slpubkey = { &p,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&validPub); + cr_assert(validPub ==1 ,"SKY_secp256k1_VerifyPubkey failed"); // FIXME: without cond : 'not give a valid preprocessing token' bool cond = (!(inputData == NULL && expected->Signatures.len != 0)); diff --git a/lib/cgo/tests/testutils/base64.c b/lib/cgo/tests/testutils/base64.c index c39b11673c..3cb4a5e5b3 100644 --- a/lib/cgo/tests/testutils/base64.c +++ b/lib/cgo/tests/testutils/base64.c @@ -15,179 +15,179 @@ Thank you for inspiration: unsigned char b64_chr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int b64_int(unsigned int ch) { - // ASCII to base64_int - // 65-90 Upper Case >> 0-25 - // 97-122 Lower Case >> 26-51 - // 48-57 Numbers >> 52-61 - // 43 Plus (+) >> 62 - // 47 Slash (/) >> 63 - // 61 Equal (=) >> 64~ - if (ch==43) - return 62; - if (ch==47) - return 63; - if (ch==61) - return 64; - if ((ch>47) && (ch<58)) - return ch + 4; - if ((ch>64) && (ch<91)) - return ch - 'A'; - if ((ch>96) && (ch<123)) - return (ch - 'a') + 26; - return -1; //Invalid character, invalid base64 string + // ASCII to base64_int + // 65-90 Upper Case >> 0-25 + // 97-122 Lower Case >> 26-51 + // 48-57 Numbers >> 52-61 + // 43 Plus (+) >> 62 + // 47 Slash (/) >> 63 + // 61 Equal (=) >> 64~ + if (ch==43) + return 62; + if (ch==47) + return 63; + if (ch==61) + return 64; + if ((ch>47) && (ch<58)) + return ch + 4; + if ((ch>64) && (ch<91)) + return ch - 'A'; + if ((ch>96) && (ch<123)) + return (ch - 'a') + 26; + return -1; //Invalid character, invalid base64 string } unsigned int b64e_size(unsigned int in_size) { - // size equals 4*floor((1/3)*(in_size+2)); - int i, j = 0; - for (i=0;i>2 ]; - out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ]; - out[k+2] = b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ]; - out[k+3] = b64_chr[ s[2]&0x3F ]; - j=0; k+=4; - } - } - - if (j) { - if (j==1) - s[1] = 0; - out[k+0] = b64_chr[ (s[0]&255)>>2 ]; - out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ]; - if (j==2) - out[k+2] = b64_chr[ ((s[1]&0x0F)<<2) ]; - else - out[k+2] = '='; - out[k+3] = '='; - k+=4; - } - - out[k] = '\0'; - - return k; + unsigned int i=0, j=0, k=0, s[3]; + + for (i=0;i>2 ]; + out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ]; + out[k+2] = b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ]; + out[k+3] = b64_chr[ s[2]&0x3F ]; + j=0; k+=4; + } + } + + if (j) { + if (j==1) + s[1] = 0; + out[k+0] = b64_chr[ (s[0]&255)>>2 ]; + out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ]; + if (j==2) + out[k+2] = b64_chr[ ((s[1]&0x0F)<<2) ]; + else + out[k+2] = '='; + out[k+3] = '='; + k+=4; + } + + out[k] = '\0'; + + return k; } int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out) { - unsigned int i=0, j=0, k=0, s[4]; - for (i=0;i>4); - if (s[2]!=64) { - out[k+1] = ((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2); - if ((s[3]!=64)) { - out[k+2] = ((s[2]&0x03)<<6)+(s[3]); k+=3; - } else { - k+=2; - } - } else { - k+=1; - } - j=0; - } - } - - return k; + unsigned int i=0, j=0, k=0, s[4]; + for (i=0;i>4); + if (s[2]!=64) { + out[k+1] = ((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2); + if ((s[3]!=64)) { + out[k+2] = ((s[2]&0x03)<<6)+(s[3]); k+=3; + } else { + k+=2; + } + } else { + k+=1; + } + j=0; + } + } + + return k; } unsigned int b64_encodef(char *InFile, char *OutFile) { - FILE *pInFile = fopen(InFile,"rb"); - FILE *pOutFile = fopen(OutFile,"wb"); - if ( (pInFile==NULL) || (pOutFile==NULL) ) - return 0; - - unsigned int i=0, j=0, c=0, s[3]; - - while(c!=EOF) { - c=fgetc(pInFile); - if (c==EOF) - break; - s[j++]=c; - if (j==3) { - fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile); - fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile); - fputc(b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ],pOutFile); - fputc(b64_chr[ s[2]&0x3F ],pOutFile); - j=0; i+=4; - } - } - - if (j) { - if (j==1) - s[1] = 0; - fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile); - fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile); - if (j==2) - fputc(b64_chr[ ((s[1]&0x0F)<<2) ],pOutFile); - else - fputc('=',pOutFile); - fputc('=',pOutFile); - i+=4; - } - - fclose(pInFile); - fclose(pOutFile); - - return i; + FILE *pInFile = fopen(InFile,"rb"); + FILE *pOutFile = fopen(OutFile,"wb"); + if ( (pInFile==NULL) || (pOutFile==NULL) ) + return 0; + + unsigned int i=0, j=0, c=0, s[3]; + + while(c!=EOF) { + c=fgetc(pInFile); + if (c==EOF) + break; + s[j++]=c; + if (j==3) { + fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile); + fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile); + fputc(b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ],pOutFile); + fputc(b64_chr[ s[2]&0x3F ],pOutFile); + j=0; i+=4; + } + } + + if (j) { + if (j==1) + s[1] = 0; + fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile); + fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile); + if (j==2) + fputc(b64_chr[ ((s[1]&0x0F)<<2) ],pOutFile); + else + fputc('=',pOutFile); + fputc('=',pOutFile); + i+=4; + } + + fclose(pInFile); + fclose(pOutFile); + + return i; } int b64_decodef(char *InFile, char *OutFile) { - FILE *pInFile = fopen(InFile,"rb"); - FILE *pOutFile = fopen(OutFile,"wb"); - if ( (pInFile==NULL) || (pOutFile==NULL) ) - return 0; - - unsigned int c=0, j=0, k=0, s[4]; - int n; - - while(c!=EOF) { - c=fgetc(pInFile); - if (c==EOF) - break; - n = b64_int(c); - if( n < 0 ) - return -1; - s[j++] = (unsigned int)n; - if (j==4) { - fputc(((s[0]&255)<<2)+((s[1]&0x30)>>4),pOutFile); - if (s[2]!=64) { - fputc(((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2),pOutFile); - if ((s[3]!=64)) { - fputc(((s[2]&0x03)<<6)+(s[3]),pOutFile); k+=3; - } else { - k+=2; - } - } else { - k+=1; - } - j=0; - } - } - - fclose(pInFile); - fclose(pOutFile); - - return (int)k; + FILE *pInFile = fopen(InFile,"rb"); + FILE *pOutFile = fopen(OutFile,"wb"); + if ( (pInFile==NULL) || (pOutFile==NULL) ) + return 0; + + unsigned int c=0, j=0, k=0, s[4]; + int n; + + while(c!=EOF) { + c=fgetc(pInFile); + if (c==EOF) + break; + n = b64_int(c); + if( n < 0 ) + return -1; + s[j++] = (unsigned int)n; + if (j==4) { + fputc(((s[0]&255)<<2)+((s[1]&0x30)>>4),pOutFile); + if (s[2]!=64) { + fputc(((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2),pOutFile); + if ((s[3]!=64)) { + fputc(((s[2]&0x03)<<6)+(s[3]),pOutFile); k+=3; + } else { + k+=2; + } + } else { + k+=1; + } + j=0; + } + } + + fclose(pInFile); + fclose(pOutFile); + + return (int)k; } diff --git a/lib/cgo/tests/testutils/json_util.c b/lib/cgo/tests/testutils/json_util.c index f741e75b66..a0f2cf3dbf 100644 --- a/lib/cgo/tests/testutils/json_util.c +++ b/lib/cgo/tests/testutils/json_util.c @@ -3,146 +3,146 @@ #include json_value* json_get_string(json_value* value, const char* key){ - int length, x; - if (value == NULL) { - return NULL; - } - if (value->type != json_object) { - return NULL; - } - length = value->u.object.length; - for (x = 0; x < length; x++) { - if( strcmp( value->u.object.values[x].name, key) == 0){ - if( value->u.object.values[x].value->type == json_string){ - return value->u.object.values[x].value; - } - } - } - return NULL; + int length, x; + if (value == NULL) { + return NULL; + } + if (value->type != json_object) { + return NULL; + } + length = value->u.object.length; + for (x = 0; x < length; x++) { + if( strcmp( value->u.object.values[x].name, key) == 0){ + if( value->u.object.values[x].value->type == json_string){ + return value->u.object.values[x].value; + } + } + } + return NULL; } int json_set_string(json_value* value, const char* new_string_value){ - if( value->type == json_string){ - int length = strlen(new_string_value); - if( length > value->u.string.length ){ - value->u.string.ptr = malloc(length + 1); - } - strcpy( value->u.string.ptr, new_string_value ); - value->u.string.length = length; - } - return 0; + if( value->type == json_string){ + int length = strlen(new_string_value); + if( length > value->u.string.length ){ + value->u.string.ptr = malloc(length + 1); + } + strcpy( value->u.string.ptr, new_string_value ); + value->u.string.length = length; + } + return 0; } int _compareJsonValues(json_value* value1, json_value* value2, const char* ignore); int compareJsonObjects(json_value* value1, json_value* value2, - const char* ignore){ - int length1 = value1->u.object.length; - int length2 = value2->u.object.length; - /*if( length1 != length2 ) - return 0;*/ - for (int x = 0; x < length1; x++) { - char* name = value1->u.object.values[x].name; - if( ignore != NULL && strcmp( ignore, name ) == 0) - continue; - int found = 0; - for( int y = 0; y < length2; y++){ - if( strcmp( value2->u.object.values[y].name, name ) == 0){ - if( !_compareJsonValues( value1->u.object.values[x].value, - value2->u.object.values[y].value, ignore ) ) - return 0; - found = 1; - break; - } - } - if( !found ) - return 0; - } - return 1; + const char* ignore){ + int length1 = value1->u.object.length; + int length2 = value2->u.object.length; + /*if( length1 != length2 ) + return 0;*/ + for (int x = 0; x < length1; x++) { + char* name = value1->u.object.values[x].name; + if( ignore != NULL && strcmp( ignore, name ) == 0) + continue; + int found = 0; + for( int y = 0; y < length2; y++){ + if( strcmp( value2->u.object.values[y].name, name ) == 0){ + if( !_compareJsonValues( value1->u.object.values[x].value, + value2->u.object.values[y].value, ignore ) ) + return 0; + found = 1; + break; + } + } + if( !found ) + return 0; + } + return 1; } int compareJsonArrays(json_value* value1, json_value* value2, const char* ignore){ - int length1 = value1->u.array.length; - int length2 = value2->u.array.length; - if( length1 != length2 ) - return 0; - for (int x = 0; x < length1; x++) { - if( !_compareJsonValues(value1->u.array.values[x], - value2->u.array.values[x], ignore) ) - return 0; - } - return 1; + int length1 = value1->u.array.length; + int length2 = value2->u.array.length; + if( length1 != length2 ) + return 0; + for (int x = 0; x < length1; x++) { + if( !_compareJsonValues(value1->u.array.values[x], + value2->u.array.values[x], ignore) ) + return 0; + } + return 1; } int _compareJsonValues(json_value* value1, json_value* value2, const char* ignore){ - if( value1 == NULL && value2 == NULL) - return 1; - if( value1 == NULL || value2 == NULL) - return 0; - if( value1->type != value2->type) - return 0; - switch (value1->type) { + if( value1 == NULL && value2 == NULL) + return 1; + if( value1 == NULL || value2 == NULL) + return 0; + if( value1->type != value2->type) + return 0; + switch (value1->type) { case json_null: return value2->type == json_null; - case json_none: - return 1; - case json_object: - return compareJsonObjects(value1, value2, ignore); - case json_array: - return compareJsonArrays(value1, value2, ignore); - case json_integer: - return value1->u.integer == value2->u.integer; - case json_double: - return fabs(value1->u.dbl - value2->u.dbl) < 0.000001; - case json_string: - return strcmp(value1->u.string.ptr, value2->u.string.ptr) == 0; - case json_boolean: - return value1->u.boolean == value2->u.boolean; - } - return 1; + case json_none: + return 1; + case json_object: + return compareJsonObjects(value1, value2, ignore); + case json_array: + return compareJsonArrays(value1, value2, ignore); + case json_integer: + return value1->u.integer == value2->u.integer; + case json_double: + return fabs(value1->u.dbl - value2->u.dbl) < 0.000001; + case json_string: + return strcmp(value1->u.string.ptr, value2->u.string.ptr) == 0; + case json_boolean: + return value1->u.boolean == value2->u.boolean; + } + return 1; } int compareJsonValues(json_value* value1, json_value* value2){ - return _compareJsonValues(value2, value1, NULL); + return _compareJsonValues(value2, value1, NULL); } int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, const char* ignoreList){ - return _compareJsonValues(value2, value1, ignoreList); + return _compareJsonValues(value2, value1, ignoreList); } json_value* get_json_value_not_strict(json_value* node, const char* path, - json_type type, int allow_null){ - int n; - const char* p = strchr(path, '/'); - if( p == NULL ) - n = strlen(path); - else - n = p - path; - if( n > 0 ) { - if( node->type == json_object){ - for (int x = 0; x < node->u.object.length; x++) { - json_object_entry * entry = &node->u.object.values[x]; - char* name = entry->name; - json_value* value = entry->value; - if( strncmp( path, name, n ) == 0){ - if( p == NULL){ - if( value->type == type || - (allow_null && value->type == json_null)) - return value; - }else - return get_json_value_not_strict( - value, p + 1, type, allow_null); - } - } - } else { - return NULL; - } - } - return NULL; + json_type type, int allow_null){ + int n; + const char* p = strchr(path, '/'); + if( p == NULL ) + n = strlen(path); + else + n = p - path; + if( n > 0 ) { + if( node->type == json_object){ + for (int x = 0; x < node->u.object.length; x++) { + json_object_entry * entry = &node->u.object.values[x]; + char* name = entry->name; + json_value* value = entry->value; + if( strncmp( path, name, n ) == 0){ + if( p == NULL){ + if( value->type == type || + (allow_null && value->type == json_null)) + return value; + }else + return get_json_value_not_strict( + value, p + 1, type, allow_null); + } + } + } else { + return NULL; + } + } + return NULL; } json_value* get_json_value(json_value* node, const char* path, - json_type type){ - return get_json_value_not_strict(node, path, type, 1); + json_type type){ + return get_json_value_not_strict(node, path, type, 1); } diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index ea053118b6..728888d064 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -29,8 +29,8 @@ int HANDLEPOOLIDX = 0; Handle HANDLE_POOL[128]; typedef struct { - Client__Handle client; - WalletResponse__Handle wallet; + Client__Handle client; + WalletResponse__Handle wallet; } wallet_register; int WALLETPOOLIDX = 0; @@ -40,207 +40,207 @@ int stdout_backup; int pipefd[2]; void * registerMemCleanup(void *p) { - int i; - for (i = 0; i < MEMPOOLIDX; i++) { - if(MEMPOOL[i] == NULL){ - MEMPOOL[i] = p; - return p; - } - } - MEMPOOL[MEMPOOLIDX++] = p; - return p; + int i; + for (i = 0; i < MEMPOOLIDX; i++) { + if(MEMPOOL[i] == NULL){ + MEMPOOL[i] = p; + return p; + } + } + MEMPOOL[MEMPOOLIDX++] = p; + return p; } void freeRegisteredMemCleanup(void *p){ - int i; - for (i = 0; i < MEMPOOLIDX; i++) { - if(MEMPOOL[i] == p){ - free(p); - MEMPOOL[i] = NULL; - break; - } - } + int i; + for (i = 0; i < MEMPOOLIDX; i++) { + if(MEMPOOL[i] == p){ + free(p); + MEMPOOL[i] = NULL; + break; + } + } } int registerJsonFree(void *p){ - int i; - for (i = 0; i < JSONPOOLIDX; i++) { - if(JSON_POOL[i] == NULL){ - JSON_POOL[i] = p; - return i; - } - } - JSON_POOL[JSONPOOLIDX++] = p; - return JSONPOOLIDX-1; + int i; + for (i = 0; i < JSONPOOLIDX; i++) { + if(JSON_POOL[i] == NULL){ + JSON_POOL[i] = p; + return i; + } + } + JSON_POOL[JSONPOOLIDX++] = p; + return JSONPOOLIDX-1; } void freeRegisteredJson(void *p){ - int i; - for (i = 0; i < JSONPOOLIDX; i++) { - if(JSON_POOL[i] == p){ - JSON_POOL[i] = NULL; - json_value_free( (json_value*)p ); - break; - } - } + int i; + for (i = 0; i < JSONPOOLIDX; i++) { + if(JSON_POOL[i] == p){ + JSON_POOL[i] = NULL; + json_value_free( (json_value*)p ); + break; + } + } } int registerWalletClean(Client__Handle clientHandle, - WalletResponse__Handle walletHandle){ - int i; - for (i = 0; i < WALLETPOOLIDX; i++) { - if(WALLET_POOL[i].wallet == 0 && WALLET_POOL[i].client == 0){ - WALLET_POOL[i].wallet = walletHandle; - WALLET_POOL[i].client = clientHandle; - return i; - } - } - WALLET_POOL[WALLETPOOLIDX].wallet = walletHandle; - WALLET_POOL[WALLETPOOLIDX].client = clientHandle; - return WALLETPOOLIDX++; + WalletResponse__Handle walletHandle){ + int i; + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].wallet == 0 && WALLET_POOL[i].client == 0){ + WALLET_POOL[i].wallet = walletHandle; + WALLET_POOL[i].client = clientHandle; + return i; + } + } + WALLET_POOL[WALLETPOOLIDX].wallet = walletHandle; + WALLET_POOL[WALLETPOOLIDX].client = clientHandle; + return WALLETPOOLIDX++; } int registerHandleClose(Handle handle){ - int i; - for (i = 0; i < HANDLEPOOLIDX; i++) { - if(HANDLE_POOL[i] == 0){ - HANDLE_POOL[i] = handle; - return i; - } - } - HANDLE_POOL[HANDLEPOOLIDX++] = handle; - return HANDLEPOOLIDX - 1; + int i; + for (i = 0; i < HANDLEPOOLIDX; i++) { + if(HANDLE_POOL[i] == 0){ + HANDLE_POOL[i] = handle; + return i; + } + } + HANDLE_POOL[HANDLEPOOLIDX++] = handle; + return HANDLEPOOLIDX - 1; } void closeRegisteredHandle(Handle handle){ - int i; - for (i = 0; i < HANDLEPOOLIDX; i++) { - if(HANDLE_POOL[i] == handle){ - HANDLE_POOL[i] = 0; - SKY_handle_close(handle); - break; - } - } + int i; + for (i = 0; i < HANDLEPOOLIDX; i++) { + if(HANDLE_POOL[i] == handle){ + HANDLE_POOL[i] = 0; + SKY_handle_close(handle); + break; + } + } } void cleanupWallet(Client__Handle client, WalletResponse__Handle wallet){ - int result; - GoString_ strWalletDir; - GoString_ strFileName; - memset(&strWalletDir, 0, sizeof(GoString_)); - memset(&strFileName, 0, sizeof(GoString_)); - - - result = SKY_api_Handle_Client_GetWalletDir(client, &strWalletDir); - if( result != SKY_OK ){ - return; - } - result = SKY_api_Handle_Client_GetWalletFileName(wallet, &strFileName); - if( result != SKY_OK ){ - free( (void*)strWalletDir.p ); - return; - } - char fullPath[128]; - if( strWalletDir.n + strFileName.n < 126){ - strcpy( fullPath, strWalletDir.p ); - if( fullPath[0] == 0 || fullPath[strlen(fullPath) - 1] != '/' ) - strcat(fullPath, "/"); - strcat( fullPath, strFileName.p ); - result = unlink( fullPath ); - if( strlen(fullPath) < 123 ){ - strcat( fullPath, ".bak" ); - result = unlink( fullPath ); - } - } - GoString str = { strFileName.p, strFileName.n }; - result = SKY_api_Client_UnloadWallet( client, str ); - GoString strFullPath = { fullPath, strlen(fullPath) }; - free( (void*)strWalletDir.p ); - free( (void*)strFileName.p ); + int result; + GoString_ strWalletDir; + GoString_ strFileName; + memset(&strWalletDir, 0, sizeof(GoString_)); + memset(&strFileName, 0, sizeof(GoString_)); + + + result = SKY_api_Handle_Client_GetWalletDir(client, &strWalletDir); + if( result != SKY_OK ){ + return; + } + result = SKY_api_Handle_Client_GetWalletFileName(wallet, &strFileName); + if( result != SKY_OK ){ + free( (void*)strWalletDir.p ); + return; + } + char fullPath[128]; + if( strWalletDir.n + strFileName.n < 126){ + strcpy( fullPath, strWalletDir.p ); + if( fullPath[0] == 0 || fullPath[strlen(fullPath) - 1] != '/' ) + strcat(fullPath, "/"); + strcat( fullPath, strFileName.p ); + result = unlink( fullPath ); + if( strlen(fullPath) < 123 ){ + strcat( fullPath, ".bak" ); + result = unlink( fullPath ); + } + } + GoString str = { strFileName.p, strFileName.n }; + result = SKY_api_Client_UnloadWallet( client, str ); + GoString strFullPath = { fullPath, strlen(fullPath) }; + free( (void*)strWalletDir.p ); + free( (void*)strFileName.p ); } void cleanRegisteredWallet( - Client__Handle client, - WalletResponse__Handle wallet){ - - int i; - for (i = 0; i < WALLETPOOLIDX; i++) { - if(WALLET_POOL[i].wallet == wallet && WALLET_POOL[i].client == client){ - WALLET_POOL[i].wallet = 0; - WALLET_POOL[i].client = 0; - cleanupWallet( client, wallet ); - return; - } - } + Client__Handle client, + WalletResponse__Handle wallet){ + + int i; + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].wallet == wallet && WALLET_POOL[i].client == client){ + WALLET_POOL[i].wallet = 0; + WALLET_POOL[i].client = 0; + cleanupWallet( client, wallet ); + return; + } + } } void cleanupMem() { - int i; + int i; - for (i = 0; i < WALLETPOOLIDX; i++) { - if(WALLET_POOL[i].client != 0 && WALLET_POOL[i].wallet != 0){ - cleanupWallet( WALLET_POOL[i].client, WALLET_POOL[i].wallet ); - } - } + for (i = 0; i < WALLETPOOLIDX; i++) { + if(WALLET_POOL[i].client != 0 && WALLET_POOL[i].wallet != 0){ + cleanupWallet( WALLET_POOL[i].client, WALLET_POOL[i].wallet ); + } + } void **ptr; for (i = MEMPOOLIDX, ptr = MEMPOOL; i; --i) { - if( *ptr ) - free(*ptr); - ptr++; + if( *ptr ) + free(*ptr); + ptr++; } for (i = JSONPOOLIDX, ptr = (void*)JSON_POOL; i; --i) { - if( *ptr ) - json_value_free(*ptr); - ptr++; + if( *ptr ) + json_value_free(*ptr); + ptr++; } for (i = 0; i < HANDLEPOOLIDX; i++) { - if( HANDLE_POOL[i] ) - SKY_handle_close(HANDLE_POOL[i]); + if( HANDLE_POOL[i] ) + SKY_handle_close(HANDLE_POOL[i]); } } json_value* loadJsonFile(const char* filename){ - FILE *fp; - struct stat filestatus; - int file_size; - char* file_contents; - json_char* json; - json_value* value; - - if ( stat(filename, &filestatus) != 0) { - return NULL; - } - file_size = filestatus.st_size; - file_contents = (char*)malloc(filestatus.st_size); - if ( file_contents == NULL) { - return NULL; - } - fp = fopen(filename, "rt"); - if (fp == NULL) { - free(file_contents); - return NULL; - } - if ( fread(file_contents, file_size, 1, fp) != 1 ) { - fclose(fp); - free(file_contents); - return NULL; - } - fclose(fp); - - json = (json_char*)file_contents; - value = json_parse(json, file_size); - free(file_contents); - return value; + FILE *fp; + struct stat filestatus; + int file_size; + char* file_contents; + json_char* json; + json_value* value; + + if ( stat(filename, &filestatus) != 0) { + return NULL; + } + file_size = filestatus.st_size; + file_contents = (char*)malloc(filestatus.st_size); + if ( file_contents == NULL) { + return NULL; + } + fp = fopen(filename, "rt"); + if (fp == NULL) { + free(file_contents); + return NULL; + } + if ( fread(file_contents, file_size, 1, fp) != 1 ) { + fclose(fp); + free(file_contents); + return NULL; + } + fclose(fp); + + json = (json_char*)file_contents; + value = json_parse(json, file_size); + free(file_contents); + return value; } void setup(void) { - srand ((unsigned int) time (NULL)); + srand ((unsigned int) time (NULL)); } void teardown(void) { - cleanupMem(); + cleanupMem(); } // TODO: Move to libsky_io.c @@ -254,15 +254,15 @@ void fprintbuff(FILE *f, void *buff, size_t n) { } int parseBoolean(const char* str, int length){ - int result = 0; - if(length == 1){ - result = str[0] == '1' || str[0] == 't' || str[0] == 'T'; - } else { - result = strncmp(str, "true", length) == 0 || - strncmp(str, "True", length) == 0 || - strncmp(str, "TRUE", length) == 0; - } - return result; + int result = 0; + if(length == 1){ + result = str[0] == '1' || str[0] == 't' || str[0] == 'T'; + } else { + result = strncmp(str, "true", length) == 0 || + strncmp(str, "True", length) == 0 || + strncmp(str, "TRUE", length) == 0; + } + return result; } void toGoString(GoString_ *s, GoString *r){ @@ -276,52 +276,52 @@ int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ pdest->cap = psource->len; int size = pdest->len * elem_size; pdest->data = malloc(size); - if( pdest->data == NULL ) - return SKY_ERROR; + if( pdest->data == NULL ) + return SKY_ERROR; registerMemCleanup( pdest->data ); memcpy(pdest->data, psource->data, size ); - return SKY_OK; + return SKY_OK; } int cutSlice(GoSlice_* slice, int start, int end, int elem_size, GoSlice_* result){ - int size = end - start; - if( size <= 0) - return SKY_ERROR; - void* data = malloc(size * elem_size); - if( data == NULL ) - return SKY_ERROR; - registerMemCleanup( data ); - result->data = data; - result->len = size; - result->cap = size; - char* p = slice->data; - p += (elem_size * start); - memcpy( data, p, elem_size * size ); - return SKY_OK; + int size = end - start; + if( size <= 0) + return SKY_ERROR; + void* data = malloc(size * elem_size); + if( data == NULL ) + return SKY_ERROR; + registerMemCleanup( data ); + result->data = data; + result->len = size; + result->cap = size; + char* p = slice->data; + p += (elem_size * start); + memcpy( data, p, elem_size * size ); + return SKY_OK; } int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* result){ - int size1 = slice1->len; - int size2 = slice2->len; - int size = size1 + size2; - if (size <= 0) - return SKY_ERROR; - void* data = malloc(size * elem_size); - if( data == NULL ) - return SKY_ERROR; - registerMemCleanup( data ); - result->data = data; - result->len = size; - result->cap = size; - char* p = data; - if(size1 > 0){ - memcpy( p, slice1->data, size1 * elem_size ); - p += (elem_size * size1); - } - if(size2 > 0){ - memcpy( p, slice2->data, size2 * elem_size ); - } - return SKY_OK; + int size1 = slice1->len; + int size2 = slice2->len; + int size = size1 + size2; + if (size <= 0) + return SKY_ERROR; + void* data = malloc(size * elem_size); + if( data == NULL ) + return SKY_ERROR; + registerMemCleanup( data ); + result->data = data; + result->len = size; + result->cap = size; + char* p = data; + if(size1 > 0){ + memcpy( p, slice1->data, size1 * elem_size ); + p += (elem_size * size1); + } + if(size2 > 0){ + memcpy( p, slice2->data, size2 * elem_size ); + } + return SKY_OK; } /* @@ -401,9 +401,9 @@ int copyUxArraytoSlice(coin__UxArray* pdest, GoSlice* psource){ pdest->cap = psource->len; int size = pdest->len * sizeof(coin__UxArray); pdest->data = malloc(size); - if( pdest->data == NULL ) - return SKY_ERROR; + if( pdest->data == NULL ) + return SKY_ERROR; registerMemCleanup( pdest->data ); memcpy(pdest->data, psource->data, size ); - return SKY_OK; -} \ No newline at end of file + return SKY_OK; +} diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c index 24e96b1198..0655d3a3d3 100644 --- a/vendor/golang.org/x/sys/unix/gccgo_c.c +++ b/vendor/golang.org/x/sys/unix/gccgo_c.c @@ -16,25 +16,25 @@ // Go to C does not support varargs functions. struct ret { - uintptr_t r; - uintptr_t err; + uintptr_t r; + uintptr_t err; }; struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) { - struct ret r; + struct ret r; - errno = 0; - r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); - r.err = errno; - return r; + errno = 0; + r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); + r.err = errno; + return r; } uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) { - return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); + return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); } // Define the use function in C so that it is not inlined. From b733b13d70da59fdf8e312fd3bc9e1e33c7366cc Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Tue, 9 Oct 2018 06:53:59 +0000 Subject: [PATCH 235/399] [lib] refs #1191 - SKY_api_Client_Blocks accepts slice of int rather than start, end range [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- lib/cgo/api.client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 9fda5f0e71..dd4961c98f 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -193,7 +193,7 @@ func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle } //export SKY_api_Client_Blocks -func SKY_api_Client_Blocks(_c C.Client__Handle, _start uint64, _end uint64, _arg1 *C.Handle) (____error_code uint32) { +func SKY_api_Client_Blocks(_c C.Client__Handle, _seqs []uint64, _arg1 *C.Handle) (____error_code uint32) { ____error_code = SKY_OK defer func() { ____error_code = catchApiPanic(____error_code, recover()) @@ -204,7 +204,7 @@ func SKY_api_Client_Blocks(_c C.Client__Handle, _start uint64, _end uint64, _arg ____error_code = SKY_BAD_HANDLE return } - __arg1, ____return_err := c.Blocks(_start, _end) + __arg1, ____return_err := c.Blocks(_seqs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg1 = registerHandle(__arg1) From 0f1317ed57388afbac3f7332038a613aadc4090b Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Wed, 10 Oct 2018 22:05:44 -0400 Subject: [PATCH 236/399] [lib] refs #1191 - Remove catchApiPanic. time.Time values as RFC3339 strings in C API args --- include/cipher.address.go.h | 7 + lib/cgo/README.md | 4 + lib/cgo/api.client.go | 240 ------------------ lib/cgo/api.spend.go | 25 -- lib/cgo/api.wallet.go | 5 - lib/cgo/api.webrpc.client.go | 45 ---- lib/cgo/cipher.address.go | 45 ---- lib/cgo/cipher.base58.base58.go | 50 ---- lib/cgo/cipher.crypto.go | 135 ---------- .../cipher.encrypt.scrypt_chacha20poly1305.go | 10 - lib/cgo/cipher.encrypt.sha256xor.go | 10 - lib/cgo/cipher.go-bip39.bip39.go | 25 -- lib/cgo/cipher.hash.go | 55 ---- lib/cgo/cipher.poly1305.poly1305.go | 5 - lib/cgo/cipher.ripemd160.ripemd160.go | 15 -- lib/cgo/cipher.scrypt.scrypt.go | 5 - lib/cgo/cipher.secp256k1-go.secp256_rand.go | 10 - .../cipher.secp256k1-go.secp256k1-go2.ec.go | 40 --- ...cipher.secp256k1-go.secp256k1-go2.field.go | 95 ------- .../cipher.secp256k1-go.secp256k1-go2.num.go | 25 -- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 45 ---- .../cipher.secp256k1-go.secp256k1-go2.xy.go | 55 ---- .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 68 +---- lib/cgo/cipher.secp256k1-go.secp256k1.go | 80 ------ lib/cgo/cli.add_private_key.go | 10 - lib/cgo/cli.check_balance.go | 10 - lib/cgo/cli.cli.go | 40 --- lib/cgo/cli.create_rawtx.go | 21 -- lib/cgo/cli.generate_addrs.go | 20 -- lib/cgo/cli.generate_wallet.go | 10 - lib/cgo/cli.outputs.go | 10 - lib/cgo/cli_helper.go | 30 --- lib/cgo/coin.block.go | 116 --------- lib/cgo/coin.math.go | 15 -- lib/cgo/coin.outputs.go | 120 --------- lib/cgo/coin.transactions.go | 240 ------------------ lib/cgo/libsky_error.go | 112 +------- lib/cgo/libsky_handle_helper.go | 4 +- lib/cgo/libsky_time.go | 18 ++ lib/cgo/testutil.testutil.go | 5 - lib/cgo/util.apputil.apputil.go | 15 -- lib/cgo/util.cert.cert.go | 28 +- lib/cgo/util.droplet.droplet.go | 10 - lib/cgo/util.fee.fee.go | 25 -- lib/cgo/util.file.file.go | 20 -- lib/cgo/util.http.json.go | 40 --- lib/cgo/util.iputil.iputil.go | 15 -- lib/cgo/util.logging.logging.go | 15 -- lib/cgo/wallet.addresses.go | 5 - lib/cgo/wallet.balance.go | 30 --- lib/cgo/wallet.crypto.go | 5 - lib/cgo/wallet.entry.go | 10 - lib/cgo/wallet.readable.go | 40 --- lib/cgo/wallet.wallet.go | 110 -------- lib/cgo/wallet_option.go | 5 - 55 files changed, 63 insertions(+), 2190 deletions(-) create mode 100644 lib/cgo/libsky_time.go diff --git a/include/cipher.address.go.h b/include/cipher.address.go.h index 902592057d..a074642724 100644 --- a/include/cipher.address.go.h +++ b/include/cipher.address.go.h @@ -1,4 +1,11 @@ +/** + * Integrity checksum, 4-bytes long. + */ typedef GoUint8_ cipher__Checksum[4]; + +/** + * Addresses of SKY accounts + */ typedef struct{ GoUint8_ Version; ///< Address version identifier. ///< Used to differentiate testnet diff --git a/lib/cgo/README.md b/lib/cgo/README.md index b23dc114a0..42b26d6ec8 100644 --- a/lib/cgo/README.md +++ b/lib/cgo/README.md @@ -99,6 +99,10 @@ invocation. The caller will be responsible for [reallocating another memory buffer](http://en.cppreference.com/w/c/memory/realloc) using a higher `cap` and retry. +### Instances of `time.Time` + +Instances of `time.Time` will be formatted as RFC3339 strings before crossing API boundaries. + ## Generating documentation Follow these steps to generate API documentation. diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index dd4961c98f..41c4a1f091 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -17,11 +17,6 @@ import "C" //export SKY_api_NewClient func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := _addr __arg1 := api.NewClient(addr) *_arg1 = registerClientHandle(__arg1) @@ -30,11 +25,6 @@ func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code ui //export SKY_api_Client_CSRF func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -50,11 +40,6 @@ func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_cod //export SKY_api_Client_Version func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -70,11 +55,6 @@ func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod //export SKY_api_Client_Outputs func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -90,11 +70,6 @@ func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_cod //export SKY_api_Client_OutputsForAddresses func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -111,11 +86,6 @@ func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _a //export SKY_api_Client_OutputsForHashes func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -132,11 +102,6 @@ func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg //export SKY_api_Client_CoinSupply func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -152,11 +117,6 @@ func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_ //export SKY_api_Client_BlockByHash func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -173,11 +133,6 @@ func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Hand //export SKY_api_Client_BlockBySeq func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -194,11 +149,6 @@ func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle //export SKY_api_Client_Blocks func SKY_api_Client_Blocks(_c C.Client__Handle, _seqs []uint64, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -214,11 +164,6 @@ func SKY_api_Client_Blocks(_c C.Client__Handle, _seqs []uint64, _arg1 *C.Handle) //export SKY_api_Client_LastBlocks func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n uint64, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -235,11 +180,6 @@ func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n uint64, _arg1 *C.Handle) //export SKY_api_Client_BlockchainMetadata func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -255,11 +195,6 @@ func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_BlockchainProgress func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -275,11 +210,6 @@ func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_Balance func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -296,11 +226,6 @@ func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.walle //export SKY_api_Client_UxOut func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -317,11 +242,6 @@ func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (_ //export SKY_api_Client_AddressUxOuts func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -338,11 +258,6 @@ func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Ha //export SKY_api_Client_Wallet func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -359,11 +274,6 @@ func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletRespo //export SKY_api_Client_Wallets func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -379,11 +289,6 @@ func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____ //export SKY_api_Client_CreateUnencryptedWallet func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -402,11 +307,6 @@ func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label s //export SKY_api_Client_CreateEncryptedWallet func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _password string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -426,11 +326,6 @@ func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _p //export SKY_api_Client_NewWalletAddress func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _password string, _arg3 *C.Strings__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -449,11 +344,6 @@ func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _p //export SKY_api_Client_WalletBalance func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -470,11 +360,6 @@ func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wall //export SKY_api_Client_Spend func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.SpendResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -494,11 +379,6 @@ func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, //export SKY_api_Client_CreateTransaction func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.CreateTransactionResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -519,11 +399,6 @@ func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 //export SKY_api_Client_UpdateWallet func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -540,11 +415,6 @@ func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____e //export SKY_api_Client_WalletFolderName func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -560,11 +430,6 @@ func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____ //export SKY_api_Client_NewSeed func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -581,11 +446,6 @@ func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString //export SKY_api_Client_WalletSeed func SKY_api_Client_WalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -603,11 +463,6 @@ func SKY_api_Client_WalletSeed(_c C.Client__Handle, _id string, _password string //export SKY_api_Client_NetworkConnection func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -624,11 +479,6 @@ func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 * //export SKY_api_Client_NetworkConnections func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -644,11 +494,6 @@ func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (__ //export SKY_api_Client_NetworkDefaultConnections func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -664,11 +509,6 @@ func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Hand //export SKY_api_Client_NetworkTrustedConnections func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -684,11 +524,6 @@ func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Hand //export SKY_api_Client_NetworkExchangeableConnections func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -704,11 +539,6 @@ func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C //export SKY_api_Client_PendingTransactions func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -724,11 +554,6 @@ func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (_ //export SKY_api_Client_Transaction func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -745,11 +570,6 @@ func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Hand //export SKY_api_Client_Transactions func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -766,11 +586,6 @@ func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C. //export SKY_api_Client_ConfirmedTransactions func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -787,11 +602,6 @@ func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, //export SKY_api_Client_UnconfirmedTransactions func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -808,11 +618,6 @@ func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string //export SKY_api_Client_InjectTransaction func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -834,11 +639,6 @@ func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction_ //export SKY_api_Client_ResendUnconfirmedTransactions func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -854,11 +654,6 @@ func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C. //export SKY_api_Client_RawTransaction func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -875,11 +670,6 @@ func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.G //export SKY_api_Client_AddressTransactions func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -896,11 +686,6 @@ func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 //export SKY_api_Client_Richlist func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams, _arg1 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -917,11 +702,6 @@ func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams //export SKY_api_Client_AddressCount func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -937,11 +717,6 @@ func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_ //export SKY_api_Client_UnloadWallet func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -957,11 +732,6 @@ func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_cod //export SKY_api_Client_Health func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -977,11 +747,6 @@ func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code //export SKY_api_Client_EncryptWallet func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -999,11 +764,6 @@ func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password str //export SKY_api_Client_DecryptWallet func SKY_api_Client_DecryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/api.spend.go b/lib/cgo/api.spend.go index f3cf8db891..4f38bac1d8 100644 --- a/lib/cgo/api.spend.go +++ b/lib/cgo/api.spend.go @@ -20,11 +20,6 @@ import "C" //export SKY_api_NewCreateTransactionResponse func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreateTransactionResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(_txn) if !ok { ____error_code = SKY_BAD_HANDLE @@ -41,11 +36,6 @@ func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs [] //export SKY_api_NewCreatedTransaction func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreatedTransaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(_txn) if !ok { ____error_code = SKY_BAD_HANDLE @@ -62,11 +52,6 @@ func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.walle //export SKY_api_CreatedTransaction_ToTransaction func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _arg0 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() r, ok := lookupCreatedTransactionHandle(_r) if !ok { ____error_code = SKY_BAD_HANDLE @@ -82,11 +67,6 @@ func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _ //export SKY_api_NewCreatedTransactionOutput func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.CreatedTransactionOutput__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() out := *(*coin.TransactionOutput)(unsafe.Pointer(_out)) txid := *(*cipher.SHA256)(unsafe.Pointer(_txid)) __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) @@ -99,11 +79,6 @@ func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid //export SKY_api_NewCreatedTransactionInput func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.CreatedTransactionInput__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() out := *(*wallet.UxBalance)(unsafe.Pointer(_out)) __arg1, ____return_err := api.NewCreatedTransactionInput(out) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/api.wallet.go b/lib/cgo/api.wallet.go index 726255d283..90b218dc52 100644 --- a/lib/cgo/api.wallet.go +++ b/lib/cgo/api.wallet.go @@ -13,11 +13,6 @@ import "C" //export SKY_api_NewWalletResponse func SKY_api_NewWalletResponse(_w C.Wallet__Handle, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/api.webrpc.client.go b/lib/cgo/api.webrpc.client.go index 6448aa354d..556ec561c2 100644 --- a/lib/cgo/api.webrpc.client.go +++ b/lib/cgo/api.webrpc.client.go @@ -18,11 +18,6 @@ import "C" //export SKY_webrpc_NewClient func SKY_webrpc_NewClient(_addr string, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := _addr __arg1, ____return_err := webrpc.NewClient(addr) @@ -35,11 +30,6 @@ func SKY_webrpc_NewClient(_addr string, _arg1 *C.WebRpcClient__Handle) (____erro //export SKY_webrpc_Client_CSRF func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { @@ -56,11 +46,6 @@ func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____ //export SKY_webrpc_Client_InjectTransaction func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -81,11 +66,6 @@ func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transa //export SKY_webrpc_Client_GetStatus func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -101,11 +81,6 @@ func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResul //export SKY_webrpc_Client_GetTransactionByID func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.TransactionResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -122,11 +97,6 @@ func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid strin //export SKY_webrpc_Client_GetAddressUxOuts func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -143,11 +113,6 @@ func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []stri //export SKY_webrpc_Client_GetBlocksInRange func SKY_webrpc_Client_GetBlocksInRange(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -165,11 +130,6 @@ func SKY_webrpc_Client_GetBlocksInRange(_c C.WebRpcClient__Handle, _start, _end //export SKY_webrpc_Client_GetBlocksBySeq func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -186,11 +146,6 @@ func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _ //export SKY_webrpc_Client_GetLastBlocks func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.address.go b/lib/cgo/cipher.address.go index 517e7aaf9f..6c3546c825 100644 --- a/lib/cgo/cipher.address.go +++ b/lib/cgo/cipher.address.go @@ -19,11 +19,6 @@ import "C" //export SKY_cipher_DecodeBase58Address func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr, err := cipher.DecodeBase58Address(_addr) ____error_code = libErrorCode(err) @@ -35,11 +30,6 @@ func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (___ //export SKY_cipher_AddressFromBytes func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr, err := cipher.AddressFromBytes(_b) ____error_code = libErrorCode(err) @@ -51,11 +41,6 @@ func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error //export SKY_cipher_AddressFromPubKey func SKY_cipher_AddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubKey := (*cipher.PubKey)(unsafe.Pointer(_pubKey)) @@ -66,11 +51,6 @@ func SKY_cipher_AddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__Ad //export SKY_cipher_AddressFromSecKey func SKY_cipher_AddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() var secKey cipher.SecKey secKey = *(*cipher.SecKey)(unsafe.Pointer(_secKey)) @@ -84,11 +64,6 @@ func SKY_cipher_AddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__Ad //export SKY_cipher_Address_Null func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := *inplaceAddress(_addr) __arg0 := addr.Null() @@ -98,11 +73,6 @@ func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_c //export SKY_cipher_Address_Bytes func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := (*cipher.Address)(unsafe.Pointer(_addr)) bytes := addr.Bytes() @@ -112,11 +82,6 @@ func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) (____ //export SKY_cipher_Address_Verify func SKY_cipher_Address_Verify(_addr *C.cipher__Address, _key *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := (*cipher.Address)(unsafe.Pointer(_addr)) key := (*cipher.PubKey)(unsafe.Pointer(_key)) @@ -127,11 +92,6 @@ func SKY_cipher_Address_Verify(_addr *C.cipher__Address, _key *C.cipher__PubKey) //export SKY_cipher_Address_String func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := (*cipher.Address)(unsafe.Pointer(_addr)) s := addr.String() @@ -141,11 +101,6 @@ func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) (__ //export SKY_cipher_Address_Checksum func SKY_cipher_Address_Checksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := (*cipher.Address)(unsafe.Pointer(_addr)) cs := addr.Checksum() diff --git a/lib/cgo/cipher.base58.base58.go b/lib/cgo/cipher.base58.base58.go index 73663ec001..2e7b1c8186 100644 --- a/lib/cgo/cipher.base58.base58.go +++ b/lib/cgo/cipher.base58.base58.go @@ -19,11 +19,6 @@ import "C" //export SKY_base58_String2Hex func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := _s __arg1, ____return_err := hex.DecodeString(s) ____error_code = libErrorCode(____return_err) @@ -36,11 +31,6 @@ func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) //export SKY_base58_Base58_ToInt func SKY_base58_Base58_ToInt(_b string, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.ToInt() ____error_code = libErrorCode(____return_err) @@ -52,11 +42,6 @@ func SKY_base58_Base58_ToInt(_b string, _arg0 *int) (____error_code uint32) { //export SKY_base58_Base58_ToHex func SKY_base58_Base58_ToHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.ToHex() ____error_code = libErrorCode(____return_err) @@ -68,11 +53,6 @@ func SKY_base58_Base58_ToHex(_b string, _arg0 *C.GoSlice_) (____error_code uint3 //export SKY_base58_Base58_Base582Int func SKY_base58_Base58_Base582Int(_b string, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.Base582Int() ____error_code = libErrorCode(____return_err) @@ -84,11 +64,6 @@ func SKY_base58_Base58_Base582Int(_b string, _arg0 *int) (____error_code uint32) //export SKY_base58_Base582Hex func SKY_base58_Base582Hex(_b string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := _b __arg1, ____return_err := base58.Base582Hex(b) ____error_code = libErrorCode(____return_err) @@ -100,11 +75,6 @@ func SKY_base58_Base582Hex(_b string, _arg1 *C.GoSlice_) (____error_code uint32) //export SKY_base58_Base58_BitHex func SKY_base58_Base58_BitHex(_b string, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := (base58.Base58)(_b) __arg0, ____return_err := b.BitHex() ____error_code = libErrorCode(____return_err) @@ -116,11 +86,6 @@ func SKY_base58_Base58_BitHex(_b string, _arg0 *C.GoSlice_) (____error_code uint //export SKY_base58_Int2Base58 func SKY_base58_Int2Base58(_val int, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() val := _val __arg1 := base58.Int2Base58(val) copyString(string(__arg1), _arg1) @@ -129,11 +94,6 @@ func SKY_base58_Int2Base58(_val int, _arg1 *C.GoString_) (____error_code uint32) //export SKY_base58_Hex2Base58 func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58(val) copyString(string(__arg1), _arg1) @@ -142,11 +102,6 @@ func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint //export SKY_base58_Hex2Base58String func SKY_base58_Hex2Base58String(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58String(val) copyString(__arg1, _arg1) @@ -155,11 +110,6 @@ func SKY_base58_Hex2Base58String(_val []byte, _arg1 *C.GoString_) (____error_cod //export SKY_base58_Hex2Base58Str func SKY_base58_Hex2Base58Str(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() val := *(*[]byte)(unsafe.Pointer(&_val)) __arg1 := base58.Hex2Base58Str(val) copyString(__arg1, _arg1) diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index 0a2b131e8c..27cc75dfcd 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -18,11 +18,6 @@ import "C" //export SKY_cipher_RandByte func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := cipher.RandByte(_n) copyToGoSlice(reflect.ValueOf(b), _arg1) @@ -31,11 +26,6 @@ func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { //export SKY_cipher_NewPubKey func SKY_cipher_NewPubKey(_b []byte, _arg1 *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey, err := cipher.NewPubKey(_b) if err == nil { @@ -47,11 +37,6 @@ func SKY_cipher_NewPubKey(_b []byte, _arg1 *C.cipher__PubKey) (____error_code ui //export SKY_cipher_PubKeyFromHex func SKY_cipher_PubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey, err := cipher.PubKeyFromHex(_s) ____error_code = libErrorCode(err) @@ -63,11 +48,6 @@ func SKY_cipher_PubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (____error_cod //export SKY_cipher_PubKeyFromSecKey func SKY_cipher_PubKeyFromSecKey(_seckey *C.cipher__SecKey, _arg1 *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) pubkey, err := cipher.PubKeyFromSecKey(*seckey) @@ -82,11 +62,6 @@ func SKY_cipher_PubKeyFromSecKey(_seckey *C.cipher__SecKey, _arg1 *C.cipher__Pub //export SKY_cipher_PubKeyFromSig func SKY_cipher_PubKeyFromSig(_sig *C.cipher__Sig, _hash *C.cipher__SHA256, _arg2 *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig := (*cipher.Sig)(unsafe.Pointer(_sig)) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) @@ -104,11 +79,6 @@ func SKY_cipher_PubKeyFromSig(_sig *C.cipher__Sig, _hash *C.cipher__SHA256, _arg //export SKY_cipher_PubKey_Verify func SKY_cipher_PubKey_Verify(_pk *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) @@ -120,11 +90,6 @@ func SKY_cipher_PubKey_Verify(_pk *C.cipher__PubKey) (____error_code uint32) { //export SKY_cipher_PubKey_Hex func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) s := pk.Hex() copyString(s, _arg1) @@ -133,11 +98,6 @@ func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) (____error //export SKY_cipher_PubKeyRipemd160 func SKY_cipher_PubKeyRipemd160(_pk *C.cipher__PubKey, _arg0 *C.cipher__Ripemd160) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) h := cipher.PubKeyRipemd160(*pk) @@ -147,11 +107,6 @@ func SKY_cipher_PubKeyRipemd160(_pk *C.cipher__PubKey, _arg0 *C.cipher__Ripemd16 //export SKY_cipher_NewSecKey func SKY_cipher_NewSecKey(_b []byte, _arg1 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sk, err := cipher.NewSecKey(_b) if err == nil { @@ -164,11 +119,6 @@ func SKY_cipher_NewSecKey(_b []byte, _arg1 *C.cipher__SecKey) (____error_code ui //export SKY_cipher_SecKeyFromHex func SKY_cipher_SecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sk, err := cipher.SecKeyFromHex(_s) errcode := libErrorCode(err) @@ -181,11 +131,6 @@ func SKY_cipher_SecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_cod //export SKY_cipher_SecKey_Verify func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) err := sk.Verify() @@ -195,11 +140,6 @@ func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) (____error_code uint32) { //export SKY_cipher_SecKey_Hex func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) s := sk.Hex() @@ -209,11 +149,6 @@ func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) (____error //export SKY_cipher_ECDH func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pub := (*cipher.PubKey)(unsafe.Pointer(_pub)) sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) @@ -227,11 +162,6 @@ func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.Go //export SKY_cipher_NewSig func SKY_cipher_NewSig(_b []byte, _arg1 *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s, err := cipher.NewSig(_b) if err == nil { @@ -243,11 +173,6 @@ func SKY_cipher_NewSig(_b []byte, _arg1 *C.cipher__Sig) (____error_code uint32) //export SKY_cipher_SigFromHex func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s, err := cipher.SigFromHex(_s) errcode := libErrorCode(err) @@ -260,11 +185,6 @@ func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint //export SKY_cipher_Sig_Hex func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := (*cipher.Sig)(unsafe.Pointer(_s)) copyString(s.Hex(), _arg1) @@ -273,11 +193,6 @@ func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) (____error_code u //export SKY_cipher_SignHash func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) s, err := cipher.SignHash(*hash, *sec) @@ -290,11 +205,6 @@ func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 //export SKY_cipher_ChkSig func SKY_cipher_ChkSig(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() address := inplaceAddress(_address) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) @@ -307,11 +217,6 @@ func SKY_cipher_ChkSig(_address *C.cipher__Address, _hash *C.cipher__SHA256, _si //export SKY_cipher_VerifySignedHash func SKY_cipher_VerifySignedHash(_sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) @@ -323,11 +228,6 @@ func SKY_cipher_VerifySignedHash(_sig *C.cipher__Sig, _hash *C.cipher__SHA256) ( //export SKY_cipher_VerifySignature func SKY_cipher_VerifySignature(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey := (*cipher.PubKey)(unsafe.Pointer(_pubkey)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) @@ -340,11 +240,6 @@ func SKY_cipher_VerifySignature(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, //export SKY_cipher_GenerateKeyPair func SKY_cipher_GenerateKeyPair(_arg0 *C.cipher__PubKey, _arg1 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() p, s := cipher.GenerateKeyPair() copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg0), uint(SizeofPubKey)) @@ -354,11 +249,6 @@ func SKY_cipher_GenerateKeyPair(_arg0 *C.cipher__PubKey, _arg1 *C.cipher__SecKey //export SKY_cipher_GenerateDeterministicKeyPair func SKY_cipher_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.cipher__PubKey, _arg2 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() p, s, err := cipher.GenerateDeterministicKeyPair(_seed) if err == nil { copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) @@ -371,11 +261,6 @@ func SKY_cipher_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.cipher__PubK //export SKY_cipher_DeterministicKeyPairIterator func SKY_cipher_DeterministicKeyPairIterator(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.cipher__PubKey, _arg3 *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h, p, s, err := cipher.DeterministicKeyPairIterator(_seed) ____error_code = libErrorCode(err) @@ -391,11 +276,6 @@ func SKY_cipher_DeterministicKeyPairIterator(_seed []byte, _arg1 *C.GoSlice_, _a //export SKY_cipher_GenerateDeterministicKeyPairs func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sks, err := cipher.GenerateDeterministicKeyPairs(_seed, _n) ____error_code = libErrorCode(err) @@ -408,11 +288,6 @@ func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoS //export SKY_cipher_GenerateDeterministicKeyPairsSeed func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h, sks, err := cipher.GenerateDeterministicKeyPairsSeed(_seed, _n) if err == nil { @@ -425,11 +300,6 @@ func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C //export SKY_cipher_CheckSecKey func SKY_cipher_CheckSecKey(_seckey *C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) @@ -440,11 +310,6 @@ func SKY_cipher_CheckSecKey(_seckey *C.cipher__SecKey) (____error_code uint32) { //export SKY_cipher_CheckSecKeyHash func SKY_cipher_CheckSecKeyHash(_seckey *C.cipher__SecKey, _hash *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) diff --git a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go index f76ce52886..26195ec61e 100644 --- a/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go +++ b/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go @@ -18,11 +18,6 @@ import "C" //export SKY_encrypt_ScryptChacha20poly1305_Encrypt func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -36,11 +31,6 @@ func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20pol //export SKY_encrypt_ScryptChacha20poly1305_Decrypt func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go index 5c8d334e1d..27e8bf48e7 100644 --- a/lib/cgo/cipher.encrypt.sha256xor.go +++ b/lib/cgo/cipher.encrypt.sha256xor.go @@ -18,11 +18,6 @@ import "C" //export SKY_encrypt_Sha256Xor_Encrypt func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) @@ -36,11 +31,6 @@ func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSl //export SKY_encrypt_Sha256Xor_Decrypt func SKY_encrypt_Sha256Xor_Decrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := encrypt.Sha256Xor{} data := *(*[]byte)(unsafe.Pointer(&_data)) password := *(*[]byte)(unsafe.Pointer(&_password)) diff --git a/lib/cgo/cipher.go-bip39.bip39.go b/lib/cgo/cipher.go-bip39.bip39.go index bceb6b4e34..a0a88c00ce 100644 --- a/lib/cgo/cipher.go-bip39.bip39.go +++ b/lib/cgo/cipher.go-bip39.bip39.go @@ -18,11 +18,6 @@ import "C" //export SKY_bip39_NewDefaultMnemomic func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0, ____return_err := gobip39.NewDefaultMnemonic() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -33,11 +28,6 @@ func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_bip39_NewEntropy func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bitSize := _bitSize __arg1, ____return_err := gobip39.NewEntropy(bitSize) ____error_code = libErrorCode(____return_err) @@ -49,11 +39,6 @@ func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint3 //export SKY_bip39_NewMnemonic func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() entropy := *(*[]byte)(unsafe.Pointer(&_entropy)) __arg1, ____return_err := gobip39.NewMnemonic(entropy) ____error_code = libErrorCode(____return_err) @@ -65,11 +50,6 @@ func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code //export SKY_bip39_MnemonicToByteArray func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() mnemonic := _mnemonic __arg1, ____return_err := gobip39.MnemonicToByteArray(mnemonic) ____error_code = libErrorCode(____return_err) @@ -81,11 +61,6 @@ func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____err //export SKY_bip39_IsMnemonicValid func SKY_bip39_IsMnemonicValid(_mnemonic string, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() mnemonic := _mnemonic __arg1 := gobip39.IsMnemonicValid(mnemonic) *_arg1 = __arg1 diff --git a/lib/cgo/cipher.hash.go b/lib/cgo/cipher.hash.go index 535b3d807e..759c8997b3 100644 --- a/lib/cgo/cipher.hash.go +++ b/lib/cgo/cipher.hash.go @@ -18,11 +18,6 @@ import "C" //export SKY_cipher_Ripemd160_Set func SKY_cipher_Ripemd160_Set(_rd *C.cipher__Ripemd160, _b []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() rd := (*cipher.Ripemd160)(unsafe.Pointer(_rd)) err := rd.Set(_b) @@ -32,11 +27,6 @@ func SKY_cipher_Ripemd160_Set(_rd *C.cipher__Ripemd160, _b []byte) (____error_co //export SKY_cipher_HashRipemd160 func SKY_cipher_HashRipemd160(_data []byte, _arg1 *C.cipher__Ripemd160) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() rd := cipher.HashRipemd160(_data) @@ -46,11 +36,6 @@ func SKY_cipher_HashRipemd160(_data []byte, _arg1 *C.cipher__Ripemd160) (____err //export SKY_cipher_SHA256_Set func SKY_cipher_SHA256_Set(_g *C.cipher__SHA256, _b []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() g := (*cipher.SHA256)(unsafe.Pointer(_g)) err := g.Set(_b) @@ -60,11 +45,6 @@ func SKY_cipher_SHA256_Set(_g *C.cipher__SHA256, _b []byte) (____error_code uint //export SKY_cipher_SHA256_Hex func SKY_cipher_SHA256_Hex(_g *C.cipher__SHA256, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() g := (*cipher.SHA256)(unsafe.Pointer(_g)) copyString(g.Hex(), _arg1) @@ -73,11 +53,6 @@ func SKY_cipher_SHA256_Hex(_g *C.cipher__SHA256, _arg1 *C.GoString_) (____error_ //export SKY_cipher_SHA256_Xor func SKY_cipher_SHA256_Xor(_g *C.cipher__SHA256, _b *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() g := (*cipher.SHA256)(unsafe.Pointer(_g)) b := (*cipher.SHA256)(unsafe.Pointer(_b)) @@ -89,11 +64,6 @@ func SKY_cipher_SHA256_Xor(_g *C.cipher__SHA256, _b *C.cipher__SHA256, _arg1 *C. //export SKY_cipher_SumSHA256 func SKY_cipher_SumSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h := cipher.SumSHA256(_b) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) @@ -102,11 +72,6 @@ func SKY_cipher_SumSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code ui //export SKY_cipher_SHA256FromHex func SKY_cipher_SHA256FromHex(_hs string, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h, err := cipher.SHA256FromHex(_hs) ____error_code = libErrorCode(err) @@ -118,11 +83,6 @@ func SKY_cipher_SHA256FromHex(_hs string, _arg1 *C.cipher__SHA256) (____error_co //export SKY_cipher_DoubleSHA256 func SKY_cipher_DoubleSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h := cipher.DoubleSHA256(_b) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) @@ -131,11 +91,6 @@ func SKY_cipher_DoubleSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code //export SKY_cipher_AddSHA256 func SKY_cipher_AddSHA256(_a *C.cipher__SHA256, _b *C.cipher__SHA256, _arg2 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := (*cipher.SHA256)(unsafe.Pointer(_a)) b := (*cipher.SHA256)(unsafe.Pointer(_b)) @@ -147,11 +102,6 @@ func SKY_cipher_AddSHA256(_a *C.cipher__SHA256, _b *C.cipher__SHA256, _arg2 *C.c //export SKY_cipher_Merkle func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h0 := (*[]cipher.SHA256)(unsafe.Pointer(_h0)) h := cipher.Merkle(*h0) copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) @@ -160,11 +110,6 @@ func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____er //export SKY_cipher_SHA256_Null func SKY_cipher_SHA256_Null(_g *C.cipher__SHA256, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() g := (*cipher.SHA256)(unsafe.Pointer(_g)) *_arg0 = g.Null() return diff --git a/lib/cgo/cipher.poly1305.poly1305.go b/lib/cgo/cipher.poly1305.poly1305.go index 70d2c60ce0..d62177b205 100644 --- a/lib/cgo/cipher.poly1305.poly1305.go +++ b/lib/cgo/cipher.poly1305.poly1305.go @@ -17,11 +17,6 @@ import "C" //export SKY_poly1305_Verify func SKY_poly1305_Verify(_mac *C.GoSlice_, _m []byte, _key *C.GoSlice_, _arg3 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() mac := (*[16]byte)(unsafe.Pointer(_mac)) m := *(*[]byte)(unsafe.Pointer(&_m)) key := (*[32]byte)(unsafe.Pointer(_key)) diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go index 83c15f3cad..3ec9eda5a8 100644 --- a/lib/cgo/cipher.ripemd160.ripemd160.go +++ b/lib/cgo/cipher.ripemd160.ripemd160.go @@ -18,11 +18,6 @@ import "C" //export SKY_ripemd160_New func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hash := ripemd160.New() *handle = registerHashHandle(&hash) return @@ -30,11 +25,6 @@ func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { //export SKY_ripemd160_Write func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h, ok := lookupHashHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -52,11 +42,6 @@ func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_c //export SKY_ripemd160_Sum func SKY_ripemd160_Sum(handle C.Hash_Handle, _p []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h, ok := lookupHashHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.scrypt.scrypt.go b/lib/cgo/cipher.scrypt.scrypt.go index 5f6e2b5b0e..d2f121b884 100644 --- a/lib/cgo/cipher.scrypt.scrypt.go +++ b/lib/cgo/cipher.scrypt.scrypt.go @@ -18,11 +18,6 @@ import "C" //export SKY_scrypt_Key func SKY_scrypt_Key(_password, _salt []byte, _N, _r, _p, _keyLen int, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() password := *(*[]byte)(unsafe.Pointer(&_password)) salt := *(*[]byte)(unsafe.Pointer(&_salt)) N := _N diff --git a/lib/cgo/cipher.secp256k1-go.secp256_rand.go b/lib/cgo/cipher.secp256k1-go.secp256_rand.go index cf1521bf62..d19688d422 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256_rand.go +++ b/lib/cgo/cipher.secp256k1-go.secp256_rand.go @@ -18,11 +18,6 @@ import "C" //export SKY_secp256k1_SumSHA256 func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1 := secp256k1go.SumSHA256(b) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -31,11 +26,6 @@ func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint3 //export SKY_secp256k1_RandByte func SKY_secp256k1_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() n := _n __arg1 := secp256k1go.RandByte(n) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go index dbfb3d9572..16e2aad786 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go @@ -18,11 +18,6 @@ import "C" //export SKY_secp256k1go_DecompressPoint func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() X := *(*[]byte)(unsafe.Pointer(&_X)) off := _off Y := *(*[]byte)(unsafe.Pointer(&_Y)) @@ -32,11 +27,6 @@ func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error //export SKY_secp256k1go_RecoverPublicKey func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _arg3 *C.GoSlice_, _arg4 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sigByte := *(*[]byte)(unsafe.Pointer(&_sigByte)) h := *(*[]byte)(unsafe.Pointer(&_h)) recid := _recid @@ -48,11 +38,6 @@ func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _a //export SKY_secp256k1go_Multiply func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := *(*[]byte)(unsafe.Pointer(&_xy)) k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.Multiply(xy, k) @@ -62,11 +47,6 @@ func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code //export SKY_secp256k1go_BaseMultiply func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.BaseMultiply(k) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -75,11 +55,6 @@ func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code //export SKY_secp256k1go_BaseMultiplyAdd func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := *(*[]byte)(unsafe.Pointer(&_xy)) k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.BaseMultiplyAdd(xy, k) @@ -89,11 +64,6 @@ func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____err //export SKY_secp256k1go_GeneratePublicKey func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() k := *(*[]byte)(unsafe.Pointer(&_k)) __arg1 := secp256k1go2.GeneratePublicKey(k) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -102,11 +72,6 @@ func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_ //export SKY_secp256k1go_SeckeyIsValid func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go2.SeckeyIsValid(seckey) *_arg1 = __arg1 @@ -115,11 +80,6 @@ func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code u //export SKY_secp256k1go_PubkeyIsValid func SKY_secp256k1go_PubkeyIsValid(_pubkey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go2.PubkeyIsValid(pubkey) *_arg1 = __arg1 diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go index bdafb1aa48..0edf788ace 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go @@ -17,11 +17,6 @@ import "C" //export SKY_secp256k1go_Field_String func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.String() copyString(__arg0, _arg0) @@ -30,11 +25,6 @@ func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) //export SKY_secp256k1go_Field_Print func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) lab := _lab fd.Print(lab) @@ -43,11 +33,6 @@ func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____er //export SKY_secp256k1go_Field_SetB32 func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := *(*[]byte)(unsafe.Pointer(&_a)) fd.SetB32(a) @@ -56,11 +41,6 @@ func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____err //export SKY_secp256k1go_Field_SetBytes func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := *(*[]byte)(unsafe.Pointer(&_a)) fd.SetBytes(a) @@ -69,11 +49,6 @@ func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____e //export SKY_secp256k1go_Field_SetHex func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) s := _s fd.SetHex(s) @@ -82,11 +57,6 @@ func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____err //export SKY_secp256k1go_Field_IsOdd func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.IsOdd() *_arg0 = __arg0 @@ -95,11 +65,6 @@ func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____er //export SKY_secp256k1go_Field_IsZero func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) __arg0 := fd.IsZero() *_arg0 = __arg0 @@ -108,11 +73,6 @@ func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____e //export SKY_secp256k1go_Field_SetInt func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := _a fd.SetInt(a) @@ -121,11 +81,6 @@ func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____err //export SKY_secp256k1go_Field_Normalize func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) fd.Normalize() return @@ -133,11 +88,6 @@ func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code //export SKY_secp256k1go_Field_GetB32 func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := *(*[]byte)(unsafe.Pointer(&_r)) fd.GetB32(r) @@ -146,11 +96,6 @@ func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____err //export SKY_secp256k1go_Field_Equals func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__Field, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) __arg1 := fd.Equals(b) @@ -160,11 +105,6 @@ func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__ //export SKY_secp256k1go_Field_SetAdd func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := (*secp256k1go2.Field)(unsafe.Pointer(_a)) fd.SetAdd(a) @@ -173,11 +113,6 @@ func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__ //export SKY_secp256k1go_Field_MulInt func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) a := _a fd.MulInt(a) @@ -186,11 +121,6 @@ func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____err //export SKY_secp256k1go_Field_Negate func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field, _m uint32) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) m := _m @@ -200,11 +130,6 @@ func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ //export SKY_secp256k1go_Field_Inv func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Inv(r) @@ -213,11 +138,6 @@ func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fie //export SKY_secp256k1go_Field_Sqrt func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Sqrt(r) @@ -226,11 +146,6 @@ func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Fi //export SKY_secp256k1go_Field_InvVar func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.InvVar(r) @@ -239,11 +154,6 @@ func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__ //export SKY_secp256k1go_Field_Mul func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) @@ -253,11 +163,6 @@ func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go_ //export SKY_secp256k1go_Field_Sqr func SKY_secp256k1go_Field_Sqr(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) fd.Sqr(r) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go index 8cd908d0a7..843e39d28d 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go @@ -17,11 +17,6 @@ import "C" //export SKY_secp256k1go_Number_Create func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() var num secp256k1go2.Number *handle = registerNumberHandle(&num) return @@ -29,11 +24,6 @@ func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint //export SKY_secp256k1go_Number_Print func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -45,11 +35,6 @@ func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____er //export SKY_secp256k1go_Number_SetHex func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -61,11 +46,6 @@ func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error //export SKY_secp256k1go_Number_IsOdd func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() num, ok := lookupNumberHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -78,11 +58,6 @@ func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____erro //export SKY_secp256k1go_Number_IsEqual func SKY_secp256k1go_Number_IsEqual(handle1 C.Number_Handle, handle2 C.Number_Handle, result *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() num1, ok := lookupNumberHandle(handle1) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go index eb7e87d11b..04a6094d20 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go @@ -18,11 +18,6 @@ import "C" //export SKY_secp256k1go_Signature_Create func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() var sig secp256k1go2.Signature *handle = registerSignatureHandle(&sig) return @@ -30,11 +25,6 @@ func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_cod //export SKY_secp256k1go_Signature_GetR func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -46,11 +36,6 @@ func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handl //export SKY_secp256k1go_Signature_GetS func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -62,11 +47,6 @@ func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handl //export SKY_secp256k1go_Signature_Print func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -78,11 +58,6 @@ func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (__ //export SKY_secp256k1go_Signature_Verify func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _arg2 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -101,11 +76,6 @@ func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp //export SKY_secp256k1go_Signature_Recover func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _recid int, _arg3 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -125,11 +95,6 @@ func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.sec //export SKY_secp256k1go_Signature_Sign func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message, _nonce C.Number_Handle, _recid *int, _arg2 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -158,11 +123,6 @@ func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message //export SKY_secp256k1go_Signature_ParseBytes func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -175,11 +135,6 @@ func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) //export SKY_secp256k1go_Signature_Bytes func SKY_secp256k1go_Signature_Bytes(handle C.Signature_Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig, ok := lookupSignatureHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go index 5ec03f47ca..e2e75f4cb7 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go @@ -18,11 +18,6 @@ import "C" //export SKY_secp256k1go_XY_Print func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) lab := _lab xy.Print(lab) @@ -31,11 +26,6 @@ func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_co //export SKY_secp256k1go_XY_ParsePubkey func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) pub := *(*[]byte)(unsafe.Pointer(&_pub)) __arg1 := xy.ParsePubkey(pub) @@ -45,11 +35,6 @@ func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 * //export SKY_secp256k1go_XY_Bytes func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := *(*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -58,11 +43,6 @@ func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____er //export SKY_secp256k1go_XY_BytesUncompressed func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.BytesUncompressed() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -71,11 +51,6 @@ func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSli //export SKY_secp256k1go_XY_SetXY func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Field) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) Y := (*secp256k1go2.Field)(unsafe.Pointer(_Y)) @@ -85,11 +60,6 @@ func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Fie //export SKY_secp256k1go_XY_IsValid func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.IsValid() *_arg0 = __arg0 @@ -98,11 +68,6 @@ func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_ //export SKY_secp256k1go_XY_SetXYZ func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) a := (*secp256k1go2.XYZ)(unsafe.Pointer(_a)) xy.SetXYZ(a) @@ -111,11 +76,6 @@ func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) ( //export SKY_secp256k1go_XY_Neg func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) r := (*secp256k1go2.XY)(unsafe.Pointer(_r)) xy.Neg(r) @@ -124,11 +84,6 @@ func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____ //export SKY_secp256k1go_XY_SetXO func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, _odd bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) odd := _odd @@ -138,11 +93,6 @@ func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, //export SKY_secp256k1go_XY_AddXY func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) xy.AddXY(a) @@ -151,11 +101,6 @@ func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (__ //export SKY_secp256k1go_XY_GetPublicKey func SKY_secp256k1go_XY_GetPublicKey(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) __arg0 := xy.GetPublicKey() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go index f89430016c..7dd90678e7 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go @@ -17,10 +17,6 @@ import "C" //export SKY_secp256k1go_XYZ_Print func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) lab := _lab xyz.Print(lab) @@ -29,11 +25,7 @@ func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error //export SKY_secp256k1go_XYZ_SetXY func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) xyz.SetXY(a) return @@ -41,11 +33,7 @@ func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) //export SKY_secp256k1go_XYZ_IsInfinity func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) __arg0 := xyz.IsInfinity() *_arg0 = __arg0 return @@ -53,11 +41,7 @@ func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____ //export SKY_secp256k1go_XYZ_IsValid func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) __arg0 := xyz.IsValid() *_arg0 = __arg0 return @@ -65,22 +49,14 @@ func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____err //export SKY_secp256k1go_XYZ_Normalize func SKY_secp256k1go_XYZ_Normalize(_xyz *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) xyz.Normalize() return } //export SKY_secp256k1go_XYZ_Equals func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) __arg1 := xyz.Equals(b) *_arg1 = __arg1 @@ -89,11 +65,7 @@ func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_ECmult func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng C.Number_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) na, ok1 := lookupNumberHandle(_na) if !ok1 { @@ -111,11 +83,7 @@ func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_Neg func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) xyz.Neg(r) return @@ -123,11 +91,7 @@ func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) ( //export SKY_secp256k1go_XYZ_Double func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) xyz.Double(r) return @@ -135,11 +99,7 @@ func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ //export SKY_secp256k1go_XYZ_AddXY func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _b *C.secp256k1go__XY) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) b := (*secp256k1go2.XY)(unsafe.Pointer(_b)) xyz.AddXY(r, b) @@ -148,11 +108,7 @@ func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, //export SKY_secp256k1go_XYZ_Add func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XYZ) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - xyz := (*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) + xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) xyz.Add(r, b) @@ -161,10 +117,6 @@ func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XY //export SKY_secp256k1go_ECmultGen func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a C.Number_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) a, ok := lookupNumberHandle(_a) if !ok { diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go index 53e12d6335..014ecca255 100644 --- a/lib/cgo/cipher.secp256k1-go.secp256k1.go +++ b/lib/cgo/cipher.secp256k1-go.secp256k1.go @@ -18,11 +18,6 @@ import "C" //export SKY_secp256k1_GenerateKeyPair func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0, __arg1 := secp256k1go.GenerateKeyPair() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -31,11 +26,6 @@ func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____er //export SKY_secp256k1_PubkeyFromSeckey func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.PubkeyFromSeckey(seckey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -44,11 +34,6 @@ func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____erro //export SKY_secp256k1_UncompressPubkey func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go.UncompressPubkey(pubkey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -57,11 +42,6 @@ func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____erro //export SKY_secp256k1_UncompressedPubkeyFromSeckey func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.UncompressedPubkeyFromSeckey(seckey) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -70,11 +50,6 @@ func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice //export SKY_secp256k1_Secp256k1Hash func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hash := *(*[]byte)(unsafe.Pointer(&_hash)) __arg1 := secp256k1go.Secp256k1Hash(hash) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -83,11 +58,6 @@ func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_cod //export SKY_secp256k1_GenerateDeterministicKeyPair func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seed := *(*[]byte)(unsafe.Pointer(&_seed)) __arg1, __arg2 := secp256k1go.GenerateDeterministicKeyPair(seed) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -97,11 +67,6 @@ func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, //export SKY_secp256k1_DeterministicKeyPairIterator func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seedIn := *(*[]byte)(unsafe.Pointer(&_seedIn)) __arg1, __arg2, __arg3 := secp256k1go.DeterministicKeyPairIterator(seedIn) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) @@ -112,11 +77,6 @@ func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice //export SKY_secp256k1_Sign func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg2 := secp256k1go.Sign(msg, seckey) @@ -126,11 +86,6 @@ func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____err //export SKY_secp256k1_SignDeterministic func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []byte, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) nonceSeed := *(*[]byte)(unsafe.Pointer(&_nonceSeed)) @@ -141,11 +96,6 @@ func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []b //export SKY_secp256k1_VerifySeckey func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) __arg1 := secp256k1go.VerifySeckey(seckey) *_arg1 = __arg1 @@ -154,11 +104,6 @@ func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint //export SKY_secp256k1_VerifyPubkey func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) __arg1 := secp256k1go.VerifyPubkey(pubkey) *_arg1 = __arg1 @@ -167,11 +112,6 @@ func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint //export SKY_secp256k1_VerifySignatureValidity func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() sig := *(*[]byte)(unsafe.Pointer(&_sig)) __arg1 := secp256k1go.VerifySignatureValidity(sig) *_arg1 = __arg1 @@ -180,11 +120,6 @@ func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_c //export SKY_secp256k1_VerifySignature func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg3 := secp256k1go.VerifySignature(_msg, _sig, _pubkey1) *_arg3 = __arg3 return @@ -192,11 +127,6 @@ func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _a //export SKY_secp256k1_SignatureErrorString func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) sig := *(*[]byte)(unsafe.Pointer(&_sig)) pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) @@ -207,11 +137,6 @@ func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byt //export SKY_secp256k1_RecoverPubkey func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() msg := *(*[]byte)(unsafe.Pointer(&_msg)) sig := *(*[]byte)(unsafe.Pointer(&_sig)) __arg2 := secp256k1go.RecoverPubkey(msg, sig) @@ -221,11 +146,6 @@ func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (_ //export SKY_secp256k1_ECDH func SKY_secp256k1_ECDH(_pub []byte, _sec []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pub := *(*[]byte)(unsafe.Pointer(&_pub)) sec := *(*[]byte)(unsafe.Pointer(&_sec)) __arg2 := secp256k1go.ECDH(pub, sec) diff --git a/lib/cgo/cli.add_private_key.go b/lib/cgo/cli.add_private_key.go index 1f96caaa30..2620fe7aa0 100644 --- a/lib/cgo/cli.add_private_key.go +++ b/lib/cgo/cli.add_private_key.go @@ -15,11 +15,6 @@ import "C" //export SKY_cli_AddPrivateKey func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() wlt, okwlt := lookupWalletHandle(_wlt) if !okwlt { ____error_code = SKY_BAD_HANDLE @@ -35,11 +30,6 @@ func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code u //export SKY_cli_AddPrivateKeyToFile func SKY_cli_AddPrivateKeyToFile(_walletFile, _key string, pwd C.PasswordReader__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() walletFile := _walletFile key := _key pr, okc := lookupPasswordReaderHandle(pwd) diff --git a/lib/cgo/cli.check_balance.go b/lib/cgo/cli.check_balance.go index 9a511d7142..d69ec3e57b 100644 --- a/lib/cgo/cli.check_balance.go +++ b/lib/cgo/cli.check_balance.go @@ -17,11 +17,6 @@ import "C" //export SKY_cli_CheckWalletBalance func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -38,11 +33,6 @@ func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _ //export SKY_cli_GetBalanceOfAddresses func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cli.cli.go b/lib/cgo/cli.cli.go index 1eaab60ca6..2911f82f60 100644 --- a/lib/cgo/cli.cli.go +++ b/lib/cgo/cli.cli.go @@ -19,11 +19,6 @@ import "C" //export SKY_cli_LoadConfig func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0, ____return_err := cli.LoadConfig() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -34,11 +29,6 @@ func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { //export SKY_cli_Config_FullWalletPath func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -52,11 +42,6 @@ func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (___ //export SKY_cli_Config_FullDBPath func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -70,11 +55,6 @@ func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____err //export SKY_cli_NewApp func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __cfg, okcfg := lookupConfigHandle(_cfg) if !okcfg { ____error_code = SKY_BAD_HANDLE @@ -91,11 +71,6 @@ func SKY_cli_NewApp(_cfg C.Config__Handle, _arg1 *C.App__Handle) (____error_code //export SKY_cli_RPCClientFromContext func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupContextHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -108,11 +83,6 @@ func SKY_cli_RPCClientFromContext(_c C.Context__Handle, _arg1 *C.WebRpcClient__H //export SKY_cli_ConfigFromContext func SKY_cli_ConfigFromContext(_c C.Context__Handle, _arg1 *C.Config__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupContextHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -131,11 +101,6 @@ func SKY_cli_NewPasswordReader(_password []byte, passwordReader *C.PasswordReade //export SKY_cli_PasswordFromBytes_Password func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() p := *(*cli.PasswordFromBytes)(unsafe.Pointer(_p)) __arg0, ____return_err := p.Password() ____error_code = libErrorCode(____return_err) @@ -147,11 +112,6 @@ func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.G //export SKY_cli_PasswordFromTerm_Password func SKY_cli_PasswordFromTerm_Password(_arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() p := cli.PasswordFromTerm{} __arg0, ____return_err := p.Password() ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/cli.create_rawtx.go b/lib/cgo/cli.create_rawtx.go index 9fed72f8ac..4907ace468 100644 --- a/lib/cgo/cli.create_rawtx.go +++ b/lib/cgo/cli.create_rawtx.go @@ -20,11 +20,6 @@ import "C" //export SKY_cli_CreateRawTxFromWallet func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { @@ -50,11 +45,6 @@ func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgA //export SKY_cli_CreateRawTxFromAddress func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { @@ -80,17 +70,11 @@ func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFil //export SKY_cli_CreateRawTx func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAddrs []string, _chgAddr string, _toAddrs []C.cli__SendAmount, _password []byte, _arg6 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - checkAPIReady() wlt, okwlt := lookupWalletHandle(_wlt) if !okwlt { @@ -111,11 +95,6 @@ func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAd //export SKY_cli_NewTransaction func SKY_cli_NewTransaction(_utxos []C.wallet__UxBalance, _keys []C.cipher__SecKey, _outs []C.coin__TransactionOutput, _arg3 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() utxos := *(*[]wallet.UxBalance)(unsafe.Pointer(&_utxos)) keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go index 8c962fa196..9865862754 100644 --- a/lib/cgo/cli.generate_addrs.go +++ b/lib/cgo/cli.generate_addrs.go @@ -19,11 +19,6 @@ import "C" //export SKY_cli_GenerateAddressesInFile func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.PasswordReader__Handle, _arg3 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() walletFile := _walletFile num := _num pr, okc := lookupPasswordReaderHandle(pwd) @@ -41,11 +36,6 @@ func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.Pass //export SKY_cli_FormatAddressesAsJSON func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1, ____return_err := cli.FormatAddressesAsJSON(addrs) ____error_code = libErrorCode(____return_err) @@ -57,11 +47,6 @@ func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString //export SKY_cli_FormatAddressesAsJoinedArray func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1 := cli.FormatAddressesAsJoinedArray(addrs) copyString(__arg1, _arg1) @@ -70,11 +55,6 @@ func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.G //export SKY_cli_AddressesToStrings func SKY_cli_AddressesToStrings(_addrs []C.cipher__Address, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) __arg1 := cli.AddressesToStrings(addrs) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) diff --git a/lib/cgo/cli.generate_wallet.go b/lib/cgo/cli.generate_wallet.go index 86cf1f461f..48714c9900 100644 --- a/lib/cgo/cli.generate_wallet.go +++ b/lib/cgo/cli.generate_wallet.go @@ -15,11 +15,6 @@ import "C" //export SKY_cli_GenerateWallet func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAddrs uint64, _arg3 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() walletFile := _walletFile __opts, okopts := lookupOptionsHandle(*_opts) if !okopts { @@ -38,11 +33,6 @@ func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAd //export SKY_cli_MakeAlphanumericSeed func SKY_cli_MakeAlphanumericSeed(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0 := cli.MakeAlphanumericSeed() copyString(__arg0, _arg0) return diff --git a/lib/cgo/cli.outputs.go b/lib/cgo/cli.outputs.go index 3668ea836d..8d4ce1f66c 100644 --- a/lib/cgo/cli.outputs.go +++ b/lib/cgo/cli.outputs.go @@ -15,11 +15,6 @@ import "C" //export SKY_cli_GetWalletOutputsFromFile func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -36,11 +31,6 @@ func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile str //export SKY_cli_GetWalletOutputs func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c, okc := lookupWebRpcClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/cli_helper.go b/lib/cgo/cli_helper.go index f589db3eee..50f3408e60 100644 --- a/lib/cgo/cli_helper.go +++ b/lib/cgo/cli_helper.go @@ -17,11 +17,6 @@ import "C" //export SKY_cli_App_Run func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() app, okapp := lookupAppHandle(_app) if !okapp { ____error_code = SKY_BAD_HANDLE @@ -37,11 +32,6 @@ func SKY_cli_App_Run(_app C.App__Handle, _args string) (____error_code uint32) { //export SKY_cli_Config_GetCoin func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -55,11 +45,6 @@ func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_ //export SKY_cli_Config_GetRPCAddress func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __c, okc := lookupConfigHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE @@ -73,11 +58,6 @@ func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____ //export SKY_cli_RPCClientFromApp func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() app, okapp := lookupAppHandle(_app) if !okapp { ____error_code = SKY_BAD_HANDLE @@ -90,11 +70,6 @@ func SKY_cli_RPCClientFromApp(_app C.App__Handle, _arg1 *C.WebRpcClient__Handle) //export SKY_cli_Getenv func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0 := os.Getenv(varname) copyString(__arg0, _arg0) return @@ -102,11 +77,6 @@ func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) //export SKY_cli_Setenv func SKY_cli_Setenv(varname string, value string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ____return_err := os.Setenv(varname, value) ____error_code = libErrorCode(____return_err) if ____return_err == nil { diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index b60c307a2a..bfaa46a628 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -33,11 +33,6 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ } } - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -59,11 +54,6 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ //export SKY_coin_SignedBlock_VerifySignature func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.cipher__PubKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := *(*coin.SignedBlock)(unsafe.Pointer(_b)) pubkey := *(*cipher.PubKey)(unsafe.Pointer(_pubkey)) ____return_err := b.VerifySignature(pubkey) @@ -75,11 +65,6 @@ func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.ci //export SKY_coin_NewGenesisBlock func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.Block__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() genesisAddr := *(*cipher.Address)(unsafe.Pointer(_genesisAddr)) genesisCoins := _genesisCoins timestamp := _timestamp @@ -93,11 +78,6 @@ func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _t //export SKY_coin_Block_HashHeader func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -110,12 +90,6 @@ func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (___ //export SKY_coin_Block_PreHashHeader func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -128,11 +102,6 @@ func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) ( //export SKY_coin_Block_Time func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -145,11 +114,6 @@ func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint //export SKY_coin_Block_Seq func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -162,11 +126,6 @@ func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint3 //export SKY_coin_Block_HashBody func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -179,11 +138,6 @@ func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____e //export SKY_coin_Block_Size func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -196,11 +150,6 @@ func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *int) (____error_code uint32) //export SKY_coin_Block_String func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -213,11 +162,6 @@ func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_co //export SKY_coin_Block_GetTransaction func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256, _arg1 *C.Transaction__Handle, _arg2 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -232,11 +176,6 @@ func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256 //export SKY_coin_NewBlockHeader func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body C.BlockBody__Handle, _arg4 *C.coin__BlockHeader) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() prev := *(*coin.BlockHeader)(unsafe.Pointer(_prev)) uxHash := *(*cipher.SHA256)(unsafe.Pointer(_uxHash)) currentTime := _currentTime @@ -253,11 +192,6 @@ func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA2 //export SKY_coin_BlockHeader_Hash func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.Hash() *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) @@ -266,11 +200,6 @@ func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256 //export SKY_coin_BlockHeader_Bytes func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.Bytes() copyToGoSlice(reflect.ValueOf(__arg0), _arg0) @@ -279,11 +208,6 @@ func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (__ //export SKY_coin_BlockHeader_String func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) __arg0 := bh.String() copyString(__arg0, _arg0) @@ -292,11 +216,6 @@ func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) ( //export SKY_coin_BlockBody_Hash func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() body, ok := lookupBlockBodyHandle(_body) if !ok { ____error_code = SKY_BAD_HANDLE @@ -309,11 +228,6 @@ func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) //export SKY_coin_BlockBody_Size func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bb, ok := lookupBlockBodyHandle(*_bb) if !ok { ____error_code = SKY_BAD_HANDLE @@ -326,11 +240,6 @@ func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *int) (____error_co //export SKY_coin_BlockBody_Bytes func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bb, ok := lookupBlockBodyHandle(_bb) if !ok { ____error_code = SKY_BAD_HANDLE @@ -343,11 +252,6 @@ func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____e //export SKY_coin_CreateUnspents func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _arg2 *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { @@ -361,11 +265,6 @@ func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle //export SKY_coin_CreateUnspent func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) tx, ok := lookupTransactionHandle(_tx) if !ok { @@ -383,11 +282,6 @@ func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, //export SKY_coin_GetBlockObject func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -399,11 +293,6 @@ func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_ //export SKY_coin_GetBlockBody func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b, ok := lookupBlockHandle(_b) if !ok { ____error_code = SKY_BAD_HANDLE @@ -415,11 +304,6 @@ func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____err //export SKY_coin_NewEmptyBlock func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle, handle *C.Block__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/coin.math.go b/lib/cgo/coin.math.go index 519efc3ed6..0e423e7342 100644 --- a/lib/cgo/coin.math.go +++ b/lib/cgo/coin.math.go @@ -13,11 +13,6 @@ import "C" //export SKY_coin_AddUint64 func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := _a b := _b __arg1, ____return_err := coin.AddUint64(a, b) @@ -30,11 +25,6 @@ func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { //export SKY_coin_Uint64ToInt64 func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := _a __arg1, ____return_err := coin.Uint64ToInt64(a) ____error_code = libErrorCode(____return_err) @@ -46,11 +36,6 @@ func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { //export SKY_coin_Int64ToUint64 func SKY_coin_Int64ToUint64(_a int64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := _a __arg1, ____return_err := coin.Int64ToUint64(a) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/coin.outputs.go b/lib/cgo/coin.outputs.go index 500c88ec92..8f456d0331 100644 --- a/lib/cgo/coin.outputs.go +++ b/lib/cgo/coin.outputs.go @@ -19,11 +19,6 @@ import "C" //export SKY_coin_UxOut_Hash func SKY_coin_UxOut_Hash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uo := (*coin.UxOut)(unsafe.Pointer(_uo)) __arg0 := uo.Hash() @@ -33,11 +28,6 @@ func SKY_coin_UxOut_Hash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (____error //export SKY_coin_UxOut_SnapshotHash func SKY_coin_UxOut_SnapshotHash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uo := (*coin.UxOut)(unsafe.Pointer(_uo)) __arg0 := uo.SnapshotHash() @@ -47,11 +37,6 @@ func SKY_coin_UxOut_SnapshotHash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (_ //export SKY_coin_UxBody_Hash func SKY_coin_UxBody_Hash(_ub *C.coin__UxBody, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ub := (*coin.UxBody)(unsafe.Pointer(_ub)) __arg0 := ub.Hash() @@ -61,11 +46,6 @@ func SKY_coin_UxBody_Hash(_ub *C.coin__UxBody, _arg0 *C.cipher__SHA256) (____err //export SKY_coin_UxOut_CoinHours func SKY_coin_UxOut_CoinHours(_uo *C.coin__UxOut, _t uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uo := (*coin.UxOut)(unsafe.Pointer(_uo)) t := _t @@ -79,11 +59,6 @@ func SKY_coin_UxOut_CoinHours(_uo *C.coin__UxOut, _t uint64, _arg1 *uint64) (___ //export SKY_coin_UxArray_Hashes func SKY_coin_UxArray_Hashes(_ua *C.coin__UxArray, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) __arg0 := ua.Hashes() @@ -93,11 +68,6 @@ func SKY_coin_UxArray_Hashes(_ua *C.coin__UxArray, _arg0 *C.GoSlice_) (____error //export SKY_coin_UxArray_HasDupes func SKY_coin_UxArray_HasDupes(_ua *C.coin__UxArray, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) *_arg0 = ua.HasDupes() @@ -106,11 +76,6 @@ func SKY_coin_UxArray_HasDupes(_ua *C.coin__UxArray, _arg0 *bool) (____error_cod //export SKY_coin_UxArray_Sort func SKY_coin_UxArray_Sort(_ua *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) ua.Sort() return @@ -118,11 +83,6 @@ func SKY_coin_UxArray_Sort(_ua *C.coin__UxArray) (____error_code uint32) { //export SKY_coin_UxArray_Len func SKY_coin_UxArray_Len(_ua *C.coin__UxArray, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) *_arg0 = ua.Len() @@ -131,11 +91,6 @@ func SKY_coin_UxArray_Len(_ua *C.coin__UxArray, _arg0 *int) (____error_code uint //export SKY_coin_UxArray_Less func SKY_coin_UxArray_Less(_ua *C.coin__UxArray, _i, _j int, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) *_arg0 = ua.Less(_i, _j) @@ -144,11 +99,6 @@ func SKY_coin_UxArray_Less(_ua *C.coin__UxArray, _i, _j int, _arg0 *bool) (____e //export SKY_coin_UxArray_Swap func SKY_coin_UxArray_Swap(_ua *C.coin__UxArray, _i, _j int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) ua.Swap(_i, _j) return @@ -156,11 +106,6 @@ func SKY_coin_UxArray_Swap(_ua *C.coin__UxArray, _i, _j int) (____error_code uin //export SKY_coin_UxArray_Coins func SKY_coin_UxArray_Coins(_ua *C.coin__UxArray, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) __arg0, ____return_err := ua.Coins() @@ -173,11 +118,6 @@ func SKY_coin_UxArray_Coins(_ua *C.coin__UxArray, _arg0 *uint64) (____error_code //export SKY_coin_UxArray_CoinHours func SKY_coin_UxArray_CoinHours(_ua *C.coin__UxArray, _headTime uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) headTime := _headTime @@ -191,11 +131,6 @@ func SKY_coin_UxArray_CoinHours(_ua *C.coin__UxArray, _headTime uint64, _arg1 *u //export SKY_coin_UxArray_Sub func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) @@ -206,11 +141,6 @@ func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * //export SKY_coin_UxArray_Add func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) other := *(*coin.UxArray)(unsafe.Pointer(_other)) __arg1 := ua.Add(other) @@ -220,11 +150,6 @@ func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 * //export SKY_coin_NewAddressUxOuts func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) address_outs := coin.NewAddressUxOuts(ua) *_address_outs = registerAddressUxOutHandle(&address_outs) @@ -233,11 +158,6 @@ func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxO //export SKY_coin_AddressUxOuts_Keys func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() address_outs, ok := lookupAddressUxOutHandle(_address_outs) if !ok { ____error_code = SKY_BAD_HANDLE @@ -250,11 +170,6 @@ func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C. //export SKY_coin_AddressUxOuts_Flatten func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() address_outs, ok := lookupAddressUxOutHandle(_address_outs) if !ok { ____error_code = SKY_BAD_HANDLE @@ -267,11 +182,6 @@ func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C //export SKY_coin_AddressUxOuts_Sub func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() auo1, ok := lookupAddressUxOutHandle(_auo1) if !ok { ____error_code = SKY_BAD_HANDLE @@ -289,11 +199,6 @@ func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO //export SKY_coin_AddressUxOuts_Add func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() auo1, ok := lookupAddressUxOutHandle(_auo1) if !ok { ____error_code = SKY_BAD_HANDLE @@ -311,11 +216,6 @@ func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxO //export SKY_coin_AddressUxOuts_Get func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a, ok := lookupAddressUxOutHandle(handle) if ok { key := *(*cipher.Address)(unsafe.Pointer(_key)) @@ -332,11 +232,6 @@ func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__A //export SKY_coin_AddressUxOuts_HasKey func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _hasKey *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a, ok := lookupAddressUxOutHandle(handle) if ok { key := *(*cipher.Address)(unsafe.Pointer(_key)) @@ -351,11 +246,6 @@ func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher //export SKY_coin_AddressUxOuts_GetOutputLength func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a, ok := lookupAddressUxOutHandle(handle) if ok { key := *(*cipher.Address)(unsafe.Pointer(_key)) @@ -372,11 +262,6 @@ func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key //export SKY_coin_AddressUxOuts_Length func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a, ok := lookupAddressUxOutHandle(handle) if ok { *_length = len(*a) @@ -389,11 +274,6 @@ func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) //export SKY_coin_AddressUxOuts_Set func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a, ok := lookupAddressUxOutHandle(handle) if ok { key := *(*cipher.Address)(unsafe.Pointer(_key)) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 1efb3ac166..b04add6bed 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -21,11 +21,6 @@ import "C" //export SKY_coin_Create_Transaction func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() tx := coin.Transaction{} *handle = registerTransactionHandle(&tx) return @@ -33,11 +28,6 @@ func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code //export SKY_coin_Transaction_Copy func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() tx, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -59,11 +49,6 @@ func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transact //export SKY_coin_GetTransactionObject func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ptx, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -75,11 +60,6 @@ func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin_ //export SKY_coin_Transaction_ResetInputs func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -91,11 +71,6 @@ func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) ( //export SKY_coin_Transaction_GetInputsCount func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -107,11 +82,6 @@ func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *i //export SKY_coin_Transaction_GetInputAt func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -127,11 +97,6 @@ func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input //export SKY_coin_Transaction_SetInputAt func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -147,11 +112,6 @@ func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input //export SKY_coin_Transaction_GetOutputsCount func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -163,11 +123,6 @@ func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length * //export SKY_coin_Transaction_GetOutputAt func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -183,11 +138,6 @@ func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, outpu //export SKY_coin_Transaction_SetOutputAt func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -203,11 +153,6 @@ func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, outpu //export SKY_coin_Transaction_GetSignaturesCount func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -219,11 +164,6 @@ func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, lengt //export SKY_coin_Transaction_GetSignatureAt func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -239,11 +179,6 @@ func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, si //export SKY_coin_Transaction_SetSignatureAt func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -259,11 +194,6 @@ func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, si //export SKY_coin_Transaction_PushSignature func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -276,11 +206,6 @@ func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.ci //export SKY_coin_Transaction_ResetOutputs func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -292,11 +217,6 @@ func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) //export SKY_coin_Transaction_ResetSignatures func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -308,11 +228,6 @@ func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count in //export SKY_coin_Transaction_Verify func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -327,11 +242,6 @@ func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code u //export SKY_coin_Transaction_VerifyInput func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -347,11 +257,6 @@ func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coi //export SKY_coin_Transaction_PushInput func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -365,11 +270,6 @@ func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.ciph //export SKY_coin_TransactionOutput_UxID func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txOut := *(*coin.TransactionOutput)(unsafe.Pointer(_txOut)) txID := *(*cipher.SHA256)(unsafe.Pointer(_txID)) __arg1 := txOut.UxID(txID) @@ -379,11 +279,6 @@ func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C //export SKY_coin_Transaction_PushOutput func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -398,11 +293,6 @@ func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.ciphe //export SKY_coin_Transaction_SignInputs func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -415,11 +305,6 @@ func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cip //export SKY_coin_Transaction_Size func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -432,11 +317,6 @@ func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *int) (____er //export SKY_coin_Transaction_Hash func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -449,11 +329,6 @@ func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SH //export SKY_coin_Transaction_SizeHash func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _arg1 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -467,11 +342,6 @@ func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *int, _ar //export SKY_coin_Transaction_TxID func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -484,11 +354,6 @@ func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) //export SKY_coin_Transaction_TxIDHex func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -501,11 +366,6 @@ func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoStrin //export SKY_coin_Transaction_UpdateHeader func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -517,11 +377,6 @@ func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_ //export SKY_coin_Transaction_HashInner func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -534,11 +389,6 @@ func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.ciphe //export SKY_coin_Transaction_Serialize func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -551,11 +401,6 @@ func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSli //export SKY_coin_TransactionDeserialize func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := *(*[]byte)(unsafe.Pointer(&_b)) __arg1, ____return_err := coin.TransactionDeserialize(b) ____error_code = libErrorCode(____return_err) @@ -567,11 +412,6 @@ func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (_ //export SKY_coin_Transaction_OutputHours func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txn, ok := lookupTransactionHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -594,11 +434,6 @@ func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_cod //export SKY_coin_GetTransactionsObject func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() ptx, ok := lookupTransactionsHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -610,11 +445,6 @@ func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coi //export SKY_coin_Transactions_Length func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(handle) if !ok { ____error_code = SKY_BAD_HANDLE @@ -626,11 +456,6 @@ func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) ( //export SKY_coin_Transactions_Add func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -662,11 +487,6 @@ func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcu return 0, errors.New("Error calculating fee") } } - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -683,11 +503,6 @@ func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcu //export SKY_coin_Transactions_GetAt func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -704,11 +519,6 @@ func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transa //export SKY_coin_Transactions_Hashes func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -721,11 +531,6 @@ func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) //export SKY_coin_Transactions_Size func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -738,11 +543,6 @@ func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *int) (____err //export SKY_coin_Transactions_TruncateBytesTo func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size int, _arg1 *C.Transactions__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -767,11 +567,6 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcul return 0, errors.New("Error calculating fee") } } - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -795,11 +590,6 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.Fe return 0, errors.New("Error calculating fee") } } - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupTransactionsHandle(tsh) if !ok { ____error_code = SKY_BAD_HANDLE @@ -812,11 +602,6 @@ func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.Fe //export SKY_coin_SortableTransactions_Sort func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -828,11 +613,6 @@ func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle //export SKY_coin_SortableTransactions_Len func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, _arg0 *int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -845,11 +625,6 @@ func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, //export SKY_coin_SortableTransactions_Less func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle, _i, _j int, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -864,11 +639,6 @@ func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle //export SKY_coin_SortableTransactions_Swap func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle, _i, _j int) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() txns, ok := lookupSortableTransactionHandle(_txns) if !ok { ____error_code = SKY_BAD_HANDLE @@ -882,11 +652,6 @@ func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle //export SKY_coin_VerifyTransactionCoinsSpending func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) ____return_err := coin.VerifyTransactionCoinsSpending(uxIn, uxOut) @@ -898,11 +663,6 @@ func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.c //export SKY_coin_VerifyTransactionHoursSpending func SKY_coin_VerifyTransactionHoursSpending(_headTime uint64, _uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() headTime := _headTime uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 4627a656d9..254da0b68e 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -2,7 +2,6 @@ package main import ( "errors" - "sync" "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/base58" @@ -36,8 +35,8 @@ const ( const ( // SKY_BAD_HANDLE invalid handle argument SKY_BAD_HANDLE = SKY_PKG_LIBCGO + iota + 1 - // SKY_API_LOCKED API locked for security reasons - SKY_API_LOCKED + // SKY_ErrInvalidTimeString invalid time value + SKY_ErrInvalidTimeString ) // Package prefixes for error codes @@ -431,15 +430,15 @@ var ( ErrorBadHandle = errors.New("Invalid or unknown handle value") // ErrorUnknown unexpected error ErrorUnknown = errors.New("Unexpected error") - // ErrorLockApi unrecoverable panic detected. - // Subsequent API requests should be rejected since API will be locked - ErrorLockApi = errors.New("Unrecoverable panic detected. API locked.") + // ErrorInvalidTimeString time string does not match expected time format + // More precise errors conditions can be found in the logs + ErrorInvalidTimeString = errors.New("Invalid time value") errorToCodeMap = map[error]uint32{ // libcgo - ErrorBadHandle: SKY_BAD_HANDLE, - ErrorUnknown: SKY_ERROR, - ErrorLockApi: SKY_API_LOCKED, + ErrorBadHandle: SKY_BAD_HANDLE, + ErrorUnknown: SKY_ERROR, + ErrorInvalidTimeString: SKY_ErrInvalidTimeString, // cipher cipher.ErrAddressInvalidLength: SKY_ErrAddressInvalidLength, cipher.ErrAddressInvalidChecksum: SKY_ErrAddressInvalidChecksum, @@ -637,98 +636,3 @@ func libErrorCode(err error) uint32 { } return SKY_ERROR } - -var ( - // isApiLocked flag set when previous unrecoverable panic is detected - // subsequent use of the API leads to SKY_API_LOCKED returned - isAPILocked = false - // apiWriteLock locks write access to isAPILocked - apiWriteLock = &sync.RWMutex{} - // apiReadLock locks read access to isAPILocked - apiReadLock = apiWriteLock.RLocker() - // haltOnPanic is enabled by default to halt process on unhandled panic - // if disabled then locking is activated instead. - // Subsequent use of the API leads to SKY_API_LOCKED error code returned - haltOnPanic = true -) - -// nolint megacheck -const ( - // SKY_OPT_HALTONPANIC controls API behavior on panic - // Supported values: - // 0 - do not halt on panic, lock API instead - // non-zero - exit the process on unrecoverable panic - SKY_OPT_HALTONPANIC = 1 + iota // nolint megacheck -) - -func getIsAPILocked() bool { - defer apiReadLock.Unlock() - apiReadLock.Lock() - return isAPILocked -} - -func lockAPI() { - defer apiWriteLock.Unlock() - apiWriteLock.Lock() - isAPILocked = true -} - -// SKY_libcgo_ConfigApiOptions set values for configurable API settings -//export SKY_libcgo_ConfigApiOption -func SKY_libcgo_ConfigApiOption(optionID uint32, optionValue uint64) { // nolint megacheck - if optionID == SKY_OPT_HALTONPANIC { - haltOnPanic = optionValue != 0 - } -} - -// checkAPIReady ensure preconditions are met for API functions to be invoked -// and lock API otherwise -func checkAPIReady() { - if getIsAPILocked() { - panic(ErrorLockApi) - } -} - -// catchApiPanic intercept signals emitted by internal implementation -// of API methods. This function is mainly used in defer statements -// exceuted immediately before returning from API calls. -// -// @param errcode error status in function body -// @param err `recover()` result -// -func catchApiPanic(errcode uint32, err interface{}) uint32 { - if errcode != SKY_OK { - // Error already detected in function body - // Return right away - return errcode - } - if getIsAPILocked() || err == ErrorLockApi { - lockAPI() - return SKY_API_LOCKED - } - if err != nil { - // Setting flag every time (i.e. even when haltOnPanic is active - // protects against hypothetical situations in which panic() - // does not abort the current process. - lockAPI() - if haltOnPanic { - // FIXME: Set process exit code on panic - /* - var exitCode int - if _err, isError := err.(error); isError { - exitCode = int(libErrorCode(_err)) - } else { - exitCode = SKY_ERROR - } - */ - panic(err) - } else { - // Let the caller know specific error that locked the API - if _err, isError := err.(error); isError { - return libErrorCode(_err) - } - return SKY_ERROR - } - } - return SKY_OK -} diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index 738d63767a..8bb40e9710 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -63,7 +63,7 @@ func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*readable.Block); isOK { - copyString(obj.Head.BlockHash, hash) + copyString(obj.Head.Hash, hash) return SKY_OK } } @@ -75,7 +75,7 @@ func SKY_Handle_Block_GetPreviousBlockHash(handle C.Handle, hash *C.GoString_) u obj, ok := lookupHandle(C.Handle(handle)) if ok { if obj, isOK := (obj).(*readable.Block); isOK { - copyString(obj.Head.PreviousBlockHash, hash) + copyString(obj.Head.PreviousHash, hash) return SKY_OK } } diff --git a/lib/cgo/libsky_time.go b/lib/cgo/libsky_time.go new file mode 100644 index 0000000000..14682801b1 --- /dev/null +++ b/lib/cgo/libsky_time.go @@ -0,0 +1,18 @@ +package main + +import ( + "log" + "time" +) + +func parseTimeValue(strTime string) (time.Time, error) { + t, err := time.Parse(time.RFC3339, strTime) + if err != nil { + log.Printf("Time conversion error. Format=%s Value=\"%s\" Error: %s", time.RFC3339, strTime, err) + } + return t, err +} + +func timeValueToString(t time.Time) string { + return t.Format(time.RFC3339) +} diff --git a/lib/cgo/testutil.testutil.go b/lib/cgo/testutil.testutil.go index 55a518a3d9..ce8776849b 100644 --- a/lib/cgo/testutil.testutil.go +++ b/lib/cgo/testutil.testutil.go @@ -17,11 +17,6 @@ import "C" //export SKY_testutil_MakeAddress func SKY_testutil_MakeAddress(_arg0 *C.cipher__Address) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0 := testutil.MakeAddress() *_arg0 = *(*C.cipher__Address)(unsafe.Pointer(&__arg0)) return diff --git a/lib/cgo/util.apputil.apputil.go b/lib/cgo/util.apputil.apputil.go index 62c5875c0c..4897d52da9 100644 --- a/lib/cgo/util.apputil.apputil.go +++ b/lib/cgo/util.apputil.apputil.go @@ -13,33 +13,18 @@ import "C" //export SKY_apputil_CatchInterruptPanic func SKY_apputil_CatchInterruptPanic() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() apputil.CatchInterruptPanic() return } //export SKY_apputil_CatchDebug func SKY_apputil_CatchDebug() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() apputil.CatchDebug() return } //export SKY_apputil_PrintProgramStatus func SKY_apputil_PrintProgramStatus() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() apputil.PrintProgramStatus() return } diff --git a/lib/cgo/util.cert.cert.go b/lib/cgo/util.cert.cert.go index 8f5b8f0036..23943a2f56 100644 --- a/lib/cgo/util.cert.cert.go +++ b/lib/cgo/util.cert.cert.go @@ -1,6 +1,10 @@ package main -import cert "github.com/skycoin/skycoin/src/util/cert" +import ( + "reflect" + + cert "github.com/skycoin/skycoin/src/util/certutil" +) /* @@ -11,20 +15,16 @@ import cert "github.com/skycoin/skycoin/src/util/cert" */ import "C" -//export SKY_cert_CreateCertIfNotExists -func SKY_cert_CreateCertIfNotExists(_host, _certFile, _keyFile string, _appName string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() - host := _host - certFile := _certFile - keyFile := _keyFile - appName := _appName - ____return_err := cert.CreateCertIfNotExists(host, certFile, keyFile, appName) - ____error_code = libErrorCode(____return_err) +//export SKY_certutil_NewTLSCertPair +func SKY_certutil_NewTLSCertPair(organization string, validUntil string, extraHosts []string, _cert *C.GoSlice_, _key *C.GoSlice_) (____error_code uint32) { + ____time_validUntil, ____return_err := parseTimeValue(validUntil) if ____return_err == nil { + cert, key, ____return_err := cert.NewTLSCertPair(organization, ____time_validUntil, extraHosts) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(cert), _cert) + copyToGoSlice(reflect.ValueOf(key), _key) + } } + ____error_code = libErrorCode(____return_err) return } diff --git a/lib/cgo/util.droplet.droplet.go b/lib/cgo/util.droplet.droplet.go index 74bebc86ec..4693a84531 100644 --- a/lib/cgo/util.droplet.droplet.go +++ b/lib/cgo/util.droplet.droplet.go @@ -13,11 +13,6 @@ import "C" //export SKY_droplet_FromString func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() b := _b __arg1, ____return_err := droplet.FromString(b) ____error_code = libErrorCode(____return_err) @@ -29,11 +24,6 @@ func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { //export SKY_droplet_ToString func SKY_droplet_ToString(_n uint64, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() n := _n __arg1, ____return_err := droplet.ToString(n) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go index 1586f336e5..4437260dd2 100644 --- a/lib/cgo/util.fee.fee.go +++ b/lib/cgo/util.fee.fee.go @@ -18,11 +18,6 @@ import "C" //export SKY_fee_VerifyTransactionFee func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() t, ok := lookupTransactionHandle(_t) if !ok { ____error_code = SKY_BAD_HANDLE @@ -37,11 +32,6 @@ func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____er //export SKY_fee_VerifyTransactionFeeForHours func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hours := _hours ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee) ____error_code = libErrorCode(____return_err) @@ -52,11 +42,6 @@ func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code u //export SKY_fee_RequiredFee func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hours := _hours __arg1 := fee.RequiredFee(hours) *_arg1 = __arg1 @@ -65,11 +50,6 @@ func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { //export SKY_fee_RemainingHours func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() hours := _hours __arg1 := fee.RemainingHours(hours) *_arg1 = __arg1 @@ -78,11 +58,6 @@ func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32 //export SKY_fee_TransactionFee func SKY_fee_TransactionFee(_tx C.Transaction__Handle, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() tx, ok := lookupTransactionHandle(_tx) if !ok { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/util.file.file.go b/lib/cgo/util.file.file.go index 5c7d27070d..5b7d6c2958 100644 --- a/lib/cgo/util.file.file.go +++ b/lib/cgo/util.file.file.go @@ -13,11 +13,6 @@ import "C" //export SKY_file_InitDataDir func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() dir := _dir __arg1, ____return_err := file.InitDataDir(dir) ____error_code = libErrorCode(____return_err) @@ -29,11 +24,6 @@ func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint3 //export SKY_file_UserHome func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0 := file.UserHome() copyString(__arg0, _arg0) return @@ -41,11 +31,6 @@ func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_file_ResolveResourceDirectory func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() path := _path __arg1 := file.ResolveResourceDirectory(path) copyString(__arg1, _arg1) @@ -54,11 +39,6 @@ func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____er //export SKY_file_DetermineResourcePath func SKY_file_DetermineResourcePath(_staticDir string, _resourceDir string, _devDir string, _arg3 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() staticDir := _staticDir resourceDir := _resourceDir devDir := _devDir diff --git a/lib/cgo/util.http.json.go b/lib/cgo/util.http.json.go index 5ce5e11ea6..d311d19659 100644 --- a/lib/cgo/util.http.json.go +++ b/lib/cgo/util.http.json.go @@ -18,11 +18,6 @@ import "C" //export SKY_httphelper_Address_UnmarshalJSON func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := inplaceHttpHelperAddress(_a) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := a.UnmarshalJSON(b) @@ -34,11 +29,6 @@ func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) //export SKY_httphelper_Address_MarshalJSON func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() a := *inplaceHttpHelperAddress(_a) __arg0, ____return_err := a.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -50,11 +40,6 @@ func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSl //export SKY_httphelper_Coins_UnmarshalJSON func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c := (*http.Coins)(unsafe.Pointer(_c)) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := c.UnmarshalJSON(b) @@ -66,11 +51,6 @@ func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (___ //export SKY_httphelper_Coins_MarshalJSON func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c := *(*http.Coins)(unsafe.Pointer(_c)) __arg0, ____return_err := c.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -82,11 +62,6 @@ func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_ //export SKY_httphelper_Coins_Value func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() c := *(*http.Coins)(unsafe.Pointer(_c)) __arg0 := c.Value() *_arg0 = __arg0 @@ -95,11 +70,6 @@ func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____err //export SKY_httphelper_Hours_UnmarshalJSON func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h := (*http.Hours)(unsafe.Pointer(_h)) b := *(*[]byte)(unsafe.Pointer(&_b)) ____return_err := h.UnmarshalJSON(b) @@ -111,11 +81,6 @@ func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (___ //export SKY_httphelper_Hours_MarshalJSON func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h := *(*http.Hours)(unsafe.Pointer(_h)) __arg0, ____return_err := h.MarshalJSON() ____error_code = libErrorCode(____return_err) @@ -127,11 +92,6 @@ func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_ //export SKY_httphelper_Hours_Value func SKY_httphelper_Hours_Value(_h *C.httphelper__Hours, _arg0 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() h := *(*http.Hours)(unsafe.Pointer(_h)) __arg0 := h.Value() *_arg0 = __arg0 diff --git a/lib/cgo/util.iputil.iputil.go b/lib/cgo/util.iputil.iputil.go index 8d93a99491..f3906de38d 100644 --- a/lib/cgo/util.iputil.iputil.go +++ b/lib/cgo/util.iputil.iputil.go @@ -13,11 +13,6 @@ import "C" //export SKY_iputil_LocalhostIP func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() __arg0, ____return_err := iputil.LocalhostIP() ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -28,11 +23,6 @@ func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { //export SKY_iputil_IsLocalhost func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := _addr __arg1 := iputil.IsLocalhost(addr) *_arg1 = __arg1 @@ -41,11 +31,6 @@ func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { //export SKY_iputil_SplitAddr func SKY_iputil_SplitAddr(_addr string, _arg1 *C.GoString_, _arg2 *uint16) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() addr := _addr __arg1, __arg2, ____return_err := iputil.SplitAddr(addr) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/util.logging.logging.go b/lib/cgo/util.logging.logging.go index f46f804a8d..b544364d68 100644 --- a/lib/cgo/util.logging.logging.go +++ b/lib/cgo/util.logging.logging.go @@ -13,33 +13,18 @@ import "C" //export SKY_logging_EnableColors func SKY_logging_EnableColors() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() logging.EnableColors() return } //export SKY_logging_DisableColors func SKY_logging_DisableColors() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() logging.DisableColors() return } //export SKY_logging_Disable func SKY_logging_Disable() (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() logging.Disable() return } diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go index ea02b54f4a..94a5537174 100644 --- a/lib/cgo/wallet.addresses.go +++ b/lib/cgo/wallet.addresses.go @@ -15,11 +15,6 @@ import "C" //export SKY_wallet_CreateAddresses func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _hideSecretKey bool, _arg4 *C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() coinType := _coinType seed := _seed genCount := _genCount diff --git a/lib/cgo/wallet.balance.go b/lib/cgo/wallet.balance.go index f80390bf89..c491ab4122 100644 --- a/lib/cgo/wallet.balance.go +++ b/lib/cgo/wallet.balance.go @@ -18,11 +18,6 @@ import "C" //export SKY_wallet_NewBalance func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() coins := _coins hours := _hours __arg1 := wallet.NewBalance(coins, hours) @@ -32,11 +27,6 @@ func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (___ //export SKY_wallet_NewBalanceFromUxOut func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__Balance) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() headTime := _headTime ux := (*coin.UxOut)(unsafe.Pointer(_ux)) __arg2, ____return_err := wallet.NewBalanceFromUxOut(headTime, ux) @@ -49,11 +39,6 @@ func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 //export SKY_wallet_Balance_Add func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1, ____return_err := bal.Add(other) @@ -66,11 +51,6 @@ func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, //export SKY_wallet_Balance_Sub func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1 := bal.Sub(other) @@ -80,11 +60,6 @@ func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, //export SKY_wallet_Balance_Equals func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) other := *(*wallet.Balance)(unsafe.Pointer(_other)) __arg1 := bal.Equals(other) @@ -94,11 +69,6 @@ func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balanc //export SKY_wallet_Balance_IsZero func SKY_wallet_Balance_IsZero(_bal *C.wallet__Balance, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) __arg0 := bal.IsZero() *_arg0 = __arg0 diff --git a/lib/cgo/wallet.crypto.go b/lib/cgo/wallet.crypto.go index 58b317e0b9..86a9bc1465 100644 --- a/lib/cgo/wallet.crypto.go +++ b/lib/cgo/wallet.crypto.go @@ -15,11 +15,6 @@ import "C" //export SKY_wallet_CryptoTypeFromString func SKY_wallet_CryptoTypeFromString(_s string, _arg1 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() s := _s __arg1, ____return_err := wallet.CryptoTypeFromString(s) ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/wallet.entry.go b/lib/cgo/wallet.entry.go index 03edc08b85..2d7c7807e3 100644 --- a/lib/cgo/wallet.entry.go +++ b/lib/cgo/wallet.entry.go @@ -17,11 +17,6 @@ import "C" //export SKY_wallet_Entry_Verify func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() we := (*wallet.Entry)(unsafe.Pointer(_we)) ____return_err := we.Verify() ____error_code = libErrorCode(____return_err) @@ -32,11 +27,6 @@ func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { //export SKY_wallet_Entry_VerifyPublic func SKY_wallet_Entry_VerifyPublic(_we *C.wallet__Entry) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() we := (*wallet.Entry)(unsafe.Pointer(_we)) ____return_err := we.VerifyPublic() ____error_code = libErrorCode(____return_err) diff --git a/lib/cgo/wallet.readable.go b/lib/cgo/wallet.readable.go index d026baf776..4e815f9d65 100644 --- a/lib/cgo/wallet.readable.go +++ b/lib/cgo/wallet.readable.go @@ -17,11 +17,6 @@ import "C" //export SKY_wallet_NewReadableEntry func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w := *(*wallet.Entry)(unsafe.Pointer(_w)) __arg1 := wallet.NewReadableEntry(w) *_arg1 = registerReadableEntryHandle(&__arg1) @@ -30,11 +25,6 @@ func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Ha //export SKY_wallet_LoadReadableEntry func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() filename := _filename __arg1, ____return_err := wallet.LoadReadableEntry(filename) ____error_code = libErrorCode(____return_err) @@ -46,11 +36,6 @@ func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Hand //export SKY_wallet_NewReadableEntryFromPubkey func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() pub := _pub __arg1 := wallet.NewReadableEntryFromPubkey(pub) *_arg1 = registerReadableEntryHandle(&__arg1) @@ -59,11 +44,6 @@ func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__ //export SKY_wallet_ReadableEntry_Save func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() re, okre := lookupReadableEntryHandle(_re) if !okre { ____error_code = SKY_BAD_HANDLE @@ -79,11 +59,6 @@ func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string //export SKY_wallet_LoadReadableWallet func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() filename := _filename __arg1, ____return_err := wallet.LoadReadableWallet(filename) ____error_code = libErrorCode(____return_err) @@ -95,11 +70,6 @@ func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Ha //export SKY_wallet_ReadableWallet_Save func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE @@ -115,11 +85,6 @@ func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename stri //export SKY_wallet_ReadableWallet_Load func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE @@ -135,11 +100,6 @@ func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename stri //export SKY_wallet_ReadableWallet_Erase func SKY_wallet_ReadableWallet_Erase(_rw C.ReadableWallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() rw, okrw := lookupReadableWalletHandle(_rw) if !okrw { ____error_code = SKY_BAD_HANDLE diff --git a/lib/cgo/wallet.wallet.go b/lib/cgo/wallet.wallet.go index e72042710e..3b1dc4b922 100644 --- a/lib/cgo/wallet.wallet.go +++ b/lib/cgo/wallet.wallet.go @@ -20,11 +20,6 @@ import "C" //export SKY_wallet_NewError func SKY_wallet_NewError(_err error) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() err := _err ____return_err := wallet.NewError(err) ____error_code = libErrorCode(____return_err) @@ -35,11 +30,6 @@ func SKY_wallet_NewError(_err error) (____error_code uint32) { //export SKY_wallet_NewWallet func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() wltName := _wltName __opts, okopts := lookupOptionsHandle(_opts) @@ -58,11 +48,6 @@ func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wal //export SKY_wallet_Wallet_Lock func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -80,11 +65,6 @@ func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType s //export SKY_wallet_Wallet_Unlock func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -102,11 +82,6 @@ func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wa //export SKY_wallet_Load func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() wltFile := _wltFile __arg1, ____return_err := wallet.Load(wltFile) @@ -119,11 +94,6 @@ func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code u //export SKY_wallet_Wallet_Save func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -140,11 +110,6 @@ func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code ui //export SKY_wallet_Wallet_Validate func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -160,11 +125,6 @@ func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { //export SKY_wallet_Wallet_Type func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -178,11 +138,6 @@ func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_ //export SKY_wallet_Wallet_Version func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -196,11 +151,6 @@ func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____err //export SKY_wallet_Wallet_Filename func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -214,11 +164,6 @@ func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____er //export SKY_wallet_Wallet_Label func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -232,11 +177,6 @@ func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error //export SKY_wallet_Wallet_IsEncrypted func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -250,11 +190,6 @@ func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_ //export SKY_wallet_Wallet_GenerateAddresses func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -272,11 +207,6 @@ func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 //export SKY_wallet_Wallet_GetAddresses func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -290,11 +220,6 @@ func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (___ //export SKY_wallet_Wallet_GetEntry func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg1 *C.wallet__Entry, _arg2 *bool) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -310,11 +235,6 @@ func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg //export SKY_wallet_Wallet_AddEntry func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() w, okw := lookupWalletHandle(_w) if !okw { @@ -331,11 +251,6 @@ func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (_ //export SKY_wallet_DistributeSpendHours func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bool, _arg2 *uint64, _arg3 *C.GoSlice_, _arg4 *uint64) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() inputHours := _inputHours nAddrs := _nAddrs @@ -349,11 +264,6 @@ func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bo //export SKY_wallet_DistributeCoinHoursProportional func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() coins := *(*[]uint64)(unsafe.Pointer(&_coins)) hours := _hours @@ -367,11 +277,6 @@ func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, //export SKY_wallet_NewUxBalances func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() headTime := _headTime uxa := *(*coin.UxArray)(unsafe.Pointer(_uxa)) @@ -385,11 +290,6 @@ func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C. //export SKY_wallet_NewUxBalance func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__UxBalance) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() headTime := _headTime ux := *(*coin.UxOut)(unsafe.Pointer(_ux)) @@ -403,11 +303,6 @@ func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wall //export SKY_wallet_ChooseSpendsMinimizeUxOuts func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uxa := *(*[]wallet.UxBalance)(unsafe.Pointer(&_uxa)) coins := _coins @@ -422,11 +317,6 @@ func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _ //export SKY_wallet_ChooseSpendsMaximizeUxOuts func SKY_wallet_ChooseSpendsMaximizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() uxa := *(*[]wallet.UxBalance)(unsafe.Pointer(&_uxa)) coins := _coins diff --git a/lib/cgo/wallet_option.go b/lib/cgo/wallet_option.go index 8a3d4199ee..f3df7638df 100644 --- a/lib/cgo/wallet_option.go +++ b/lib/cgo/wallet_option.go @@ -14,11 +14,6 @@ import "C" //export SKY_wallet_CreateOptionsHandle func SKY_wallet_CreateOptionsHandle(coin string, label string, seed string, encrypt bool, pwd string, cryptoType string, scanN uint64, _opts *C.Options__Handle) (____error_code uint32) { - ____error_code = SKY_OK - defer func() { - ____error_code = catchApiPanic(____error_code, recover()) - }() - checkAPIReady() var walletOptions wallet.Options walletOptions.Coin = (wallet.CoinType)(coin) From 15728d8d6d743d595eb450161a9f848e1a693581 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 12 Oct 2018 11:12:17 +0800 Subject: [PATCH 237/399] Increase version upgrade node timeout for linux travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cf34b49621..4d18a7e886 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ go: matrix: include: - os: linux - env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=5s + env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=30s - os: osx # Do not start osx build for PR if: type != pull_request From 5c00c6e2e4b17f33d64993a59c8f9d07bc0cba1f Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 12 Oct 2018 11:18:56 +0800 Subject: [PATCH 238/399] Add CHANGELOG warning about network protocol upgrade --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb07ff3ee..396de502de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,14 @@ In the v0.26.0 these features and functions will be removed. If you have a need - `/api/v1/wallet/spend` endpoint (use `POST /api/v1/wallet/transaction` followed by `POST /api/v1/injectTransaction` instead) - The unversioned REST API (the `-enable-unversioned-api` option will be removed, prefix your API requests with `/api/v1`) +### Notice + +Nodes v0.23.0 and earlier will not be able to connect to v0.25.0 due to a change in the introduction packet message. + +Nodes v0.24.1 and earlier will not be able to connect to v0.26.0 due to a similar change. + +Make sure to upgrade to v0.25.0 so that your node will continue to connect once v0.26.0 is released. + ### Added - Add `-csv` option to `cli send` and `cli createRawTransaction`, which will send coins to multiple addresses defined in a csv file From 88f6d42410fce9eb50c4ec14057a824170e51b3b Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 11 Oct 2018 23:46:13 -0400 Subject: [PATCH 239/399] [lib] refs #1191 - Translate error codes returned by fee calculator call backs into objects [====] Synthesis: Tested: 138 | Passing: 137 | Failing: 1 | Crashing: 0 --- lib/cgo/coin.transactions.go | 13 ++- lib/cgo/libsky_error.go | 18 +++- ...k_cipher.encrypt.scrypt_chacha20poly1305.c | 2 +- .../tests/check_cipher.secp256k1.secp256.c | 28 +++--- .../check_cipher.secp256k1.secp256k1-go2.ec.c | 4 +- ...eck_cipher.secp256k1.secp256k1-go2.field.c | 2 +- ...check_cipher.secp256k1.secp256k1-go2.sig.c | 6 +- ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 2 +- lib/cgo/tests/check_coin.coin.c | 6 +- lib/cgo/tests/check_coin.outputs.c | 2 +- lib/cgo/tests/check_coin.transactions.c | 93 ++++++++++--------- 11 files changed, 98 insertions(+), 78 deletions(-) diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index b04add6bed..f0f78f2c4b 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -3,6 +3,7 @@ package main import ( "errors" "reflect" + "strconv" "unsafe" cipher "github.com/skycoin/skycoin/src/cipher" @@ -559,13 +560,15 @@ func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalcul feeCalc := func(pTx *coin.Transaction) (uint64, error) { var fee C.GoUint64_ handle := registerTransactionHandle(pTx) - result := C.callFeeCalculator(pFeeCalc, handle, &fee) + errorcode := C.callFeeCalculator(pFeeCalc, handle, &fee) closeHandle(Handle(handle)) - if result == SKY_OK { - return uint64(fee), nil - } else { - return 0, errors.New("Error calculating fee") + if errorcode != SKY_OK { + if err, exists := codeToErrorMap[uint32(errorcode)]; exists { + return 0, err + } + return 0, errors.New("C fee calculator failed code=" + strconv.Itoa(int(errorcode))) } + return uint64(fee), nil } txns, ok := lookupTransactionsHandle(tsh) if !ok { diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 254da0b68e..04ed2f7a89 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -35,8 +35,8 @@ const ( const ( // SKY_BAD_HANDLE invalid handle argument SKY_BAD_HANDLE = SKY_PKG_LIBCGO + iota + 1 - // SKY_ErrInvalidTimeString invalid time value - SKY_ErrInvalidTimeString + // SKY_INVALID_TIMESTRING invalid time value + SKY_INVALID_TIMESTRING ) // Package prefixes for error codes @@ -434,11 +434,12 @@ var ( // More precise errors conditions can be found in the logs ErrorInvalidTimeString = errors.New("Invalid time value") + codeToErrorMap = make(map[uint32]error, 0) errorToCodeMap = map[error]uint32{ // libcgo ErrorBadHandle: SKY_BAD_HANDLE, ErrorUnknown: SKY_ERROR, - ErrorInvalidTimeString: SKY_ErrInvalidTimeString, + ErrorInvalidTimeString: SKY_INVALID_TIMESTRING, // cipher cipher.ErrAddressInvalidLength: SKY_ErrAddressInvalidLength, cipher.ErrAddressInvalidChecksum: SKY_ErrAddressInvalidChecksum, @@ -601,6 +602,10 @@ var ( } ) +func errorObjectFromCode(errcode uint32) error { + return codeToErrorMap[errcode] +} + func libErrorCode(err error) uint32 { if err == nil { return SKY_OK @@ -636,3 +641,10 @@ func libErrorCode(err error) uint32 { } return SKY_ERROR } + +func init() { + // Init reverse error code map + for _err := range errorToCodeMap { + codeToErrorMap[errorToCodeMap[_err]] = _err + } +} diff --git a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c index 93f208fad0..0a9265539f 100644 --- a/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c +++ b/lib/cgo/tests/check_cipher.encrypt.scrypt_chacha20poly1305.c @@ -132,7 +132,7 @@ Test(cipher_encrypt_scrypt_chacha20poly1305, TestScryptChacha20poly1305Encrypt) registerMemCleanup((void *)result.data); cr_assert(result.len > SCRYPTCHACHA20METALENGTHSIZE, "SKY_encrypt_ScryptChacha20poly1305_Encrypt failed, result data length too short"); int decode_len = b64_decode((const unsigned char *)result.data, - result.len, str); + result.len, (unsigned char *) str); cr_assert(decode_len >= SCRYPTCHACHA20METALENGTHSIZE, "base64_decode_string failed"); cr_assert(decode_len < BUFFER_SIZE, "base64_decode_string failed, buffer overflow"); metalength = (unsigned int)str[0]; diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c index a136350245..d91a6b52ce 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256.c @@ -203,7 +203,7 @@ Test(cipher_secp256k1, Test_Secp256_02s) error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); @@ -233,7 +233,7 @@ Test(cipher_secp256k1, Test_Secp256_02) error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); @@ -268,7 +268,7 @@ Test(cipher_secp256k1, Test_Secp256_02a) error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); GoInt result; @@ -304,7 +304,7 @@ Test(cipher_secp256k1, Test_Secp256_03) error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; @@ -338,7 +338,7 @@ Test(cipher_secp256k1, Test_Secp256_04) error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); unsigned char last = ((unsigned char *)sig.data)[64]; @@ -381,7 +381,7 @@ Test(cipher_secp256k1, Test_Secp256_06a_alt0) GoInt code; error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); cr_assert(sig.len == 65, "Signature should be 65 bytes long."); @@ -421,7 +421,7 @@ Test(cipher_secp256k1, Test_Secp256_06b) cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code == SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); + error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); GoInt result; @@ -599,7 +599,7 @@ Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) seed.data = (void *)testArray[2 * i]; seed.len = strlen(testArray[2 * i]); seed.cap = seed.len; - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferSec1, BUFFER_SIZE); error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, (GoSlice_ *)&s1, (GoSlice_ *)&s2, (GoSlice_ *)&sec2); @@ -660,8 +660,8 @@ Test(cipher_secp256k1, Test_DeterministicWallets1) for (int i = 0; i < test_count; i++) { - seed.len = hexnstr(testArray[2 * i], bufferSeed, BUFFER_SIZE); - sec1.len = hexnstr(testArray[2 * i + 1], bufferSec1, BUFFER_SIZE); + seed.len = hexnstr(testArray[2 * i], (unsigned char*) bufferSeed, BUFFER_SIZE); + sec1.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferSec1, BUFFER_SIZE); error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, (GoSlice_ *)&s1, (GoSlice_ *)&s2, (GoSlice_ *)&sec2); @@ -717,8 +717,8 @@ Test(cipher_secp256k1, Test_Secp256k1_Hash) for (int i = 0; i < test_count; i++) { - hash1.len = hexnstr(testArray[2 * i], bufferHash1, BUFFER_SIZE); - hash2.len = hexnstr(testArray[2 * i + 1], bufferHash2, BUFFER_SIZE); + hash1.len = hexnstr(testArray[2 * i], (unsigned char*) bufferHash1, BUFFER_SIZE); + hash2.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferHash2, BUFFER_SIZE); error_code = SKY_secp256k1_Secp256k1Hash(hash1, (GoSlice_ *)&hash3); cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); @@ -791,8 +791,8 @@ Test(cipher_secp256k1, Test_DeterministicWalletGeneration) seed.len = newSeed.len; } - privateExpected.len = hexnstr(pSecOut, bufferPrivateExpected, BUFFER_SIZE); - publicExpected.len = hexnstr(pPubOut, bufferPublicExpected, BUFFER_SIZE); + privateExpected.len = hexnstr(pSecOut, (unsigned char*)bufferPrivateExpected, BUFFER_SIZE); + publicExpected.len = hexnstr(pPubOut, (unsigned char*)bufferPublicExpected, BUFFER_SIZE); cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c index 0d997a2e99..51156f8c09 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c @@ -89,7 +89,7 @@ Test(cipher_secp256k1_xyz, TestXYZECMult){ error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, u2, u1); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); - GoInt8 equal = 0; + GoUint8 equal = 0; error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); @@ -138,7 +138,7 @@ Test(cipher_secp256k1_xyz, TestXYZECMultGen){ error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - GoInt8 equal = 0; + GoUint8 equal = 0; error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c index 4b64688262..d3a3f4d2db 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c @@ -26,7 +26,7 @@ Test(cipher_secp256k1_field, TestFieldInv){ memset(&expected, 0, sizeof(secp256k1go__Field)); GoUint32 error_code; - GoInt8 equal = 0; + GoUint8 equal = 0; GoString InStr = {INHEX, strlen(INHEX)}; GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c index 4f62dea557..e8bd4954be 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c @@ -47,7 +47,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ GoString X = {X1, strlen(X1)}; GoString Y = {Y1, strlen(Y1)}; GoInt rid = 0; - GoInt8 result; + GoUint8 result; error_code = SKY_secp256k1go_Signature_Create(&sig); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); @@ -107,7 +107,7 @@ Test(cipher_secp256k1_sig, TestSigRecover){ cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - GoInt8 equal; + GoUint8 equal; error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); @@ -235,7 +235,7 @@ Test(cipher_secp256k1_sig, TestSigSign) { registerHandleClose(sig); GoInt res; - GoInt8 equal; + GoUint8 equal; result = SKY_secp256k1go_Signature_Sign(sig, sec, msg, non, &recid, &res); cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c index 270e6bec57..9f006db10e 100644 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c +++ b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c @@ -55,7 +55,7 @@ Test(cipher_secp256k1_xyz, TestXYZDouble){ error_code = SKY_secp256k1go_XYZ_Double(&a, &r); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); - GoInt8 equal = 0; + GoUint8 equal = 0; error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); diff --git a/lib/cgo/tests/check_coin.coin.c b/lib/cgo/tests/check_coin.coin.c index d5b92b2dee..c2bc417e15 100644 --- a/lib/cgo/tests/check_coin.coin.c +++ b/lib/cgo/tests/check_coin.coin.c @@ -18,7 +18,7 @@ Test(coin_coin, TestAddress1){ char* address_hex = "02fa939957e9fc52140e180264e621c2576a1bfe781f88792fb315ca3d1786afb8"; char address[128]; int result; - int length = hexnstr(address_hex, address, 128); + int length = hexnstr(address_hex, (unsigned char *) address, 128); cr_assert(length > 0, "Error decoding hex string"); GoSlice slice = { address, length, 128 }; cipher__PubKey pubkey; @@ -33,7 +33,7 @@ Test(coin_coin, TestAddress2){ char* address_hex = "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; char address[128]; int result; - int length = hexnstr(address_hex, address, 128); + int length = hexnstr(address_hex, (unsigned char *) address, 128); cr_assert(length > 0, "Error decoding hex string"); GoSlice slice = { address, length, 128 }; cipher__PubKey pubkey; @@ -63,7 +63,7 @@ Test(coin_coin, TestCrypto2){ char* address_hex = "5a42c0643bdb465d90bf673b99c14f5fa02db71513249d904573d2b8b63d353d"; char address[128]; int result; - int length = hexnstr(address_hex, address, 128); + int length = hexnstr(address_hex, (unsigned char *) address, 128); cr_assert(length == 32, "Error decoding hex string"); GoSlice slice = { address, length, 128 }; diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 1c525cf715..8be98381b6 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -577,7 +577,7 @@ Test(coin_outputs, TestAddressUxOutsSub) cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_Length failed"); // One address should have been removed, because no elements cr_assert(length == 2, "Invalid length %d", length); - GoInt8_ hasKey; + GoUint8_ hasKey; result = SKY_coin_AddressUxOuts_HasKey(h3, &(pData + 2)->Body.Address, &hasKey); cr_assert(result == SKY_OK, "SKY_coin_AddressUxOuts_HasKey failed"); cr_assert(hasKey == 0); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index b8d7235147..7c9894c512 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -978,6 +978,53 @@ void testTransactionSorting(Transactions__Handle hTrans, } } +GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ * pFee, void *context) +{ + cipher__SHA256 *thirdHash = (cipher__SHA256 *) context; + cipher__SHA256 hash; + + int result = SKY_coin_Transaction_Hash(handle, &hash); + if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + { + *pFee = MaxUint64 / 2; + } + else + { + coin__Transaction *pTx; + result = SKY_coin_GetTransactionObject(handle, &pTx); + if (result == SKY_OK) + { + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; +} + +GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ * pFee, void *context) +{ + cipher__SHA256 hash; + cipher__SHA256 *thirdHash = (cipher__SHA256 *) context; + + int result = SKY_coin_Transaction_Hash(handle, &hash); + if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + { + *pFee = 0; + result = SKY_ERROR; + } + else + { + coin__Transaction *pTx; + result = SKY_coin_GetTransactionObject(handle, &pTx); + if (result == SKY_OK) + { + coin__TransactionOutput *pOutput = pTx->Out.data; + *pFee = 100 * Million - pOutput->Hours; + } + } + return result; +} + Test(coin_transactions, TestSortTransactions) { int n = 6; @@ -1020,55 +1067,13 @@ Test(coin_transactions, TestSortTransactions) FeeCalculator fc2 = {feeCalculator2, NULL}; testTransactionSorting(hashSortedTxnsHandle, index2, 2, expec2, 2, &fc2, "hash tiebreaker"); - GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ * pFee, void *context) - { - cipher__SHA256 hash; - int result = SKY_coin_Transaction_Hash(handle, &hash); - if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) - { - *pFee = MaxUint64 / 2; - } - else - { - coin__Transaction *pTx; - result = SKY_coin_GetTransactionObject(handle, &pTx); - if (result == SKY_OK) - { - coin__TransactionOutput *pOutput = pTx->Out.data; - *pFee = 100 * Million - pOutput->Hours; - } - } - return result; - } int index3[] = {1, 2, 0}; int expec3[] = {2, 0, 1}; - FeeCalculator f3 = {feeCalculator3, NULL}; + FeeCalculator f3 = {feeCalculator3, &thirdHash}; testTransactionSorting(transactionsHandle, index3, 3, expec3, 3, &f3, "invalid fee multiplication is capped"); - GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ * pFee, void *context) - { - cipher__SHA256 hash; - int result = SKY_coin_Transaction_Hash(handle, &hash); - if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) - { - *pFee = 0; - result = SKY_ERROR; - } - else - { - coin__Transaction *pTx; - result = SKY_coin_GetTransactionObject(handle, &pTx); - if (result == SKY_OK) - { - coin__TransactionOutput *pOutput = pTx->Out.data; - *pFee = 100 * Million - pOutput->Hours; - } - } - return result; - } - int index4[] = {1, 2, 0}; int expec4[] = {0, 1}; - FeeCalculator f4 = {feeCalculator4, NULL}; + FeeCalculator f4 = {feeCalculator4, &thirdHash}; testTransactionSorting(transactionsHandle, index4, 3, expec4, 2, &f4, "failed fee calc is filtered"); } From 2e64746f81044ee073b95f4eb1de0b354f30400c Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 00:18:57 -0400 Subject: [PATCH 240/399] [lib] refs #1191 - Fix seg fault in fee calculator test case --- lib/cgo/tests/check_coin.transactions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 7c9894c512..8a850d850b 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -984,7 +984,7 @@ GoUint32_ feeCalculator3(Transaction__Handle handle, GoUint64_ * pFee, void *con cipher__SHA256 hash; int result = SKY_coin_Transaction_Hash(handle, &hash); - if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + if (result == SKY_OK && (memcmp(&hash, thirdHash, sizeof(cipher__SHA256)) == 0)) { *pFee = MaxUint64 / 2; } @@ -1007,7 +1007,7 @@ GoUint32_ feeCalculator4(Transaction__Handle handle, GoUint64_ * pFee, void *con cipher__SHA256 *thirdHash = (cipher__SHA256 *) context; int result = SKY_coin_Transaction_Hash(handle, &hash); - if (result == SKY_OK && (memcmp(&hash, &thirdHash, sizeof(cipher__SHA256)) == 0)) + if (result == SKY_OK && (memcmp(&hash, thirdHash, sizeof(cipher__SHA256)) == 0)) { *pFee = 0; result = SKY_ERROR; From 957be8f54fddc6520b81db90b9b7d4221d81203a Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 12 Oct 2018 13:09:52 +0800 Subject: [PATCH 241/399] Add run-daemon.sh, update docs --- CHANGELOG.md | 1 + INSTALLATION.md | 8 ++++---- INTEGRATION.md | 4 ++++ Makefile | 7 +++++-- README.md | 21 ++++++++++++++------- electron/package-source.sh | 6 +++--- run.sh => run-client.sh | 2 ++ run-daemon.sh | 24 ++++++++++++++++++++++++ 8 files changed, 57 insertions(+), 16 deletions(-) rename run.sh => run-client.sh (92%) create mode 100755 run-daemon.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb07ff3ee..69e3459b48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ In the v0.26.0 these features and functions will be removed. If you have a need - `cli addressGen` arguments have changed - `cli generateWallet` renamed to `cli walletCreate` - `cli generateAddresses` renamed to `cli walletAddAddresses` +- `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. ### Removed diff --git a/INSTALLATION.md b/INSTALLATION.md index 7ef426d19f..7fa6f5db95 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -53,8 +53,8 @@ In China, use `--source=https://github.com/golang/go` to bypass firewall when fe gvm install go1.4 --source=https://github.com/golang/go gvm use go1.4 -gvm install go1.10.2 -gvm use go1.10.2 --default +gvm install go1.11.1 +gvm use go1.11.1 --default ``` #### Installation issues @@ -62,7 +62,7 @@ If you open up new a terminal and the `go` command is not found then add this to ```sh [[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm" -gvm use go1.10.2 >/dev/null +gvm use go1.11.1 >/dev/null ``` ## Install Go manually @@ -72,7 +72,7 @@ Let's go to home directory and declare `go`'s version that you want to download. ```sh cd ~ -export GOV=1.10.2 # golang version +export GOV=1.11.1 # golang version ``` After that, let's download and uncompress golang source. diff --git a/INTEGRATION.md b/INTEGRATION.md index ecf219bb62..e4d5506980 100644 --- a/INTEGRATION.md +++ b/INTEGRATION.md @@ -32,6 +32,7 @@ and to use the CLI tool for wallet operations (seed and address generation, tran +- [Running the skycoin node](#running-the-skycoin-node) - [API Documentation](#api-documentation) - [Wallet REST API](#wallet-rest-api) - [Skycoin command line interface](#skycoin-command-line-interface) @@ -67,6 +68,9 @@ and to use the CLI tool for wallet operations (seed and address generation, tran +## Running the skycoin node + +For integrations, the skycoin node should be run from source with `./run-daemon.sh`. This requires go1.10+ to be installed. ## API Documentation diff --git a/Makefile b/Makefile index a70b3ed0fe..0da91cf127 100644 --- a/Makefile +++ b/Makefile @@ -61,8 +61,11 @@ else LDFLAGS=$(LIBC_FLAGS) endif -run: ## Run the skycoin node. To add arguments, do 'make ARGS="--foo" run'. - ./run.sh ${ARGS} +run-client: ## Run skycoin with desktop client configuration. To add arguments, do 'make ARGS="--foo" run'. + ./run-client.sh ${ARGS} + +run-daemon: ## Run skycoin with server daemon configuration. To add arguments, do 'make ARGS="--foo" run'. + ./run-daemon.sh ${ARGS} run-help: ## Show skycoin node help @go run cmd/$(COIN)/$(COIN).go --help diff --git a/README.md b/README.md index 03bee29dc2..3eeadc2436 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ scratch, to remedy the rough edges in the Bitcoin design. - [Rules](#rules) - [Management](#management) - [Configuration Modes](#configuration-modes) - - [Development Desktop Daemon Mode](#development-desktop-daemon-mode) + - [Development Desktop Client Mode](#development-desktop-client-mode) - [Server Daemon Mode](#server-daemon-mode) - [Electron Desktop Client Mode](#electron-desktop-client-mode) - [Standalone Desktop Client Mode](#standalone-desktop-client-mode) @@ -297,7 +297,7 @@ The live integration tests run against a live runnning skycoin node, so before r need to start a skycoin node: ```sh -./run.sh -launch-browser=false +./run-daemon.sh ``` After the skycoin node is up, run the following command to start the live tests: @@ -507,17 +507,24 @@ There are 4 configuration modes in which you can run a skycoin node: - Electron Desktop Client - Standalone Desktop Client -#### Development Desktop Daemon Mode -This mode is configured via `run.sh` +#### Development Desktop Client Mode +This mode is configured via `run-client.sh` ```bash -$ ./run.sh +$ ./run-client.sh ``` #### Server Daemon Mode The default settings for a skycoin node are chosen for `Server Daemon`, which is typically run from source. This mode is usually preferred to be run with security options, though `-disable-csrf` is normal for server daemon mode, it is left enabled by default. + +```bash +$ ./run-daemon.sh +``` + +To disable CSRF: + ```bash -$ go run cmd/skycoin/skycoin.go +$ ./run-daemon.sh -disable-csrf ``` #### Electron Desktop Client Mode @@ -565,7 +572,7 @@ Performs these actions before releasing: * `make check` * `make integration-test-live` (see [live integration tests](#live-integration-tests)) both with an unencrypted and encrypted wallet, and once with `-networking-disabled` * `go run cmd/cli/cli.go checkdb` against a synced node -* On all OSes, make sure that the client runs properly from the command line (`./run.sh`) +* On all OSes, make sure that the client runs properly from the command line (`./run-client.sh` and `./run-daemon.sh`) * Build the releases and make sure that the Electron client runs properly on Windows, Linux and macOS. * Use a clean data directory with no wallets or database to sync from scratch and verify the wallet setup wizard. * Load a test wallet with nonzero balance from seed to confirm wallet loading works diff --git a/electron/package-source.sh b/electron/package-source.sh index fe6a5d57dc..a10149db55 100755 --- a/electron/package-source.sh +++ b/electron/package-source.sh @@ -10,17 +10,17 @@ pushd "${SCRIPTDIR}" if [[ "$OSTYPE" == "linux"* ]]; then tar -C .. -cvPf "${SRC_TAR}" --owner=0 --group=0 --exclude=electron \ --exclude=node_modules --exclude=_deprecated --exclude='.*' \ - src cmd run.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ + src cmd run-client.sh run-daemon.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ >/dev/null elif [[ "$OSTYPE" == "darwin"* ]]; then tar -C .. -cvf "${SRC_TAR}" --exclude=electron \ --exclude=node_modules --exclude=_deprecated --exclude='.*' \ - src cmd run.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ + src cmd run-client.sh run-daemon.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ >/dev/null elif [[ "$OSTYPE" == "msys"* ]]; then tar -C .. -cvPf "${SRC_TAR}" --owner=0 --group=0 --exclude=electron \ --exclude=node_modules --exclude=_deprecated --exclude='.*' \ - src cmd run.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ + src cmd run-client.sh run-daemon.sh README.md INSTALLATION.md CHANGELOG.md INTEGRATION.md \ >/dev/null fi diff --git a/run.sh b/run-client.sh similarity index 92% rename from run.sh rename to run-client.sh index c7b191fcc9..17cce6d597 100755 --- a/run.sh +++ b/run-client.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Runs skycoin in desktop client configuration + set -x DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/run-daemon.sh b/run-daemon.sh new file mode 100755 index 0000000000..4340b94058 --- /dev/null +++ b/run-daemon.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Runs skycoin in daemon mode configuration + +set -x + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo "skycoin binary dir:" "$DIR" +pushd "$DIR" >/dev/null + +COMMIT=$(git rev-parse HEAD) +BRANCH=$(git rev-parse --abbrev-ref HEAD) +GOLDFLAGS="-X main.Commit=${COMMIT} -X main.Branch=${BRANCH}" + +GORUNFLAGS=${GORUNFLAGS:-} + +go run -ldflags "${GOLDFLAGS}" $GORUNFLAGS cmd/skycoin/skycoin.go \ + -enable-gui=false \ + -launch-browser=false \ + -rpc-interface=false \ + -log-level=debug \ + $@ + +popd >/dev/null From eea9368e86ad126f9518da8b790854b3bc5345d1 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 01:27:42 -0400 Subject: [PATCH 242/399] [lib] refs #1191 - Rename header files renamed: include/feecalc.h -> include/skyfee.h renamed: include/transutil.h -> include/skytxn.h [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- include/{feecalc.h => skyfee.h} | 0 include/{transutil.h => skytxn.h} | 0 lib/cgo/coin.block.go | 2 +- lib/cgo/coin.transactions.go | 2 +- lib/cgo/tests/check_cipher.encrypt.sha256xor.c | 1 - lib/cgo/tests/check_coin.block.c | 2 +- lib/cgo/tests/check_coin.coin.c | 2 +- lib/cgo/tests/check_coin.outputs.c | 2 +- lib/cgo/tests/check_coin.transactions.c | 2 +- lib/cgo/tests/testutils/transutils.c | 2 +- 10 files changed, 7 insertions(+), 8 deletions(-) rename include/{feecalc.h => skyfee.h} (100%) rename include/{transutil.h => skytxn.h} (100%) diff --git a/include/feecalc.h b/include/skyfee.h similarity index 100% rename from include/feecalc.h rename to include/skyfee.h diff --git a/include/transutil.h b/include/skytxn.h similarity index 100% rename from include/transutil.h rename to include/skytxn.h diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index bfaa46a628..be7f7cafe6 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -15,7 +15,7 @@ import ( #include #include "skytypes.h" - #include "feecalc.h" + #include "skyfee.h" */ import "C" diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index f0f78f2c4b..b0f5f61117 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -16,7 +16,7 @@ import ( #include #include "skytypes.h" - #include "feecalc.h" + #include "skyfee.h" */ import "C" diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c index 94e5d159e3..b13c9f7825 100644 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c @@ -169,7 +169,6 @@ Test(cipher_encrypt_sha256xor, TestEncrypt){ if( test_data[i].success ){ cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); } else { - fprintf(stderr, "Errorcode %d\n", errcode); cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); } if( errcode == SKY_OK ){ diff --git a/lib/cgo/tests/check_coin.block.c b/lib/cgo/tests/check_coin.block.c index 726bcb4621..cc99d372b4 100644 --- a/lib/cgo/tests/check_coin.block.c +++ b/lib/cgo/tests/check_coin.block.c @@ -9,7 +9,7 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#include "transutil.h" +#include "skytxn.h" #include "skycriterion.h" #include "time.h" diff --git a/lib/cgo/tests/check_coin.coin.c b/lib/cgo/tests/check_coin.coin.c index c2bc417e15..2fbc746680 100644 --- a/lib/cgo/tests/check_coin.coin.c +++ b/lib/cgo/tests/check_coin.coin.c @@ -9,7 +9,7 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#include "transutil.h" +#include "skytxn.h" #include "time.h" TestSuite(coin_coin, .init = setup, .fini = teardown); diff --git a/lib/cgo/tests/check_coin.outputs.c b/lib/cgo/tests/check_coin.outputs.c index 8be98381b6..63174cd92d 100644 --- a/lib/cgo/tests/check_coin.outputs.c +++ b/lib/cgo/tests/check_coin.outputs.c @@ -9,7 +9,7 @@ #include "skystring.h" #include "skytest.h" #include "skycriterion.h" -#include "transutil.h" +#include "skytxn.h" TestSuite(coin_outputs, .init = setup, .fini = teardown); diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 8a850d850b..62c50fa1bf 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -10,7 +10,7 @@ #include "skystring.h" #include "skytest.h" #include "skycriterion.h" -#include "transutil.h" +#include "skytxn.h" TestSuite(coin_transaction, .init = setup, .fini = teardown); diff --git a/lib/cgo/tests/testutils/transutils.c b/lib/cgo/tests/testutils/transutils.c index 67c75b4225..c94b3907f9 100644 --- a/lib/cgo/tests/testutils/transutils.c +++ b/lib/cgo/tests/testutils/transutils.c @@ -9,7 +9,7 @@ #include "skyerrors.h" #include "skystring.h" #include "skytest.h" -#include "transutil.h" +#include "skytxn.h" GoUint32_ zeroFeeCalculator(Transaction__Handle handle, GoUint64_ *pFee, void* context){ *pFee = 0; From 641b4867fab4b056a6e0fad68a1bf13a49d45a16 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 01:38:31 -0400 Subject: [PATCH 243/399] [lib] refs #1191 - Header files included twice --- lib/cgo/cipher.address.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/cgo/cipher.address.go b/lib/cgo/cipher.address.go index 6c3546c825..e81196fe21 100644 --- a/lib/cgo/cipher.address.go +++ b/lib/cgo/cipher.address.go @@ -12,8 +12,6 @@ import ( #include #include #include "skytypes.h" - - #include "skytypes.h" */ import "C" From 0eb9fd43dc78fda04701fa99f36a027f5a3ce4f8 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 02:29:36 -0400 Subject: [PATCH 244/399] [lib] refs #1191 - Silence make lint warnings Reported in https://travis-ci.org/simelo/skycoin/jobs/440480957#L1870-L1883 --- lib/cgo/libsky_error.go | 6 +----- lib/cgo/libsky_time.go | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 04ed2f7a89..bea289fd1d 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -434,7 +434,7 @@ var ( // More precise errors conditions can be found in the logs ErrorInvalidTimeString = errors.New("Invalid time value") - codeToErrorMap = make(map[uint32]error, 0) + codeToErrorMap = make(map[uint32]error) errorToCodeMap = map[error]uint32{ // libcgo ErrorBadHandle: SKY_BAD_HANDLE, @@ -602,10 +602,6 @@ var ( } ) -func errorObjectFromCode(errcode uint32) error { - return codeToErrorMap[errcode] -} - func libErrorCode(err error) uint32 { if err == nil { return SKY_OK diff --git a/lib/cgo/libsky_time.go b/lib/cgo/libsky_time.go index 14682801b1..256dd4e76b 100644 --- a/lib/cgo/libsky_time.go +++ b/lib/cgo/libsky_time.go @@ -12,7 +12,3 @@ func parseTimeValue(strTime string) (time.Time, error) { } return t, err } - -func timeValueToString(t time.Time) string { - return t.Format(time.RFC3339) -} From 7f12e029fb2a699083433c87082d89e0e9e06ce3 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 12 Oct 2018 14:52:14 +0800 Subject: [PATCH 245/399] Add daemon builds; bump version 0.25.0-rc1 --- .Doxyfile | 2 +- .gitignore | 1 + CHANGELOG.md | 1 + Makefile | 10 ++- cmd/cli/README.md | 2 +- cmd/skycoin/skycoin.go | 2 +- electron/build-conf.sh | 40 ++++++--- electron/build-daemon-release.sh | 27 ++++++ electron/build-electron-release.sh | 2 +- electron/build-standalone-release.sh | 2 +- electron/build.sh | 10 ++- electron/compress-daemon-release.sh | 105 ++++++++++++++++++++++++ electron/gox.sh | 4 +- electron/package-daemon-release.sh | 91 ++++++++++++++++++++ electron/package-electron-release.sh | 2 +- electron/package-lock.json | 2 +- electron/package-standalone-release.sh | 6 +- electron/package.json | 2 +- electron/skycoin/current-skycoin.json | 2 +- src/cli/cli.go | 2 +- src/gui/static/src/current-skycoin.json | 2 +- template/coin.template | 2 +- 22 files changed, 285 insertions(+), 34 deletions(-) create mode 100755 electron/build-daemon-release.sh create mode 100755 electron/compress-daemon-release.sh create mode 100755 electron/package-daemon-release.sh diff --git a/.Doxyfile b/.Doxyfile index d67edcf2ff..edd47781df 100644 --- a/.Doxyfile +++ b/.Doxyfile @@ -5,7 +5,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = libskycoin -PROJECT_NUMBER = 0.24.1-develop +PROJECT_NUMBER = 0.25.0-rc1-develop PROJECT_BRIEF = "Skycoin C client library" PROJECT_LOGO = ./docs/assets/sky.libc.jpg OUTPUT_DIRECTORY = ./docs/libc diff --git a/.gitignore b/.gitignore index 40d3912098..9a4f877bdb 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,7 @@ electron/node_modules electron/.gox_output electron/.electron_output electron/.standalone_output +electron/.daemon_output # Do not ignore the icons folder !electron/build !electron/build/icons diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bf1a19937..f9ecc73d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ In the v0.26.0 these features and functions will be removed. If you have a need - Add `/api/v2/wallet/recover` to recover an encrypted wallet by providing the seed - Add `fiberAddressGen` CLI command to generate distribution addresses for fiber coins - Coinhour burn factor can be configured at runtime with `COINHOUR_BURN_FACTOR` envvar +- Daemon configured builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. The builds available for previous versions are configured for desktop client use. ### Fixed diff --git a/Makefile b/Makefile index 0da91cf127..461ac7ab81 100644 --- a/Makefile +++ b/Makefile @@ -212,18 +212,22 @@ build-ui: ## Builds the UI build-ui-travis: ## Builds the UI for travis cd $(GUI_STATIC_DIR) && npm run build-travis -release: ## Build electron and standalone apps. Use osarch=${osarch} to specify the platform. Example: 'make release osarch=darwin/amd64', multiple platform can be supported in this way: 'make release osarch="darwin/amd64 windows/amd64"'. Supported architectures are: darwin/amd64 windows/amd64 windows/386 linux/amd64 linux/arm, the builds are located in electron/release folder. +release: ## Build electron, standalone and daemon apps. Use osarch=${osarch} to specify the platform. Example: 'make release osarch=darwin/amd64', multiple platform can be supported in this way: 'make release osarch="darwin/amd64 windows/amd64"'. Supported architectures are: darwin/amd64 windows/amd64 windows/386 linux/amd64 linux/arm, the builds are located in electron/release folder. cd $(ELECTRON_DIR) && ./build.sh ${osarch} @echo release files are in the folder of electron/release -release-bin: ## Build standalone apps. Use osarch=${osarch} to specify the platform. Example: 'make release-bin osarch=darwin/amd64' Supported architectures are the same as 'release' command. +release-standalone: ## Build standalone apps. Use osarch=${osarch} to specify the platform. Example: 'make release-standalone osarch=darwin/amd64' Supported architectures are the same as 'release' command. cd $(ELECTRON_DIR) && ./build-standalone-release.sh ${osarch} @echo release files are in the folder of electron/release -release-gui: ## Build electron apps. Use osarch=${osarch} to specify the platform. Example: 'make release-gui osarch=darwin/amd64' Supported architectures are the same as 'release' command. +release-electron: ## Build electron apps. Use osarch=${osarch} to specify the platform. Example: 'make release-electron osarch=darwin/amd64' Supported architectures are the same as 'release' command. cd $(ELECTRON_DIR) && ./build-electron-release.sh ${osarch} @echo release files are in the folder of electron/release +release-daemon: ## Build daemon apps. Use osarch=${osarch} to specify the platform. Example: 'make release-daemon osarch=darwin/amd64' Supported architectures are the same as 'release' command. + cd $(ELECTRON_DIR) && ./build-daemon-release.sh ${osarch} + @echo release files are in the folder of electron/release + clean-release: ## Clean dist files and delete all builds in electron/release rm $(ELECTRON_DIR)/release/* diff --git a/cmd/cli/README.md b/cmd/cli/README.md index 841a1cb836..2f1c70f979 100644 --- a/cmd/cli/README.md +++ b/cmd/cli/README.md @@ -129,7 +129,7 @@ USAGE: skycoin-cli [global options] command [command options] [arguments...] VERSION: - 0.24.1 + 0.25.0-rc1 COMMANDS: addPrivateKey Add a private key to specific wallet diff --git a/cmd/skycoin/skycoin.go b/cmd/skycoin/skycoin.go index 00f8e50d69..b615a75065 100644 --- a/cmd/skycoin/skycoin.go +++ b/cmd/skycoin/skycoin.go @@ -20,7 +20,7 @@ import ( var ( // Version of the node. Can be set by -ldflags - Version = "0.24.1" + Version = "0.25.0-rc1" // Commit ID. Can be set by -ldflags Commit = "" // Branch name. Can be set by -ldflags diff --git a/electron/build-conf.sh b/electron/build-conf.sh index 9faad32837..e90a7be550 100755 --- a/electron/build-conf.sh +++ b/electron/build-conf.sh @@ -25,9 +25,13 @@ else fi GOX_OUTPUT=".gox_output" +GOX_GUI_OUTPUT="${GOX_OUTPUT}/gui" +GOX_DMN_OUTPUT="${GOX_OUTPUT}/daemon" STL_OUTPUT=".standalone_output" +DMN_OUTPUT=".daemon_output" + FINAL_OUTPUT="release" GUI_DIST_DIR="../src/gui/static/dist" # Do not append "/" to this path @@ -35,50 +39,60 @@ GUI_DIST_DIR="../src/gui/static/dist" # Do not append "/" to this path # Variable suffix guide: # _APP -- name of the OS X app # _ELN_PLT -- directory name created by electron for its build of this platform -# _ELN -- our name for electron/gui releases -# _ELN_ZIP -- our compressed name for electron/gui releases -# _STL -- our name for standalone/non-gui releases -# _STL_ZIP -- our compressed name for standalone/non-gui releases +# _ELN -- our name for electron gui releases +# _ELN_ZIP -- our compressed name for electron gui releases +# _STL -- our name for standalone gui releases +# _STL_ZIP -- our compressed name for standalone gui releases +# _DMN -- our name for daemon releases +# _DMN_ZIP -- our compressed name for daemon releases if [[ $GOX_OSARCH == *"darwin/amd64"* ]]; then OSX64_APP="${PDT_NAME}.app" OSX64_ELN_PLT="darwin-x64" - OSX64_ELN="${PKG_NAME}-${APP_VERSION}-gui-osx-darwin-x64" + OSX64_ELN="${PKG_NAME}-${APP_VERSION}-gui-electron-osx-darwin-x64" OSX64_ELN_ZIP="${OSX64_ELN}.zip" - OSX64_STL="${PKG_NAME}-${APP_VERSION}-bin-osx-darwin-x64" + OSX64_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-osx-darwin-x64" OSX64_STL_ZIP="${OSX64_STL}.zip" + OSX64_DMN="${PKG_NAME}-${APP_VERSION}-daemon-osx-darwin-x64" + OSX64_DMN_ZIP="${OSX64_DMN}.zip" OSX64_OUT="mac_x64" fi if [[ $GOX_OSARCH == *"linux/amd64"* ]]; then - LNX64_ELN="${PKG_NAME}-${APP_VERSION}-gui-linux-x64" + LNX64_ELN="${PKG_NAME}-${APP_VERSION}-gui-electron-linux-x64" LNX64_ELN_PLT="linux-x64" LNX64_ELN_ZIP="${LNX64_ELN}.tar.gz" - LNX64_STL="${PKG_NAME}-${APP_VERSION}-bin-linux-x64" + LNX64_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-linux-x64" LNX64_STL_ZIP="${LNX64_STL}.tar.gz" + LNX64_DMN="${PKG_NAME}-${APP_VERSION}-daemon-linux-x64" + LNX64_DMN_ZIP="${LNX64_DMN}.tar.gz" LNX64_OUT="linux_x64" fi if [[ $GOX_OSARCH == *"windows/amd64"* ]]; then - WIN64_ELN="${PKG_NAME}-${APP_VERSION}-gui-win-x64" + WIN64_ELN="${PKG_NAME}-${APP_VERSION}-gui-electron-win-x64" WIN64_ELN_PLT="win32-x64" WIN64_ELN_ZIP="${WIN64_ELN}.zip" - WIN64_STL="${PKG_NAME}-${APP_VERSION}-bin-win-x64" + WIN64_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-win-x64" WIN64_STL_ZIP="${WIN64_STL}.zip" WIN64_OUT="win_x64" fi if [[ $GOX_OSARCH == *"windows/386"* ]]; then - WIN32_ELN="${PKG_NAME}-${APP_VERSION}-gui-win-x86" + WIN32_ELN="${PKG_NAME}-${APP_VERSION}-gui-electron-win-x86" WIN32_ELN_PLT="win32-ia32" WIN32_ELN_ZIP="${WIN32_ELN}.zip" - WIN32_STL="${PKG_NAME}-${APP_VERSION}-bin-win-x86" + WIN32_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-win-x86" WIN32_STL_ZIP="${WIN32_STL}.zip" + WIN32_DMN="${PKG_NAME}-${APP_VERSION}-daemon-win-x86" + WIN32_DMN_ZIP="${WIN32_DMN}.zip" WIN32_OUT="win_ia32" fi if [[ $GOX_OSARCH == *"linux/arm"* ]]; then - LNX_ARM_STL="${PKG_NAME}-${APP_VERSION}-bin-linux-arm" + LNX_ARM_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-linux-arm" LNX_ARM_STL_ZIP="${LNX_ARM_STL}.tar.gz" + LNX_ARM_DMN="${PKG_NAME}-${APP_VERSION}-daemon-linux-arm" + LNX_ARM_DMN_ZIP="${LNX_ARM_DMN}.tar.gz" LNX_ARM_OUT="linux_arm" fi diff --git a/electron/build-daemon-release.sh b/electron/build-daemon-release.sh new file mode 100755 index 0000000000..48181a2340 --- /dev/null +++ b/electron/build-daemon-release.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e -o pipefail + +GOX_OSARCH="$@" + +. build-conf.sh "$GOX_OSARCH" + +SKIP_COMPILATION=${SKIP_COMPILATION:-0} + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +if [ $SKIP_COMPILATION -ne 1 ]; then + CONFIG_MODE= ./gox.sh "$GOX_OSARCH" "$GOX_DMN_OUTPUT" +fi + +echo +echo "===========================" +echo "Packaging daemon release" +./package-daemon-release.sh "$GOX_OSARCH" + +echo "------------------------------" +echo "Compressing daemon release" +./compress-daemon-release.sh "$GOX_OSARCH" + +popd >/dev/null diff --git a/electron/build-electron-release.sh b/electron/build-electron-release.sh index de8daf6cdb..b3d492a6f6 100755 --- a/electron/build-electron-release.sh +++ b/electron/build-electron-release.sh @@ -23,7 +23,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null if [ $SKIP_COMPILATION -ne 1 ]; then - ./gox.sh "$GOX_OSARCH" "$GOX_OUTPUT" + CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" fi if [ -e "$ELN_OUTPUT" ]; then diff --git a/electron/build-standalone-release.sh b/electron/build-standalone-release.sh index ce2b5bec54..7b893b3ad4 100755 --- a/electron/build-standalone-release.sh +++ b/electron/build-standalone-release.sh @@ -12,7 +12,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null if [ $SKIP_COMPILATION -ne 1 ]; then - ./gox.sh "$GOX_OSARCH" "$GOX_OUTPUT" + CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" fi echo diff --git a/electron/build.sh b/electron/build.sh index 17fb0ae0fc..a5f48d3a03 100755 --- a/electron/build.sh +++ b/electron/build.sh @@ -13,8 +13,8 @@ pushd "$SCRIPTDIR" >/dev/null echo "Compiling with gox" pwd -# Build with gox here and make the other scripts skip it -./gox.sh "$GOX_OSARCH" "$GOX_OUTPUT" +# Build the client mode with gox here so that the standalone and electron releases don't need to compile twice +CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" echo "Installing node modules" ./install-node-modules.sh @@ -31,4 +31,10 @@ echo "Building electron release" SKIP_COMPILATION=1 ./build-electron-release.sh "$GOX_OSARCH" +echo +echo "===========================" +echo "Building daemon release" + +./build-daemon-release.sh "$GOX_OSARCH" + popd >/dev/null diff --git a/electron/compress-daemon-release.sh b/electron/compress-daemon-release.sh new file mode 100755 index 0000000000..41f80e257c --- /dev/null +++ b/electron/compress-daemon-release.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +set -e -o pipefail + +# Compresses packaged daemon release after +# ./package-daemon-release.sh is done + +GOX_OSARCH="$@" + +. build-conf.sh "$GOX_OSARCH" + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +# Compress archives +pushd "$DMN_OUTPUT" >/dev/null + +FINALS=() + +# OS X +if [ -e "$OSX64_DMN" ]; then + if [ -e "$OSX64_DMN_ZIP" ]; then + echo "Removing old $OSX64_DMN_ZIP" + rm "$OSX64_DMN_ZIP" + fi + echo "Zipping $OSX64_DMN_ZIP" + # -y preserves symlinks, + # so that the massive .framework library isn't duplicated + zip -r -y --quiet "$OSX64_DMN_ZIP" "$OSX64_DMN" + FINALS+=("$OSX64_DMN_ZIP") +fi + +# Windows 64bit +if [ -e "$WIN64_DMN" ]; then + if [ -e "$WIN64_DMN_ZIP" ]; then + echo "Removing old $WIN64_DMN_ZIP" + rm "$WIN64_DMN_ZIP" + fi + echo "Zipping $WIN64_DMN_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + zip -r --quiet -X "$WIN64_DMN_ZIP" "$WIN64_DMN" + elif [[ "$OSTYPE" == "darwin"* ]]; then + zip -r --quiet "$WIN64_DMN_ZIP" "$WIN64_DMN" + elif [[ "$OSTYPE" == "msys"* ]]; then + 7z a "$WIN64_DMN_ZIP" "$WIN64_DMN" + fi + FINALS+=("$WIN64_DMN_ZIP") +fi + +# Windows 32bit +if [ -e "$WIN32_DMN" ]; then + if [ -e "$WIN32_DMN_ZIP" ]; then + echo "Removing old $WIN32_DMN_ZIP" + rm "$WIN32_DMN_ZIP" + fi + echo "Zipping $WIN32_DMN_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + zip -r --quiet -X "$WIN32_DMN_ZIP" "$WIN32_DMN" + elif [[ "$OSTYPE" == "darwin"* ]]; then + zip -r --quiet "$WIN32_DMN_ZIP" "$WIN32_DMN" + elif [[ "$OSTYPE" == "msys"* ]]; then + 7z a "$WIN32_DMN_ZIP" "$WIN32_DMN" + fi + FINALS+=("$WIN32_DMN_ZIP") +fi + +# Linux +if [ -e "$LNX64_DMN" ]; then + if [ -e "$LNX64_DMN_ZIP" ]; then + echo "Removing old $LNX64_DMN_ZIP" + rm "$LNX64_DMN_ZIP" + fi + echo "Zipping $LNX64_DMN_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + tar czf "$LNX64_DMN_ZIP" --owner=0 --group=0 "$LNX64_DMN" + elif [[ "$OSTYPE" == "darwin"* ]]; then + tar czf "$LNX64_DMN_ZIP" "$LNX64_DMN" + fi + FINALS+=("$LNX64_DMN_ZIP") +fi + +# Linux arm +if [ -e "$LNX_ARM_DMN" ]; then + if [ -e "$LNX_ARM_DMN_ZIP" ]; then + echo "Removing old $LNX_ARM_DMN_ZIP" + rm "$LNX_ARM_DMN_ZIP" + fi + echo "Zipping $LNX_ARM_DMN_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + tar czf "$LNX_ARM_DMN_ZIP" --owner=0 --group=0 "$LNX_ARM_DMN" + elif [[ "$OSTYPE" == "darwin"* ]]; then + tar czf "$LNX_ARM_DMN_ZIP" "$LNX_ARM_DMN" + fi + FINALS+=("$LNX_ARM_DMN_ZIP") +fi + +popd >/dev/null + +# Move to final release dir +mkdir -p "$FINAL_OUTPUT" +for var in "${FINALS[@]}"; do + mv "${DMN_OUTPUT}/${var}" "$FINAL_OUTPUT" +done + +popd >/dev/null diff --git a/electron/gox.sh b/electron/gox.sh index 4b1232da79..7836485273 100755 --- a/electron/gox.sh +++ b/electron/gox.sh @@ -20,6 +20,8 @@ CMD="${PKG_NAME}" OSARCH="$1" OUTPUT="$2" +CONFIG_MODE=${CONFIG_MODE:-} + if [ -z "$OSARCH" ]; then echo "$USAGE" exit 1 @@ -46,7 +48,7 @@ COMMIT=`git rev-parse HEAD` gox -osarch="$OSARCH" \ -gcflags="-trimpath=${HOME}" \ -asmflags="-trimpath=${HOME}" \ - -ldflags="-X main.Version=${APP_VERSION} -X main.Commit=${COMMIT} -X main.ConfigMode=STANDALONE_CLIENT" \ + -ldflags="-X main.Version=${APP_VERSION} -X main.Commit=${COMMIT} -X main.ConfigMode=${CONFIG_MODE}" \ -output="${OUTPUT}{{.Dir}}_{{.OS}}_{{.Arch}}" \ "${CMDDIR}/${CMD}" diff --git a/electron/package-daemon-release.sh b/electron/package-daemon-release.sh new file mode 100755 index 0000000000..baf4c7fbf7 --- /dev/null +++ b/electron/package-daemon-release.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +set -e -o pipefail + +# Builds the daemon release + +GOX_OSARCH="$@" + +echo "In package daemon release: $GOX_OSARCH" + +. build-conf.sh "$GOX_OSARCH" + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +DESTSRCS=() + +function copy_if_exists { + if [ -z "$1" -o -z "$2" -o -z "$3" ]; then + echo "copy_if_exists requires 3 args" + exit 1 + fi + + BIN="${GOX_DMN_OUTPUT}/${1}" + DESTDIR="$2" + DESTSRC="$3" + + if [ -f "$BIN" ]; then + if [ -e "$DESTDIR" ]; then + rm -r "$DESTDIR" + fi + mkdir -p "$DESTDIR" + + # Copy binary to electron app + echo "Copying $BIN to $DESTDIR" + cp "$BIN" "$DESTDIR" + + # Copy static resources to electron app + echo "Copying $GUI_DIST_DIR to ${DESTDIR}/src/gui/static" + mkdir -p "${DESTDIR}/src/gui/static" + cp -R "$GUI_DIST_DIR" "${DESTDIR}/src/gui/static" + + echo "Adding $DESTSRC to package-source.sh list" + DESTSRCS+=("$DESTSRC") + else + echo "$BIN does not exsit" + fi +} + +echo "Copying ${PKG_NAME} binaries" + +# OS X +if [ ! -z "$OSX64_DMN" ]; then + OSX64="${DMN_OUTPUT}/${OSX64_DMN}" + OSX64_SRC="${OSX64}/src" + copy_if_exists "${OSX64_OUT}/${PKG_NAME}" "$OSX64" "$OSX64_SRC" +fi + +# Linux amd64 +if [ ! -z "$LNX64_DMN" ]; then + LNX64="${DMN_OUTPUT}/${LNX64_DMN}" + LNX64_SRC="${LNX64}/src" + copy_if_exists "${LNX64_OUT}/${PKG_NAME}" "$LNX64" "$LNX64_SRC" +fi + +# Linux arm +if [ ! -z "$LNX_ARM_DMN" ]; then + LNX_ARM="${DMN_OUTPUT}/${LNX_ARM_DMN}" + LNX_ARM_SRC="${LNX_ARM}/src" + copy_if_exists "${LNX_ARM_OUT}/${PKG_NAME}" "$LNX_ARM" "$LNX_ARM_SRC" +fi + +# Windows amd64 +if [ ! -z "$WIN64_DMN" ]; then + WIN64="${DMN_OUTPUT}/${WIN64_DMN}" + WIN64_SRC="${WIN64}/src" + copy_if_exists "${WIN64_OUT}/${PKG_NAME}.exe" "$WIN64" "$WIN64_SRC" +fi + +# Windows 386 +if [ ! -z "$WIN32_DMN" ]; then + WIN32="${DMN_OUTPUT}/${WIN32_DMN}" + WIN32_SRC="${WIN32}/src" + copy_if_exists "${WIN32_OUT}/${PKG_NAME}.exe" "$WIN32" "$WIN32_SRC" +fi + +# Copy the source for reference +# tar it with filters, move it, then untar in order to do this +echo "Copying source snapshot" + +./package-source.sh "${DESTSRCS[@]}" diff --git a/electron/package-electron-release.sh b/electron/package-electron-release.sh index 4323743744..8caa500a5f 100755 --- a/electron/package-electron-release.sh +++ b/electron/package-electron-release.sh @@ -40,7 +40,7 @@ function copy_if_exists { exit 1 fi - BIN="${GOX_OUTPUT}/${1}" + BIN="${GOX_GUI_OUTPUT}/${1}" DESTDIR="$2" DESTBIN="${DESTDIR}/${3}" DESTSRC="$4" diff --git a/electron/package-lock.json b/electron/package-lock.json index 55fceada87..30dc94d2df 100644 --- a/electron/package-lock.json +++ b/electron/package-lock.json @@ -1,6 +1,6 @@ { "name": "skycoin", - "version": "0.24.1", + "version": "0.25.0-rc1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/electron/package-standalone-release.sh b/electron/package-standalone-release.sh index ae01c4cbaa..c43ab151d8 100755 --- a/electron/package-standalone-release.sh +++ b/electron/package-standalone-release.sh @@ -21,7 +21,7 @@ function copy_if_exists { exit 1 fi - BIN="${GOX_OUTPUT}/${1}" + BIN="${GOX_GUI_OUTPUT}/${1}" DESTDIR="$2" DESTSRC="$3" @@ -49,7 +49,7 @@ function copy_if_exists { echo "Copying ${PKG_NAME} binaries" -# OS X +# OS X if [ ! -z "$OSX64_STL" ]; then OSX64="${STL_OUTPUT}/${OSX64_STL}" OSX64_SRC="${OSX64}/src" @@ -88,4 +88,4 @@ fi # tar it with filters, move it, then untar in order to do this echo "Copying source snapshot" -./package-source.sh "${DESTSRCS[@]}" \ No newline at end of file +./package-source.sh "${DESTSRCS[@]}" diff --git a/electron/package.json b/electron/package.json index b8ef8daf9f..c961efac0a 100644 --- a/electron/package.json +++ b/electron/package.json @@ -3,7 +3,7 @@ "productName": "Skycoin", "author": "skycoin", "main": "src/electron-main.js", - "version": "0.24.1", + "version": "0.25.0-rc1", "description": "skycoin wallet", "license": "MIT", "build": { diff --git a/electron/skycoin/current-skycoin.json b/electron/skycoin/current-skycoin.json index 381e17e55d..400f1dcc6f 100644 --- a/electron/skycoin/current-skycoin.json +++ b/electron/skycoin/current-skycoin.json @@ -1 +1 @@ -versionData='{ "version": "0.24.1" }'; +versionData='{ "version": "0.25.0-rc1" }'; diff --git a/src/cli/cli.go b/src/cli/cli.go index d88dd81a3e..470d96bee6 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -26,7 +26,7 @@ import ( const ( // Version is the CLI Version - Version = "0.24.1" + Version = "0.25.0-rc1" walletExt = ".wlt" defaultCoin = "skycoin" defaultWalletName = "$COIN_cli" + walletExt diff --git a/src/gui/static/src/current-skycoin.json b/src/gui/static/src/current-skycoin.json index 381e17e55d..400f1dcc6f 100644 --- a/src/gui/static/src/current-skycoin.json +++ b/src/gui/static/src/current-skycoin.json @@ -1 +1 @@ -versionData='{ "version": "0.24.1" }'; +versionData='{ "version": "0.25.0-rc1" }'; diff --git a/template/coin.template b/template/coin.template index b001774873..04aa268237 100755 --- a/template/coin.template +++ b/template/coin.template @@ -20,7 +20,7 @@ import ( var ( // Version of the node. Can be set by -ldflags - Version = "0.24.1" + Version = "0.25.0-rc1" // Commit ID. Can be set by -ldflags Commit = "" // Branch name. Can be set by -ldflags From eb78f10680e8217ec2144bdf1eb2124d6a4d7a21 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 12 Oct 2018 16:42:08 +0800 Subject: [PATCH 246/399] Don't put src in release builds --- CHANGELOG.md | 1 + Makefile | 2 +- electron/build-electron-release.sh | 12 ++++++------ electron/package-daemon-release.sh | 17 ++++++++--------- electron/package-electron-release.sh | 12 ++++++++---- electron/package-standalone-release.sh | 12 ++++++++---- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9ecc73d5f..a6066ee75b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ In the v0.26.0 these features and functions will be removed. If you have a need - Remove `USE_CSRF` envvar from the CLI tool. It uses the REST API client now, which will automatically detect CSRF as needed, so no additional configuration is necessary. Operators may still wish to disable CSRF on their remote node to reduce request overhead. - Remove `-enable-wallet-api` and `-enable-seed-api` in place of including `WALLET` and `INSECURE_WALLET_SEED` in `-enable-api-sets`. +- Copies of the source code removed from release builds due to build artifact size ## [0.24.1] - 2018-07-30 diff --git a/Makefile b/Makefile index 461ac7ab81..8f343f5364 100644 --- a/Makefile +++ b/Makefile @@ -229,7 +229,7 @@ release-daemon: ## Build daemon apps. Use osarch=${osarch} to specify the platfo @echo release files are in the folder of electron/release clean-release: ## Clean dist files and delete all builds in electron/release - rm $(ELECTRON_DIR)/release/* + rm -r $(ELECTRON_DIR)/release clean-coverage: ## Remove coverage output files rm -rf ./coverage/ diff --git a/electron/build-electron-release.sh b/electron/build-electron-release.sh index b3d492a6f6..73f4afdee7 100755 --- a/electron/build-electron-release.sh +++ b/electron/build-electron-release.sh @@ -57,12 +57,12 @@ pushd "$FINAL_OUTPUT" >/dev/null if [ -e "mac" ]; then pushd "mac" >/dev/null if [ -e "${PDT_NAME}-${APP_VERSION}.dmg" ]; then - mv "${PDT_NAME}-${APP_VERSION}.dmg" "../${PKG_NAME}-${APP_VERSION}-gui-osx-x64.dmg" + mv "${PDT_NAME}-${APP_VERSION}.dmg" "../${PKG_NAME}-${APP_VERSION}-gui-electron-osx-x64.dmg" elif [ -e "${PDT_NAME}.app" ]; then if [[ "$OSTYPE" == "darwin"* ]]; then - tar czf "../${PKG_NAME}-${APP_VERSION}-gui-osx-x64.zip" "${PDT_NAME}.app" + tar czf "../${PKG_NAME}-${APP_VERSION}-gui-electron-osx-x64.zip" "${PDT_NAME}.app" elif [[ "$OSTYPE" == "linux"* ]]; then - tar czf "../${PKG_NAME}-${APP_VERSION}-gui-osx-x64.zip" --owner=0 --group=0 "${PDT_NAME}.app" + tar czf "../${PKG_NAME}-${APP_VERSION}-gui-electron-osx-x64.zip" --owner=0 --group=0 "${PDT_NAME}.app" fi fi popd >/dev/null @@ -70,7 +70,7 @@ if [ -e "mac" ]; then fi IMG="${PKG_NAME}-${APP_VERSION}-x86_64.AppImage" -DEST_IMG="${PKG_NAME}-${APP_VERSION}-gui-linux-x64.AppImage" +DEST_IMG="${PKG_NAME}-${APP_VERSION}-gui-electron-linux-x64.AppImage" if [ -e $IMG ]; then mv "$IMG" "$DEST_IMG" chmod +x "$DEST_IMG" @@ -79,7 +79,7 @@ fi EXE="${PDT_NAME} Setup ${APP_VERSION}.exe" if [ -e "$EXE" ]; then if [ ! -z $WIN32_ELN ] && [ ! -z $WIN64_ELN ]; then - mv "$EXE" "${PKG_NAME}-${APP_VERSION}-gui-win-setup.exe" + mv "$EXE" "${PKG_NAME}-${APP_VERSION}-gui-electron-win-setup.exe" elif [ ! -z $WIN32_ELN ]; then mv "$EXE" "${WIN32_ELN}.exe" elif [ ! -z $WIN64_ELN ]; then @@ -90,7 +90,7 @@ fi # rename dmg file name DMG="${PKG_NAME}-${APP_VERSION}.dmg" if [ -e "$DMG" ]; then - mv "$DMG" "${PKG_NAME}-${APP_VERSION}-gui-osx.dmg" + mv "$DMG" "${PKG_NAME}-${APP_VERSION}-gui-electron-osx.dmg" fi # delete app zip file diff --git a/electron/package-daemon-release.sh b/electron/package-daemon-release.sh index baf4c7fbf7..aed5d65e1c 100755 --- a/electron/package-daemon-release.sh +++ b/electron/package-daemon-release.sh @@ -31,14 +31,13 @@ function copy_if_exists { fi mkdir -p "$DESTDIR" - # Copy binary to electron app + # Copy binary to app echo "Copying $BIN to $DESTDIR" cp "$BIN" "$DESTDIR" - # Copy static resources to electron app - echo "Copying $GUI_DIST_DIR to ${DESTDIR}/src/gui/static" - mkdir -p "${DESTDIR}/src/gui/static" - cp -R "$GUI_DIST_DIR" "${DESTDIR}/src/gui/static" + # Copy changelog to app + echo "Copying CHANGELOG.md to $DESTDIR" + cp ../CHANGELOG.md "$DESTDIR" echo "Adding $DESTSRC to package-source.sh list" DESTSRCS+=("$DESTSRC") @@ -84,8 +83,8 @@ if [ ! -z "$WIN32_DMN" ]; then copy_if_exists "${WIN32_OUT}/${PKG_NAME}.exe" "$WIN32" "$WIN32_SRC" fi -# Copy the source for reference -# tar it with filters, move it, then untar in order to do this -echo "Copying source snapshot" +# # Copy the source for reference +# # tar it with filters, move it, then untar in order to do this +# echo "Copying source snapshot" -./package-source.sh "${DESTSRCS[@]}" +# ./package-source.sh "${DESTSRCS[@]}" diff --git a/electron/package-electron-release.sh b/electron/package-electron-release.sh index 8caa500a5f..30a1124e82 100755 --- a/electron/package-electron-release.sh +++ b/electron/package-electron-release.sh @@ -55,6 +55,10 @@ function copy_if_exists { echo "Copying $GUI_DIST_DIR to $DESTDIR" cp -R "$GUI_DIST_DIR" "$DESTDIR" + # Copy changelog to app + echo "Copying CHANGELOG.md to $DESTDIR" + cp ../CHANGELOG.md "$DESTDIR" + DESTSRCS+=("$DESTSRC") else echo "$BIN does not exist" @@ -68,8 +72,8 @@ copy_if_exists "${PKG_NAME}_windows_amd64.exe" "$WIN64_RES" "${PKG_NAME}.exe" "$ copy_if_exists "${PKG_NAME}_windows_386.exe" "$WIN32_RES" "${PKG_NAME}.exe" "$WIN32_SRC" copy_if_exists "${PKG_NAME}_linux_amd64" "$LNX64_RES" "${PKG_NAME}" "$LNX64_SRC" -# Copy the source for reference -# tar it with filters, move it, then untar in order to do this -echo "Copying source snapshot" +# # Copy the source for reference +# # tar it with filters, move it, then untar in order to do this +# echo "Copying source snapshot" -./package-source.sh "${DESTSRCS[@]}" +# ./package-source.sh "${DESTSRCS[@]}" diff --git a/electron/package-standalone-release.sh b/electron/package-standalone-release.sh index c43ab151d8..55759776e8 100755 --- a/electron/package-standalone-release.sh +++ b/electron/package-standalone-release.sh @@ -40,6 +40,10 @@ function copy_if_exists { mkdir -p "${DESTDIR}/src/gui/static" cp -R "$GUI_DIST_DIR" "${DESTDIR}/src/gui/static" + # Copy changelog to app + echo "Copying CHANGELOG.md to $DESTDIR" + cp ../CHANGELOG.md "$DESTDIR" + echo "Adding $DESTSRC to package-source.sh list" DESTSRCS+=("$DESTSRC") else @@ -84,8 +88,8 @@ if [ ! -z "$WIN32_STL" ]; then copy_if_exists "${WIN32_OUT}/${PKG_NAME}.exe" "$WIN32" "$WIN32_SRC" fi -# Copy the source for reference -# tar it with filters, move it, then untar in order to do this -echo "Copying source snapshot" +# # Copy the source for reference +# # tar it with filters, move it, then untar in order to do this +# echo "Copying source snapshot" -./package-source.sh "${DESTSRCS[@]}" +# ./package-source.sh "${DESTSRCS[@]}" From 4813fe7a75532ef6369c812110ee5eb73bf7d15d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 11:59:07 -0400 Subject: [PATCH 247/399] [lib] refs #1191 - Fix errors reported in Travis build #3252 - Comment out code for SKY_wallet_CreateAddresses - Adapt SKY_cli_FormatAddressesAsJSON to support array of Addresser interface - Add missing brackets in lib/cgo/libsky_error.go Reported in https://travis-ci.org/skycoin/skycoin/builds/440661290?utm_source=github_status&utm_medium=notification --- lib/cgo/README.md | 5 +++++ lib/cgo/cli.generate_addrs.go | 7 ++++++- lib/cgo/libsky_error.go | 4 +++- lib/cgo/wallet.addresses.go | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/cgo/README.md b/lib/cgo/README.md index 42b26d6ec8..d0843ab789 100644 --- a/lib/cgo/README.md +++ b/lib/cgo/README.md @@ -103,6 +103,11 @@ using a higher `cap` and retry. Instances of `time.Time` will be formatted as RFC3339 strings before crossing API boundaries. +### Interface types + +At the moment there is limited support for functions with arguments +of interface types or collections of these types. + ## Generating documentation Follow these steps to generate API documentation. diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go index 9865862754..c890e41a18 100644 --- a/lib/cgo/cli.generate_addrs.go +++ b/lib/cgo/cli.generate_addrs.go @@ -37,7 +37,12 @@ func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.Pass //export SKY_cli_FormatAddressesAsJSON func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) - __arg1, ____return_err := cli.FormatAddressesAsJSON(addrs) + // TODO : Support for arrays of interface objects in cgogen + var __addrs = make([]cipher.Addresser, len(addrs)) + for _, addr := range addrs { + __addrs = append(__addrs, addr) + } + __arg1, ____return_err := cli.FormatAddressesAsJSON(__addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { copyString(__arg1, _arg1) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index e157ce887f..bea289fd1d 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -641,4 +641,6 @@ func libErrorCode(err error) uint32 { func init() { // Init reverse error code map for _err := range errorToCodeMap { - codeToErrorMap[errorToCodeMap[_err]] = _err \ No newline at end of file + codeToErrorMap[errorToCodeMap[_err]] = _err + } +} diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go index 94a5537174..d6d2051f83 100644 --- a/lib/cgo/wallet.addresses.go +++ b/lib/cgo/wallet.addresses.go @@ -13,6 +13,8 @@ import ( */ import "C" +// FIXME: Removed from src/ . What's the way to do it now? +/* //export SKY_wallet_CreateAddresses func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _hideSecretKey bool, _arg4 *C.ReadableWallet__Handle) (____error_code uint32) { coinType := _coinType @@ -26,3 +28,4 @@ func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _ } return } +*/ From cce35c5321a7a7a2e172d5ca7c2daa9f3cc9fd44 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 15:06:48 -0400 Subject: [PATCH 248/399] [lib] refs #1191 - Use toAddresserArray in functions with args of cipher.Addresser type - coinType arg in NewReadableEntry - Remove SKY_wallet_LoadReadableEntry, SKY_wallet_NewReadableEntryFromPubkey, SKY_wallet_ReadableEntry_Save --- lib/cgo/cli.generate_addrs.go | 12 +++++------ lib/cgo/libsky_types.go | 23 +++++++++++++++++++++ lib/cgo/wallet.addresses.go | 2 +- lib/cgo/wallet.readable.go | 39 +++-------------------------------- 4 files changed, 32 insertions(+), 44 deletions(-) create mode 100644 lib/cgo/libsky_types.go diff --git a/lib/cgo/cli.generate_addrs.go b/lib/cgo/cli.generate_addrs.go index c890e41a18..da13765e61 100644 --- a/lib/cgo/cli.generate_addrs.go +++ b/lib/cgo/cli.generate_addrs.go @@ -37,11 +37,7 @@ func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.Pass //export SKY_cli_FormatAddressesAsJSON func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) - // TODO : Support for arrays of interface objects in cgogen - var __addrs = make([]cipher.Addresser, len(addrs)) - for _, addr := range addrs { - __addrs = append(__addrs, addr) - } + __addrs := toAddresserArray(addrs) __arg1, ____return_err := cli.FormatAddressesAsJSON(__addrs) ____error_code = libErrorCode(____return_err) if ____return_err == nil { @@ -53,7 +49,8 @@ func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString //export SKY_cli_FormatAddressesAsJoinedArray func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) - __arg1 := cli.FormatAddressesAsJoinedArray(addrs) + __addrs := toAddresserArray(addrs) + __arg1 := cli.FormatAddressesAsJoinedArray(__addrs) copyString(__arg1, _arg1) return } @@ -61,7 +58,8 @@ func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.G //export SKY_cli_AddressesToStrings func SKY_cli_AddressesToStrings(_addrs []C.cipher__Address, _arg1 *C.GoSlice_) (____error_code uint32) { addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) - __arg1 := cli.AddressesToStrings(addrs) + __addrs := toAddresserArray(addrs) + __arg1 := cli.AddressesToStrings(__addrs) copyToGoSlice(reflect.ValueOf(__arg1), _arg1) return } diff --git a/lib/cgo/libsky_types.go b/lib/cgo/libsky_types.go new file mode 100644 index 0000000000..20c43f143e --- /dev/null +++ b/lib/cgo/libsky_types.go @@ -0,0 +1,23 @@ +package main + +import ( + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +func toAddresserArray(addrs []cipher.Address) []cipher.Addresser { + // TODO : Support for arrays of interface objects in cgogen + var __addrs = make([]cipher.Addresser, len(addrs)) + for _, addr := range addrs { + __addrs = append(__addrs, addr) + } + return __addrs +} diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go index d6d2051f83..e6c5fba8ee 100644 --- a/lib/cgo/wallet.addresses.go +++ b/lib/cgo/wallet.addresses.go @@ -1,7 +1,7 @@ package main import ( - wallet "github.com/skycoin/skycoin/src/wallet" +// wallet "github.com/skycoin/skycoin/src/wallet" ) /* diff --git a/lib/cgo/wallet.readable.go b/lib/cgo/wallet.readable.go index 4e815f9d65..0747bda66c 100644 --- a/lib/cgo/wallet.readable.go +++ b/lib/cgo/wallet.readable.go @@ -16,47 +16,14 @@ import ( import "C" //export SKY_wallet_NewReadableEntry -func SKY_wallet_NewReadableEntry(_w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { +func SKY_wallet_NewReadableEntry(_coinType string, _w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { + coinType := wallet.CoinType(_coinType) w := *(*wallet.Entry)(unsafe.Pointer(_w)) - __arg1 := wallet.NewReadableEntry(w) + __arg1 := wallet.NewReadableEntry(coinType, w) *_arg1 = registerReadableEntryHandle(&__arg1) return } -//export SKY_wallet_LoadReadableEntry -func SKY_wallet_LoadReadableEntry(_filename string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - filename := _filename - __arg1, ____return_err := wallet.LoadReadableEntry(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg1 = registerReadableEntryHandle(&__arg1) - } - return -} - -//export SKY_wallet_NewReadableEntryFromPubkey -func SKY_wallet_NewReadableEntryFromPubkey(_pub string, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { - pub := _pub - __arg1 := wallet.NewReadableEntryFromPubkey(pub) - *_arg1 = registerReadableEntryHandle(&__arg1) - return -} - -//export SKY_wallet_ReadableEntry_Save -func SKY_wallet_ReadableEntry_Save(_re C.ReadableEntry__Handle, _filename string) (____error_code uint32) { - re, okre := lookupReadableEntryHandle(_re) - if !okre { - ____error_code = SKY_BAD_HANDLE - return - } - filename := _filename - ____return_err := re.Save(filename) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - } - return -} - //export SKY_wallet_LoadReadableWallet func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Handle) (____error_code uint32) { filename := _filename From bd3dc793129d26cac15e76eebbd7a4dcc5956ac1 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 22:08:53 -0400 Subject: [PATCH 249/399] [lib] refs #1191 - Type GoUint8_ for Version field of cipher__BitcoinAddress struct --- include/cipher.bitcoin.go.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cipher.bitcoin.go.h b/include/cipher.bitcoin.go.h index fd55b071af..b08b11fe38 100644 --- a/include/cipher.bitcoin.go.h +++ b/include/cipher.bitcoin.go.h @@ -2,7 +2,7 @@ * Addresses of Bitcoin accounts */ typedef struct { - unsigned char Version; ///< Address version identifier. + GoUint8_ Version; ///< Address version identifier. ///< Used to differentiate testnet ///< vs mainnet addresses, for instance. cipher__Ripemd160 Key; ///< Address hash identifier. From ea6419c87f3f93091b47d17f45fbd1acb617c9d1 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 12 Oct 2018 22:46:03 -0400 Subject: [PATCH 250/399] [lib] refs #1191 - Remove SKY_API_LOCKED and add SKY_INVALID_TIMESTRING in header files --- include/skyerrors.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index e8c5b18480..7afe823457 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -16,10 +16,10 @@ #define SKY_ERRORS_H // Generic error conditions -#define SKY_OK 0 -#define SKY_ERROR 0x7FFFFFFF -#define SKY_BAD_HANDLE 0x7F000001 -#define SKY_API_LOCKED 0x7F000002 +#define SKY_OK 0 +#define SKY_ERROR 0x7FFFFFFF +#define SKY_BAD_HANDLE 0x7F000001 +#define SKY_INVALID_TIMESTRING 0x7F000002 // Package error code prefix list #define SKY_PKG_API 0x01000000 From 01fb7777ff55a776ee18ed7c5b44a8e634249152 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 17:24:23 +0800 Subject: [PATCH 251/399] Build CLI tool for releases --- .gitignore | 1 + Makefile | 13 ++- electron/build-cli-release.sh | 27 ++++++ electron/build-conf.sh | 32 ++++++-- electron/build-daemon-release.sh | 2 +- electron/build-electron-release.sh | 8 +- electron/build-standalone-release.sh | 2 +- electron/build.sh | 8 +- electron/clean.sh | 2 +- electron/compress-cli-release.sh | 105 ++++++++++++++++++++++++ electron/compress-daemon-release.sh | 6 +- electron/compress-electron-release.sh | 6 +- electron/compress-standalone-release.sh | 6 +- electron/gox.sh | 39 +++++---- electron/package-cli-release.sh | 94 +++++++++++++++++++++ electron/package-daemon-release.sh | 12 +-- electron/package-electron-release.sh | 10 +-- electron/package-standalone-release.sh | 12 +-- src/cli/cli.go | 7 +- 19 files changed, 328 insertions(+), 64 deletions(-) create mode 100755 electron/build-cli-release.sh create mode 100755 electron/compress-cli-release.sh create mode 100755 electron/package-cli-release.sh diff --git a/.gitignore b/.gitignore index 9a4f877bdb..3e6cb73981 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,7 @@ electron/.gox_output electron/.electron_output electron/.standalone_output electron/.daemon_output +electron/.cli_output # Do not ignore the icons folder !electron/build !electron/build/icons diff --git a/Makefile b/Makefile index 8f343f5364..3e305207e6 100644 --- a/Makefile +++ b/Makefile @@ -228,8 +228,17 @@ release-daemon: ## Build daemon apps. Use osarch=${osarch} to specify the platfo cd $(ELECTRON_DIR) && ./build-daemon-release.sh ${osarch} @echo release files are in the folder of electron/release -clean-release: ## Clean dist files and delete all builds in electron/release - rm -r $(ELECTRON_DIR)/release +release-cli: ## Build CLI apps. Use osarch=${osarch} to specify the platform. Example: 'make release-cli osarch=darwin/amd64' Supported architectures are the same as 'release' command. + cd $(ELECTRON_DIR) && ./build-cli-release.sh ${osarch} + @echo release files are in the folder of electron/release + +clean-release: ## Remove all electron build artifacts + rm -rf $(ELECTRON_DIR)/release + rm -rf $(ELECTRON_DIR)/.gox_output + rm -rf $(ELECTRON_DIR)/.daemon_output + rm -rf $(ELECTRON_DIR)/.cli_output + rm -rf $(ELECTRON_DIR)/.standalone_output + rm -rf $(ELECTRON_DIR)/.electron_output clean-coverage: ## Remove coverage output files rm -rf ./coverage/ diff --git a/electron/build-cli-release.sh b/electron/build-cli-release.sh new file mode 100755 index 0000000000..edccb5755f --- /dev/null +++ b/electron/build-cli-release.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e -o pipefail + +GOX_OSARCH="$@" + +. build-conf.sh "$GOX_OSARCH" + +SKIP_COMPILATION=${SKIP_COMPILATION:-0} + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +if [ $SKIP_COMPILATION -ne 1 ]; then + CMD="cli" CONFIG_MODE= ./gox.sh "$GOX_OSARCH" "$GOX_CLI_OUTPUT_DIR" "$GOX_CLI_OUTPUT_NAME" +fi + +echo +echo "===========================" +echo "Packaging cli release" +./package-cli-release.sh "$GOX_OSARCH" + +echo "------------------------------" +echo "Compressing cli release" +./compress-cli-release.sh "$GOX_OSARCH" + +popd >/dev/null diff --git a/electron/build-conf.sh b/electron/build-conf.sh index e90a7be550..e92c2ff0d0 100755 --- a/electron/build-conf.sh +++ b/electron/build-conf.sh @@ -15,7 +15,7 @@ PDT_NAME=`grep productName package.json | sed 's/[,\", ]//g' | awk '{split($0,s, ELN_VERSION="v1.4.13" ELN_OUTPUT_BASE=".electron_output" -ELN_OUTPUT="${ELN_OUTPUT_BASE}/${ELN_VERSION}" +ELN_OUTPUT_DIR="${ELN_OUTPUT_BASE}/${ELN_VERSION}" if [ -n "$1" ]; then @@ -24,15 +24,17 @@ else GOX_OSARCH="linux/amd64 linux/arm windows/amd64 windows/386 darwin/amd64" fi -GOX_OUTPUT=".gox_output" -GOX_GUI_OUTPUT="${GOX_OUTPUT}/gui" -GOX_DMN_OUTPUT="${GOX_OUTPUT}/daemon" +GOX_OUTPUT_DIR=".gox_output" +GOX_GUI_OUTPUT_DIR="${GOX_OUTPUT_DIR}/gui" +GOX_DMN_OUTPUT_DIR="${GOX_OUTPUT_DIR}/daemon" +GOX_CLI_OUTPUT_DIR="${GOX_OUTPUT_DIR}/cli" +GOX_CLI_OUTPUT_NAME="${PKG_NAME}-cli" -STL_OUTPUT=".standalone_output" +STL_OUTPUT_DIR=".standalone_output" +DMN_OUTPUT_DIR=".daemon_output" +CLI_OUTPUT_DIR=".cli_output" -DMN_OUTPUT=".daemon_output" - -FINAL_OUTPUT="release" +FINAL_OUTPUT_DIR="release" GUI_DIST_DIR="../src/gui/static/dist" # Do not append "/" to this path @@ -45,6 +47,8 @@ GUI_DIST_DIR="../src/gui/static/dist" # Do not append "/" to this path # _STL_ZIP -- our compressed name for standalone gui releases # _DMN -- our name for daemon releases # _DMN_ZIP -- our compressed name for daemon releases +# _CLI -- our name for cli releases +# _CLI_ZIP -- our compressed name for cli releases if [[ $GOX_OSARCH == *"darwin/amd64"* ]]; then OSX64_APP="${PDT_NAME}.app" @@ -55,6 +59,8 @@ if [[ $GOX_OSARCH == *"darwin/amd64"* ]]; then OSX64_STL_ZIP="${OSX64_STL}.zip" OSX64_DMN="${PKG_NAME}-${APP_VERSION}-daemon-osx-darwin-x64" OSX64_DMN_ZIP="${OSX64_DMN}.zip" + OSX64_CLI="${PKG_NAME}-${APP_VERSION}-cli-osx-darwin-x64" + OSX64_CLI_ZIP="${OSX64_CLI}.zip" OSX64_OUT="mac_x64" fi @@ -66,6 +72,8 @@ if [[ $GOX_OSARCH == *"linux/amd64"* ]]; then LNX64_STL_ZIP="${LNX64_STL}.tar.gz" LNX64_DMN="${PKG_NAME}-${APP_VERSION}-daemon-linux-x64" LNX64_DMN_ZIP="${LNX64_DMN}.tar.gz" + LNX64_CLI="${PKG_NAME}-${APP_VERSION}-cli-linux-x64" + LNX64_CLI_ZIP="${LNX64_CLI}.tar.gz" LNX64_OUT="linux_x64" fi @@ -75,6 +83,10 @@ if [[ $GOX_OSARCH == *"windows/amd64"* ]]; then WIN64_ELN_ZIP="${WIN64_ELN}.zip" WIN64_STL="${PKG_NAME}-${APP_VERSION}-gui-standalone-win-x64" WIN64_STL_ZIP="${WIN64_STL}.zip" + WIN64_DMN="${PKG_NAME}-${APP_VERSION}-daemon-win-x64" + WIN64_DMN_ZIP="${WIN64_DMN}.zip" + WIN64_CLI="${PKG_NAME}-${APP_VERSION}-cli-win-x64" + WIN64_CLI_ZIP="${WIN64_CLI}.zip" WIN64_OUT="win_x64" fi @@ -86,6 +98,8 @@ if [[ $GOX_OSARCH == *"windows/386"* ]]; then WIN32_STL_ZIP="${WIN32_STL}.zip" WIN32_DMN="${PKG_NAME}-${APP_VERSION}-daemon-win-x86" WIN32_DMN_ZIP="${WIN32_DMN}.zip" + WIN32_CLI="${PKG_NAME}-${APP_VERSION}-cli-win-x86" + WIN32_CLI_ZIP="${WIN32_CLI}.zip" WIN32_OUT="win_ia32" fi @@ -94,5 +108,7 @@ if [[ $GOX_OSARCH == *"linux/arm"* ]]; then LNX_ARM_STL_ZIP="${LNX_ARM_STL}.tar.gz" LNX_ARM_DMN="${PKG_NAME}-${APP_VERSION}-daemon-linux-arm" LNX_ARM_DMN_ZIP="${LNX_ARM_DMN}.tar.gz" + LNX_ARM_CLI="${PKG_NAME}-${APP_VERSION}-cli-linux-arm" + LNX_ARM_CLI_ZIP="${LNX_ARM_CLI}.tar.gz" LNX_ARM_OUT="linux_arm" fi diff --git a/electron/build-daemon-release.sh b/electron/build-daemon-release.sh index 48181a2340..218cbae9d6 100755 --- a/electron/build-daemon-release.sh +++ b/electron/build-daemon-release.sh @@ -12,7 +12,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null if [ $SKIP_COMPILATION -ne 1 ]; then - CONFIG_MODE= ./gox.sh "$GOX_OSARCH" "$GOX_DMN_OUTPUT" + CONFIG_MODE= ./gox.sh "$GOX_OSARCH" "$GOX_DMN_OUTPUT_DIR" fi echo diff --git a/electron/build-electron-release.sh b/electron/build-electron-release.sh index 73f4afdee7..642513b8e4 100755 --- a/electron/build-electron-release.sh +++ b/electron/build-electron-release.sh @@ -23,11 +23,11 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null if [ $SKIP_COMPILATION -ne 1 ]; then - CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" + CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT_DIR" fi -if [ -e "$ELN_OUTPUT" ]; then - rm -r "$ELN_OUTPUT" +if [ -e "$ELN_OUTPUT_DIR" ]; then + rm -r "$ELN_OUTPUT_DIR" fi if [ ! -z "$WIN64_ELN" ] && [ ! -z "$WIN32_ELN" ]; then @@ -53,7 +53,7 @@ if [ ! -z "$OSX64_ELN" ]; then fi fi -pushd "$FINAL_OUTPUT" >/dev/null +pushd "$FINAL_OUTPUT_DIR" >/dev/null if [ -e "mac" ]; then pushd "mac" >/dev/null if [ -e "${PDT_NAME}-${APP_VERSION}.dmg" ]; then diff --git a/electron/build-standalone-release.sh b/electron/build-standalone-release.sh index 7b893b3ad4..01a671ef69 100755 --- a/electron/build-standalone-release.sh +++ b/electron/build-standalone-release.sh @@ -12,7 +12,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null if [ $SKIP_COMPILATION -ne 1 ]; then - CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" + CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT_DIR" fi echo diff --git a/electron/build.sh b/electron/build.sh index a5f48d3a03..dd13502b4d 100755 --- a/electron/build.sh +++ b/electron/build.sh @@ -14,7 +14,7 @@ pushd "$SCRIPTDIR" >/dev/null echo "Compiling with gox" pwd # Build the client mode with gox here so that the standalone and electron releases don't need to compile twice -CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT" +CONFIG_MODE=STANDALONE_CLIENT ./gox.sh "$GOX_OSARCH" "$GOX_GUI_OUTPUT_DIR" echo "Installing node modules" ./install-node-modules.sh @@ -37,4 +37,10 @@ echo "Building daemon release" ./build-daemon-release.sh "$GOX_OSARCH" +echo +echo "===========================" +echo "Building cli release" + +./build-cli-release.sh "$GOX_OSARCH" + popd >/dev/null diff --git a/electron/clean.sh b/electron/clean.sh index 3b927e5a11..783faf5dbe 100755 --- a/electron/clean.sh +++ b/electron/clean.sh @@ -16,7 +16,7 @@ function rmnofail { done } -rmnofail "$ELN_OUTPUT_BASE" "$STL_OUTPUT" "$GOX_OUTPUT" "$FINAL_OUTPUT" +rmnofail "$ELN_OUTPUT_BASE" "$STL_OUTPUT_DIR" "$GOX_OUTPUT_DIR" "$FINAL_OUTPUT_DIR" # don't remove the electron cache by default, most of the time when we want # to clean up build artifacts we don't want to clean this up, and downloading diff --git a/electron/compress-cli-release.sh b/electron/compress-cli-release.sh new file mode 100755 index 0000000000..5d0c3c63ae --- /dev/null +++ b/electron/compress-cli-release.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +set -e -o pipefail + +# Compresses packaged cli release after +# ./package-cli-release.sh is done + +GOX_OSARCH="$@" + +. build-conf.sh "$GOX_OSARCH" + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +# Compress archives +pushd "$CLI_OUTPUT_DIR" >/dev/null + +FINALS=() + +# OS X +if [ -e "$OSX64_CLI" ]; then + if [ -e "$OSX64_CLI_ZIP" ]; then + echo "Removing old $OSX64_CLI_ZIP" + rm "$OSX64_CLI_ZIP" + fi + echo "Zipping $OSX64_CLI_ZIP" + # -y preserves symlinks, + # so that the massive .framework library isn't duplicated + zip -r -y --quiet "$OSX64_CLI_ZIP" "$OSX64_CLI" + FINALS+=("$OSX64_CLI_ZIP") +fi + +# Windows 64bit +if [ -e "$WIN64_CLI" ]; then + if [ -e "$WIN64_CLI_ZIP" ]; then + echo "Removing old $WIN64_CLI_ZIP" + rm "$WIN64_CLI_ZIP" + fi + echo "Zipping $WIN64_CLI_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + zip -r --quiet -X "$WIN64_CLI_ZIP" "$WIN64_CLI" + elif [[ "$OSTYPE" == "darwin"* ]]; then + zip -r --quiet "$WIN64_CLI_ZIP" "$WIN64_CLI" + elif [[ "$OSTYPE" == "msys"* ]]; then + 7z a "$WIN64_CLI_ZIP" "$WIN64_CLI" + fi + FINALS+=("$WIN64_CLI_ZIP") +fi + +# Windows 32bit +if [ -e "$WIN32_CLI" ]; then + if [ -e "$WIN32_CLI_ZIP" ]; then + echo "Removing old $WIN32_CLI_ZIP" + rm "$WIN32_CLI_ZIP" + fi + echo "Zipping $WIN32_CLI_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + zip -r --quiet -X "$WIN32_CLI_ZIP" "$WIN32_CLI" + elif [[ "$OSTYPE" == "darwin"* ]]; then + zip -r --quiet "$WIN32_CLI_ZIP" "$WIN32_CLI" + elif [[ "$OSTYPE" == "msys"* ]]; then + 7z a "$WIN32_CLI_ZIP" "$WIN32_CLI" + fi + FINALS+=("$WIN32_CLI_ZIP") +fi + +# Linux +if [ -e "$LNX64_CLI" ]; then + if [ -e "$LNX64_CLI_ZIP" ]; then + echo "Removing old $LNX64_CLI_ZIP" + rm "$LNX64_CLI_ZIP" + fi + echo "Zipping $LNX64_CLI_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + tar czf "$LNX64_CLI_ZIP" --owner=0 --group=0 "$LNX64_CLI" + elif [[ "$OSTYPE" == "darwin"* ]]; then + tar czf "$LNX64_CLI_ZIP" "$LNX64_CLI" + fi + FINALS+=("$LNX64_CLI_ZIP") +fi + +# Linux arm +if [ -e "$LNX_ARM_CLI" ]; then + if [ -e "$LNX_ARM_CLI_ZIP" ]; then + echo "Removing old $LNX_ARM_CLI_ZIP" + rm "$LNX_ARM_CLI_ZIP" + fi + echo "Zipping $LNX_ARM_CLI_ZIP" + if [[ "$OSTYPE" == "linux"* ]]; then + tar czf "$LNX_ARM_CLI_ZIP" --owner=0 --group=0 "$LNX_ARM_CLI" + elif [[ "$OSTYPE" == "darwin"* ]]; then + tar czf "$LNX_ARM_CLI_ZIP" "$LNX_ARM_CLI" + fi + FINALS+=("$LNX_ARM_CLI_ZIP") +fi + +popd >/dev/null + +# Move to final release dir +mkdir -p "$FINAL_OUTPUT_DIR" +for var in "${FINALS[@]}"; do + mv "${CLI_OUTPUT_DIR}/${var}" "$FINAL_OUTPUT_DIR" +done + +popd >/dev/null diff --git a/electron/compress-daemon-release.sh b/electron/compress-daemon-release.sh index 41f80e257c..72adc31c0c 100755 --- a/electron/compress-daemon-release.sh +++ b/electron/compress-daemon-release.sh @@ -13,7 +13,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null # Compress archives -pushd "$DMN_OUTPUT" >/dev/null +pushd "$DMN_OUTPUT_DIR" >/dev/null FINALS=() @@ -97,9 +97,9 @@ fi popd >/dev/null # Move to final release dir -mkdir -p "$FINAL_OUTPUT" +mkdir -p "$FINAL_OUTPUT_DIR" for var in "${FINALS[@]}"; do - mv "${DMN_OUTPUT}/${var}" "$FINAL_OUTPUT" + mv "${DMN_OUTPUT_DIR}/${var}" "$FINAL_OUTPUT_DIR" done popd >/dev/null diff --git a/electron/compress-electron-release.sh b/electron/compress-electron-release.sh index bebfe2c822..b29565bcfe 100755 --- a/electron/compress-electron-release.sh +++ b/electron/compress-electron-release.sh @@ -13,7 +13,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null # Compress archives -pushd "$ELN_OUTPUT" >/dev/null +pushd "$ELN_OUTPUT_DIR" >/dev/null FINALS=() @@ -81,9 +81,9 @@ fi popd >/dev/null # Move to final release dir -mkdir -p "$FINAL_OUTPUT" +mkdir -p "$FINAL_OUTPUT_DIR" for var in "${FINALS[@]}"; do - mv "${ELN_OUTPUT}/${var}" "$FINAL_OUTPUT" + mv "${ELN_OUTPUT_DIR}/${var}" "$FINAL_OUTPUT_DIR" done popd >/dev/null diff --git a/electron/compress-standalone-release.sh b/electron/compress-standalone-release.sh index ecddc0dcd2..92c5ac1c44 100755 --- a/electron/compress-standalone-release.sh +++ b/electron/compress-standalone-release.sh @@ -13,7 +13,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null # Compress archives -pushd "$STL_OUTPUT" >/dev/null +pushd "$STL_OUTPUT_DIR" >/dev/null FINALS=() @@ -97,9 +97,9 @@ fi popd >/dev/null # Move to final release dir -mkdir -p "$FINAL_OUTPUT" +mkdir -p "$FINAL_OUTPUT_DIR" for var in "${FINALS[@]}"; do - mv "${STL_OUTPUT}/${var}" "$FINAL_OUTPUT" + mv "${STL_OUTPUT_DIR}/${var}" "$FINAL_OUTPUT_DIR" done popd >/dev/null diff --git a/electron/gox.sh b/electron/gox.sh index 7836485273..9fda02d26d 100755 --- a/electron/gox.sh +++ b/electron/gox.sh @@ -15,10 +15,11 @@ if it does not exist. Defaults to the working directory. SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CMDDIR="../cmd" # relative to compile/electron/ -CMD="${PKG_NAME}" +CMD="${CMD:-$PKG_NAME}" # name of folder in ../cmd to build. defaults to PKG_NAME which is the name of the coin OSARCH="$1" -OUTPUT="$2" +OUTPUT_DIR="$2" +BIN_NAME="${3:-CMD}" CONFIG_MODE=${CONFIG_MODE:-} @@ -27,29 +28,31 @@ if [ -z "$OSARCH" ]; then exit 1 fi -case "$OUTPUT" in +case "$OUTPUT_DIR" in "") ;; */) ;; *) - OUTPUT+="/" + OUTPUT_DIR+="/" ;; esac pushd "$SCRIPTDIR" >/dev/null -if [ -n "$OUTPUT" ]; then - mkdir -p "$OUTPUT" +if [ -n "$OUTPUT_DIR" ]; then + mkdir -p "$OUTPUT_DIR" fi COMMIT=`git rev-parse HEAD` +CLI_IMPORT_PATH=`go list ../src/cli` + gox -osarch="$OSARCH" \ -gcflags="-trimpath=${HOME}" \ -asmflags="-trimpath=${HOME}" \ - -ldflags="-X main.Version=${APP_VERSION} -X main.Commit=${COMMIT} -X main.ConfigMode=${CONFIG_MODE}" \ - -output="${OUTPUT}{{.Dir}}_{{.OS}}_{{.Arch}}" \ + -ldflags="-X main.Version=${APP_VERSION} -X main.Commit=${COMMIT} -X main.ConfigMode=${CONFIG_MODE} -X ${CLI_IMPORT_PATH}.Version=${APP_VERSION}" \ + -output="${OUTPUT_DIR}{{.Dir}}_{{.OS}}_{{.Arch}}" \ "${CMDDIR}/${CMD}" # move the executable files into ${os}_${arch} folders, electron-builder will pack @@ -64,33 +67,33 @@ do case "${s[0]}" in "windows") if [ "${s[1]}" = "386" ]; then - OUT="${OUTPUT}${WIN32_OUT}" + OUT="${OUTPUT_DIR}${WIN32_OUT}" echo "mkdir $OUT" mkdir -p "$OUT" - mv "${OUTPUT}${PKG_NAME}_${s[0]}_${s[1]}.exe" "${OUT}/${PKG_NAME}.exe" + mv "${OUTPUT_DIR}${CMD}_${s[0]}_${s[1]}.exe" "${OUT}/${BIN_NAME}.exe" else - OUT="${OUTPUT}${WIN64_OUT}" + OUT="${OUTPUT_DIR}${WIN64_OUT}" mkdir -p "${OUT}" - mv "${OUTPUT}${PKG_NAME}_${s[0]}_${s[1]}.exe" "${OUT}/${PKG_NAME}.exe" + mv "${OUTPUT_DIR}${CMD}_${s[0]}_${s[1]}.exe" "${OUT}/${BIN_NAME}.exe" fi ;; "darwin") - OUT="${OUTPUT}${OSX64_OUT}" + OUT="${OUTPUT_DIR}${OSX64_OUT}" echo "mkdir ${OUT}" mkdir -p "${OUT}" - mv "${OUTPUT}${PKG_NAME}_${s[0]}_${s[1]}" "${OUT}/${PKG_NAME}" + mv "${OUTPUT_DIR}${CMD}_${s[0]}_${s[1]}" "${OUT}/${BIN_NAME}" ;; "linux") if [ "${s[1]}" = "amd64" ]; then - OUT="${OUTPUT}${LNX64_OUT}" + OUT="${OUTPUT_DIR}${LNX64_OUT}" echo "mkdir ${OUT}" mkdir -p "${OUT}" - mv "${OUTPUT}${PKG_NAME}_${s[0]}_${s[1]}" "${OUT}/${PKG_NAME}" + mv "${OUTPUT_DIR}${CMD}_${s[0]}_${s[1]}" "${OUT}/${BIN_NAME}" elif [ "${s[1]}" = "arm" ]; then - OUT="${OUTPUT}${LNX_ARM_OUT}" + OUT="${OUTPUT_DIR}${LNX_ARM_OUT}" echo "mkdir ${OUT}" mkdir -p "${OUT}" - mv "${OUTPUT}${PKG_NAME}_${s[0]}_${s[1]}" "${OUT}/${PKG_NAME}" + mv "${OUTPUT_DIR}${CMD}_${s[0]}_${s[1]}" "${OUT}/${BIN_NAME}" fi ;; esac diff --git a/electron/package-cli-release.sh b/electron/package-cli-release.sh new file mode 100755 index 0000000000..84e85867eb --- /dev/null +++ b/electron/package-cli-release.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +set -e -o pipefail + +# Builds the cli release + +GOX_OSARCH="$@" + +echo "In package cli release: $GOX_OSARCH" + +. build-conf.sh "$GOX_OSARCH" + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$SCRIPTDIR" >/dev/null + +DESTSRCS=() + +function copy_if_exists { + if [ -z "$1" -o -z "$2" -o -z "$3" ]; then + echo "copy_if_exists requires 3 args" + exit 1 + fi + + BIN="${GOX_CLI_OUTPUT_DIR}/${1}" + DESTDIR="$2" + DESTSRC="$3" + + if [ -f "$BIN" ]; then + if [ -e "$DESTDIR" ]; then + rm -r "$DESTDIR" + fi + mkdir -p "$DESTDIR" + + # Copy binary to app + echo "Copying $BIN to $DESTDIR" + cp "$BIN" "$DESTDIR" + + # Copy changelog to app + echo "Copying CHANGELOG.md to $DESTDIR" + cp ../CHANGELOG.md "$DESTDIR" + + # Copy cmd/cli/README.md to app + echo "Copying cmd/cli/README.md to $DESTDIR" + cp ../cmd/cli/README.md "$DESTDIR" + + echo "Adding $DESTSRC to package-source.sh list" + DESTSRCS+=("$DESTSRC") + else + echo "$BIN does not exsit" + fi +} + +echo "Copying ${GOX_CLI_OUTPUT_NAME} binaries" + +# OS X +if [ ! -z "$OSX64_CLI" ]; then + OSX64="${CLI_OUTPUT_DIR}/${OSX64_CLI}" + OSX64_SRC="${OSX64}/src" + copy_if_exists "${OSX64_OUT}/${GOX_CLI_OUTPUT_NAME}" "$OSX64" "$OSX64_SRC" +fi + +# Linux amd64 +if [ ! -z "$LNX64_CLI" ]; then + LNX64="${CLI_OUTPUT_DIR}/${LNX64_CLI}" + LNX64_SRC="${LNX64}/src" + copy_if_exists "${LNX64_OUT}/${GOX_CLI_OUTPUT_NAME}" "$LNX64" "$LNX64_SRC" +fi + +# Linux arm +if [ ! -z "$LNX_ARM_CLI" ]; then + LNX_ARM="${CLI_OUTPUT_DIR}/${LNX_ARM_CLI}" + LNX_ARM_SRC="${LNX_ARM}/src" + copy_if_exists "${LNX_ARM_OUT}/${GOX_CLI_OUTPUT_NAME}" "$LNX_ARM" "$LNX_ARM_SRC" +fi + +# Windows amd64 +if [ ! -z "$WIN64_CLI" ]; then + WIN64="${CLI_OUTPUT_DIR}/${WIN64_CLI}" + WIN64_SRC="${WIN64}/src" + copy_if_exists "${WIN64_OUT}/${GOX_CLI_OUTPUT_NAME}.exe" "$WIN64" "$WIN64_SRC" +fi + +# Windows 386 +if [ ! -z "$WIN32_CLI" ]; then + WIN32="${CLI_OUTPUT_DIR}/${WIN32_CLI}" + WIN32_SRC="${WIN32}/src" + copy_if_exists "${WIN32_OUT}/${GOX_CLI_OUTPUT_NAME}.exe" "$WIN32" "$WIN32_SRC" +fi + +# # Copy the source for reference +# # tar it with filters, move it, then untar in order to do this +# echo "Copying source snapshot" + +# ./package-source.sh "${DESTSRCS[@]}" diff --git a/electron/package-daemon-release.sh b/electron/package-daemon-release.sh index aed5d65e1c..989046bfef 100755 --- a/electron/package-daemon-release.sh +++ b/electron/package-daemon-release.sh @@ -21,7 +21,7 @@ function copy_if_exists { exit 1 fi - BIN="${GOX_DMN_OUTPUT}/${1}" + BIN="${GOX_DMN_OUTPUT_DIR}/${1}" DESTDIR="$2" DESTSRC="$3" @@ -50,35 +50,35 @@ echo "Copying ${PKG_NAME} binaries" # OS X if [ ! -z "$OSX64_DMN" ]; then - OSX64="${DMN_OUTPUT}/${OSX64_DMN}" + OSX64="${DMN_OUTPUT_DIR}/${OSX64_DMN}" OSX64_SRC="${OSX64}/src" copy_if_exists "${OSX64_OUT}/${PKG_NAME}" "$OSX64" "$OSX64_SRC" fi # Linux amd64 if [ ! -z "$LNX64_DMN" ]; then - LNX64="${DMN_OUTPUT}/${LNX64_DMN}" + LNX64="${DMN_OUTPUT_DIR}/${LNX64_DMN}" LNX64_SRC="${LNX64}/src" copy_if_exists "${LNX64_OUT}/${PKG_NAME}" "$LNX64" "$LNX64_SRC" fi # Linux arm if [ ! -z "$LNX_ARM_DMN" ]; then - LNX_ARM="${DMN_OUTPUT}/${LNX_ARM_DMN}" + LNX_ARM="${DMN_OUTPUT_DIR}/${LNX_ARM_DMN}" LNX_ARM_SRC="${LNX_ARM}/src" copy_if_exists "${LNX_ARM_OUT}/${PKG_NAME}" "$LNX_ARM" "$LNX_ARM_SRC" fi # Windows amd64 if [ ! -z "$WIN64_DMN" ]; then - WIN64="${DMN_OUTPUT}/${WIN64_DMN}" + WIN64="${DMN_OUTPUT_DIR}/${WIN64_DMN}" WIN64_SRC="${WIN64}/src" copy_if_exists "${WIN64_OUT}/${PKG_NAME}.exe" "$WIN64" "$WIN64_SRC" fi # Windows 386 if [ ! -z "$WIN32_DMN" ]; then - WIN32="${DMN_OUTPUT}/${WIN32_DMN}" + WIN32="${DMN_OUTPUT_DIR}/${WIN32_DMN}" WIN32_SRC="${WIN32}/src" copy_if_exists "${WIN32_OUT}/${PKG_NAME}.exe" "$WIN32" "$WIN32_SRC" fi diff --git a/electron/package-electron-release.sh b/electron/package-electron-release.sh index 30a1124e82..a88add7e4d 100755 --- a/electron/package-electron-release.sh +++ b/electron/package-electron-release.sh @@ -12,10 +12,10 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$SCRIPTDIR" >/dev/null -OSX64="${ELN_OUTPUT}/${OSX64_ELN_PLT}" -WIN64="${ELN_OUTPUT}/${WIN64_ELN_PLT}" -WIN32="${ELN_OUTPUT}/${WIN32_ELN_PLT}" -LNX64="${ELN_OUTPUT}/${LNX64_ELN_PLT}" +OSX64="${ELN_OUTPUT_DIR}/${OSX64_ELN_PLT}" +WIN64="${ELN_OUTPUT_DIR}/${WIN64_ELN_PLT}" +WIN32="${ELN_OUTPUT_DIR}/${WIN32_ELN_PLT}" +LNX64="${ELN_OUTPUT_DIR}/${LNX64_ELN_PLT}" OSX64_RES="${OSX64}/${OSX64_APP}/Contents/Resources/app" WIN64_RES="${WIN64}/resources/app" @@ -40,7 +40,7 @@ function copy_if_exists { exit 1 fi - BIN="${GOX_GUI_OUTPUT}/${1}" + BIN="${GOX_GUI_OUTPUT_DIR}/${1}" DESTDIR="$2" DESTBIN="${DESTDIR}/${3}" DESTSRC="$4" diff --git a/electron/package-standalone-release.sh b/electron/package-standalone-release.sh index 55759776e8..605021adc3 100755 --- a/electron/package-standalone-release.sh +++ b/electron/package-standalone-release.sh @@ -21,7 +21,7 @@ function copy_if_exists { exit 1 fi - BIN="${GOX_GUI_OUTPUT}/${1}" + BIN="${GOX_GUI_OUTPUT_DIR}/${1}" DESTDIR="$2" DESTSRC="$3" @@ -55,35 +55,35 @@ echo "Copying ${PKG_NAME} binaries" # OS X if [ ! -z "$OSX64_STL" ]; then - OSX64="${STL_OUTPUT}/${OSX64_STL}" + OSX64="${STL_OUTPUT_DIR}/${OSX64_STL}" OSX64_SRC="${OSX64}/src" copy_if_exists "${OSX64_OUT}/${PKG_NAME}" "$OSX64" "$OSX64_SRC" fi # Linux amd64 if [ ! -z "$LNX64_STL" ]; then - LNX64="${STL_OUTPUT}/${LNX64_STL}" + LNX64="${STL_OUTPUT_DIR}/${LNX64_STL}" LNX64_SRC="${LNX64}/src" copy_if_exists "${LNX64_OUT}/${PKG_NAME}" "$LNX64" "$LNX64_SRC" fi # Linux arm if [ ! -z "$LNX_ARM_STL" ]; then - LNX_ARM="${STL_OUTPUT}/${LNX_ARM_STL}" + LNX_ARM="${STL_OUTPUT_DIR}/${LNX_ARM_STL}" LNX_ARM_SRC="${LNX_ARM}/src" copy_if_exists "${LNX_ARM_OUT}/${PKG_NAME}" "$LNX_ARM" "$LNX_ARM_SRC" fi # Windows amd64 if [ ! -z "$WIN64_STL" ]; then - WIN64="${STL_OUTPUT}/${WIN64_STL}" + WIN64="${STL_OUTPUT_DIR}/${WIN64_STL}" WIN64_SRC="${WIN64}/src" copy_if_exists "${WIN64_OUT}/${PKG_NAME}.exe" "$WIN64" "$WIN64_SRC" fi # Windows 386 if [ ! -z "$WIN32_STL" ]; then - WIN32="${STL_OUTPUT}/${WIN32_STL}" + WIN32="${STL_OUTPUT_DIR}/${WIN32_STL}" WIN32_SRC="${WIN32}/src" copy_if_exists "${WIN32_OUT}/${PKG_NAME}.exe" "$WIN32" "$WIN32_SRC" fi diff --git a/src/cli/cli.go b/src/cli/cli.go index 470d96bee6..88a475b6e9 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -24,9 +24,12 @@ import ( "github.com/skycoin/skycoin/src/util/file" ) -const ( +var ( // Version is the CLI Version - Version = "0.25.0-rc1" + Version = "0.25.0-rc1" +) + +const ( walletExt = ".wlt" defaultCoin = "skycoin" defaultWalletName = "$COIN_cli" + walletExt From 3af63243f4540bbc90a92acc05bd64ad371e0abc Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 17:33:39 +0800 Subject: [PATCH 252/399] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7327750705..c4857a8df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Add `fiberAddressGen` CLI command to generate distribution addresses for fiber coins - Coinhour burn factor can be configured at runtime with `COINHOUR_BURN_FACTOR` envvar - Daemon configured builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. The builds available for previous versions are configured for desktop client use. +- `skycoin-cli` builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. ### Fixed From eb0f0f03044ede3332001c1106f75d9f147081a5 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 18:10:12 +0800 Subject: [PATCH 253/399] Fixups --- electron/gox.sh | 2 +- electron/package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/electron/gox.sh b/electron/gox.sh index 9fda02d26d..79497e241d 100755 --- a/electron/gox.sh +++ b/electron/gox.sh @@ -19,7 +19,7 @@ CMD="${CMD:-$PKG_NAME}" # name of folder in ../cmd to build. defaults to PKG_NA OSARCH="$1" OUTPUT_DIR="$2" -BIN_NAME="${3:-CMD}" +BIN_NAME="${3:-$CMD}" CONFIG_MODE=${CONFIG_MODE:-} diff --git a/electron/package.json b/electron/package.json index c961efac0a..bb934ac2e9 100644 --- a/electron/package.json +++ b/electron/package.json @@ -16,7 +16,7 @@ "category": "public.app-category.productivity", "extraFiles": [ { - "from": ".gox_output/${os}_${arch}", + "from": ".gox_output/gui/${os}_${arch}", "to": "./Resources/app" } ] @@ -25,7 +25,7 @@ "target": "nsis", "extraFiles": [ { - "from": ".gox_output/${os}_${arch}", + "from": ".gox_output/gui/${os}_${arch}", "to": "./resources/app" } ] @@ -34,7 +34,7 @@ "category": "Network", "extraFiles": [ { - "from": ".gox_output/${os}_${arch}", + "from": ".gox_output/gui/${os}_${arch}", "to": "./resources/app" }, { From 64849ae91f819d872163ed86ab956248426e7d5a Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 18:45:18 +0800 Subject: [PATCH 254/399] Document /spend and unversioned API migration --- CHANGELOG.md | 2 +- src/api/README.md | 195 +++++++++++++++++++++---------- src/util/droplet/droplet_test.go | 8 ++ 3 files changed, 140 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7327750705..8848ef40d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. In the v0.26.0 these features and functions will be removed. If you have a need for any of these features, let us know. - JSON-RPC 2.0 interface (this is no longer used by the CLI tool, and the REST API supports everything the JSON-RPC 2.0 API does). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from-the-jsonrpc-api -- `/api/v1/wallet/spend` endpoint (use `POST /api/v1/wallet/transaction` followed by `POST /api/v1/injectTransaction` instead) +- `/api/v1/wallet/spend` endpoint (use `POST /api/v1/wallet/transaction` followed by `POST /api/v1/injectTransaction` instead). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from--api-v1-spend - The unversioned REST API (the `-enable-unversioned-api` option will be removed, prefix your API requests with `/api/v1`) ### Notice diff --git a/src/api/README.md b/src/api/README.md index 607b027570..702fb60893 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -8,7 +8,76 @@ The API has two versions, `/api/v1` and `/api/v2`. Previously, there was no `/api/vx` prefix. Starting in application version v0.24.0, the existing endpoints from v0.23.0 are now prefixed with `/api/v1`. To retain the old endpoints, run the application -with `-enable-unversioned-api`. +with `-enable-unversioned-api`. This option will be removed in v0.26.0 +and the `/api/v1` prefix will be required for previously unversioned endpoints. + + + +- [API Version 1](#api-version-1) +- [API Version 2](#api-version-2) +- [API Sets](#api-sets) +- [Authentication](#authentication) +- [CSRF](#csrf) + - [Get current csrf token](#get-current-csrf-token) +- [General system checks](#general-system-checks) + - [Health check](#health-check) + - [Version info](#version-info) + - [Prometheus metrics](#prometheus-metrics) +- [Simple query APIs](#simple-query-apis) + - [Get balance of addresses](#get-balance-of-addresses) + - [Get unspent output set of address or hash](#get-unspent-output-set-of-address-or-hash) + - [Verify an address](#verify-an-address) +- [Wallet APIs](#wallet-apis) + - [Get wallet](#get-wallet) + - [Get unconfirmed transactions of a wallet](#get-unconfirmed-transactions-of-a-wallet) + - [Get wallets](#get-wallets) + - [Get wallet folder name](#get-wallet-folder-name) + - [Generate wallet seed](#generate-wallet-seed) + - [Create a wallet from seed](#create-a-wallet-from-seed) + - [Generate new address in wallet](#generate-new-address-in-wallet) + - [Updates wallet label](#updates-wallet-label) + - [Get wallet balance](#get-wallet-balance) + - [Spend coins from wallet](#spend-coins-from-wallet) + - [Create transaction](#create-transaction) + - [Unload wallet](#unload-wallet) + - [Encrypt wallet](#encrypt-wallet) + - [Decrypt wallet](#decrypt-wallet) + - [Get wallet seed](#get-wallet-seed) + - [Recover encrypted wallet by seed](#recover-encrypted-wallet-by-seed) +- [Transaction APIs](#transaction-apis) + - [Get unconfirmed transactions](#get-unconfirmed-transactions) + - [Get transaction info by id](#get-transaction-info-by-id) + - [Get raw transaction by id](#get-raw-transaction-by-id) + - [Inject raw transaction](#inject-raw-transaction) + - [Get transactions that are addresses related](#get-transactions-that-are-addresses-related) + - [Resend unconfirmed transactions](#resend-unconfirmed-transactions) + - [Verify encoded transaction](#verify-encoded-transaction) +- [Block APIs](#block-apis) + - [Get blockchain metadata](#get-blockchain-metadata) + - [Get blockchain progress](#get-blockchain-progress) + - [Get block by hash or seq](#get-block-by-hash-or-seq) + - [Get blocks in specific range](#get-blocks-in-specific-range) + - [Get last N blocks](#get-last-n-blocks) +- [Explorer APIs](#explorer-apis) + - [Get address affected transactions](#get-address-affected-transactions) +- [Uxout APIs](#uxout-apis) + - [Get uxout](#get-uxout) + - [Get historical unspent outputs for an address](#get-historical-unspent-outputs-for-an-address) +- [Coin supply related information](#coin-supply-related-information) + - [Coin supply](#coin-supply) + - [Richlist show top N addresses by uxouts](#richlist-show-top-n-addresses-by-uxouts) + - [Count unique addresses](#count-unique-addresses) +- [Network status](#network-status) + - [Get information for a specific connection](#get-information-for-a-specific-connection) + - [Get a list of all connections](#get-a-list-of-all-connections) + - [Get a list of all default connections](#get-a-list-of-all-default-connections) + - [Get a list of all trusted connections](#get-a-list-of-all-trusted-connections) + - [Get a list of all connections discovered through peer exchange](#get-a-list-of-all-connections-discovered-through-peer-exchange) +- [Migration from the unversioned API](#migration-from-the-unversioned-api) +- [Migrating from the JSONRPC API](#migrating-from-the-jsonrpc-api) +- [Migrating from /api/v1/spend](#migrating-from-apiv1spend) + + ## API Version 1 @@ -79,68 +148,6 @@ The username and password should be provided in an `Authorization: Basic` header Authentication can only be enabled when using HTTPS with `-web-interface-https`, unless `-web-interface-plaintext-auth` is enabled. - - -- [CSRF](#csrf) - - [Get current csrf token](#get-current-csrf-token) -- [General system checks](#general-system-checks) - - [Health check](#health-check) - - [Version info](#version-info) - - [Prometheus metrics](#prometheus-metrics) -- [Simple query APIs](#simple-query-apis) - - [Get balance of addresses](#get-balance-of-addresses) - - [Get unspent output set of address or hash](#get-unspent-output-set-of-address-or-hash) - - [Verify an address](#verify-an-address) -- [Wallet APIs](#wallet-apis) - - [Get wallet](#get-wallet) - - [Get unconfirmed transactions of a wallet](#get-unconfirmed-transactions-of-a-wallet) - - [Get wallets](#get-wallets) - - [Get wallet folder name](#get-wallet-folder-name) - - [Generate wallet seed](#generate-wallet-seed) - - [Create a wallet from seed](#create-a-wallet-from-seed) - - [Generate new address in wallet](#generate-new-address-in-wallet) - - [Updates wallet label](#updates-wallet-label) - - [Get wallet balance](#get-wallet-balance) - - [Spend coins from wallet](#spend-coins-from-wallet) - - [Create transaction](#create-transaction) - - [Unload wallet](#unload-wallet) - - [Encrypt wallet](#encrypt-wallet) - - [Decrypt wallet](#decrypt-wallet) - - [Get wallet seed](#get-wallet-seed) - - [Recover encrypted wallet by seed](#recover-encrypted-wallet-by-seed) -- [Transaction APIs](#transaction-apis) - - [Get unconfirmed transactions](#get-unconfirmed-transactions) - - [Get transaction info by id](#get-transaction-info-by-id) - - [Get raw transaction by id](#get-raw-transaction-by-id) - - [Inject raw transaction](#inject-raw-transaction) - - [Get transactions that are addresses related](#get-transactions-that-are-addresses-related) - - [Resend unconfirmed transactions](#resend-unconfirmed-transactions) - - [Verify encoded transaction](#verify-encoded-transaction) -- [Block APIs](#block-apis) - - [Get blockchain metadata](#get-blockchain-metadata) - - [Get blockchain progress](#get-blockchain-progress) - - [Get block by hash or seq](#get-block-by-hash-or-seq) - - [Get blocks in specific range](#get-blocks-in-specific-range) - - [Get last N blocks](#get-last-n-blocks) -- [Explorer APIs](#explorer-apis) - - [Get address affected transactions](#get-address-affected-transactions) -- [Uxout APIs](#uxout-apis) - - [Get uxout](#get-uxout) - - [Get historical unspent outputs for an address](#get-historical-unspent-outputs-for-an-address) -- [Coin supply related information](#coin-supply-related-information) - - [Coin supply](#coin-supply) - - [Richlist show top N addresses by uxouts](#richlist-show-top-n-addresses-by-uxouts) - - [Count unique addresses](#count-unique-addresses) -- [Network status](#network-status) - - [Get information for a specific connection](#get-information-for-a-specific-connection) - - [Get a list of all connections](#get-a-list-of-all-connections) - - [Get a list of all default connections](#get-a-list-of-all-default-connections) - - [Get a list of all trusted connections](#get-a-list-of-all-trusted-connections) - - [Get a list of all connections discovered through peer exchange](#get-a-list-of-all-connections-discovered-through-peer-exchange) -- [Migrating from the JSONRPC API](#migrating-from-the-jsonrpc-api) - - - ## CSRF All `POST`, `PUT` and `DELETE` requests require a CSRF token, obtained with a `GET /api/v1/csrf` call. @@ -3731,9 +3738,22 @@ Result: ] ``` +## Migration from the unversioned API + +The unversioned API are the API endpoints without an `/api` prefix. +These endpoints are all prefixed with `/api/v1` now. + +`-enable-unversioned-api` was added as an option to assist migration to `/api/v1` +but this option will be removed in v0.26.0. + +To migrate from the unversioned API, add `/api/v1` to all endpoints that you call +that do not have an `/api` prefix already. + +For example, `/block` would become `/api/v1/block`. + ## Migrating from the JSONRPC API -The JSONRPC-2.0 RPC API will be removed as of version `0.26.0`. +The JSONRPC-2.0 RPC API will be removed in v0.26.0. Anyone still using this can follow this guide to migrate to the REST API: * `get_status` is replaced by `/api/v1/blockchain/metadata` and `/api/v1/health` @@ -3742,3 +3762,50 @@ Anyone still using this can follow this guide to migrate to the REST API: * `get_outputs` is replaced by `/api/v1/outputs` * `inject_transaction` is replaced by `/api/v1/injectTransaction` * `get_transaction` is replaced by `/api/v1/transaction` + +## Migrating from /api/v1/spend + +The `POST /api/v1/spend` endpoint is deprecated and will be removed in v0.26.0. + +To migrate from it, use [`POST /api/v1/wallet/transaction`](#create-transaction) followed by [`POST /api/v1/injectTransaction`](#inject-raw-transaction). +Do not create another transaction before injecting the created transaction, otherwise you might create two conflicting transactions. + +`POST /api/v1/wallet/transaction` has more options for creating the transaction than the `/api/v1/spend` endpoint. +To replicate the same behavior as `/api/v1/spend`, use the following request body template: + +```json +{ + "hours_selection": { + "type": "auto", + "mode": "share", + "share_factor": "0.5", + }, + "wallet": { + "id": "$wallet_id", + "password": "$password" + }, + "to": [{ + "address": "$dst", + "coins": "$coins" + }] +} +``` + +You must use a string for `"coins"` instead of an integer measured in "droplets" (the smallest unit of currency in Skycoin, 1/1000000 of a skycoin). +For example, if you sent 1 Skycoin with `/api/v1/spend` you would have specified the `coins` field as `1000000`. +Now, you would specify it as `"1"`. + +Some examples: + +* 123.456 coins: before `123456000`, now `"123.456"` +* 0.1 coins: before `100000`, now `"0.1"` +* 1 coin: before `1000000`, now `"1"` + +Extra zeros on the `"coins"` string are ok, for example `"1"` is the same as `"1.0"` or `"1.000000"`. + +Only provide `"password"` if the wallet is encrypted. Note that decryption can take a few seconds, and this can impact +throughput. + +The response to `POST /api/v1/wallet/transaction` will include a verbose decoded transaction with details +and the hex-encoded binary transaction in the `"encoded_transaction"` field. +Use the value of `"encoded_transaction"` as the `"rawtx"` value in the request to `/api/v1/injectTransaction`. diff --git a/src/util/droplet/droplet_test.go b/src/util/droplet/droplet_test.go index 44ff0cb7c0..332f72f779 100644 --- a/src/util/droplet/droplet_test.go +++ b/src/util/droplet/droplet_test.go @@ -150,6 +150,14 @@ func TestFromString(t *testing.T) { s: "1.0000001", e: ErrTooManyDecimals, }, + { + s: "1.0000000", // 7 decimal places, but they are 0s + n: 1e6, + }, + { + s: "1.000001000", + n: 1e6 + 1e0, + }, } for _, tcc := range cases { From e403727480dcd65e6e07e52ad7993f509123155c Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 18:46:03 +0800 Subject: [PATCH 255/399] Update changelog --- CHANGELOG.md | 2 +- src/api/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8848ef40d1..499d36b7a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ In the v0.26.0 these features and functions will be removed. If you have a need - JSON-RPC 2.0 interface (this is no longer used by the CLI tool, and the REST API supports everything the JSON-RPC 2.0 API does). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from-the-jsonrpc-api - `/api/v1/wallet/spend` endpoint (use `POST /api/v1/wallet/transaction` followed by `POST /api/v1/injectTransaction` instead). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from--api-v1-spend -- The unversioned REST API (the `-enable-unversioned-api` option will be removed, prefix your API requests with `/api/v1`) +- The unversioned REST API (the `-enable-unversioned-api` option will be removed, prefix your API requests with `/api/v1`). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from-the-unversioned-api ### Notice diff --git a/src/api/README.md b/src/api/README.md index 702fb60893..095f6bb003 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -73,7 +73,7 @@ and the `/api/v1` prefix will be required for previously unversioned endpoints. - [Get a list of all default connections](#get-a-list-of-all-default-connections) - [Get a list of all trusted connections](#get-a-list-of-all-trusted-connections) - [Get a list of all connections discovered through peer exchange](#get-a-list-of-all-connections-discovered-through-peer-exchange) -- [Migration from the unversioned API](#migration-from-the-unversioned-api) +- [Migrating from the unversioned API](#migrating-from-the-unversioned-api) - [Migrating from the JSONRPC API](#migrating-from-the-jsonrpc-api) - [Migrating from /api/v1/spend](#migrating-from-apiv1spend) @@ -3738,7 +3738,7 @@ Result: ] ``` -## Migration from the unversioned API +## Migrating from the unversioned API The unversioned API are the API endpoints without an `/api` prefix. These endpoints are all prefixed with `/api/v1` now. From 9d06af646be22e4990e07a53ff45bc505374f9a0 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 19:37:25 +0800 Subject: [PATCH 256/399] Fixup --- src/api/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/README.md b/src/api/README.md index 095f6bb003..02fc9fc226 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3806,6 +3806,8 @@ Extra zeros on the `"coins"` string are ok, for example `"1"` is the same as `"1 Only provide `"password"` if the wallet is encrypted. Note that decryption can take a few seconds, and this can impact throughput. +The request header `Content-Type` must be `application/json`. + The response to `POST /api/v1/wallet/transaction` will include a verbose decoded transaction with details and the hex-encoded binary transaction in the `"encoded_transaction"` field. Use the value of `"encoded_transaction"` as the `"rawtx"` value in the request to `/api/v1/injectTransaction`. From feb4f7f76c9bed565be03990847ca7c1b9ae743a Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 13 Oct 2018 21:07:36 +0800 Subject: [PATCH 257/399] Accept Extra in into packet again; handle protocol version better --- include/skyerrors.h | 18 +++++++++--------- lib/cgo/libsky_error.go | 4 ++-- src/daemon/daemon.go | 14 ++++++++++---- src/daemon/gnet/pool.go | 2 ++ src/daemon/messages.go | 21 +++++++++++---------- src/daemon/messages_test.go | 6 +++--- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 1053e3c529..6bfa87fc15 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -103,7 +103,7 @@ #define SKY_ErrWriteQueueFull 0x0600000E #define SKY_ErrNoReachableConnections 0x0600000F #define SKY_ErrMaxDefaultConnectionsReached 0x06000010 -#define SKY_ErrDisconnectInvalidVersion 0x06000011 +#define SKY_ErrDisconnectVersionNotSupported 0x06000011 #define SKY_ErrDisconnectIntroductionTimeout 0x06000012 #define SKY_ErrDisconnectVersionSendFailed 0x06000013 #define SKY_ErrDisconnectIsBlacklisted 0x06000014 @@ -118,14 +118,14 @@ #define SKY_ConnectionError 0x0600001D // util error codes -#define SKY_ErrTxnNoFee 0x09000000 -#define SKY_ErrTxnInsufficientFee 0x09000001 -#define SKY_ErrTxnInsufficientCoinHours 0x09000002 -#define SKY_ErrNegativeValue 0x09000003 -#define SKY_ErrTooManyDecimals 0x09000004 -#define SKY_ErrTooLarge 0x09000005 -#define SKY_ErrEmptyDirectoryName 0x09000006 -#define SKY_ErrDotDirectoryName 0x09000007 +#define SKY_ErrTxnNoFee 0x09000000 +#define SKY_ErrTxnInsufficientFee 0x09000001 +#define SKY_ErrTxnInsufficientCoinHours 0x09000002 +#define SKY_ErrNegativeValue 0x09000003 +#define SKY_ErrTooManyDecimals 0x09000004 +#define SKY_ErrTooLarge 0x09000005 +#define SKY_ErrEmptyDirectoryName 0x09000006 +#define SKY_ErrDotDirectoryName 0x09000007 // visor error codes #define SKY_ErrHistoryDBCorrupted 0x0A000000 diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 8d60e7ed6d..b5119dbdbb 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -225,7 +225,7 @@ const ( // SKY_ErrMaxDefaultConnectionsReached returns when maximum number of default connections is reached SKY_ErrMaxDefaultConnectionsReached // nolint megacheck // SKY_ErrDisconnectReasons invalid version - SKY_ErrDisconnectInvalidVersion + SKY_ErrDisconnectVersionNotSupported // SKY_ErrDisconnectIntroductionTimeout timeout SKY_ErrDisconnectIntroductionTimeout // SKY_ErrDisconnectVersionSendFailed version send failed @@ -472,7 +472,7 @@ var ( gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, - daemon.ErrDisconnectInvalidVersion: SKY_ErrDisconnectInvalidVersion, + daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, daemon.ErrDisconnectVersionSendFailed: SKY_ErrDisconnectVersionSendFailed, daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 3fcaac6284..5544153637 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -22,8 +22,8 @@ import ( ) var ( - // ErrDisconnectInvalidVersion invalid version - ErrDisconnectInvalidVersion gnet.DisconnectReason = errors.New("Invalid version") + // ErrDisconnectVersionNotSupported version is below minimum supported version + ErrDisconnectVersionNotSupported gnet.DisconnectReason = errors.New("Version is below minimum supported version") // ErrDisconnectIntroductionTimeout timeout ErrDisconnectIntroductionTimeout gnet.DisconnectReason = errors.New("Version timeout") // ErrDisconnectVersionSendFailed version send failed @@ -123,7 +123,11 @@ func (cfg *Config) preprocess() Config { // DaemonConfig configuration for the Daemon type DaemonConfig struct { // nolint: golint // Protocol version. TODO -- manage version better - Version int32 + ProtocolVersion int32 + // Minimum accepted protocol version + MinProtocolVersion int32 + // Maximum accepted protocol version + MaxProtocolVersion int32 // IP Address to serve on. Leave empty for automatic assignment Address string // BlockchainPubkey blockchain pubkey string @@ -181,6 +185,8 @@ type DaemonConfig struct { // nolint: golint func NewDaemonConfig() DaemonConfig { return DaemonConfig{ Version: 2, + MinProtocolVersion: 2, + MaxProtocolVersion: 2, Address: "", Port: 6677, OutgoingRate: time.Second * 5, @@ -962,7 +968,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.expectingIntroductions.Add(a, time.Now().UTC()) logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.Version, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey[:]) + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey[:]) if err := dm.pool.Pool.SendMessage(a, m); err != nil { logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) } diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 9ee946297c..3af93b4be3 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -810,6 +810,8 @@ func (pool *ConnectionPool) disconnect(addr string) bool { return false } + // TODO -- send disconnect reason packet + delete(pool.pool, conn.ID) delete(pool.addresses, addr) delete(pool.defaultConnections, addr) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 0dcde846fa..dc5ce7b940 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -228,13 +228,14 @@ type IntroductionMessage struct { Mirror uint32 // Port is the port that this client is listening on Port uint16 - // Our client version + // Protocol version Version int32 c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() valid bool `enc:"-"` // skip it during encoding - // Pubkey is the blockchain pubkey - Pubkey []byte `enc:",omitempty"` + // Extra is extra bytes added to the struct to accomodate multiple version of this packet. + // Currently it contains the blockchain pubkey but will accept a client that does not provide it. + Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message @@ -243,7 +244,7 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey [] Mirror: mirror, Version: version, Port: port, - Pubkey: pubkey, + Extra: pubkey, } } @@ -263,14 +264,14 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return ErrDisconnectSelf } - // Disconnect if not running the same version - if intro.Version != d.DaemonConfig().Version { - logger.Infof("%s has different version %d. Disconnecting.", - mc.Addr, intro.Version) - if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidVersion); err != nil { + // Disconnect if peer version is not within the supported range + dc := d.DaemonConfig() + if intro.Version < dc.MinProtocolVersion { + logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.Version, dc.MinProtocolVersion) + if err := d.Disconnect(mc.Addr, ErrDisconnectVersionBelowMin); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } - return ErrDisconnectInvalidVersion + return ErrDisconnectVersionNotSupported } logger.Infof("%s verified for version %d", mc.Addr, intro.Version) diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index cece758c85..f51c2cd3ee 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -181,17 +181,17 @@ func TestIntroductionMessage(t *testing.T) { err: ErrDisconnectSelf, }, { - name: "Invalid version", + name: "Version below minimum supported version", mockValue: daemonMockValue{ mirror: 10000, version: 1, - disconnectReason: ErrDisconnectInvalidVersion, + disconnectReason: ErrDisconnectVersionNotSupported, }, intro: &IntroductionMessage{ Mirror: 10001, Version: 0, }, - err: ErrDisconnectInvalidVersion, + err: ErrDisconnectVersionNotSupported, }, { name: "Invalid address", From 07f9f2c8ed7acbf28096210c10c408841bfe3e31 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 13 Oct 2018 13:38:46 -0400 Subject: [PATCH 258/399] [lib] refs #1191 - Document context parameter of callback functions. Remove unused C functions ... copyUxArraytoSlice, toGoString --- include/skytest.h | 39 ++++++++++++++++------- lib/cgo/README.md | 26 +++++++++------ lib/cgo/tests/testutils/libsky_testutil.c | 17 ---------- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/include/skytest.h b/include/skytest.h index 6bfeda6e70..25faccab23 100644 --- a/include/skytest.h +++ b/include/skytest.h @@ -7,13 +7,19 @@ #ifndef LIBSKY_TESTING_H #define LIBSKY_TESTING_H -void * registerMemCleanup(void *p); +/*---------------------------------------------------------------------- + * I/O + *---------------------------------------------------------------------- + */ void fprintbuff(FILE *f, void *buff, size_t n); -json_value* json_get_string(json_value* value, const char* key); +/*---------------------------------------------------------------------- + * Memory handling + *---------------------------------------------------------------------- + */ -int json_set_string(json_value* value, const char* new_string_value); +void * registerMemCleanup(void *p); int registerJsonFree(void *p); @@ -32,8 +38,23 @@ void cleanRegisteredWallet( Client__Handle client, WalletResponse__Handle wallet); +int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size); + +int cutSlice(GoSlice_* slice, int start, int end, int elem_size, GoSlice_* result); + +int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* result); + +/*---------------------------------------------------------------------- + * JSON helpers + *---------------------------------------------------------------------- + */ + json_value* loadJsonFile(const char* filename); +json_value* json_get_string(json_value* value, const char* key); + +int json_set_string(json_value* value, const char* new_string_value); + int compareJsonValues(json_value* value1, json_value* value2); json_value* get_json_value(json_value* node, const char* path, @@ -46,16 +67,12 @@ int compareJsonValuesWithIgnoreList(json_value* value1, json_value* value2, cons int parseBoolean(const char* str, int length); -int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size); - -int cutSlice(GoSlice_* slice, int start, int end, int elem_size, GoSlice_* result); - -int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* result); +/*---------------------------------------------------------------------- + * Test infrastructure + *---------------------------------------------------------------------- + */ void setup(void); void teardown(void); -extern void toGoString(GoString_ *s, GoString *r); -extern int copyUxArraytoSlice(coin__UxArray* pdest, GoSlice* psource); - #endif diff --git a/lib/cgo/README.md b/lib/cgo/README.md index d0843ab789..90c4fd507a 100644 --- a/lib/cgo/README.md +++ b/lib/cgo/README.md @@ -63,6 +63,23 @@ equivalent C types are defined for each Skycoin core struct that might be needed by developers. The result of this translation is available in [skytpes.h](../../include/skytypes.h). +#### Instances of `time.Time` + +Instances of `time.Time` will be formatted as RFC3339 strings before crossing API boundaries. + +#### Interface types + +At present there is limited support for functions with arguments +of interface types or collections of such types. + +#### Callback functions + +Given the fact that most widely used C language toolchains have no support for +function closures, signatures of API functions with callback parameters differ +from the originals in that they include an additional `void *` parameter +callers can use to supply context information. The very same pointer is passed +in to the callback function itself in a similar manner. + ### Memory management Caller is responsible for allocating memory for objects meant to be @@ -99,15 +116,6 @@ invocation. The caller will be responsible for [reallocating another memory buffer](http://en.cppreference.com/w/c/memory/realloc) using a higher `cap` and retry. -### Instances of `time.Time` - -Instances of `time.Time` will be formatted as RFC3339 strings before crossing API boundaries. - -### Interface types - -At the moment there is limited support for functions with arguments -of interface types or collections of these types. - ## Generating documentation Follow these steps to generate API documentation. diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index 728888d064..96f642b3f3 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -265,12 +265,6 @@ int parseBoolean(const char* str, int length){ return result; } -void toGoString(GoString_ *s, GoString *r){ -GoString * tmp = r; - - *tmp = (*(GoString *) s); -} - int copySlice(GoSlice_* pdest, GoSlice_* psource, int elem_size){ pdest->len = psource->len; pdest->cap = psource->len; @@ -396,14 +390,3 @@ int getCountWord(const char *str) { return len; }*/ -int copyUxArraytoSlice(coin__UxArray* pdest, GoSlice* psource){ - pdest->len = psource->len; - pdest->cap = psource->len; - int size = pdest->len * sizeof(coin__UxArray); - pdest->data = malloc(size); - if( pdest->data == NULL ) - return SKY_ERROR; - registerMemCleanup( pdest->data ); - memcpy(pdest->data, psource->data, size ); - return SKY_OK; -} From 891f962e84a70fb13fd34e5b3dca044e774b93a1 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 13 Oct 2018 14:05:05 -0400 Subject: [PATCH 259/399] [lib] refs #1191 - Remove SKY_wallet_CreateAddresses [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- lib/cgo/wallet.addresses.go | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 lib/cgo/wallet.addresses.go diff --git a/lib/cgo/wallet.addresses.go b/lib/cgo/wallet.addresses.go deleted file mode 100644 index e6c5fba8ee..0000000000 --- a/lib/cgo/wallet.addresses.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( -// wallet "github.com/skycoin/skycoin/src/wallet" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -// FIXME: Removed from src/ . What's the way to do it now? -/* -//export SKY_wallet_CreateAddresses -func SKY_wallet_CreateAddresses(_coinType string, _seed string, _genCount int, _hideSecretKey bool, _arg4 *C.ReadableWallet__Handle) (____error_code uint32) { - coinType := _coinType - seed := _seed - genCount := _genCount - hideSecretKey := _hideSecretKey - __arg4, ____return_err := wallet.CreateAddresses(wallet.CoinType(coinType), seed, genCount, hideSecretKey) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - *_arg4 = registerReadableWalletHandle(__arg4) - } - return -} -*/ From 7aab123e2f141d97dc28b8ff39ad262ef894f454 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sat, 13 Oct 2018 18:16:57 +0000 Subject: [PATCH 260/399] [lib] refs #1191 - Silence C compile time warnings [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- lib/cgo/tests/testutils/libsky_criterion.c | 1 + lib/cgo/tests/testutils/libsky_testutil.c | 72 ---------------------- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index cd802fea90..c7d7b414df 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -104,6 +104,7 @@ char *cr_user_cipher__Ripemd160_tostr(cipher__Ripemd160 *rp1) strnhex((unsigned char *)rp1, hexdump, sizeof(cipher__Ripemd160)); cr_asprintf(&out, "(cipher__Ripemd160) { %s }", hexdump); + return out; } int cr_user_cipher__SHA256_noteq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index 96f642b3f3..437c088818 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -318,75 +318,3 @@ int concatSlices(GoSlice_* slice1, GoSlice_* slice2, int elem_size, GoSlice_* re return SKY_OK; } -/* -json_value *loadGoldenFile_Cli(const char *file) { - char path[STRING_SIZE]; - if (strlen(TEST_DATA_DIR) + strlen(file) < STRING_SIZE) { - strcpy(path, TEST_DATA_DIR); - strcat(path, file); - return loadJsonFile(path); - } - return NULL; -} - -void createTempWalletDir(bool encrypt) { - const char *temp = "build/libskycoin/wallet-data-dir"; - - int valueMkdir = mkdir(temp, S_IRWXU); - - if (valueMkdir == -1) { - int errr = system("rm -r build/libskycoin/wallet-data-dir/*.*"); - } - - // Copy the testdata/$stableWalletName to the temporary dir. - char walletPath[JSON_BIG_FILE_SIZE]; - if (encrypt) { - strcpy(walletPath, stableEncryptWalletName); - } else { - strcpy(walletPath, stableWalletName); - } - unsigned char pathnameURL[BUFFER_SIZE]; - strcpy(pathnameURL, temp); - strcat(pathnameURL, "/"); - strcat(pathnameURL, walletPath); - - FILE *rf; - FILE *f; - f = fopen(pathnameURL, "wb"); - unsigned char fullUrl[BUFFER_SIZE]; - strcpy(fullUrl, TEST_DATA_DIR); - strcat(fullUrl, walletPath); - rf = fopen(fullUrl, "rb"); - unsigned char buff[2048]; - int readBits; - // Copy file rf to f - if (f && rf) { - while ((readBits = fread(buff, 1, 2048, rf))) - fwrite(buff, 1, readBits, f); - - fclose(rf); - fclose(f); - - GoString WalletDir = {"WALLET_DIR", 10}; - GoString Dir = {temp, strlen(temp)}; - SKY_cli_Setenv(WalletDir, Dir); - GoString WalletPath = {"WALLET_NAME", 11}; - GoString pathname = {walletPath, strlen(walletPath)}; - SKY_cli_Setenv(WalletPath, pathname); - } - strcpy(walletPath, ""); -}; - - -int getCountWord(const char *str) { - int len = 0; - do { - str = strpbrk(str, " "); // find separator - if (str) - str += strspn(str, " "); // skip separator - ++len; // increment word count - } while (str && *str); - - return len; -}*/ - From f793666511daefae62dacc8b84049bf9ea202d70 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sat, 13 Oct 2018 19:10:09 +0000 Subject: [PATCH 261/399] [lib] refs #1191 - Do not export cipher.encrypt.sha256xor in C API See https://github.com/skycoin/skycoin/pull/1639#pullrequestreview-164458710 [====] Synthesis: Tested: 136 | Passing: 136 | Failing: 0 | Crashing: 0 --- lib/cgo/README.md | 4 + lib/cgo/cipher.encrypt.sha256xor.go | 43 --- .../tests/check_cipher.encrypt.sha256xor.c | 302 ------------------ 3 files changed, 4 insertions(+), 345 deletions(-) delete mode 100644 lib/cgo/cipher.encrypt.sha256xor.go delete mode 100644 lib/cgo/tests/check_cipher.encrypt.sha256xor.c diff --git a/lib/cgo/README.md b/lib/cgo/README.md index 90c4fd507a..4e2ed9c6bd 100644 --- a/lib/cgo/README.md +++ b/lib/cgo/README.md @@ -56,6 +56,10 @@ classes and objects. This makes it suitable for writing third-party applications and integrations. The notable differences between go lang and C languages have consequences for the consumers of the API. +The following subsets of the golang API are not available in the C client library: + +- `cipher.encrypt.sha256xor` + ### Data types Skycoin core objects may not be passed across API boundaries. Therefore diff --git a/lib/cgo/cipher.encrypt.sha256xor.go b/lib/cgo/cipher.encrypt.sha256xor.go deleted file mode 100644 index 27e8bf48e7..0000000000 --- a/lib/cgo/cipher.encrypt.sha256xor.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - encrypt "github.com/skycoin/skycoin/src/cipher/encrypt" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_encrypt_Sha256Xor_Encrypt -func SKY_encrypt_Sha256Xor_Encrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - s := encrypt.Sha256Xor{} - data := *(*[]byte)(unsafe.Pointer(&_data)) - password := *(*[]byte)(unsafe.Pointer(&_password)) - __arg2, ____return_err := s.Encrypt(data, password) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - } - return -} - -//export SKY_encrypt_Sha256Xor_Decrypt -func SKY_encrypt_Sha256Xor_Decrypt(_data []byte, _password []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - s := encrypt.Sha256Xor{} - data := *(*[]byte)(unsafe.Pointer(&_data)) - password := *(*[]byte)(unsafe.Pointer(&_password)) - __arg2, ____return_err := s.Decrypt(data, password) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - } - return -} diff --git a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c b/lib/cgo/tests/check_cipher.encrypt.sha256xor.c deleted file mode 100644 index b13c9f7825..0000000000 --- a/lib/cgo/tests/check_cipher.encrypt.sha256xor.c +++ /dev/null @@ -1,302 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "base64.h" - -#define BUFFER_SIZE 1024 -#define PASSWORD1 "pwd" -#define PASSWORD2 "key" -#define PASSWORD3 "9JMkCPphe73NQvGhmab" -#define WRONGPASSWORD "wrongpassword" -#define SHA256XORDATALENGTHSIZE 4 -#define SHA256XORBLOCKSIZE 32 -#define SHA256XORCHECKSUMSIZE 32 -#define SHA256XORNONCESIZE 32 - -TestSuite(cipher_encrypt_sha256xor, .init = setup, .fini = teardown); - -typedef struct{ - int dataLength; - GoSlice* pwd; - GoSlice* decryptPwd; - int success; - int tampered; -} TEST_DATA; - -int putUvarint(GoSlice* buf , GoUint64 x){ - int i = 0; - while( x >= 0x80 && i < buf->cap) { - ((unsigned char*)buf->data)[i] = ((GoUint8)x) | 0x80; - x >>= 7; - i++; - } - if( i < buf->cap ){ - ((unsigned char*)buf->data)[i] = (GoUint8)(x); - buf->len = i + 1; - } else { - buf->len = i; - } - return buf->len; -} - -int putVarint(GoSlice* buf , GoInt64 x){ - GoUint64 ux = (GoUint64)x << 1; - if ( x < 0 ) { - ux = ~ux; - } - return putUvarint(buf, ux); -} - -void hashKeyIndexNonce(GoSlice_ key, GoInt64 index, - cipher__SHA256 *nonceHash, cipher__SHA256 *resultHash){ - GoUint32 errcode; - int length = 32 + sizeof(cipher__SHA256); - unsigned char buff[length]; - GoSlice slice = {buff, 0, length}; - memset(buff, 0, length * sizeof(char)); - putVarint( &slice, index ); - memcpy(buff + 32, *nonceHash, sizeof(cipher__SHA256)); - slice.len = length; - cipher__SHA256 indexNonceHash; - errcode = SKY_cipher_SumSHA256(slice, &indexNonceHash); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); - SKY_cipher_AddSHA256(key.data, &indexNonceHash, resultHash); - cr_assert(errcode == SKY_OK, "SKY_cipher_AddSHA256 failed. Error adding hashes"); -} - -void makeEncryptedData(GoSlice data, GoUint32 dataLength, GoSlice pwd, coin__UxArray* encrypted){ - GoUint32 fullLength = dataLength + SHA256XORDATALENGTHSIZE; - GoUint32 n = fullLength / SHA256XORBLOCKSIZE; - GoUint32 m = fullLength % SHA256XORBLOCKSIZE; - GoUint32 errcode; - - if( m > 0 ){ - fullLength += SHA256XORBLOCKSIZE - m; - } - cr_assert(SHA256XORBLOCKSIZE == sizeof(cipher__SHA256), "Size of SHA256 block size different that cipher.SHA256 struct"); - fullLength += SHA256XORBLOCKSIZE; - char* buffer = malloc(fullLength); - cr_assert(buffer != NULL, "Couldn\'t allocate buffer"); - //Add data length to the beginning, saving space for the checksum - for(int i = 0; i < SHA256XORDATALENGTHSIZE; i++){ - int shift = i * 8; - buffer[i + SHA256XORBLOCKSIZE] = (dataLength & (0xFF << shift)) >> shift; - } - //Add the data - memcpy(buffer + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE, - data.data, dataLength); - //Add padding - for(int i = dataLength + SHA256XORDATALENGTHSIZE + SHA256XORBLOCKSIZE; i < fullLength; i++){ - buffer[i] = 0; - } - //Buffer with space for the checksum, then data length, then data, and then padding - GoSlice _data = {buffer + SHA256XORBLOCKSIZE, - fullLength - SHA256XORBLOCKSIZE, - fullLength - SHA256XORBLOCKSIZE}; - //GoSlice _hash = {buffer, 0, SHA256XORBLOCKSIZE}; - errcode = SKY_cipher_SumSHA256(_data, (cipher__SHA256*)buffer); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash"); - char bufferNonce[SHA256XORNONCESIZE]; - GoSlice sliceNonce = {bufferNonce, 0, SHA256XORNONCESIZE}; - randBytes(&sliceNonce, SHA256XORNONCESIZE); - cipher__SHA256 hashNonce; - errcode = SKY_cipher_SumSHA256(sliceNonce, &hashNonce); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating hash for nonce"); - char bufferHash[BUFFER_SIZE]; - coin__UxArray hashPassword = {bufferHash, 0, BUFFER_SIZE}; - errcode = SKY_secp256k1_Secp256k1Hash(pwd, &hashPassword); - cr_assert(errcode == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed. Error calculating hash for password"); - cipher__SHA256 h; - - - int fullDestLength = fullLength + sizeof(cipher__SHA256) + SHA256XORNONCESIZE; - int destBufferStart = sizeof(cipher__SHA256) + SHA256XORNONCESIZE; - unsigned char* dest_buffer = malloc(fullDestLength); - cr_assert(dest_buffer != NULL, "Couldn\'t allocate result buffer"); - for(int i = 0; i < n; i++){ - hashKeyIndexNonce(hashPassword, i, &hashNonce, &h); - cipher__SHA256* pBuffer = (cipher__SHA256*)(buffer + i *SHA256XORBLOCKSIZE); - cipher__SHA256* xorResult = (cipher__SHA256*)(dest_buffer + destBufferStart + i *SHA256XORBLOCKSIZE); - SKY_cipher_SHA256_Xor(pBuffer, &h, xorResult); - } - // Prefix the nonce - memcpy(dest_buffer + sizeof(cipher__SHA256), bufferNonce, SHA256XORNONCESIZE); - // Calculates the checksum - GoSlice nonceAndDataBytes = {dest_buffer + sizeof(cipher__SHA256), - fullLength + SHA256XORNONCESIZE, - fullLength + SHA256XORNONCESIZE - }; - cipher__SHA256* checksum = (cipher__SHA256*)dest_buffer; - errcode = SKY_cipher_SumSHA256(nonceAndDataBytes, checksum); - cr_assert(errcode == SKY_OK, "SKY_cipher_SumSHA256 failed. Error calculating final checksum"); - unsigned char bufferb64[BUFFER_SIZE]; - unsigned int size = b64_encode((const unsigned char*)dest_buffer, fullDestLength, encrypted->data); - encrypted->len = size; -} - -Test(cipher_encrypt_sha256xor, TestEncrypt){ - unsigned char buff[BUFFER_SIZE]; - unsigned char encryptedBuffer[BUFFER_SIZE]; - unsigned char encryptedText[BUFFER_SIZE]; - GoSlice data = { buff, 0, BUFFER_SIZE }; - coin__UxArray encrypted = { encryptedBuffer, 0, BUFFER_SIZE }; - GoSlice pwd1 = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; - GoSlice pwd2 = { PASSWORD2, strlen(PASSWORD2), strlen(PASSWORD2) }; - GoSlice pwd3 = { PASSWORD3, strlen(PASSWORD3), strlen(PASSWORD3) }; - GoSlice nullPwd = {NULL, 0, 0}; - GoUint32 errcode; - - TEST_DATA test_data[] = { - {1, &nullPwd, &nullPwd, 0, 0}, - {1, &pwd2, &nullPwd, 1, 0}, - {2, &pwd1, &nullPwd, 1, 0}, - {32, &pwd1, &nullPwd, 1, 0}, - {64, &pwd3, &nullPwd, 1, 0}, - {65, &pwd3, &nullPwd, 1, 0}, - }; - - for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ - randBytes(&data, test_data[i].dataLength); - errcode = SKY_encrypt_Sha256Xor_Encrypt(data, *(test_data[i].pwd), &encrypted); - if( test_data[i].success ){ - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); - } else { - cr_assert(errcode == SKY_ErrSHA256orMissingPassword, "SKY_encrypt_Sha256Xor_Encrypt with null pwd."); - } - if( errcode == SKY_OK ){ - cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); - cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); - ((char*)encrypted.data)[encrypted.len] = 0; - - int n = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) / SHA256XORBLOCKSIZE; - int m = (SHA256XORDATALENGTHSIZE + test_data[i].dataLength) % SHA256XORBLOCKSIZE; - if ( m > 0 ) { - n++; - } - - int decode_length = b64_decode((const unsigned char*)encrypted.data, - encrypted.len, encryptedText); - cr_assert(decode_length >= 0, "base64_decode_string failed."); - int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - - cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); - cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); - cipher__SHA256 enc_hash; - cipher__SHA256 cal_hash; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - enc_hash[j] = (GoUint8_)encryptedText[j]; - } - int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; - GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; - SKY_cipher_SumSHA256(slice, &cal_hash); - int equal = 1; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - if(enc_hash[j] != cal_hash[j]){ - equal = 0; - break; - } - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); - } - } - - for(int i = 33; i <= 64; i++){ - randBytes(&data, i); - errcode = SKY_encrypt_Sha256Xor_Encrypt(data, pwd1, &encrypted); - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Encrypt failed."); - cr_assert(encrypted.cap > 0, "Buffer for encrypted data is too short"); - cr_assert(encrypted.len < BUFFER_SIZE, "Too large encrypted data"); - ((char*)encrypted.data)[encrypted.len] = 0; - - int n = (SHA256XORDATALENGTHSIZE + i) / SHA256XORBLOCKSIZE; - int m = (SHA256XORDATALENGTHSIZE + i) % SHA256XORBLOCKSIZE; - if ( m > 0 ) { - n++; - } - - int decode_length = b64_decode((const unsigned char*)encrypted.data, - encrypted.len, encryptedText); - cr_assert( decode_length >= 0, "base64_decode failed" ); - int totalEncryptedDataLen = SHA256XORCHECKSUMSIZE + SHA256XORNONCESIZE + 32 + n*SHA256XORBLOCKSIZE; // 32 is the hash data length - - cr_assert(totalEncryptedDataLen == decode_length, "SKY_encrypt_Sha256Xor_Encrypt failed, encrypted data length incorrect."); - cr_assert(SHA256XORCHECKSUMSIZE == sizeof(cipher__SHA256), "Size of SHA256 struct different than size in constant declaration"); - cipher__SHA256 enc_hash; - cipher__SHA256 cal_hash; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - enc_hash[j] = (GoUint8_)encryptedText[j]; - } - int len_minus_checksum = decode_length - SHA256XORCHECKSUMSIZE; - GoSlice slice = {&encryptedText[SHA256XORCHECKSUMSIZE], len_minus_checksum, len_minus_checksum}; - SKY_cipher_SumSHA256(slice, &cal_hash); - int equal = 1; - for(int j = 0; j < SHA256XORCHECKSUMSIZE; j++){ - if(enc_hash[j] != cal_hash[j]){ - equal = 0; - break; - } - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Encrypt failed, incorrect hash sum."); - - } -} - -Test(cipher_encrypt_sha256xor, TestDecrypt){ - unsigned char buff[BUFFER_SIZE]; - unsigned char encrypted_buffer[BUFFER_SIZE]; - unsigned char decrypted_buffer[BUFFER_SIZE]; - GoSlice data = {buff, 0, BUFFER_SIZE}; - GoSlice pwd = { PASSWORD1, strlen(PASSWORD1), strlen(PASSWORD1) }; - GoSlice wrong_pwd = { WRONGPASSWORD, strlen(WRONGPASSWORD), strlen(WRONGPASSWORD) }; - coin__UxArray encrypted = {encrypted_buffer, 0, BUFFER_SIZE}; - coin__UxArray decrypted = {decrypted_buffer, 0, BUFFER_SIZE}; - GoSlice emptyPwd = {"", 1, 1}; - GoSlice nullPwd = {NULL, 0, 0}; - GoUint32 errcode; - - TEST_DATA test_data[] = { - {32, &pwd, &pwd, 0, 1}, //Data tampered to verify invalid checksum - {32, &pwd, &emptyPwd, 0, 0}, //Empty password - {32, &pwd, &nullPwd, 0, 0}, //Null password - {32, &pwd, &wrong_pwd, 0, 0}, //Wrong password - }; - for(int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++){ - randBytes(&data, 32); - makeEncryptedData(data, test_data[i].dataLength, *test_data[i].pwd, &encrypted); - //SKY_encrypt_Sha256Xor_Encrypt(&encryptSettings, data, pwd, &encrypted); - cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - if( test_data[i].tampered ){ - ((unsigned char*)(encrypted.data))[ encrypted.len - 1 ]++; - } - errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, *test_data[i].decryptPwd, &decrypted); - if( test_data[i].success ){ - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); - } else { - cr_assert(errcode != SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt with invalid parameters successful. %x\n",errcode); - } - } - - for(int i = 0; i <= 64; i++){ - randBytes(&data, i); - //makeEncryptedData(data, i, pwd, &encrypted); - SKY_encrypt_Sha256Xor_Encrypt(data, pwd, &encrypted); - cr_assert(encrypted.len > 0, "SKY_encrypt_Sha256Xor_Encrypt failed. Empty encrypted data"); - errcode = SKY_encrypt_Sha256Xor_Decrypt(*(GoSlice*)&encrypted, pwd, &decrypted); - cr_assert(errcode == SKY_OK, "SKY_encrypt_Sha256Xor_Decrypt failed."); - cr_assert(data.len == decrypted.len, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data length different than original data length"); - int equal = 1; - for(int j = 0; j < data.len; j++){ - if( ((unsigned char*)data.data)[j] != ((unsigned char*)decrypted.data)[j] ) - equal = 0; - } - cr_assert(equal == 1, "SKY_encrypt_Sha256Xor_Decrypt failed. Decrypted data different than original data"); - } -} From f12c0110fcbcf7de524a87159f3e8912e6cedbff Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sat, 13 Oct 2018 20:24:47 +0000 Subject: [PATCH 262/399] [lib] refs #1191 - Revert changes in secp256k1-go cipher lib [====] Synthesis: Tested: 136 | Passing: 136 | Failing: 0 | Crashing: 0 --- lib/cgo/libsky_error.go | 5 ----- src/cipher/secp256k1-go/secp256k1-go2/ec.go | 8 +------ src/cipher/secp256k1-go/secp256k1.go | 24 +++++++-------------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index bea289fd1d..34d694d3eb 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -7,7 +7,6 @@ import ( "github.com/skycoin/skycoin/src/cipher/base58" "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/cipher/encrypt" - "github.com/skycoin/skycoin/src/cipher/secp256k1-go" "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" @@ -595,10 +594,6 @@ var ( wallet.ErrWalletParamsConflict: SKY_ErrWalletParamsConflict, wallet.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts, wallet.ErrUnknownWalletID: SKY_ErrUnknownWalletID, - - secp256k1.ErrVerifySignatureInvalidInputsNils: SKY_ErrVerifySignatureInvalidInputsNils, - secp256k1.ErrVerifySignatureInvalidSigLength: SKY_ErrVerifySignatureInvalidSigLength, - secp256k1.ErrVerifySignatureInvalidPubkeysLength: SKY_ErrVerifySignatureInvalidPubkeysLength, } ) diff --git a/src/cipher/secp256k1-go/secp256k1-go2/ec.go b/src/cipher/secp256k1-go/secp256k1-go2/ec.go index a38aff0b4c..04b3efc53c 100644 --- a/src/cipher/secp256k1-go/secp256k1-go2/ec.go +++ b/src/cipher/secp256k1-go/secp256k1-go2/ec.go @@ -3,15 +3,9 @@ package secp256k1go import ( //"encoding/hex" "bytes" - "errors" "log" ) -// Error definition -var ( - ErrMustPass64bytePubKey = errors.New("must pass in 64 byte pubkey") -) - // func ecdsaVerify(pubkey, sig, msg []byte) int { // var m Number // var s Signature @@ -119,7 +113,7 @@ func RecoverPublicKey(sigByte []byte, h []byte, recid int) ([]byte, int) { var pubkey XY if len(sigByte) != 64 { - log.Panic(ErrMustPass64bytePubKey) + log.Panic("must pass in 64 byte pubkey") } var sig Signature diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index a4299109ed..dc4e45d1f5 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -7,28 +7,17 @@ package secp256k1 import ( "bytes" "encoding/hex" - "errors" "log" secp "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) -var ( - ErrVerifySignatureInvalidInputsNils = errors.New("VerifySignature, ERROR: invalid input, nils") - ErrVerifySignatureInvalidSigLength = errors.New("VerifySignature, invalid signature length") - ErrVerifySignatureInvalidPubkeysLength = errors.New("VerifySignature, invalid pubkey length") - ErrSignInvalidSeckeyLength = errors.New("Sign, Invalid seckey length") - ErrSignInvalidSeckey = errors.New("Attempting to sign with invalid seckey") - ErrSignMessageNil = errors.New("Sign, message nil") - ErrSecp25k1SignSignatureFailed = errors.New("Secp25k1-go, Sign, signature operation failed") - ErrSecp256k1InvalidLengthPubKey = errors.New("pubkey length wrong") -) - //intenal, may fail //may return nil func pubkeyFromSeckey(seckey []byte) []byte { if len(seckey) != 32 { log.Panic("seckey length invalid") + return nil } if secp.SeckeyIsValid(seckey) != 1 { @@ -236,13 +225,13 @@ func DeterministicKeyPairIterator(seedIn []byte) ([]byte, []byte, []byte) { // Sign sign hash func Sign(msg []byte, seckey []byte) []byte { if len(seckey) != 32 { - log.Panic(ErrSignInvalidSeckeyLength) + log.Panic("Sign, Invalid seckey length") } if secp.SeckeyIsValid(seckey) != 1 { - log.Panic(ErrSignInvalidSeckey) + log.Panic("Attempting to sign with invalid seckey") } if len(msg) == 0 { - log.Panic(ErrSignMessageNil) + log.Panic("Sign, message nil") } var nonce = RandByte(32) var sig = make([]byte, 65) @@ -261,7 +250,7 @@ func Sign(msg []byte, seckey []byte) []byte { ret := cSig.Sign(&seckey1, &msg1, &nonce1, &recid) if ret != 1 { - log.Panic(ErrSecp25k1SignSignatureFailed) + log.Panic("Secp25k1-go, Sign, signature operation failed") } sigBytes := cSig.Bytes() @@ -480,6 +469,7 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { log.Printf("RecoverPubkey: code %d", ret) return nil } + //var pubkey2 []byte = pubkey1.Bytes() //compressed if pubkey == nil { log.Panic("ERROR: impossible, pubkey nil and ret ==1") @@ -487,7 +477,9 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { if len(pubkey) != 33 { log.Panic("pubkey length wrong") } + return pubkey + //nonce1.SetBytes(nonce_seed) } From 17977c1fccebf519ed560eedd6b9cf267dc9ee4f Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sat, 13 Oct 2018 16:29:45 -0400 Subject: [PATCH 263/399] [lib] refs #1191 - Change position of return nil in secp256k1 cipher lib [====] Synthesis: Tested: 136 | Passing: 136 | Failing: 0 | Crashing: 0 --- src/cipher/secp256k1-go/secp256k1.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index dc4e45d1f5..9aa4634909 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -17,11 +17,11 @@ import ( func pubkeyFromSeckey(seckey []byte) []byte { if len(seckey) != 32 { log.Panic("seckey length invalid") - return nil } if secp.SeckeyIsValid(seckey) != 1 { log.Panic("always ensure seckey is valid") + return nil } var pubkey = secp.GeneratePublicKey(seckey) //always returns true From 997c61909b15764acd68deceb21958f3cf098cb7 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 13 Oct 2018 18:59:36 -0400 Subject: [PATCH 264/399] [daemon] refs #735 - Log errors sending GIVP + RJCT . Fix hex dum example test --- src/daemon/messages.go | 9 ++++++-- src/daemon/messages_example_test.go | 27 +++++++++++++++++++++++ src/daemon/messages_test.go | 34 +++++------------------------ 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 8a49084ebe..7fb5b0a337 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -366,9 +366,14 @@ func (intro *IntroductionMessage) Process(d Daemoner) { if intro.validationError == pex.ErrPeerlistFull { peers := d.RandomExchangeable(d.PexConfig().ReplyCount) givpMsg := NewGivePeersMessage(peers) - d.SendMessage(intro.c.Addr, givpMsg) + if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { + logger.Errorf("Send GivePeersMessage to %s failed: %v", intro.c.Addr, err) + } rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") - d.SendMessage(intro.c.Addr, rjctMsg) + if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { + logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) + } + } return } diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 274de6d175..aa9e0635dc 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -757,3 +757,30 @@ func ExampleAnnounceTxnsMessage() { // 0x003c | 5c bf 72 f9 8c c6 a6 2c 72 97 23 cb c0 75 0d 3b ... Transactions[1] // 0x004c | } + +func ExampleRejectMessage() { + defer gnet.EraseMessages() + setupMsgEncoding() + + rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, []byte{}) + message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") + fmt.Println("RejectWithPeersMessage:") + var mai = NewMessagesAnnotationsIterator(message) + w := bufio.NewWriter(os.Stdout) + err := NewFromIterator(gnet.EncodeMessage(message), &mai, w) + if err != nil { + fmt.Println(err) + } + // Output: + // RejectWithPeersMessage: + // 0x0000 | 31 00 00 00 ....................................... Length + // 0x0004 | 52 4a 43 54 ....................................... Prefix + // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix + // 0x000c | 0c 00 00 00 ....................................... ErrorCode + // 0x0010 | 1d 00 00 00 45 78 61 6d 70 6c 65 52 65 6a 65 63 + // 0x0020 | 74 57 69 74 68 50 65 65 72 73 4d 65 73 73 61 67 + // 0x0030 | 65 ................................................ Reason + // 0x0031 | 00 00 00 00 ....................................... Reserved length + // 0x0035 | + +} diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index e9f21d3486..f216505097 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -83,7 +83,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Pubkey: pubkey[:], + Pubkey: pubkey[:], }, err: nil, }, @@ -103,7 +103,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Pubkey: pubkey[:], + Pubkey: pubkey[:], }, err: nil, }, @@ -123,7 +123,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Pubkey: append(pubkey[:], []byte("additional data")...), + Pubkey: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -144,7 +144,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Pubkey: pubkey2[:], + Pubkey: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -165,7 +165,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Pubkey: []byte("invalid extra data"), + Pubkey: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, @@ -281,30 +281,6 @@ func TestIntroductionMessage(t *testing.T) { } } -} - -func ExampleRejectMessage() { - defer gnet.EraseMessages() - setupMsgEncoding() - - rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, []byte{}) - message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") - fmt.Println("RejectWithPeersMessage:") - var mai = NewMessagesAnnotationsIterator(message) - w := bufio.NewWriter(os.Stdout) - util.HexDumpFromIterator(gnet.EncodeMessage(message), &mai, w) - // Output: - // RejectWithPeersMessage: - // 0x0000 | 31 00 00 00 ....................................... Length - // 0x0004 | 52 4a 43 54 ....................................... Prefix - // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix - // 0x000c | 0c 00 00 00 ....................................... ErrorCode - // 0x0010 | 1d 00 00 00 45 78 61 6d 70 6c 65 52 65 6a 65 63 - // 0x0020 | 74 57 69 74 68 50 65 65 72 73 4d 65 73 73 61 67 - // 0x0030 | 65 ................................................ Reason - // 0x0031 | 00 00 00 00 ....................................... Reserved length - // 0x0035 | - func TestMessageEncodeDecode(t *testing.T) { update := false From c34ad9490cac8e49681db53f0408a7503fe62f1a Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Sun, 14 Oct 2018 12:53:45 -0400 Subject: [PATCH 265/399] Fix the initial state of the Selects on Safari --- .../send-form-advanced/send-form-advanced.component.html | 1 + .../pages/send-skycoin/send-form/send-form.component.html | 1 + src/gui/static/src/assets/i18n/en.json | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/static/src/app/components/pages/send-skycoin/send-form-advanced/send-form-advanced.component.html b/src/gui/static/src/app/components/pages/send-skycoin/send-form-advanced/send-form-advanced.component.html index 775fd64d32..7ec7ecb5f8 100644 --- a/src/gui/static/src/app/components/pages/send-skycoin/send-form-advanced/send-form-advanced.component.html +++ b/src/gui/static/src/app/components/pages/send-skycoin/send-form-advanced/send-form-advanced.component.html @@ -3,6 +3,7 @@
+ diff --git a/src/gui/static/src/assets/i18n/en.json b/src/gui/static/src/assets/i18n/en.json index a6473fb6e0..6cebcc2897 100644 --- a/src/gui/static/src/assets/i18n/en.json +++ b/src/gui/static/src/assets/i18n/en.json @@ -169,7 +169,8 @@ "send-button": "Send", "back-button": "Back", "simple": "Simple", - "advanced": "Advanced" + "advanced": "Advanced", + "select-wallet": "Select Wallet" }, "reset": { From a03ce0c29abd2013e22229f767f55e332c0b8726 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 14 Oct 2018 19:25:50 -0400 Subject: [PATCH 266/399] [daemon] refs #735 - Proper disconnection in send results loop after sending RJCT message --- src/daemon/daemon.go | 10 ++++++++++ src/daemon/messages.go | 43 ++++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 57c41f31f5..af70be2e8c 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -1083,6 +1083,16 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { switch r.Message.(type) { case SendingTxnsMessage: dm.announcedTxns.add(r.Message.(SendingTxnsMessage).GetFiltered()) + case DisconnectPeerMessage: + // If message was sent successfully and disconnection follows + // since the other end should eventually disconnect after processing it + // then it's safe at this point to close connection to peer + dpm := r.Message.(DisconnectPeerMessage) + address := dpm.PeerAddress() + reason := dpm.ErrorReason() + if err := dm.Disconnect(address, reason); err != nil { + logger.WithError(reason).WithField("addr", address).Warning("Failed to disconnect peer") + } default: } } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 7fb5b0a337..8842a47e15 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -20,8 +20,10 @@ import ( var ( // Every rejection message prefix must start with "RJCT" prefix rejectPrefix = [...]byte{82, 74, 67, 84} - // ErrAckReject disconnect since peer sent RJCT message - ErrAckReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") + // ErrRecvReject disconnect since peer sent RJCT message + ErrRecvReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") + // ErrSendReject disconnect since RJCT message was sent to peer + ErrSendReject gnet.DisconnectReason = errors.New("Disconnect: Reject message sent to peer") ) // Message represent a packet to be serialized over the network by @@ -367,14 +369,14 @@ func (intro *IntroductionMessage) Process(d Daemoner) { peers := d.RandomExchangeable(d.PexConfig().ReplyCount) givpMsg := NewGivePeersMessage(peers) if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { - logger.Errorf("Send GivePeersMessage to %s failed: %v", intro.c.Addr, err) + logger.WithError(err).WithField("addr", intro.c.Addr).Error("Send GivePeersMessage failed") } - rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") - if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { - logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) - } - } + rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") + if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { + logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) + } + return } // Add the remote peer with their chosen listening port @@ -441,6 +443,14 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err return nil } +// DisconnectPeerMessage sent to peer immediately before disconnection +type DisconnectPeerMessage interface { + // PeerAddress to disconnect + PeerAddress() string + // ErrorReason leading to disconnection + ErrorReason() gnet.DisconnectReason +} + // RejectMessage sent to inform peers of a protocol failure. // Whenever possible the node should send back prior to this // other message including data useful for peer recovery, especially @@ -466,8 +476,9 @@ func NewRejectMessage(msg gnet.Message, err error, reason string) *RejectMessage if !exists { logger.Panicf("Rejecting unknown message type %s", t) } + // Infinite loop. Never reject RJCT message if reflect.DeepEqual(prefix[:], rejectPrefix[:]) { - logger.Panicf("Message type %s (prefix = %s) may not be rejected", t, prefix) + logger.WithField("gnetmsg", prefix).Panicf("Message type %s may not be rejected", t) } return &RejectMessage{ @@ -478,6 +489,16 @@ func NewRejectMessage(msg gnet.Message, err error, reason string) *RejectMessage } } +// PeerAddress extracted from message context +func (rpm *RejectMessage) PeerAddress() string { + return rpm.c.Addr +} + +// Reason disconnect peer after sending RejectMessage +func (rpm *RejectMessage) ErrorReason() gnet.DisconnectReason { + return ErrSendReject +} + // Handle an event queued by Handle() func (rpm *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { rpm.c = mc @@ -486,7 +507,9 @@ func (rpm *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) er // Process Recover from message rejection state func (rpm *RejectMessage) Process(d Daemoner) { - d.Disconnect(rpm.c.Addr, ErrAckReject) + if err := d.Disconnect(rpm.c.Addr, ErrRecvReject); err != nil { + logger.WithError(err).WithField("addr", rpm.c.Addr).Warning("Failed to disconnect peer") + } } // GetBlocksMessage sent to request blocks since LastBlock From 8c13740167f59f9922459d4e0d23f1dad7a6cf33 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 14 Oct 2018 20:12:23 -0400 Subject: [PATCH 267/399] [daemon] refs #735 - Silence make lint warnings Reported in https://travis-ci.org/skycoin/skycoin/builds/441430678#L1839-L1848 --- src/daemon/messages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 8842a47e15..deca0cbe0f 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -494,7 +494,7 @@ func (rpm *RejectMessage) PeerAddress() string { return rpm.c.Addr } -// Reason disconnect peer after sending RejectMessage +// ErrorReason disconnect peer after sending RejectMessage func (rpm *RejectMessage) ErrorReason() gnet.DisconnectReason { return ErrSendReject } From c8307224ad3dc06af2d5cd2f9ff6d3b28649a75d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 14 Oct 2018 21:45:49 -0400 Subject: [PATCH 268/399] [daemon] refs #735 - Boundary conditions for error object <=> code translation --- src/daemon/errors.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 4d8880f4e5..f80cde5815 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -50,14 +50,21 @@ const Success = 0 // GetError Retrieve error object by corresponding error code func GetError(code uint32) error { - return errorByCode[code] + if code < uint32(len(errorByCode)) { + return errorByCode[code] + } + return nil } // GetErrorCode Retrieve error code representing corresponding error object func GetErrorCode(err error) uint32 { - if initErrorCodeMap != nil { - initErrorCodeMap() - initErrorCodeMap = nil + if code, exists := errorCodeByError[err]; exists { + return code } - return errorCodeByError[err] + return ErrorCodeUnknown +} + +func init() { + initErrorCodeMap() + initErrorCodeMap = nil } From 0731c49acb05d310107f04ddb1399f36b4f7adc7 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 14 Oct 2018 21:51:56 -0400 Subject: [PATCH 269/399] [daemon] refs #735 - Send RJCT meesage only on pex.ErrPeerlistFull (else peer disconnected) --- src/daemon/messages.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index deca0cbe0f..3ca0b91de0 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -371,10 +371,10 @@ func (intro *IntroductionMessage) Process(d Daemoner) { if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { logger.WithError(err).WithField("addr", intro.c.Addr).Error("Send GivePeersMessage failed") } - } - rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") - if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { - logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) + rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") + if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { + logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) + } } return From e2e3afb2e2e2e549e6459d98e17bb08175c787d3 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 15 Oct 2018 19:54:50 +0800 Subject: [PATCH 270/399] Fixups --- include/skyerrors.h | 2 +- lib/cgo/libsky_error.go | 56 ++++++++++++------------ src/daemon/daemon.go | 11 ++--- src/daemon/messages.go | 27 ++++++------ src/daemon/messages_benchmark_test.go | 2 +- src/daemon/messages_example_test.go | 43 +++++++++++++++++-- src/daemon/messages_test.go | 61 +++++++++++++++------------ 7 files changed, 120 insertions(+), 82 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 6bfa87fc15..98f4d51529 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -112,7 +112,7 @@ #define SKY_ErrDisconnectIdle 0x06000017 #define SKY_ErrDisconnectNoIntroduction 0x06000018 #define SKY_ErrDisconnectIPLimitReached 0x06000019 -#define SKY_ErrDisconnectOtherError 0x0600001A +#define SKY_ErrDisconnectIncomprehensibleError 0x0600001A #define SKY_ErrDisconnectMaxDefaultConnectionReached 0x0600001B #define SKY_ErrDisconnectMaxOutgoingConnectionsReached 0x0600001C #define SKY_ConnectionError 0x0600001D diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index b5119dbdbb..b100c97abd 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -242,8 +242,8 @@ const ( SKY_ErrDisconnectNoIntroduction // SKY_ErrDisconnectIPLimitReached ip limit reached SKY_ErrDisconnectIPLimitReached - // SKY_ErrDisconnectOtherError this is returned when a seemingly impossible error is encountered - SKY_ErrDisconnectOtherError + // SKY_ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered + SKY_ErrDisconnectIncomprehensibleError // SKY_ErrDisconnectMaxDefaultConnectionReached Maximum number of default connections was reached SKY_ErrDisconnectMaxDefaultConnectionReached // nolint megacheck // SKY_ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed @@ -456,32 +456,32 @@ var ( // daemon // Removed in 34ad39ddb350 // gnet.ErrMaxDefaultConnectionsReached: SKY_ErrMaxDefaultConnectionsReached, - pex.ErrPeerlistFull: SKY_ErrPeerlistFull, - pex.ErrInvalidAddress: SKY_ErrInvalidAddress, - pex.ErrNoLocalhost: SKY_ErrNoLocalhost, - pex.ErrNotExternalIP: SKY_ErrNotExternalIP, - pex.ErrPortTooLow: SKY_ErrPortTooLow, - pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, - gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, - gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, - gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, - gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, - gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, - gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, - gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, - gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, - gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, - gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, - daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, - daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, - daemon.ErrDisconnectVersionSendFailed: SKY_ErrDisconnectVersionSendFailed, - daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, - daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, - daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, - daemon.ErrDisconnectIdle: SKY_ErrDisconnectIdle, - daemon.ErrDisconnectNoIntroduction: SKY_ErrDisconnectNoIntroduction, - daemon.ErrDisconnectIPLimitReached: SKY_ErrDisconnectIPLimitReached, - daemon.ErrDisconnectOtherError: SKY_ErrDisconnectOtherError, + pex.ErrPeerlistFull: SKY_ErrPeerlistFull, + pex.ErrInvalidAddress: SKY_ErrInvalidAddress, + pex.ErrNoLocalhost: SKY_ErrNoLocalhost, + pex.ErrNotExternalIP: SKY_ErrNotExternalIP, + pex.ErrPortTooLow: SKY_ErrPortTooLow, + pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, + gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, + gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, + gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, + gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, + gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, + gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, + gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, + gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, + gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, + gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, + daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, + daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, + daemon.ErrDisconnectVersionSendFailed: SKY_ErrDisconnectVersionSendFailed, + daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, + daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, + daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, + daemon.ErrDisconnectIdle: SKY_ErrDisconnectIdle, + daemon.ErrDisconnectNoIntroduction: SKY_ErrDisconnectNoIntroduction, + daemon.ErrDisconnectIPLimitReached: SKY_ErrDisconnectIPLimitReached, + daemon.ErrDisconnectIncomprehensibleError: SKY_ErrDisconnectIncomprehensibleError, // Removed // daemon.ErrDisconnectMaxDefaultConnectionReached: SKY_ErrDisconnectMaxDefaultConnectionReached, daemon.ErrDisconnectMaxOutgoingConnectionsReached: SKY_ErrDisconnectMaxOutgoingConnectionsReached, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 5544153637..65948f7ecd 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -40,9 +40,9 @@ var ( ErrDisconnectNoIntroduction gnet.DisconnectReason = errors.New("First message was not an Introduction") // ErrDisconnectIPLimitReached ip limit reached ErrDisconnectIPLimitReached gnet.DisconnectReason = errors.New("Maximum number of connections for this IP was reached") - // ErrDisconnectOtherError this is returned when a seemingly impossible error is encountered + // ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered // e.g. net.Conn.Addr() returns an invalid ip:port - ErrDisconnectOtherError gnet.DisconnectReason = errors.New("Incomprehensible error") + ErrDisconnectIncomprehensibleError gnet.DisconnectReason = errors.New("Incomprehensible error") // ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed ErrDisconnectMaxOutgoingConnectionsReached gnet.DisconnectReason = errors.New("Maximum outgoing connections was reached") // ErrDisconnectBlockchainPubkeyNotMatched is returned when the blockchain pubkey in introduction does not match @@ -126,8 +126,6 @@ type DaemonConfig struct { // nolint: golint ProtocolVersion int32 // Minimum accepted protocol version MinProtocolVersion int32 - // Maximum accepted protocol version - MaxProtocolVersion int32 // IP Address to serve on. Leave empty for automatic assignment Address string // BlockchainPubkey blockchain pubkey string @@ -184,9 +182,8 @@ type DaemonConfig struct { // nolint: golint // NewDaemonConfig creates daemon config func NewDaemonConfig() DaemonConfig { return DaemonConfig{ - Version: 2, + ProtocolVersion: 2, MinProtocolVersion: 2, - MaxProtocolVersion: 2, Address: "", Port: 6677, OutgoingRate: time.Second * 5, @@ -968,7 +965,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.expectingIntroductions.Add(a, time.Now().UTC()) logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey[:]) + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey) if err := dm.pool.Pool.SendMessage(a, m); err != nil { logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index dc5ce7b940..829cd63f4c 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -233,18 +233,18 @@ type IntroductionMessage struct { c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() valid bool `enc:"-"` // skip it during encoding - // Extra is extra bytes added to the struct to accomodate multiple version of this packet. + // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. // Currently it contains the blockchain pubkey but will accept a client that does not provide it. Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message -func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey []byte) *IntroductionMessage { +func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey) *IntroductionMessage { return &IntroductionMessage{ Mirror: mirror, Version: version, Port: port, - Extra: pubkey, + Extra: pubkey[:], } } @@ -268,7 +268,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa dc := d.DaemonConfig() if intro.Version < dc.MinProtocolVersion { logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.Version, dc.MinProtocolVersion) - if err := d.Disconnect(mc.Addr, ErrDisconnectVersionBelowMin); err != nil { + if err := d.Disconnect(mc.Addr, ErrDisconnectVersionNotSupported); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } return ErrDisconnectVersionNotSupported @@ -278,16 +278,16 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // v25 Checks the blockchain pubkey, would accept message with no Pubkey // v26 would check the blockchain pubkey and reject if not matched or not provided - if len(intro.Pubkey) > 0 { + if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey - if len(intro.Pubkey) < len(bcPubKey) { + if len(intro.Extra) < len(bcPubKey) { logger.Infof("Extra data length does not meet the minimum requirement") if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } return ErrDisconnectInvalidExtraData } - copy(bcPubKey[:], intro.Pubkey[:len(bcPubKey)]) + copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) if d.BlockchainPubkey() != bcPubKey { logger.Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) @@ -298,17 +298,16 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } } - // only solicited connection can be added to exchange peer list, cause accepted - // connection may not have incomming port. + // only solicited connection can be added to exchange peer list, because accepted + // connection may not have an incoming port ip, port, err := iputil.SplitAddr(mc.Addr) if err != nil { - // This should never happen, but the program should still work if it - // does. + // This should never happen, but the program should still work if it does logger.Errorf("Invalid Addr() for connection: %s", mc.Addr) - if err := d.Disconnect(mc.Addr, ErrDisconnectOtherError); err != nil { + if err := d.Disconnect(mc.Addr, ErrDisconnectIncomprehensibleError); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } - return ErrDisconnectOtherError + return ErrDisconnectIncomprehensibleError } // Checks if the introduction message is from outgoing connection. @@ -366,7 +365,7 @@ func (intro *IntroductionMessage) Process(d Daemoner) { // This should never happen, but the program should not allow itself // to be corrupted in case it does logger.Errorf("Invalid port for connection %s", a) - if err := d.Disconnect(intro.c.Addr, ErrDisconnectOtherError); err != nil { + if err := d.Disconnect(intro.c.Addr, ErrDisconnectIncomprehensibleError); err != nil { logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") } return diff --git a/src/daemon/messages_benchmark_test.go b/src/daemon/messages_benchmark_test.go index c3a066360d..62ee758a94 100644 --- a/src/daemon/messages_benchmark_test.go +++ b/src/daemon/messages_benchmark_test.go @@ -67,7 +67,7 @@ var introMessageObj = IntroductionMessage{ Mirror: 1234, Port: 5678, Version: 1, - Pubkey: introPubKey[:], + Extra: introPubKey[:], } func BenchmarkDeserializeRawIntroductionMessage(b *testing.B) { diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 274de6d175..00fae5e49f 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -416,7 +416,10 @@ func ExampleOmitEmptySliceTestStruct() { func ExampleIntroductionMessage() { defer gnet.EraseMessages() setupMsgEncoding() - var message = NewIntroductionMessage(1234, 5, 7890, nil) + + pk := cipher.MustPubKeyFromHex("0328c576d3f420e7682058a981173a4b374c7cc5ff55bf394d3cf57059bbe6456a") + + var message = NewIntroductionMessage(1234, 5, 7890, pk) fmt.Println("IntroductionMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) @@ -426,12 +429,46 @@ func ExampleIntroductionMessage() { } // Output: // IntroductionMessage: - // 0x0000 | 0e 00 00 00 ....................................... Length + // 0x0000 | 33 00 00 00 ....................................... Length // 0x0004 | 49 4e 54 52 ....................................... Prefix // 0x0008 | d2 04 00 00 ....................................... Mirror // 0x000c | d2 1e ............................................. Port // 0x000e | 05 00 00 00 ....................................... Version - // 0x0012 | + // 0x0012 | 21 00 00 00 ....................................... Extra length + // 0x0016 | 03 ................................................ Extra[0] + // 0x0017 | 28 ................................................ Extra[1] + // 0x0018 | c5 ................................................ Extra[2] + // 0x0019 | 76 ................................................ Extra[3] + // 0x001a | d3 ................................................ Extra[4] + // 0x001b | f4 ................................................ Extra[5] + // 0x001c | 20 ................................................ Extra[6] + // 0x001d | e7 ................................................ Extra[7] + // 0x001e | 68 ................................................ Extra[8] + // 0x001f | 20 ................................................ Extra[9] + // 0x0020 | 58 ................................................ Extra[10] + // 0x0021 | a9 ................................................ Extra[11] + // 0x0022 | 81 ................................................ Extra[12] + // 0x0023 | 17 ................................................ Extra[13] + // 0x0024 | 3a ................................................ Extra[14] + // 0x0025 | 4b ................................................ Extra[15] + // 0x0026 | 37 ................................................ Extra[16] + // 0x0027 | 4c ................................................ Extra[17] + // 0x0028 | 7c ................................................ Extra[18] + // 0x0029 | c5 ................................................ Extra[19] + // 0x002a | ff ................................................ Extra[20] + // 0x002b | 55 ................................................ Extra[21] + // 0x002c | bf ................................................ Extra[22] + // 0x002d | 39 ................................................ Extra[23] + // 0x002e | 4d ................................................ Extra[24] + // 0x002f | 3c ................................................ Extra[25] + // 0x0030 | f5 ................................................ Extra[26] + // 0x0031 | 70 ................................................ Extra[27] + // 0x0032 | 59 ................................................ Extra[28] + // 0x0033 | bb ................................................ Extra[29] + // 0x0034 | e6 ................................................ Extra[30] + // 0x0035 | 45 ................................................ Extra[31] + // 0x0036 | 6a ................................................ Extra[32] + // 0x0037 | } func ExampleGetPeersMessage() { diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index f51c2cd3ee..f285242232 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -27,7 +27,8 @@ func TestIntroductionMessage(t *testing.T) { } type daemonMockValue struct { - version uint32 + protocolVersion uint32 + minProtocolVersion uint32 mirror uint32 isDefaultConnection bool isMaxConnectionsReached bool @@ -53,8 +54,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message without extra bytes", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -71,8 +72,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -83,7 +84,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Pubkey: pubkey[:], + Extra: pubkey[:], }, err: nil, }, @@ -91,8 +92,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -103,7 +104,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Pubkey: pubkey[:], + Extra: pubkey[:], }, err: nil, }, @@ -111,8 +112,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with pubkey and additional data", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -123,7 +124,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Pubkey: append(pubkey[:], []byte("additional data")...), + Extra: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -131,8 +132,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with different pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -144,7 +145,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Pubkey: pubkey2[:], + Extra: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -152,8 +153,8 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with invalid pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, + mirror: 10000, + protocolVersion: 1, getMirrorPortResult: mirrorPortResult{ exist: false, }, @@ -165,7 +166,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Pubkey: []byte("invalid extra data"), + Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, @@ -183,9 +184,10 @@ func TestIntroductionMessage(t *testing.T) { { name: "Version below minimum supported version", mockValue: daemonMockValue{ - mirror: 10000, - version: 1, - disconnectReason: ErrDisconnectVersionNotSupported, + mirror: 10000, + protocolVersion: 1, + minProtocolVersion: 2, + disconnectReason: ErrDisconnectVersionNotSupported, }, intro: &IntroductionMessage{ Mirror: 10001, @@ -198,8 +200,8 @@ func TestIntroductionMessage(t *testing.T) { addr: "121.121.121.121", mockValue: daemonMockValue{ mirror: 10000, - version: 1, - disconnectReason: ErrDisconnectOtherError, + protocolVersion: 1, + disconnectReason: ErrDisconnectIncomprehensibleError, pubkey: pubkey, }, intro: &IntroductionMessage{ @@ -207,14 +209,14 @@ func TestIntroductionMessage(t *testing.T) { Version: 1, Port: 6000, }, - err: ErrDisconnectOtherError, + err: ErrDisconnectIncomprehensibleError, }, { name: "incomming connection", addr: "121.121.121.121:12345", mockValue: daemonMockValue{ mirror: 10000, - version: 1, + protocolVersion: 1, isDefaultConnection: true, isMaxConnectionsReached: true, getMirrorPortResult: mirrorPortResult{ @@ -236,7 +238,7 @@ func TestIntroductionMessage(t *testing.T) { addr: "121.121.121.121:6000", mockValue: daemonMockValue{ mirror: 10000, - version: 1, + protocolVersion: 1, isDefaultConnection: true, getMirrorPortResult: mirrorPortResult{ exist: true, @@ -261,7 +263,10 @@ func TestIntroductionMessage(t *testing.T) { tc.intro.c = mc d := &MockDaemoner{} - d.On("DaemonConfig").Return(DaemonConfig{Version: int32(tc.mockValue.version)}) + d.On("DaemonConfig").Return(DaemonConfig{ + ProtocolVersion: int32(tc.mockValue.protocolVersion), + MinProtocolVersion: int32(tc.mockValue.minProtocolVersion), + }) d.On("Mirror").Return(tc.mockValue.mirror) d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) @@ -307,7 +312,7 @@ func TestMessageEncodeDecode(t *testing.T) { Mirror: 99998888, Port: 8888, Version: 12341234, - Pubkey: introPubKey[:], + Extra: introPubKey[:], }, }, { From 0dbd8d4ea6a081c650a12b5e4c71827415d81273 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Tue, 16 Oct 2018 20:24:51 +0000 Subject: [PATCH 271/399] [daemon] refs #735 - Updated error list and sample message hex dump --- src/daemon/errors.go | 13 ++++++++++--- src/daemon/messages_example_test.go | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index f80cde5815..cd90207c53 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -7,7 +7,7 @@ import ( var errorByCode = [...]error{ nil, - ErrDisconnectInvalidVersion, + ErrDisconnectVersionNotSupported, ErrDisconnectIntroductionTimeout, ErrDisconnectVersionSendFailed, ErrDisconnectIsBlacklisted, @@ -16,16 +16,23 @@ var errorByCode = [...]error{ ErrDisconnectIdle, ErrDisconnectNoIntroduction, ErrDisconnectIPLimitReached, - ErrDisconnectOtherError, + ErrDisconnectIncomprehensibleError, + ErrDisconnectMaxOutgoingConnectionsReached, + ErrDisconnectBlockchainPubkeyNotMatched, + ErrDisconnectInvalidExtraData, + ErrDisconnectPeerlistFull, + ErrOutgoingConnectionsDisabled, gnet.ErrDisconnectReadFailed, gnet.ErrDisconnectWriteFailed, gnet.ErrDisconnectSetReadDeadlineFailed, gnet.ErrDisconnectInvalidMessageLength, gnet.ErrDisconnectMalformedMessage, gnet.ErrDisconnectUnknownMessage, - nil, // gnet.ErrDisconnectWriteQueueFull, + gnet.ErrWriteQueueFull, gnet.ErrDisconnectUnexpectedError, gnet.ErrConnectionPoolClosed, + gnet.ErrNoReachableConnections, + gnet.ErrPoolEmpty, pex.ErrPeerlistFull, pex.ErrInvalidAddress, pex.ErrNoLocalhost, diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index ebb91d41fd..9c975a7710 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -799,9 +799,9 @@ func ExampleRejectMessage() { defer gnet.EraseMessages() setupMsgEncoding() - rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, []byte{}) + rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, cipher.PubKey{}) message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") - fmt.Println("RejectWithPeersMessage:") + fmt.Println("RejectMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) err := NewFromIterator(gnet.EncodeMessage(message), &mai, w) @@ -809,11 +809,11 @@ func ExampleRejectMessage() { fmt.Println(err) } // Output: - // RejectWithPeersMessage: + // RejectMessage: // 0x0000 | 31 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 54 ....................................... Prefix // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix - // 0x000c | 0c 00 00 00 ....................................... ErrorCode + // 0x000c | 11 00 00 00 ....................................... ErrorCode // 0x0010 | 1d 00 00 00 45 78 61 6d 70 6c 65 52 65 6a 65 63 // 0x0020 | 74 57 69 74 68 50 65 65 72 73 4d 65 73 73 61 67 // 0x0030 | 65 ................................................ Reason From a4cd10be11d12deb569c3df3a5c4c3726b950cd0 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Tue, 16 Oct 2018 21:38:27 +0000 Subject: [PATCH 272/399] [daemon] refs #735 - Silence make lint warnings Reported in https://travis-ci.org/skycoin/skycoin/builds/442369755#L1841-L1847 --- src/daemon/messages_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 75d1c8f990..314b6fa0c5 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -84,7 +84,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Extra: pubkey[:], + Extra: pubkey[:], }, err: nil, }, @@ -104,7 +104,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Extra: pubkey[:], + Extra: pubkey[:], }, err: nil, }, @@ -124,7 +124,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Extra: append(pubkey[:], []byte("additional data")...), + Extra: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -145,7 +145,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Extra: pubkey2[:], + Extra: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -166,7 +166,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, validationError: nil, - Extra: []byte("invalid extra data"), + Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, From 202a80bd26dfe270d6a7e76a1b89e426d6a1e2b0 Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Tue, 16 Oct 2018 18:12:27 -0400 Subject: [PATCH 273/399] Fix Electron menu --- electron/src/electron-main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index 0d55831446..13339d9ba7 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -232,13 +232,13 @@ function createWindow(url) { }, { label: 'Edit', submenu: [ - { label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' }, - { label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' }, + { label: 'Undo', accelerator: 'CmdOrCtrl+Z', role: 'undo' }, + { label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' }, { type: 'separator' }, - { label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' }, - { label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' }, - { label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' }, - { label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' } + { label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' }, + { label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' }, + { label: 'Paste', accelerator: 'CmdOrCtrl+V', role: 'paste' }, + { label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectall' } ] }, { label: 'Show', From cffdd04f32194a92332bc5eaf6070277b92e07bb Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 18 Oct 2018 21:54:08 +0800 Subject: [PATCH 274/399] Add useragent to intro packet --- cmd/newcoin/newcoin.go | 20 ++- cmd/skycoin/skycoin.go | 4 + src/cipher/encoder/encoder.go | 32 +++- src/cipher/encoder/encoder_test.go | 75 +++++++++ src/daemon/daemon.go | 15 +- src/daemon/gateway.go | 15 ++ src/daemon/messages.go | 66 ++++++-- src/daemon/pex/peerlist.go | 14 +- src/daemon/pex/pex.go | 28 +++- src/daemon/storage.go | 35 ++++ src/readable/network.go | 2 + src/skycoin/config.go | 37 ++++- src/skycoin/parameters.go | 4 +- src/skycoin/skycoin.go | 7 +- src/util/useragent/useragent.go | 182 +++++++++++++++++++++ src/util/useragent/useragent_test.go | 229 +++++++++++++++++++++++++++ template/coin.template | 4 + 17 files changed, 730 insertions(+), 39 deletions(-) create mode 100644 src/util/useragent/useragent.go create mode 100644 src/util/useragent/useragent_test.go diff --git a/cmd/newcoin/newcoin.go b/cmd/newcoin/newcoin.go index fc183b71be..fcbfa62751 100644 --- a/cmd/newcoin/newcoin.go +++ b/cmd/newcoin/newcoin.go @@ -4,7 +4,9 @@ newcoin generates a new coin cmd from a toml configuration file package main import ( + "errors" "fmt" + "regexp" "os" "path/filepath" @@ -23,6 +25,7 @@ const ( // CoinTemplateParameters represents parameters used to generate the new coin files. type CoinTemplateParameters struct { + CoinName string Version string PeerListURL string Port int @@ -108,6 +111,12 @@ func createCoinCommand() cli.Command { Action: func(c *cli.Context) error { // -- parse flags -- // + coinName := c.String("coin") + + if err := validateCoinName(coinName); err != nil { + return err + } + templateDir := c.String("template-dir") coinTemplateFile := c.String("coin-template-file") @@ -136,8 +145,6 @@ func createCoinCommand() cli.Command { return err } - coinName := c.String("coin") - // -- parse template and create new coin.go and visor parameters.go -- // config, err := skycoin.NewParameters(configFile, configDir) @@ -200,6 +207,7 @@ func createCoinCommand() cli.Command { } err = t.ExecuteTemplate(coinFile, coinTemplateFile, CoinTemplateParameters{ + CoinName: coinName, PeerListURL: config.Node.PeerListURL, Port: config.Node.Port, WebInterfacePort: config.Node.WebInterfacePort, @@ -234,6 +242,14 @@ func createCoinCommand() cli.Command { } } +func validateCoinName(s string) error { + x := regexp.MustCompile(`^[A-Za-z0-9\-_+]+$`) + if !x.MatchString(s) { + return errors.New("invalid coin name. must only contain the characters A-Za-z0-9 and -_+") + } + return nil +} + func main() { if e := app.Run(os.Args); e != nil { log.Fatal(e) diff --git a/cmd/skycoin/skycoin.go b/cmd/skycoin/skycoin.go index b615a75065..210950e5c1 100644 --- a/cmd/skycoin/skycoin.go +++ b/cmd/skycoin/skycoin.go @@ -32,6 +32,9 @@ var ( logger = logging.MustGetLogger("main") + // CoinName name of coin + CoinName = "skycoin" + // GenesisSignatureStr hex string of genesis signature GenesisSignatureStr = "eb10468d10054d15f2b6f8946cd46797779aa20a7617ceb4be884189f219bc9a164e56a5b9f7bec392a804ff3740210348d73db77a37adb542a8e08d429ac92700" // GenesisAddressStr genesis address string @@ -58,6 +61,7 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ + CoinName: CoinName, GenesisSignatureStr: GenesisSignatureStr, GenesisAddressStr: GenesisAddressStr, GenesisCoinVolume: GenesisCoinVolume, diff --git a/src/cipher/encoder/encoder.go b/src/cipher/encoder/encoder.go index 805ab58b30..0f6e98845c 100644 --- a/src/cipher/encoder/encoder.go +++ b/src/cipher/encoder/encoder.go @@ -150,6 +150,32 @@ func DeserializeAtomic(in []byte, data interface{}) (int, error) { } } +// SerializeString serializes a string to []byte +func SerializeString(s string) []byte { + v := reflect.ValueOf(s) + size, err := datasizeWrite(v) + if err != nil { + log.Panic(err) + } + buf := make([]byte, size) + e := &encoder{buf: buf} + e.value(v) + return buf +} + +// DeserializeString deserializes a string from []byte, returning the string and the number of bytes read +func DeserializeString(b []byte) (string, int, error) { + var s string + v := reflect.ValueOf(&s) + + n, err := DeserializeRawToValue(b, v) + if err != nil { + return "", 0, err + } + + return s, n, nil +} + // DeserializeRaw deserializes `in` buffer into return // parameter. If `data` is not a Pointer or Map type an error // is returned. If `in` buffer can't be deserialized, @@ -198,7 +224,11 @@ func DeserializeRawToValue(in []byte, v reflect.Value) (int, error) { copy(d1.buf, in) err := d1.value(v) - return inlen - len(d1.buf), err + if err != nil { + return 0, err + } + + return inlen - len(d1.buf), nil } // Serialize returns serialized basic type-based `data` diff --git a/src/cipher/encoder/encoder_test.go b/src/cipher/encoder/encoder_test.go index 8d09718478..bb49d44c98 100644 --- a/src/cipher/encoder/encoder_test.go +++ b/src/cipher/encoder/encoder_test.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "encoding/hex" "errors" + "fmt" "io/ioutil" "math" "os" @@ -1191,3 +1192,77 @@ func TestDeserializeRawNotPointer(t *testing.T) { b = Serialize(m) require.NotEmpty(t, b) } + +func TestSerializeString(t *testing.T) { + cases := []struct { + s string + x []byte + }{ + { + s: "", + x: []byte{0, 0, 0, 0}, + }, + { + s: "foo", + x: []byte{3, 0, 0, 0, 'f', 'o', 'o'}, + }, + } + + for _, tc := range cases { + t.Run(tc.s, func(t *testing.T) { + require.Equal(t, tc.x, SerializeString(tc.s)) + }) + } +} + +func TestDeserializeString(t *testing.T) { + cases := []struct { + s string + x []byte + n int + err error + }{ + { + s: "", + x: []byte{0, 0, 0, 0}, + n: 4, + }, + { + s: "foo", + x: []byte{3, 0, 0, 0, 'f', 'o', 'o'}, + n: 7, + }, + { + x: []byte{3, 0, 0}, + err: ErrBufferUnderflow, + }, + { + x: nil, + err: ErrBufferUnderflow, + }, + { + x: []byte{3, 0, 0, 0, 'f'}, + err: ErrBufferUnderflow, + }, + { + s: "foo", + x: []byte{3, 0, 0, 0, 'f', 'o', 'o', 'x'}, + n: 7, + }, + } + + for _, tc := range cases { + t.Run(fmt.Sprintf("s=%s err=%s", tc.s, tc.err), func(t *testing.T) { + s, n, err := DeserializeString(tc.x) + if tc.err != nil { + require.Equal(t, tc.err, err) + require.Equal(t, tc.n, n) + return + } + + require.NoError(t, err) + require.Equal(t, tc.s, s) + require.Equal(t, tc.n, n) + }) + } +} diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 65948f7ecd..7b4a6d6828 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -17,6 +17,7 @@ import ( "github.com/skycoin/skycoin/src/util/elapse" "github.com/skycoin/skycoin/src/util/iputil" "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skycoin/src/util/useragent" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/dbutil" ) @@ -50,6 +51,8 @@ var ( // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") + // ErrDisconnectInvalidUserAgent is returned if the peer provides an invalid user agent + ErrDisconnectInvalidUserAgent gnet.DisconnectReason = errors.New("Invalid user agent") // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") @@ -177,6 +180,8 @@ type DaemonConfig struct { // nolint: golint UnconfirmedRemoveInvalidRate time.Duration // Default "trusted" peers DefaultConnections []string + // User agent (sent in introduction messages) + UserAgent string } // NewDaemonConfig creates daemon config @@ -242,6 +247,7 @@ type Daemoner interface { RemoveFromExpectingIntroductions(addr string) RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error + RecordUserAgent(addr string, userAgent useragent.Data) error } // Daemon stateful properties of the daemon @@ -404,6 +410,8 @@ func (dm *Daemon) Run() error { defer logger.Info("Daemon closed") defer close(dm.done) + logger.Infof("Daemon UserAgent is %s", dm.Config.UserAgent) + errC := make(chan error, 5) var wg sync.WaitGroup @@ -965,7 +973,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.expectingIntroductions.Add(a, time.Now().UTC()) logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey) + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.UserAgent) if err := dm.pool.Pool.SendMessage(a, m); err != nil { logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) } @@ -1382,6 +1390,11 @@ func (dm *Daemon) SetHasIncomingPort(addr string) error { return dm.pex.SetHasIncomingPort(addr, true) } +// RecordUserAgent sets the peer's user agent +func (dm *Daemon) RecordUserAgent(addr string, userAgent useragent.Data) error { + return dm.pex.SetUserAgent(addr, userAgent) +} + // IncreaseRetryTimes increases the retry times of given peer func (dm *Daemon) IncreaseRetryTimes(addr string) { dm.pex.IncreaseRetryTimes(addr) diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index e60a0b0b6e..a9078ec246 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -99,6 +99,7 @@ type Connection struct { Mirror uint32 ListenPort uint16 Height uint64 + UserAgent string } // GetOutgoingConnections returns solicited (outgoing) connections @@ -113,6 +114,7 @@ func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { if gw.d.pool.Pool == nil { + logger.Debug("getOutgoingConnections pool is nil") return nil, nil } @@ -122,6 +124,8 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { return nil, err } + logger.Info("getOutgoingConnections: Number of conns:", len(cs)) + conns := make([]Connection, 0, len(cs)) for _, c := range cs { @@ -186,6 +190,16 @@ func (gw *Gateway) newConnection(c *gnet.Connection) *Connection { height, _ := gw.d.Heights.Get(addr) + var userAgent string + pexPeer, exist := gw.d.pex.GetPeerByAddr(addr) + if exist { + var err error + userAgent, err = pexPeer.UserAgent.Build() + if err != nil { + logger.WithError(err).WithField("addr", addr).Error("pex peer's user agent data cannot be built to string") + } + } + return &Connection{ ID: c.ID, Addr: addr, @@ -196,6 +210,7 @@ func (gw *Gateway) newConnection(c *gnet.Connection) *Connection { Mirror: mirror, ListenPort: gw.d.GetListenPort(addr), Height: height, + UserAgent: userAgent, } } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 829cd63f4c..a0bb20f17f 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -10,10 +10,12 @@ import ( "time" "github.com/skycoin/skycoin/src/cipher" + "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/util/iputil" + "github.com/skycoin/skycoin/src/util/useragent" ) // Message represent a packet to be serialized over the network by @@ -221,10 +223,9 @@ func (gpm *GivePeersMessage) Process(d Daemoner) { d.AddPeers(peers) } -// IntroductionMessage jan IntroductionMessage is sent on first connect by both parties +// IntroductionMessage an IntroductionMessage is sent on first connect by both parties type IntroductionMessage struct { - // Mirror is a random value generated on client startup that is used - // to identify self-connections + // Mirror is a random value generated on client startup that is used to identify self-connections Mirror uint32 // Port is the port that this client is listening on Port uint16 @@ -232,19 +233,27 @@ type IntroductionMessage struct { Version int32 c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() - valid bool `enc:"-"` // skip it during encoding + valid bool `enc:"-"` // skip it during encoding + userAgentData useragent.Data `enc:"-"` // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. - // Currently it contains the blockchain pubkey but will accept a client that does not provide it. + // Currently it contains the blockchain pubkey and user agent but will accept a client that does not provide it. Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message -func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey) *IntroductionMessage { +func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey, userAgent string) *IntroductionMessage { + userAgentSerialized := encoder.SerializeString(userAgent) + + extra := make([]byte, len(pubkey)+len(userAgentSerialized)) + + copy(extra[:len(pubkey)], pubkey[:]) + copy(extra[len(pubkey):], userAgentSerialized) + return &IntroductionMessage{ Mirror: mirror, Version: version, Port: port, - Extra: pubkey[:], + Extra: extra, } } @@ -253,7 +262,7 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey ci // Process(), where we do modifications that are not threadsafe func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { d := daemon.(Daemoner) - + var userAgentData useragent.Data err := func() error { // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { @@ -276,12 +285,14 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa logger.Infof("%s verified for version %d", mc.Addr, intro.Version) - // v25 Checks the blockchain pubkey, would accept message with no Pubkey - // v26 would check the blockchain pubkey and reject if not matched or not provided + // v24 does not send blockchain pubkey or user agent + // v25 sends blockchain pubkey and user agent + // v24 and v25 check the blockchain pubkey and user agent, would accept message with no Pubkey and user agent + // v26 would check the blockchain pubkey and reject if not matched or not provided, and parses a user agent if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.Infof("Extra data length does not meet the minimum requirement") + logger.Info("Extra data length does not meet the minimum requirement") if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -296,6 +307,25 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } return ErrDisconnectBlockchainPubkeyNotMatched } + + userAgentSerialized := intro.Extra[len(bcPubKey):] + userAgent, _, err := encoder.DeserializeString(userAgentSerialized) + if err != nil { + logger.WithError(err).Info("Extra data user agent string could not be deserialized") + if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { + logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") + } + return ErrDisconnectInvalidExtraData + } + + userAgentData, err = useragent.Parse(useragent.Sanitize(userAgent)) + if err != nil { + logger.WithError(err).WithField("userAgent", userAgent).Info("User agent is invalid") + if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidUserAgent); err != nil { + logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") + } + return ErrDisconnectInvalidUserAgent + } } // only solicited connection can be added to exchange peer list, because accepted @@ -337,6 +367,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa }() intro.valid = (err == nil) + intro.userAgentData = userAgentData intro.c = mc if err != nil { @@ -360,8 +391,7 @@ func (intro *IntroductionMessage) Process(d Daemoner) { a := intro.c.Addr // Record their listener, to avoid double connections - err := d.RecordConnectionMirror(a, intro.Mirror) - if err != nil { + if err := d.RecordConnectionMirror(a, intro.Mirror); err != nil { // This should never happen, but the program should not allow itself // to be corrupted in case it does logger.Errorf("Invalid port for connection %s", a) @@ -371,12 +401,14 @@ func (intro *IntroductionMessage) Process(d Daemoner) { return } + // Record the user agent of the peer + d.RecordUserAgent(a, intro.userAgentData) + // Request blocks immediately after they're confirmed - err = d.RequestBlocksFromAddr(intro.c.Addr) - if err == nil { - logger.Debugf("Successfully requested blocks from %s", intro.c.Addr) - } else { + if err := d.RequestBlocksFromAddr(intro.c.Addr); err != nil { logger.Warning(err) + } else { + logger.Debugf("Successfully requested blocks from %s", intro.c.Addr) } // Announce unconfirmed txns diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index 4d2cb1609a..af42b54b8c 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -9,6 +9,7 @@ import ( "time" "github.com/skycoin/skycoin/src/util/file" + "github.com/skycoin/skycoin/src/util/useragent" ) // Peers peer list @@ -204,7 +205,7 @@ func (pl *peerlist) setAllUntrusted() { } } -// setHasIncomingPort updates whether the peer is valid and has public incoming port +// setHasIncomingPort marks the peer's port as being publicly accessible func (pl *peerlist) setHasIncomingPort(addr string, hasIncomingPort bool) error { if p, ok := pl.peers[addr]; ok { p.HasIncomingPort = hasIncomingPort @@ -215,6 +216,17 @@ func (pl *peerlist) setHasIncomingPort(addr string, hasIncomingPort bool) error return fmt.Errorf("set peer.HasIncomingPort failed: %v does not exist in peer list", addr) } +// setUserAgent sets a peer's user agent +func (pl *peerlist) setUserAgent(addr string, userAgent useragent.Data) error { + if p, ok := pl.peers[addr]; ok { + p.UserAgent = userAgent + p.Seen() + return nil + } + + return fmt.Errorf("set peer.UserAgent failed: %v does not exist in peer list", addr) +} + // len returns number of peers func (pl *peerlist) len() int { return len(pl.peers) diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index f17c9458de..00a6e27238 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -20,6 +20,7 @@ import ( "github.com/cenkalti/backoff" "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skycoin/src/util/useragent" ) //TODO: @@ -96,12 +97,13 @@ func validateAddress(ipPort string, allowLocalhost bool) (string, error) { // Peer represents a known peer type Peer struct { - Addr string // An address of the form ip:port - LastSeen int64 // Unix timestamp when this peer was last seen - Private bool // Whether it should omitted from public requests - Trusted bool // Whether this peer is trusted - HasIncomingPort bool // Whether this peer has accessible public port - RetryTimes int `json:"-"` // records the retry times + Addr string // An address of the form ip:port + LastSeen int64 // Unix timestamp when this peer was last seen + Private bool // Whether it should omitted from public requests + Trusted bool // Whether this peer is trusted + HasIncomingPort bool // Whether this peer has accessible public port + UserAgent useragent.Data // Peer's last reported user agent + RetryTimes int `json:"-"` // records the retry times } // NewPeer returns a *Peer initialized by an address string of the form ip:port @@ -525,6 +527,20 @@ func (px *Pex) SetHasIncomingPort(addr string, hasPublicPort bool) error { return px.peerlist.setHasIncomingPort(cleanAddr, hasPublicPort) } +// SetUserAgent sets the peer's user agent +func (px *Pex) SetUserAgent(addr string, userAgent useragent.Data) error { + px.Lock() + defer px.Unlock() + + cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) + if err != nil { + logger.Errorf("Invalid address %s: %v", addr, err) + return ErrInvalidAddress + } + + return px.peerlist.setUserAgent(cleanAddr, userAgent) +} + // RemovePeer removes peer func (px *Pex) RemovePeer(addr string) { px.Lock() diff --git a/src/daemon/storage.go b/src/daemon/storage.go index 2d66bffcf1..3d78bf4fb9 100644 --- a/src/daemon/storage.go +++ b/src/daemon/storage.go @@ -287,3 +287,38 @@ func (s *IPCount) Get(ip string) (int, bool) { v, ok := s.value[ip] return v, ok } + +// UserAgents records connections' user agents +type UserAgents struct { + value map[string]string + sync.Mutex +} + +// NewUserAgents creates a UserAgents +func NewUserAgents() *UserAgents { + return &UserAgents{ + value: make(map[string]string), + } +} + +// Set sets a peer's user agent +func (s *UserAgents) Set(addr, userAgent string) { + s.Lock() + defer s.Unlock() + s.value[addr] = userAgent +} + +// Get returns a peer's user agent +func (s *UserAgents) Get(addr string) (string, bool) { + s.Lock() + defer s.Unlock() + v, ok := s.value[addr] + return v, ok +} + +// Remove removes a peer's user agent +func (s *UserAgents) Remove(addr string) { + s.Lock() + defer s.Unlock() + delete(s.value, addr) +} diff --git a/src/readable/network.go b/src/readable/network.go index b2e09a5b6f..bf384e5178 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -18,6 +18,7 @@ type Connection struct { Mirror uint32 `json:"mirror"` ListenPort uint16 `json:"listen_port"` Height uint64 `json:"height"` + UserAgent string `json:"user_agent"` } // NewConnection copies daemon.Connection to a struct with json tags @@ -32,5 +33,6 @@ func NewConnection(c *daemon.Connection) Connection { Mirror: c.Mirror, ListenPort: c.ListenPort, Height: c.Height, + UserAgent: c.UserAgent, } } diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 05269a1edf..2aba95ba40 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -16,6 +16,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/file" + "github.com/skycoin/skycoin/src/util/useragent" "github.com/skycoin/skycoin/src/wallet" ) @@ -31,6 +32,9 @@ type Config struct { // NodeConfig records the node's configuration type NodeConfig struct { + // Name of the coin + CoinName string + // Disable peer exchange DisablePEX bool // Download peer list @@ -112,9 +116,14 @@ type NodeConfig struct { // GUI directory contains assets for the HTML interface GUIDirectory string - ReadTimeout time.Duration - WriteTimeout time.Duration - IdleTimeout time.Duration + // Timeouts for the HTTP listener + HTTPReadTimeout time.Duration + HTTPWriteTimeout time.Duration + HTTPIdleTimeout time.Duration + + // Remark to include in user agent sent in the wire protocol introduction + UserAgentRemark string + userAgent string // Logging ColorLog bool @@ -176,6 +185,7 @@ type NodeConfig struct { // NewNodeConfig returns a new node config instance func NewNodeConfig(mode string, node NodeParameters) NodeConfig { nodeConfig := NodeConfig{ + CoinName: node.CoinName, GenesisSignatureStr: node.GenesisSignatureStr, GenesisAddressStr: node.GenesisAddressStr, GenesisCoinVolume: node.GenesisCoinVolume, @@ -250,9 +260,9 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { // Timeout settings for http.Server // https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ - ReadTimeout: time.Second * 10, - WriteTimeout: time.Second * 60, - IdleTimeout: time.Second * 120, + HTTPReadTimeout: time.Second * 10, + HTTPWriteTimeout: time.Second * 60, + HTTPIdleTimeout: time.Second * 120, // Centralized network configuration RunMaster: false, @@ -336,6 +346,19 @@ func (c *Config) postProcess() error { c.Node.Arbitrating = true } + userAgentData := useragent.Data{ + Coin: c.Node.CoinName, + Version: c.Build.Version, + Remark: c.Node.UserAgentRemark, + } + + userAgent, err := userAgentData.Build() + if err != nil { + return err + } + + c.Node.userAgent = userAgent + apiSets, err := buildAPISets(c.Node) if err != nil { return err @@ -485,6 +508,8 @@ func (c *NodeConfig) RegisterFlags() { flag.BoolVar(&c.DisableDefaultPeers, "disable-default-peers", c.DisableDefaultPeers, "disable the hardcoded default peers") flag.StringVar(&c.CustomPeersFile, "custom-peers-file", c.CustomPeersFile, "load custom peers from a newline separate list of ip:port in a file. Note that this is different from the peers.json file in the data directory") + flag.StringVar(&c.UserAgentRemark, "user-agent-remark", c.UserAgentRemark, "additional remark to include in the user agent sent over the wire protocol") + // Key Configuration Data flag.BoolVar(&c.RunMaster, "master", c.RunMaster, "run the daemon as blockchain master server") diff --git a/src/skycoin/parameters.go b/src/skycoin/parameters.go index 3f388223cb..62a568ee3a 100644 --- a/src/skycoin/parameters.go +++ b/src/skycoin/parameters.go @@ -15,6 +15,7 @@ type Parameters struct { // NodeParameters records the node's configurable parameters type NodeParameters struct { + CoinName string `mapstructure:"coin_name"` PeerListURL string `mapstructure:"peer_list_url"` Port int `mapstructure:"port"` WebInterfacePort int `mapstructure:"web_interface_port"` @@ -26,8 +27,7 @@ type NodeParameters struct { GenesisCoinVolume uint64 `mapstructure:"genesis_coin_volume"` DefaultConnections []string `mapstructure:"default_connections"` - DataDirectory string - ProfileCPUFile string + DataDirectory string } // VisorParameters are the parameters used to generate parameters.go in visor diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 96dc18f202..18f628f45d 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -368,6 +368,7 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Daemon.DataDirectory = c.config.Node.DataDirectory dc.Daemon.LogPings = !c.config.Node.DisablePingPong dc.Daemon.BlockchainPubkey = c.config.Node.blockchainPubkey + dc.Daemon.UserAgent = c.config.Node.userAgent if c.config.Node.OutgoingConnectionsRate == 0 { c.config.Node.OutgoingConnectionsRate = time.Millisecond @@ -410,9 +411,9 @@ func (c *Coin) createGUI(d *daemon.Daemon, host string) (*api.Server, error) { EnableJSON20RPC: c.config.Node.RPCInterface, EnableGUI: c.config.Node.EnableGUI, EnableUnversionedAPI: c.config.Node.EnableUnversionedAPI, - ReadTimeout: c.config.Node.ReadTimeout, - WriteTimeout: c.config.Node.WriteTimeout, - IdleTimeout: c.config.Node.IdleTimeout, + ReadTimeout: c.config.Node.HTTPReadTimeout, + WriteTimeout: c.config.Node.HTTPWriteTimeout, + IdleTimeout: c.config.Node.HTTPIdleTimeout, EnabledAPISets: c.config.Node.enabledAPISets, HostWhitelist: c.config.Node.hostWhitelist, BuildInfo: readable.BuildInfo{ diff --git a/src/util/useragent/useragent.go b/src/util/useragent/useragent.go new file mode 100644 index 0000000000..04082f9f24 --- /dev/null +++ b/src/util/useragent/useragent.go @@ -0,0 +1,182 @@ +// Package useragent implements methods for managing Skycoin user agents. +// +// A skycoin user agent has the following format: +// `$NAME:$VERSION[$GIT_HASH]($REMARK)` +// +// `$NAME` and `$VERSION` are required. +// +// * `$NAME` is the coin or application's name, e.g. `Skycoin`. It can contain the following characters: `A-Za-z0-9\-_+`. +// * `$VERSION` must start with a valid semver version, e.g. `1.2.3`, and maybe follow by additional characters, e.g. `1.2.3-rc1` +// * `$GIT_HASH` is optional. If not present, the enclosing brackets `[]` should be omitted. +// The value of `$GIT_HASH` should be the short hash of the git head of the current build. +// * `$REMARK` is optional. If not present, the enclosing brackets `()` should be omitted. +// It can contain the following characters: `A-Za-z0-9\-_+;:!$%,.=?~ ` (include the space character). +package useragent + +import ( + "encoding/json" + "errors" + "fmt" + "regexp" + "strings" + + "github.com/blang/semver" +) + +const ( + // IllegalChars are printable ascii characters forbidden from a user agent string. All other ascii or bytes are also forbidden. + IllegalChars = `<>&"'#@|{}` + "`" + // MaxLen the maximum length of a user agent + MaxLen = 256 + + pattern = `^([A-Za-z0-9\-_+]+):([0-9]+\.[0-9]+\.[0-9][\-A-Za-z0-9]*)(\([A-Za-z0-9\-_+;:!$%,.=?~ ]+\))?$` +) + +var ( + illegalCharsSanitizeRe *regexp.Regexp + illegalCharsCheckRe *regexp.Regexp + re *regexp.Regexp + + // ErrIllegalChars user agent contains illegal characters + ErrIllegalChars = errors.New("User agent has invalid character(s)") + // ErrTooLong user agent exceeds a certain max length + ErrTooLong = errors.New("User agent is too long") + // ErrMalformed user agent does not match the user agent pattern + ErrMalformed = errors.New("User agent is malformed") +) + +func init() { + illegalCharsSanitizeRe = regexp.MustCompile(fmt.Sprintf("([^[:print:]]|[%s])+", IllegalChars)) + illegalCharsCheckRe = regexp.MustCompile(fmt.Sprintf("[^[:print:]]|[%s]", IllegalChars)) + re = regexp.MustCompile(pattern) +} + +// Data holds parsed user agent data +type Data struct { + Coin string + Version string + Remark string +} + +// Build builds a user agent string. Returns an error if the user agent would be invalid. +func (d Data) Build() (string, error) { + if d.Coin == "" { + return "", errors.New("missing coin name") + } + if d.Version == "" { + return "", errors.New("missing version") + } + + _, err := semver.Parse(d.Version) + if err != nil { + return "", err + } + + s := d.build() + + if err := validate(s); err != nil { + fmt.Println("validate failed") + return "", err + } + + d2, err := Parse(s) + if err != nil { + return "", fmt.Errorf("Built a user agent that fails to parse: %q %v", s, err) + } + + if d2 != d { + return "", errors.New("Built a user agent that does not parse to the original format") + } + + return s, nil +} + +func (d Data) build() string { + if d.Coin == "" || d.Version == "" { + return "" + } + + remark := d.Remark + if remark != "" { + remark = fmt.Sprintf("(%s)", remark) + } + + return fmt.Sprintf("%s:%s%s", d.Coin, d.Version, remark) +} + +// MarshalJSON marshals Data as JSON +func (d Data) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%s"`, d.build())), nil +} + +// UnmarshalJSON unmarshals []byte to Data +func (d *Data) UnmarshalJSON(v []byte) error { + var s string + if err := json.Unmarshal(v, &s); err != nil { + return err + } + + if s == "" { + return nil + } + + parsed, err := Parse(s) + if err != nil { + return err + } + + *d = parsed + return nil +} + +// Parse parses a user agent string to Data +func Parse(userAgent string) (Data, error) { + if err := validate(userAgent); err != nil { + return Data{}, err + } + + subs := re.FindAllStringSubmatch(userAgent, -1) + + if len(subs) == 0 { + return Data{}, ErrMalformed + } + + m := subs[0] + + if m[0] != userAgent { + // This should not occur since the pattern has ^$ boundaries applied, but just in case + return Data{}, errors.New("User agent did not match pattern completely") + } + + coin := m[1] + version := m[2] + remark := m[3] + + remark = strings.TrimPrefix(remark, "(") + remark = strings.TrimSuffix(remark, ")") + + return Data{ + Coin: coin, + Version: version, + Remark: remark, + }, nil +} + +// validate validates a user agent string. The user agent must not contain illegal characters. +func validate(userAgent string) error { + if len(userAgent) > MaxLen { + return ErrTooLong + } + + fmt.Println("validate", userAgent) + if illegalCharsCheckRe.MatchString(userAgent) { + return ErrIllegalChars + } + + return nil +} + +// Sanitize removes illegal characters from a user agent string +func Sanitize(userAgent string) string { + return illegalCharsSanitizeRe.ReplaceAllLiteralString(userAgent, "") +} diff --git a/src/util/useragent/useragent_test.go b/src/util/useragent/useragent_test.go new file mode 100644 index 0000000000..5e5dc2572b --- /dev/null +++ b/src/util/useragent/useragent_test.go @@ -0,0 +1,229 @@ +package useragent + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDataBuild(t *testing.T) { + cases := []struct { + name string + data Data + userAgent string + err error + }{ + { + name: "without remark", + userAgent: "Skycoin:0.24.1", + data: Data{ + Coin: "Skycoin", + Version: "0.24.1", + }, + }, + { + name: "with remark", + userAgent: "Skycoin:0.24.1(remark; foo)", + data: Data{ + Coin: "Skycoin", + Version: "0.24.1", + Remark: "remark; foo", + }, + }, + { + name: "invalid characters in coin", + data: Data{ + Coin: "foo<>", + Version: "0.24.1", + }, + err: ErrIllegalChars, + }, + { + name: "invalid characters in version", + data: Data{ + Coin: "foo", + Version: "<0.24.1", + }, + err: errors.New(`Invalid character(s) found in major number "<0"`), + }, + { + name: "invalid characters in remark", + data: Data{ + Coin: "foo", + Version: "0.24.1", + Remark: "<>", + }, + err: ErrIllegalChars, + }, + { + name: "missing coin", + data: Data{ + Version: "0.24.1", + }, + err: errors.New("missing coin name"), + }, + { + name: "missing version", + data: Data{ + Coin: "Skycoin", + }, + err: errors.New("missing version"), + }, + { + name: "version is not valid semver", + data: Data{ + Coin: "Skycoin", + Version: "0.24", + }, + err: errors.New("No Major.Minor.Patch elements found"), + }, + { + name: "invalid remark", + data: Data{ + Coin: "skycoin", + Version: "0.24.1", + Remark: "\t", + }, + err: ErrIllegalChars, + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + userAgent, err := tc.data.Build() + + if tc.err != nil { + require.Equal(t, tc.err, err) + return + } + + require.NoError(t, err) + require.Equal(t, tc.userAgent, userAgent) + }) + } +} + +func TestParse(t *testing.T) { + + strOfLen := func(n int) string { + x := make([]string, n) + for i := range x { + x[i] = "a" + } + return strings.Join(x, "") + } + + cases := []struct { + name string + userAgent string + data Data + err error + }{ + { + name: "too long", + userAgent: fmt.Sprintf("skycoin:0.24.1[abcdefg](%s)", strOfLen(245)), + err: ErrTooLong, + }, + { + name: "no tab chars allowed", + userAgent: "skycoin:0.24.1(\t)", + err: ErrIllegalChars, + }, + { + name: "no newlines allowed", + userAgent: "skycoin:0.24.1(\n)", + err: ErrIllegalChars, + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + d, err := Parse(tc.userAgent) + if tc.err != nil { + require.Equal(t, tc.err, err) + return + } + + require.NoError(t, err) + require.Equal(t, tc.data, d) + }) + } +} + +func TestDataJSON(t *testing.T) { + d := Data{} + + x, err := json.Marshal(d) + require.NoError(t, err) + require.Equal(t, `""`, string(x)) + + d.Coin = "skycoin" + d.Version = "0.25.0-rc1" + + x, err = json.Marshal(d) + require.NoError(t, err) + require.Equal(t, `"skycoin:0.25.0-rc1"`, string(x)) + + var e Data + err = json.Unmarshal([]byte(x), &e) + require.NoError(t, err) + require.Equal(t, d, e) + + d.Remark = "foo; bar" + + x, err = json.Marshal(d) + require.NoError(t, err) + require.Equal(t, `"skycoin:0.25.0-rc1(foo; bar)"`, string(x)) + + e = Data{} + err = json.Unmarshal([]byte(x), &e) + require.NoError(t, err) + require.Equal(t, d, e) + + // Fails, does not parse to a string + err = json.Unmarshal([]byte("{}"), &e) + require.Error(t, err) + + // OK, empty string + e = Data{} + err = json.Unmarshal([]byte(`""`), &e) + require.NoError(t, err) + require.Equal(t, Data{}, e) + + // Fails, does not parse + err = json.Unmarshal([]byte(`"skycoin:0.24.1(<>)"`), &e) + require.Equal(t, ErrIllegalChars, err) +} + +func TestSanitize(t *testing.T) { + for i := 0; i < len(IllegalChars); i++ { + x := "t" + IllegalChars[i:i+1] + t.Run(x, func(t *testing.T) { + require.Equal(t, "t", Sanitize(x)) + }) + } + + for i := 0; i < 256; i++ { + j := byte(i) + if j >= ' ' || j <= '~' { + continue + } + + v := []byte{'t', j} + + t.Run(fmt.Sprintf("%q", j), func(t *testing.T) { + require.Equal(t, "t", Sanitize(string(v))) + }) + } + + z := "dog\t\t\t\ncat\x01t\xE3\xE4t" + require.Equal(t, "dogcattt", Sanitize(z)) + + // Should not have anything stripped + x := "Skycoin:0.24.1(foo; bar)" + require.Equal(t, x, Sanitize(x)) +} diff --git a/template/coin.template b/template/coin.template index 04aa268237..20315dcf8e 100755 --- a/template/coin.template +++ b/template/coin.template @@ -32,6 +32,9 @@ var ( logger = logging.MustGetLogger("main") + // CoinName name of coin + CoinName = "skycoin" + // GenesisSignatureStr hex string of genesis signature GenesisSignatureStr = "{{.GenesisSignatureStr}}" // GenesisAddressStr genesis address string @@ -54,6 +57,7 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ + CoinName: CoinName, GenesisSignatureStr: GenesisSignatureStr, GenesisAddressStr: GenesisAddressStr, GenesisCoinVolume: GenesisCoinVolume, From b20732dd9256cd29ace8e1d5f90bf9ed04251baf Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 00:07:05 +0800 Subject: [PATCH 275/399] Add maxlen param to encoder --- CHANGELOG.md | 1 + README.md | 5 + src/cipher/encoder/encoder.go | 137 ++++++++++++++++++-------- src/cipher/encoder/encoder_test.go | 138 +++++++++++++++++++++------ src/daemon/messages.go | 13 ++- src/daemon/messages_example_test.go | 28 +++++- src/daemon/messages_test.go | 70 +++++++++++--- src/daemon/mock_daemoner_test.go | 15 +++ src/util/useragent/useragent.go | 22 +++-- src/util/useragent/useragent_test.go | 11 +-- 10 files changed, 337 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e096609f..1edfb1e207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Coinhour burn factor can be configured at runtime with `COINHOUR_BURN_FACTOR` envvar - Daemon configured builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. The builds available for previous versions are configured for desktop client use. - `skycoin-cli` builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. +- A user agent string is sent in the wire protocol's introduction packet ### Fixed diff --git a/README.md b/README.md index 83577d3450..f502043c74 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ scratch, to remedy the rough edges in the Bitcoin design. - [Creating a new coin](#creating-a-new-coin) - [Running with a custom coin hour burn factor](#running-with-a-custom-coin-hour-burn-factor) - [URI Specification](#uri-specification) +- [Wire protocol user agent](#wire-protocol-user-agent) - [Development](#development) - [Modules](#modules) - [Client libraries](#client-libraries) @@ -238,6 +239,10 @@ Example Skycoin URIs: * `skycoin:2hYbwYudg34AjkJJCRVRcMeqSWHUixjkfwY?amount=123.456&hours=70` * `skycoin:2hYbwYudg34AjkJJCRVRcMeqSWHUixjkfwY?amount=123.456&hours=70&label=friend&message=Birthday%20Gift` +## Wire protocol user agent + +[Wire protocol user agent description](https://github.com/skycoin/skycoin/wiki/Wire-protocol-user-agent) + ## Development We have two branches: `master` and `develop`. diff --git a/src/cipher/encoder/encoder.go b/src/cipher/encoder/encoder.go index 0f6e98845c..c16887c1aa 100644 --- a/src/cipher/encoder/encoder.go +++ b/src/cipher/encoder/encoder.go @@ -16,6 +16,13 @@ // // Encoding of maps is supported, but note that the use of them results in non-deterministic output. // If determinism is required, do not use map. +// +// A length restriction to certain fields can be applied when decoding. +// Use the tag `,maxlen=` on a struct field to apply this restriction. +// `maxlen` works for string and slice types. The length is interpreted as the length +// of the string or the number of elements in the slice. +// Note that maxlen does not affect serialization; it may serialize objects which could fail deserialization. +// Callers should check their length restricted values manually prior to serialization. package encoder import ( @@ -24,6 +31,7 @@ import ( "log" "math" "reflect" + "strconv" "strings" ) @@ -36,6 +44,8 @@ var ( ErrInvalidOmitEmpty = errors.New("omitempty only supported for the final field in the struct") // ErrRemainingBytes bytes remain in buffer after deserializing object ErrRemainingBytes = errors.New("Bytes remain in buffer after deserializing object") + // ErrMaxLenExceeded a specified maximum length was exceeded when serializing or deserializing a variable length field + ErrMaxLenExceeded = errors.New("Maximum length exceeded for variable length field") ) // SerializeAtomic encoder an integer or boolean contained in `data` to bytes. @@ -164,16 +174,21 @@ func SerializeString(s string) []byte { } // DeserializeString deserializes a string from []byte, returning the string and the number of bytes read -func DeserializeString(b []byte) (string, int, error) { +func DeserializeString(in []byte, maxlen int) (string, int, error) { var s string v := reflect.ValueOf(&s) + v = v.Elem() + + inlen := len(in) + d1 := &decoder{buf: make([]byte, inlen)} + copy(d1.buf, in) - n, err := DeserializeRawToValue(b, v) + err := d1.value(v, maxlen) if err != nil { return "", 0, err } - return s, n, nil + return s, inlen - len(d1.buf), nil } // DeserializeRaw deserializes `in` buffer into return @@ -194,7 +209,7 @@ func DeserializeRaw(in []byte, data interface{}) error { d1 := &decoder{buf: make([]byte, len(in))} copy(d1.buf, in) - if err := d1.value(v); err != nil { + if err := d1.value(v, 0); err != nil { return err } @@ -223,7 +238,7 @@ func DeserializeRawToValue(in []byte, v reflect.Value) (int, error) { d1 := &decoder{buf: make([]byte, inlen)} copy(d1.buf, in) - err := d1.value(v) + err := d1.value(v, 0) if err != nil { return 0, err } @@ -363,21 +378,24 @@ func datasizeWrite(v reflect.Value) (int, error) { continue } - tag, omitempty := ParseTag(ff.Tag.Get("enc")) + tag := ff.Tag.Get("enc") + omitempty := TagOmitempty(tag) if omitempty && i != nFields-1 { log.Panic(ErrInvalidOmitEmpty) } - if tag != "-" { - fv := v.Field(i) - if !omitempty || !isEmpty(fv) { - s, err := datasizeWrite(fv) - if err != nil { - return 0, err - } - sum += s + if len(tag) > 0 && tag[0] == '-' { + continue + } + + fv := v.Field(i) + if !omitempty || !isEmpty(fv) { + s, err := datasizeWrite(fv) + if err != nil { + return 0, err } + sum += s } } return sum, nil @@ -398,18 +416,37 @@ func datasizeWrite(v reflect.Value) (int, error) { } } -// ParseTag to extract encoder args from raw string. Returns the tag name and if omitempty was specified -func ParseTag(tag string) (string, bool) { +func TagOmitempty(tag string) bool { + return strings.Contains(tag, ",omitempty") +} + +func tagName(tag string) string { commaIndex := strings.Index(tag, ",") if commaIndex == -1 { - return tag, false + return tag + } + + return tag[:commaIndex] +} + +func tagMaxLen(tag string) int { + maxlenIndex := strings.Index(tag, ",maxlen=") + if maxlenIndex == -1 { + return 0 } - if tag[commaIndex+1:] == "omitempty" { - return tag[:commaIndex], true + maxlenRem := tag[maxlenIndex+len(",maxlen="):] + commaIndex := strings.Index(maxlenRem, ",") + if commaIndex != -1 { + maxlenRem = maxlenRem[:commaIndex] } - return tag[:commaIndex], false + maxlen, err := strconv.Atoi(maxlenRem) + if err != nil { + panic("maxlen must be a number") + } + + return maxlen } /* @@ -586,7 +623,7 @@ func (d *decoder) int64() (int64, error) { func (e *encoder) int64(x int64) { e.uint64(uint64(x)) } -func (d *decoder) value(v reflect.Value) error { +func (d *decoder) value(v reflect.Value, maxlen int) error { kind := v.Kind() switch kind { case reflect.Array: @@ -607,7 +644,7 @@ func (d *decoder) value(v reflect.Value) error { d.buf = d.buf[length:] default: for i := 0; i < length; i++ { - if err := d.value(v.Index(i)); err != nil { + if err := d.value(v.Index(i), 0); err != nil { return err } } @@ -639,10 +676,10 @@ func (d *decoder) value(v reflect.Value) error { for i := 0; i < length; i++ { keyv := reflect.Indirect(reflect.New(key)) elemv := reflect.Indirect(reflect.New(elem)) - if err := d.value(keyv); err != nil { + if err := d.value(keyv, 0); err != nil { return err } - if err := d.value(elemv); err != nil { + if err := d.value(elemv, 0); err != nil { return err } v.SetMapIndex(keyv, elemv) @@ -667,6 +704,10 @@ func (d *decoder) value(v reflect.Value) error { return nil } + if maxlen > 0 && length > maxlen { + return ErrMaxLenExceeded + } + t := v.Type() elem := t.Elem() @@ -678,7 +719,7 @@ func (d *decoder) value(v reflect.Value) error { elemvs := reflect.MakeSlice(t, length, length) for i := 0; i < length; i++ { elemv := reflect.Indirect(elemvs.Index(i)) - if err := d.value(elemv); err != nil { + if err := d.value(elemv, 0); err != nil { return err } } @@ -695,20 +736,29 @@ func (d *decoder) value(v reflect.Value) error { continue } - tag, omitempty := ParseTag(ff.Tag.Get("enc")) + tag := ff.Tag.Get("enc") + omitempty := TagOmitempty(tag) if omitempty && i != nFields-1 { log.Panic(ErrInvalidOmitEmpty) } - if tag != "-" { - fv := v.Field(i) - if fv.CanSet() && ff.Name != "_" { - if err := d.value(fv); err != nil { - // omitempty fields at the end of the buffer are ignored - if !(omitempty && len(d.buf) == 0) { - return err - } + if len(tag) > 0 && tag[0] == '-' { + continue + } + + fv := v.Field(i) + if fv.CanSet() && ff.Name != "_" { + maxlen := tagMaxLen(tag) + + if err := d.value(fv, maxlen); err != nil { + if err == ErrMaxLenExceeded { + return err + } + + // omitempty fields at the end of the buffer are ignored if missing + if !omitempty || len(d.buf) != 0 { + return err } } } @@ -729,6 +779,10 @@ func (d *decoder) value(v reflect.Value) error { return ErrBufferUnderflow } + if maxlen > 0 && length > maxlen { + return ErrMaxLenExceeded + } + v.SetString(string(d.buf[:length])) d.buf = d.buf[length:] @@ -858,17 +912,20 @@ func (e *encoder) value(v reflect.Value) { continue } - tag, omitempty := ParseTag(ff.Tag.Get("enc")) + tag := ff.Tag.Get("enc") + omitempty := TagOmitempty(tag) if omitempty && i != nFields-1 { log.Panic(ErrInvalidOmitEmpty) } - if tag != "-" { - fv := v.Field(i) - if !(omitempty && isEmpty(fv)) && (fv.CanSet() || ff.Name != "_") { - e.value(fv) - } + if len(tag) > 0 && tag[0] == '-' { + continue + } + + fv := v.Field(i) + if !(omitempty && isEmpty(fv)) && (fv.CanSet() || ff.Name != "_") { + e.value(fv) } } diff --git a/src/cipher/encoder/encoder_test.go b/src/cipher/encoder/encoder_test.go index bb49d44c98..aab1c5a6d7 100644 --- a/src/cipher/encoder/encoder_test.go +++ b/src/cipher/encoder/encoder_test.go @@ -882,50 +882,36 @@ func TestOmitEmptyFinalFieldOnly(t *testing.T) { }) } -func TestParseTag(t *testing.T) { +func TestTagOmitempty(t *testing.T) { cases := []struct { tag string - name string omitempty bool }{ - { - tag: "foo", - name: "foo", - }, - { - tag: "foo,", - name: "foo", - }, - { - tag: "foo,asdasd", - name: "foo", - }, { tag: "foo,omitempty", - name: "foo", omitempty: true, }, { - tag: "omitempty", - name: "omitempty", + tag: "omitempty", + omitempty: false, }, { tag: ",omitempty", omitempty: true, }, { - tag: "", + tag: "", + omitempty: false, }, { - tag: "-", - name: "-", + tag: "-", + omitempty: false, }, } for _, tc := range cases { t.Run(tc.tag, func(t *testing.T) { - name, omitempty := ParseTag(tc.tag) - require.Equal(t, tc.name, name) + omitempty := TagOmitempty(tc.tag) require.Equal(t, tc.omitempty, omitempty) }) } @@ -1193,6 +1179,91 @@ func TestDeserializeRawNotPointer(t *testing.T) { require.NotEmpty(t, b) } +func TestDeserializeMaxLenExceeded(t *testing.T) { + // maxlen for strings + type Foo struct { + X string `enc:",maxlen=2"` + } + + b := Serialize(Foo{X: "foo"}) + require.NotEmpty(t, b) + + var f Foo + err := DeserializeRaw(b, &f) + require.Equal(t, ErrMaxLenExceeded, err) + + g := Foo{X: "fo"} + b = Serialize(g) + require.NotEmpty(t, b) + + f = Foo{} + err = DeserializeRaw(b, &f) + require.NoError(t, err) + require.Equal(t, g, f) + + // maxlen for slices + type Bar struct { + X []string `enc:",maxlen=2"` + } + + b = Serialize(Bar{X: []string{"f", "o", "o"}}) + require.NotEmpty(t, b) + + var k Bar + err = DeserializeRaw(b, &k) + require.Equal(t, ErrMaxLenExceeded, err) + + c := Bar{X: []string{"f", "o"}} + b = Serialize(c) + require.NotEmpty(t, b) + + k = Bar{} + err = DeserializeRaw(b, &k) + require.NoError(t, err) + require.Equal(t, c, k) + + // Invalid maxlen value panics + type Baz struct { + X string `enc:",maxlen=foo"` + } + + b = Serialize(Baz{X: "foo"}) + require.NotEmpty(t, b) + + var z Baz + require.Panics(t, func() { + DeserializeRaw(b, &z) + }) + + // maxlen for final omitempty byte array + type Car struct { + X string + Y []byte `enc:",omitempty,maxlen=2"` + } + + b = Serialize(Car{ + X: "foo", + Y: []byte("foo"), + }) + require.NotEmpty(t, b) + + var w Car + err = DeserializeRaw(b, &w) + require.Equal(t, ErrMaxLenExceeded, err) + + v := Car{ + X: "foo", + Y: []byte("fo"), + } + b = Serialize(v) + require.NotEmpty(t, b) + + w = Car{} + err = DeserializeRaw(b, &w) + require.NoError(t, err) + require.Equal(t, v, w) +} + func TestSerializeString(t *testing.T) { cases := []struct { s string @@ -1217,10 +1288,11 @@ func TestSerializeString(t *testing.T) { func TestDeserializeString(t *testing.T) { cases := []struct { - s string - x []byte - n int - err error + s string + x []byte + n int + maxLen int + err error }{ { s: "", @@ -1249,11 +1321,23 @@ func TestDeserializeString(t *testing.T) { x: []byte{3, 0, 0, 0, 'f', 'o', 'o', 'x'}, n: 7, }, + { + s: "foo", + x: []byte{3, 0, 0, 0, 'f', 'o', 'o', 'x'}, + maxLen: 2, + err: ErrMaxLenExceeded, + }, + { + s: "foo", + x: []byte{3, 0, 0, 0, 'f', 'o', 'o', 'x'}, + maxLen: 3, + n: 7, + }, } for _, tc := range cases { t.Run(fmt.Sprintf("s=%s err=%s", tc.s, tc.err), func(t *testing.T) { - s, n, err := DeserializeString(tc.x) + s, n, err := DeserializeString(tc.x, tc.maxLen) if tc.err != nil { require.Equal(t, tc.err, err) require.Equal(t, tc.n, n) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index a0bb20f17f..bd2e0af952 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -237,11 +237,22 @@ type IntroductionMessage struct { userAgentData useragent.Data `enc:"-"` // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. // Currently it contains the blockchain pubkey and user agent but will accept a client that does not provide it. + // If any of this data is provided, it must include a valid blockchain pubkey and a valid user agent string (maxlen=256). Extra []byte `enc:",omitempty"` + + // v26 fields: + // ExtraByte uint32 + // Pubkey cipher.Pubkey + // UserAgent string `enc:",maxlen=256"` + // Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey, userAgent string) *IntroductionMessage { + if len(userAgent) > useragent.MaxLen { + logger.Panicf("user agent %q exceeds max len %d", userAgent, useragent.MaxLen) + } + userAgentSerialized := encoder.SerializeString(userAgent) extra := make([]byte, len(pubkey)+len(userAgentSerialized)) @@ -309,7 +320,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } userAgentSerialized := intro.Extra[len(bcPubKey):] - userAgent, _, err := encoder.DeserializeString(userAgentSerialized) + userAgent, _, err := encoder.DeserializeString(userAgentSerialized, useragent.MaxLen) if err != nil { logger.WithError(err).Info("Extra data user agent string could not be deserialized") if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 00fae5e49f..0264d46da9 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -216,7 +216,7 @@ func (mai *MessagesAnnotationsIterator) Next() (Annotation, bool) { if i < mai.MaxField { f = t.Field(i) if f.Type.Kind() == reflect.Slice { - if _, omitempty := encoder.ParseTag(f.Tag.Get("enc")); omitempty { + if encoder.TagOmitempty(f.Tag.Get("enc")) { if i == mai.MaxField-1 { vF = v.Field(i) if vF.Len() == 0 { @@ -419,7 +419,7 @@ func ExampleIntroductionMessage() { pk := cipher.MustPubKeyFromHex("0328c576d3f420e7682058a981173a4b374c7cc5ff55bf394d3cf57059bbe6456a") - var message = NewIntroductionMessage(1234, 5, 7890, pk) + var message = NewIntroductionMessage(1234, 5, 7890, pk, "skycoin:0.24.1") fmt.Println("IntroductionMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) @@ -429,12 +429,12 @@ func ExampleIntroductionMessage() { } // Output: // IntroductionMessage: - // 0x0000 | 33 00 00 00 ....................................... Length + // 0x0000 | 45 00 00 00 ....................................... Length // 0x0004 | 49 4e 54 52 ....................................... Prefix // 0x0008 | d2 04 00 00 ....................................... Mirror // 0x000c | d2 1e ............................................. Port // 0x000e | 05 00 00 00 ....................................... Version - // 0x0012 | 21 00 00 00 ....................................... Extra length + // 0x0012 | 33 00 00 00 ....................................... Extra length // 0x0016 | 03 ................................................ Extra[0] // 0x0017 | 28 ................................................ Extra[1] // 0x0018 | c5 ................................................ Extra[2] @@ -468,7 +468,25 @@ func ExampleIntroductionMessage() { // 0x0034 | e6 ................................................ Extra[30] // 0x0035 | 45 ................................................ Extra[31] // 0x0036 | 6a ................................................ Extra[32] - // 0x0037 | + // 0x0037 | 0e ................................................ Extra[33] + // 0x0038 | 00 ................................................ Extra[34] + // 0x0039 | 00 ................................................ Extra[35] + // 0x003a | 00 ................................................ Extra[36] + // 0x003b | 73 ................................................ Extra[37] + // 0x003c | 6b ................................................ Extra[38] + // 0x003d | 79 ................................................ Extra[39] + // 0x003e | 63 ................................................ Extra[40] + // 0x003f | 6f ................................................ Extra[41] + // 0x0040 | 69 ................................................ Extra[42] + // 0x0041 | 6e ................................................ Extra[43] + // 0x0042 | 3a ................................................ Extra[44] + // 0x0043 | 30 ................................................ Extra[45] + // 0x0044 | 2e ................................................ Extra[46] + // 0x0045 | 32 ................................................ Extra[47] + // 0x0046 | 34 ................................................ Extra[48] + // 0x0047 | 2e ................................................ Extra[49] + // 0x0048 | 31 ................................................ Extra[50] + // 0x0049 | } func ExampleGetPeersMessage() { diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index f285242232..119413a990 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -69,7 +69,7 @@ func TestIntroductionMessage(t *testing.T) { err: nil, }, { - name: "INTR message with pubkey", + name: "INTR message with pubkey but empty user agent", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ mirror: 10000, @@ -77,19 +77,20 @@ func TestIntroductionMessage(t *testing.T) { getMirrorPortResult: mirrorPortResult{ exist: false, }, - pubkey: pubkey, + pubkey: pubkey, + disconnectReason: ErrDisconnectInvalidUserAgent, }, intro: &IntroductionMessage{ Mirror: 10001, Port: 6000, Version: 1, - valid: true, - Extra: pubkey[:], + valid: false, + Extra: append(pubkey[:], []byte{0, 0, 0, 0}...), }, - err: nil, + err: ErrDisconnectInvalidUserAgent, }, { - name: "INTR message with pubkey", + name: "INTR message with pubkey and user agent", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ mirror: 10000, @@ -104,12 +105,12 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Extra: pubkey[:], + Extra: append(pubkey[:], encoder.SerializeString("skycoin:0.24.1")...), }, err: nil, }, { - name: "INTR message with pubkey and additional data", + name: "INTR message with pubkey, user agent and additional data", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ mirror: 10000, @@ -124,7 +125,7 @@ func TestIntroductionMessage(t *testing.T) { Port: 6000, Version: 1, valid: true, - Extra: append(pubkey[:], []byte("additional data")...), + Extra: append(append(pubkey[:], encoder.SerializeString("skycoin:0.24.1")...), []byte("additional data")...), }, err: nil, }, @@ -144,8 +145,8 @@ func TestIntroductionMessage(t *testing.T) { Mirror: 10001, Port: 6000, Version: 1, - valid: true, - Extra: pubkey2[:], + valid: false, + Extra: append(pubkey2[:], encoder.SerializeString("skycoin:0.24.1")...), }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -165,11 +166,53 @@ func TestIntroductionMessage(t *testing.T) { Mirror: 10001, Port: 6000, Version: 1, - valid: true, + valid: false, Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, + { + name: "INTR message with pubkey, malformed user agent bytes", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + protocolVersion: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + disconnectReason: ErrDisconnectInvalidExtraData, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: false, + Extra: append(pubkey[:], []byte{1, 2, 3}...), + }, + err: ErrDisconnectInvalidExtraData, + }, + { + name: "INTR message with pubkey, invalid user agent after parsing", + addr: "121.121.121.121:6000", + mockValue: daemonMockValue{ + mirror: 10000, + protocolVersion: 1, + getMirrorPortResult: mirrorPortResult{ + exist: false, + }, + pubkey: pubkey, + disconnectReason: ErrDisconnectInvalidUserAgent, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + Port: 6000, + Version: 1, + valid: false, + Extra: append(pubkey[:], encoder.SerializeString("skycoin:0241")...), + }, + err: ErrDisconnectInvalidUserAgent, + }, { name: "Disconnect self connection", mockValue: daemonMockValue{ @@ -212,7 +255,7 @@ func TestIntroductionMessage(t *testing.T) { err: ErrDisconnectIncomprehensibleError, }, { - name: "incomming connection", + name: "incoming connection", addr: "121.121.121.121:12345", mockValue: daemonMockValue{ mirror: 10000, @@ -266,6 +309,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("DaemonConfig").Return(DaemonConfig{ ProtocolVersion: int32(tc.mockValue.protocolVersion), MinProtocolVersion: int32(tc.mockValue.minProtocolVersion), + UserAgent: "skycoin:0.24.1", }) d.On("Mirror").Return(tc.mockValue.mirror) d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index bb54805a00..d271b45bbf 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -7,6 +7,7 @@ import coin "github.com/skycoin/skycoin/src/coin" import gnet "github.com/skycoin/skycoin/src/daemon/gnet" import mock "github.com/stretchr/testify/mock" import pex "github.com/skycoin/skycoin/src/daemon/pex" +import useragent "github.com/skycoin/skycoin/src/util/useragent" import visor "github.com/skycoin/skycoin/src/visor" // MockDaemoner is an autogenerated mock type for the Daemoner type @@ -393,6 +394,20 @@ func (_m *MockDaemoner) RecordPeerHeight(addr string, height uint64) { _m.Called(addr, height) } +// RecordUserAgent provides a mock function with given fields: addr, userAgent +func (_m *MockDaemoner) RecordUserAgent(addr string, userAgent useragent.Data) error { + ret := _m.Called(addr, userAgent) + + var r0 error + if rf, ok := ret.Get(0).(func(string, useragent.Data) error); ok { + r0 = rf(addr, userAgent) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // RemoveFromExpectingIntroductions provides a mock function with given fields: addr func (_m *MockDaemoner) RemoveFromExpectingIntroductions(addr string) { _m.Called(addr) diff --git a/src/util/useragent/useragent.go b/src/util/useragent/useragent.go index 04082f9f24..e87d5bf39d 100644 --- a/src/util/useragent/useragent.go +++ b/src/util/useragent/useragent.go @@ -1,16 +1,16 @@ // Package useragent implements methods for managing Skycoin user agents. // // A skycoin user agent has the following format: +// // `$NAME:$VERSION[$GIT_HASH]($REMARK)` // // `$NAME` and `$VERSION` are required. // // * `$NAME` is the coin or application's name, e.g. `Skycoin`. It can contain the following characters: `A-Za-z0-9\-_+`. -// * `$VERSION` must start with a valid semver version, e.g. `1.2.3`, and maybe follow by additional characters, e.g. `1.2.3-rc1` -// * `$GIT_HASH` is optional. If not present, the enclosing brackets `[]` should be omitted. -// The value of `$GIT_HASH` should be the short hash of the git head of the current build. +// * `$VERSION` must be a valid [semver](http://semver.org/) version, e.g. `1.2.3` or `1.2.3-rc1`. +// Semver has the option of including build metadata such as the git commit hash, but this is not included by the default client. // * `$REMARK` is optional. If not present, the enclosing brackets `()` should be omitted. -// It can contain the following characters: `A-Za-z0-9\-_+;:!$%,.=?~ ` (include the space character). +// It can contain the following characters: `A-Za-z0-9\-_+;:!$%,.=?~ ` (includes the space character). package useragent import ( @@ -29,7 +29,7 @@ const ( // MaxLen the maximum length of a user agent MaxLen = 256 - pattern = `^([A-Za-z0-9\-_+]+):([0-9]+\.[0-9]+\.[0-9][\-A-Za-z0-9]*)(\([A-Za-z0-9\-_+;:!$%,.=?~ ]+\))?$` + pattern = `^([A-Za-z0-9\-_+]+):([0-9]+\.[0-9]+\.[0-9][A-Za-z0-9\-.+]*)(\([A-Za-z0-9\-_+;:!$%,.=?~ ]+\))?$` ) var ( @@ -43,6 +43,8 @@ var ( ErrTooLong = errors.New("User agent is too long") // ErrMalformed user agent does not match the user agent pattern ErrMalformed = errors.New("User agent is malformed") + // ErrEmpty user agent is an empty string + ErrEmpty = errors.New("User agent is an empty string") ) func init() { @@ -75,7 +77,6 @@ func (d Data) Build() (string, error) { s := d.build() if err := validate(s); err != nil { - fmt.Println("validate failed") return "", err } @@ -131,6 +132,10 @@ func (d *Data) UnmarshalJSON(v []byte) error { // Parse parses a user agent string to Data func Parse(userAgent string) (Data, error) { + if len(userAgent) == 0 { + return Data{}, ErrEmpty + } + if err := validate(userAgent); err != nil { return Data{}, err } @@ -152,6 +157,10 @@ func Parse(userAgent string) (Data, error) { version := m[2] remark := m[3] + if _, err := semver.Parse(version); err != nil { + return Data{}, errors.New("User agent version is not a valid semver: %v", err) + } + remark = strings.TrimPrefix(remark, "(") remark = strings.TrimSuffix(remark, ")") @@ -168,7 +177,6 @@ func validate(userAgent string) error { return ErrTooLong } - fmt.Println("validate", userAgent) if illegalCharsCheckRe.MatchString(userAgent) { return ErrIllegalChars } diff --git a/src/util/useragent/useragent_test.go b/src/util/useragent/useragent_test.go index 5e5dc2572b..2687958a87 100644 --- a/src/util/useragent/useragent_test.go +++ b/src/util/useragent/useragent_test.go @@ -108,15 +108,6 @@ func TestDataBuild(t *testing.T) { } func TestParse(t *testing.T) { - - strOfLen := func(n int) string { - x := make([]string, n) - for i := range x { - x[i] = "a" - } - return strings.Join(x, "") - } - cases := []struct { name string userAgent string @@ -125,7 +116,7 @@ func TestParse(t *testing.T) { }{ { name: "too long", - userAgent: fmt.Sprintf("skycoin:0.24.1[abcdefg](%s)", strOfLen(245)), + userAgent: fmt.Sprintf("skycoin:0.24.1[abcdefg](%s)", strings.Repeat("a", 245)), err: ErrTooLong, }, { From 6b5b23c887e27fc754158149dbf062a19f503fcb Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 00:33:30 +0800 Subject: [PATCH 276/399] Save user agent to peers.json --- cmd/newcoin/newcoin.go | 6 +++--- src/daemon/gateway.go | 5 +---- src/daemon/messages.go | 13 ++++++------- src/daemon/pex/peerlist.go | 4 ++++ src/util/useragent/useragent.go | 14 +++++++++++--- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/cmd/newcoin/newcoin.go b/cmd/newcoin/newcoin.go index fcbfa62751..dec3e083a9 100644 --- a/cmd/newcoin/newcoin.go +++ b/cmd/newcoin/newcoin.go @@ -4,7 +4,6 @@ newcoin generates a new coin cmd from a toml configuration file package main import ( - "errors" "fmt" "regexp" @@ -16,6 +15,7 @@ import ( "github.com/skycoin/skycoin/src/skycoin" "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skycoin/src/util/useragent" ) const ( @@ -243,9 +243,9 @@ func createCoinCommand() cli.Command { } func validateCoinName(s string) error { - x := regexp.MustCompile(`^[A-Za-z0-9\-_+]+$`) + x := regexp.MustCompile(fmt.Sprintf(`^%s$`, useragent.NamePattern)) if !x.MatchString(s) { - return errors.New("invalid coin name. must only contain the characters A-Za-z0-9 and -_+") + return fmt.Errorf("invalid coin name. must only contain the characters %s", useragent.NamePattern) } return nil } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index a9078ec246..bf40ea4199 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -114,7 +114,6 @@ func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { if gw.d.pool.Pool == nil { - logger.Debug("getOutgoingConnections pool is nil") return nil, nil } @@ -124,8 +123,6 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { return nil, err } - logger.Info("getOutgoingConnections: Number of conns:", len(cs)) - conns := make([]Connection, 0, len(cs)) for _, c := range cs { @@ -196,7 +193,7 @@ func (gw *Gateway) newConnection(c *gnet.Connection) *Connection { var err error userAgent, err = pexPeer.UserAgent.Build() if err != nil { - logger.WithError(err).WithField("addr", addr).Error("pex peer's user agent data cannot be built to string") + logger.Critical().WithError(err).WithField("addr", addr).Error("pex peer's user agent data cannot be built to string") } } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index bd2e0af952..5dcfcce0f4 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -223,7 +223,7 @@ func (gpm *GivePeersMessage) Process(d Daemoner) { d.AddPeers(peers) } -// IntroductionMessage an IntroductionMessage is sent on first connect by both parties +// IntroductionMessage is sent on first connect by both parties type IntroductionMessage struct { // Mirror is a random value generated on client startup that is used to identify self-connections Mirror uint32 @@ -235,16 +235,15 @@ type IntroductionMessage struct { // We validate the message in Handle() and cache the result for Process() valid bool `enc:"-"` // skip it during encoding userAgentData useragent.Data `enc:"-"` + // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. // Currently it contains the blockchain pubkey and user agent but will accept a client that does not provide it. // If any of this data is provided, it must include a valid blockchain pubkey and a valid user agent string (maxlen=256). - Extra []byte `enc:",omitempty"` - - // v26 fields: - // ExtraByte uint32 - // Pubkey cipher.Pubkey + // Contents of extra: + // ExtraByte uint32 // length prefix of []byte + // Pubkey cipher.Pubkey // blockchain pubkey // UserAgent string `enc:",maxlen=256"` - // Extra []byte `enc:",omitempty"` + Extra []byte `enc:",omitempty"` } // NewIntroductionMessage creates introduction message diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index af42b54b8c..0c869f39ba 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -52,6 +52,7 @@ func loadCachedPeersFile(path string) (map[string]*Peer, error) { } if err != nil { + logger.WithField("path", path).WithError(err).Error("Failed to load peers file") return nil, err } @@ -324,6 +325,7 @@ type PeerJSON struct { Trusted bool // Whether this peer is trusted HasIncomePort *bool `json:"HasIncomePort,omitempty"` // Whether this peer has incoming port [DEPRECATED] HasIncomingPort *bool // Whether this peer has incoming port + UserAgent useragent.Data } // newPeerJSON returns a PeerJSON from a Peer @@ -334,6 +336,7 @@ func newPeerJSON(p Peer) PeerJSON { Private: p.Private, Trusted: p.Trusted, HasIncomingPort: &p.HasIncomingPort, + UserAgent: p.UserAgent, } } @@ -377,5 +380,6 @@ func newPeerFromJSON(p PeerJSON) (*Peer, error) { Private: p.Private, Trusted: p.Trusted, HasIncomingPort: hasIncomingPort, + UserAgent: p.UserAgent, }, nil } diff --git a/src/util/useragent/useragent.go b/src/util/useragent/useragent.go index e87d5bf39d..a864c372fa 100644 --- a/src/util/useragent/useragent.go +++ b/src/util/useragent/useragent.go @@ -29,7 +29,15 @@ const ( // MaxLen the maximum length of a user agent MaxLen = 256 - pattern = `^([A-Za-z0-9\-_+]+):([0-9]+\.[0-9]+\.[0-9][A-Za-z0-9\-.+]*)(\([A-Za-z0-9\-_+;:!$%,.=?~ ]+\))?$` + // NamePattern is the regex pattern for the name portion of the user agent + NamePattern = `[A-Za-z0-9\-_+]+` + // VersionPattern is the regex pattern for the version portion of the user agent + VersionPattern = `[0-9]+\.[0-9]+\.[0-9][A-Za-z0-9\-.+]*` + // RemarkPattern is the regex pattern for the remark portion of the user agent + RemarkPattern = `[A-Za-z0-9\-_+;:!$%,.=?~ ]+` + + // Pattern is the regex pattern for the user agent in entirety + Pattern = `^(` + NamePattern + `):(` + VersionPattern + `)(\(` + RemarkPattern + `\))?$` ) var ( @@ -50,7 +58,7 @@ var ( func init() { illegalCharsSanitizeRe = regexp.MustCompile(fmt.Sprintf("([^[:print:]]|[%s])+", IllegalChars)) illegalCharsCheckRe = regexp.MustCompile(fmt.Sprintf("[^[:print:]]|[%s]", IllegalChars)) - re = regexp.MustCompile(pattern) + re = regexp.MustCompile(Pattern) } // Data holds parsed user agent data @@ -158,7 +166,7 @@ func Parse(userAgent string) (Data, error) { remark := m[3] if _, err := semver.Parse(version); err != nil { - return Data{}, errors.New("User agent version is not a valid semver: %v", err) + return Data{}, fmt.Errorf("User agent version is not a valid semver: %v", err) } remark = strings.TrimPrefix(remark, "(") From 0e6ffc073ada67d2f1dd56ee027a595df130ddf3 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 00:34:59 +0800 Subject: [PATCH 277/399] Fixup --- template/coin.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/coin.template b/template/coin.template index 20315dcf8e..ee1e647eee 100755 --- a/template/coin.template +++ b/template/coin.template @@ -33,7 +33,7 @@ var ( logger = logging.MustGetLogger("main") // CoinName name of coin - CoinName = "skycoin" + CoinName = "{{.CoinName}}" // GenesisSignatureStr hex string of genesis signature GenesisSignatureStr = "{{.GenesisSignatureStr}}" From 12a27f1bd43baed1350038160282b5dc01fd5928 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 10:20:28 +0800 Subject: [PATCH 278/399] Fix lint --- src/cipher/encoder/encoder.go | 3 ++- src/cipher/encoder/encoder_test.go | 2 +- src/daemon/messages.go | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cipher/encoder/encoder.go b/src/cipher/encoder/encoder.go index c16887c1aa..6d4ceef4ac 100644 --- a/src/cipher/encoder/encoder.go +++ b/src/cipher/encoder/encoder.go @@ -416,11 +416,12 @@ func datasizeWrite(v reflect.Value) (int, error) { } } +// TagOmitempty returns true if the tag specifies omitempty func TagOmitempty(tag string) bool { return strings.Contains(tag, ",omitempty") } -func tagName(tag string) string { +func tagName(tag string) string { // nolint: deadcode,megacheck commaIndex := strings.Index(tag, ",") if commaIndex == -1 { return tag diff --git a/src/cipher/encoder/encoder_test.go b/src/cipher/encoder/encoder_test.go index aab1c5a6d7..34cdf99726 100644 --- a/src/cipher/encoder/encoder_test.go +++ b/src/cipher/encoder/encoder_test.go @@ -1232,7 +1232,7 @@ func TestDeserializeMaxLenExceeded(t *testing.T) { var z Baz require.Panics(t, func() { - DeserializeRaw(b, &z) + _ = DeserializeRaw(b, &z) // nolint: errcheck }) // maxlen for final omitempty byte array diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 5dcfcce0f4..0dffaddd49 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -404,7 +404,7 @@ func (intro *IntroductionMessage) Process(d Daemoner) { if err := d.RecordConnectionMirror(a, intro.Mirror); err != nil { // This should never happen, but the program should not allow itself // to be corrupted in case it does - logger.Errorf("Invalid port for connection %s", a) + logger.WithError(err).WithField("addr", a).Error("Invalid port for connection") if err := d.Disconnect(intro.c.Addr, ErrDisconnectIncomprehensibleError); err != nil { logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") } @@ -412,11 +412,13 @@ func (intro *IntroductionMessage) Process(d Daemoner) { } // Record the user agent of the peer - d.RecordUserAgent(a, intro.userAgentData) + if err := d.RecordUserAgent(a, intro.userAgentData); err != nil { + logger.WithError(err).WithField("addr", a).Errorf("RecordUserAgent failed, userAgentData=%+v", intro.userAgentData) + } // Request blocks immediately after they're confirmed if err := d.RequestBlocksFromAddr(intro.c.Addr); err != nil { - logger.Warning(err) + logger.WithError(err).Warning() } else { logger.Debugf("Successfully requested blocks from %s", intro.c.Addr) } From 174b02d2b975450426bb9405a781f24b98257ad7 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 11:38:40 +0800 Subject: [PATCH 279/399] Fixup --- src/daemon/gateway.go | 2 +- src/util/useragent/useragent.go | 5 +++++ src/util/useragent/useragent_test.go | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index bf40ea4199..bbf6d948c8 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -189,7 +189,7 @@ func (gw *Gateway) newConnection(c *gnet.Connection) *Connection { var userAgent string pexPeer, exist := gw.d.pex.GetPeerByAddr(addr) - if exist { + if exist && !pexPeer.UserAgent.Empty() { var err error userAgent, err = pexPeer.UserAgent.Build() if err != nil { diff --git a/src/util/useragent/useragent.go b/src/util/useragent/useragent.go index a864c372fa..b04763f11d 100644 --- a/src/util/useragent/useragent.go +++ b/src/util/useragent/useragent.go @@ -68,6 +68,11 @@ type Data struct { Remark string } +// Empty returns true if the Data is empty +func (d Data) Empty() bool { + return d == (Data{}) +} + // Build builds a user agent string. Returns an error if the user agent would be invalid. func (d Data) Build() (string, error) { if d.Coin == "" { diff --git a/src/util/useragent/useragent_test.go b/src/util/useragent/useragent_test.go index 2687958a87..787ddbee1e 100644 --- a/src/util/useragent/useragent_test.go +++ b/src/util/useragent/useragent_test.go @@ -218,3 +218,12 @@ func TestSanitize(t *testing.T) { x := "Skycoin:0.24.1(foo; bar)" require.Equal(t, x, Sanitize(x)) } + +func TestEmpty(t *testing.T) { + var d Data + require.True(t, d.Empty()) + + d.Coin = "skycoin" + d.Version = "0.24.1" + require.False(t, d.Empty()) +} From e2213bb8b09256d273f8d85b50deb299ea70cd74 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 15:39:45 +0800 Subject: [PATCH 280/399] Add deprecation warning for /explorer/address --- CHANGELOG.md | 2 + src/api/README.md | 122 ++++++++++++++++++++++++++++++++++++++++++-- src/api/explorer.go | 2 + 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e096609f..ef219c509d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ In the v0.26.0 these features and functions will be removed. If you have a need - JSON-RPC 2.0 interface (this is no longer used by the CLI tool, and the REST API supports everything the JSON-RPC 2.0 API does). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from-the-jsonrpc-api - `/api/v1/wallet/spend` endpoint (use `POST /api/v1/wallet/transaction` followed by `POST /api/v1/injectTransaction` instead). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from--api-v1-spend - The unversioned REST API (the `-enable-unversioned-api` option will be removed, prefix your API requests with `/api/v1`). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from-the-unversioned-api +- `/api/v1/explorer/address` endpoint (use `GET /api/v1/transactions?verbose=1` instead). See https://github.com/skycoin/skycoin/blob/develop/src/api/README.md#migrating-from--api-v1-explorer-address ### Notice @@ -79,6 +80,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateWallet` renamed to `cli walletCreate` - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. +- `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` ### Removed diff --git a/src/api/README.md b/src/api/README.md index 02fc9fc226..7199a51ba4 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -49,7 +49,7 @@ and the `/api/v1` prefix will be required for previously unversioned endpoints. - [Get transaction info by id](#get-transaction-info-by-id) - [Get raw transaction by id](#get-raw-transaction-by-id) - [Inject raw transaction](#inject-raw-transaction) - - [Get transactions that are addresses related](#get-transactions-that-are-addresses-related) + - [Get transactions for addresses](#get-transactions-for-addresses) - [Resend unconfirmed transactions](#resend-unconfirmed-transactions) - [Verify encoded transaction](#verify-encoded-transaction) - [Block APIs](#block-apis) @@ -76,6 +76,7 @@ and the `/api/v1` prefix will be required for previously unversioned endpoints. - [Migrating from the unversioned API](#migrating-from-the-unversioned-api) - [Migrating from the JSONRPC API](#migrating-from-the-jsonrpc-api) - [Migrating from /api/v1/spend](#migrating-from-apiv1spend) +- [Migration from /api/v1/explorer/address](#migration-from-apiv1exploreraddress) @@ -1889,7 +1890,7 @@ Result: "3615fc23cc12a5cb9190878a2151d1cf54129ff0cd90e5fc4f4e7debebad6868" ``` -### Get transactions that are addresses related +### Get transactions for addresses API sets: `READ` @@ -1908,18 +1909,22 @@ If the transaction is confirmed, the calculated hours are the hours the transact If the transaction is unconfirmed, the calculated hours are based upon the current system time, and are approximately equal to the hours the output would have if it become confirmed immediately. -To get address related confirmed transactions: +The `"time"` field at the top level of each object in the response array indicates either the confirmed timestamp of a confirmed +transaction or the last received timestamp of an unconfirmed transaction. + +To get confirmed transactions for one or more addresses: ```sh curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY&confirmed=1 ``` -To get address related unconfirmed transactions: +To unconfirmed transactions for one or more addresses: + ```sh curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY&confirmed=0 ``` -To get all addresses related transactions: +To both confirmed and unconfirmed transactions for one or more addresses: ```sh curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY @@ -3220,6 +3225,8 @@ Args: address ``` +**Deprecated** Use `/api/v1/transactions?verbose=1&addrs=` instead. + Example: ```sh @@ -3811,3 +3818,108 @@ The request header `Content-Type` must be `application/json`. The response to `POST /api/v1/wallet/transaction` will include a verbose decoded transaction with details and the hex-encoded binary transaction in the `"encoded_transaction"` field. Use the value of `"encoded_transaction"` as the `"rawtx"` value in the request to `/api/v1/injectTransaction`. + +## Migration from /api/v1/explorer/address + +The `GET /api/v1/explorer/address` endpoint is deprecated and will be removed in v0.26.0. + +To migrate from it, use [`GET /api/v1/transactions?verbose=1`](#get-transactions-for-addresses). + +`/api/v1/explorer/address` accepted a single `address` query parameter. `/api/v1/transactions` uses an `addrs` query parameter and +accepts multiple addresses at once. + +The response data is the same but the structure is slightly different. Compare the follow two example responses: + +`/api/v1/explorer/address?address=WzPDgdfL1NzSbX96tscUNXUqtCRLjaBugC`: + +```json +[ + { + "status": { + "confirmed": true, + "unconfirmed": false, + "height": 38076, + "block_seq": 15493 + }, + "timestamp": 1518878675, + "length": 183, + "type": 0, + "txid": "6d8e2f8b436a2f38d604b3aa1196ef2176779c5e11e33fbdd09f993fe659c39f", + "inner_hash": "8da7c64dcedeeb6aa1e0d21fb84a0028dcd68e6801f1a3cc0224fdd50682046f", + "fee": 126249, + "sigs": [ + "c60e43980497daad59b4c72a2eac053b1584f960c57a5e6ac8337118dccfcee4045da3f60d9be674867862a13fdd87af90f4b85cbf39913bde13674e0a039b7800" + ], + "inputs": [ + { + "uxid": "349b06e5707f633fd2d8f048b687b40462d875d968b246831434fb5ab5dcac38", + "owner": "WzPDgdfL1NzSbX96tscUNXUqtCRLjaBugC", + "coins": "125.000000", + "hours": 34596, + "calculated_hours": 178174 + } + ], + "outputs": [ + { + "uxid": "5b4a79c7de2e9099e083bbc8096619ae76ba6fbe34875c61bbe2d3bfa6b18b99", + "dst": "2NfNKsaGJEndpSajJ6TsKJfsdDjW2gFsjXg", + "coins": "125.000000", + "hours": 51925 + } + ] + } +] +``` + +`/api/v1/transactions?verbose=1&addrs=WzPDgdfL1NzSbX96tscUNXUqtCRLjaBugC`: + +```json +[ + { + "status": { + "confirmed": true, + "unconfirmed": false, + "height": 57564, + "block_seq": 7498 + }, + "time": 1514743602, + "txn": { + "timestamp": 1514743602, + "length": 220, + "type": 0, + "txid": "df5bcef198fe6e96d496c30482730f895cabc1d55b338afe5633b0c2889d02f9", + "inner_hash": "4677ff9b9b56485495a45693cc09f8496199929fccb52091d32f2d3cf2ee8a41", + "fee": 69193, + "sigs": [ + "8e1f6f621a11f737ac2031be975d4b2fc17bf9f17a0da0a2fe219ee018011ab506e2ad0367be302a8d859cc355c552313389cd0aa9fa98dc7d2085a52f11ef5a00" + ], + "inputs": [ + { + "uxid": "2374201ff29f1c024ccfc6c53160e741d06720562853ad3613c121acd8389031", + "owner": "2GgFvqoyk9RjwVzj8tqfcXVXB4orBwoc9qv", + "coins": "162768.000000", + "hours": 485, + "calculated_hours": 138385 + } + ], + "outputs": [ + { + "uxid": "63f299fc85fe6fc34d392718eee55909837c7231b6ffd93e5a9a844c4375b313", + "dst": "2GgFvqoyk9RjwVzj8tqfcXVXB4orBwoc9qv", + "coins": "162643.000000", + "hours": 34596 + }, + { + "uxid": "349b06e5707f633fd2d8f048b687b40462d875d968b246831434fb5ab5dcac38", + "dst": "WzPDgdfL1NzSbX96tscUNXUqtCRLjaBugC", + "coins": "125.000000", + "hours": 34596 + } + ] + } + } +] +``` + +The transaction data is wrapped in a `"txn"` field. A `"time"` field is present at the top level. This `"time"` field +is either the confirmation timestamp of a confirmed transaction or the last received time of an unconfirmed transaction. diff --git a/src/api/explorer.go b/src/api/explorer.go index 33085fe4a5..f48c99e6cf 100644 --- a/src/api/explorer.go +++ b/src/api/explorer.go @@ -163,6 +163,8 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { // address [string] func transactionsForAddressHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + logger.Critical().Warning("Call to deprecated /api/v1/explorer/address endpoint") + if r.Method != http.MethodGet { wh.Error405(w) return From cc936c4c38066cd0ad76df7e6f55b180dc94f606 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 19 Oct 2018 15:41:21 +0800 Subject: [PATCH 281/399] Fixups --- src/api/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/README.md b/src/api/README.md index 7199a51ba4..b6d7e70939 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -1918,13 +1918,13 @@ To get confirmed transactions for one or more addresses: curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY&confirmed=1 ``` -To unconfirmed transactions for one or more addresses: +To get unconfirmed transactions for one or more addresses: ```sh curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY&confirmed=0 ``` -To both confirmed and unconfirmed transactions for one or more addresses: +To get both confirmed and unconfirmed transactions for one or more addresses: ```sh curl http://127.0.0.1:6420/api/v1/transactions?addrs=7cpQ7t3PZZXvjTst8G7Uvs7XH4LeM8fBPD,6dkVxyKFbFKg9Vdg6HPg1UANLByYRqkrdY From 28327cbcd34e93591e43a0a89347bdc472a8bb50 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 09:36:42 +0800 Subject: [PATCH 282/399] Expose user agent and coin name in /health --- CHANGELOG.md | 2 +- ci-scripts/integration-test-stable.sh | 6 +++-- cmd/cli/README.md | 2 ++ src/api/README.md | 2 ++ src/api/health.go | 12 ++++++++- src/api/health_test.go | 13 +++++++++- src/api/http.go | 16 +++++++++--- src/api/integration/integration_test.go | 13 ++++++++++ .../status-csrf-enabled-no-unconfirmed.golden | 5 +++- .../testdata/status-csrf-enabled.golden | 2 ++ .../testdata/status-no-unconfirmed.golden | 2 ++ src/cli/integration/testdata/status.golden | 2 ++ src/daemon/daemon.go | 26 ++++++++++++++----- src/daemon/messages.go | 3 +++ src/daemon/messages_test.go | 6 ++++- src/skycoin/config.go | 7 +++-- src/skycoin/skycoin.go | 12 ++++++--- 17 files changed, 106 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1edfb1e207..27c76dbc28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Add `-csv` option to `cli send` and `cli createRawTransaction`, which will send coins to multiple addresses defined in a csv file - Add `-disable-default-peers` option to disable the default hardcoded peers and mark all cached peers as untrusted - Add `-custom-peers-file` to load peers from disk. This peers file is a newline separate list of `ip:port` strings -- Add `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled` configuration settings to the `/api/v1/health` endpoint response +- Add `user_agent`, `coin`, `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled` configuration settings to the `/api/v1/health` endpoint response - Add `verbose` flag to `/api/v1/block`, `/api/v1/blocks`, `/api/v1/last_blocks`, `/api/v1/pendingTxs`, `/api/v1/transaction`, `/api/v1/transactions`, `/api/v1/wallet/transactions` to return verbose block data, which includes the address, coins, hours and calculcated_hours of the block's transaction's inputs - Add `encoded` flag to `/api/v1/transaction` to return an encoded transaction - Add `-http-prof-host` option to choose the HTTP profiler's bind hostname (defaults to `localhost:6060`) diff --git a/ci-scripts/integration-test-stable.sh b/ci-scripts/integration-test-stable.sh index e482e04c3f..08d822b636 100755 --- a/ci-scripts/integration-test-stable.sh +++ b/ci-scripts/integration-test-stable.sh @@ -116,7 +116,8 @@ set +e if [[ -z $TEST || $TEST = "api" ]]; then -SKYCOIN_INTEGRATION_TESTS=1 SKYCOIN_INTEGRATION_TEST_MODE=$MODE SKYCOIN_NODE_HOST=$HOST USE_CSRF=$USE_CSRF DB_NO_UNCONFIRMED=$DB_NO_UNCONFIRMED \ +SKYCOIN_INTEGRATION_TESTS=1 SKYCOIN_INTEGRATION_TEST_MODE=$MODE SKYCOIN_NODE_HOST=$HOST \ + USE_CSRF=$USE_CSRF DB_NO_UNCONFIRMED=$DB_NO_UNCONFIRMED COIN=$COIN \ go test ./src/api/integration/... $UPDATE -timeout=3m $VERBOSE $RUN_TESTS API_FAIL=$? @@ -125,7 +126,8 @@ fi if [[ -z $TEST || $TEST = "cli" ]]; then -SKYCOIN_INTEGRATION_TESTS=1 SKYCOIN_INTEGRATION_TEST_MODE=$MODE RPC_ADDR=$RPC_ADDR USE_CSRF=$USE_CSRF DB_NO_UNCONFIRMED=$DB_NO_UNCONFIRMED \ +SKYCOIN_INTEGRATION_TESTS=1 SKYCOIN_INTEGRATION_TEST_MODE=$MODE RPC_ADDR=$RPC_ADDR \ + USE_CSRF=$USE_CSRF DB_NO_UNCONFIRMED=$DB_NO_UNCONFIRMED COIN=$COIN \ go test ./src/cli/integration/... $UPDATE -timeout=3m $VERBOSE $RUN_TESTS CLI_FAIL=$? diff --git a/cmd/cli/README.md b/cmd/cli/README.md index 2f1c70f979..6dea79c40d 100644 --- a/cmd/cli/README.md +++ b/cmd/cli/README.md @@ -1630,6 +1630,8 @@ $ skycoin-cli status "commit": "620405485d3276c16c0379bc3b88b588e34c45e1", "branch": "develop" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 8, "uptime": "4h1m23.697072461s", "csrf_enabled": true, diff --git a/src/api/README.md b/src/api/README.md index 02fc9fc226..2916ae7932 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -222,6 +222,8 @@ Response: "commit": "8798b5ee43c7ce43b9b75d57a1a6cd2c1295cd1e", "branch": "develop" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 8, "uptime": "6m30.629057248s", "csrf_enabled": true, diff --git a/src/api/health.go b/src/api/health.go index f08559971e..2ae13fccd6 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -19,6 +19,8 @@ type BlockchainMetadata struct { type HealthResponse struct { BlockchainMetadata BlockchainMetadata `json:"blockchain"` Version readable.BuildInfo `json:"version"` + CoinName string `json:"coin"` + DaemonUserAgent string `json:"user_agent"` OpenConnections int `json:"open_connections"` Uptime wh.Duration `json:"uptime"` CSRFEnabled bool `json:"csrf_enabled"` @@ -51,12 +53,20 @@ func healthHandler(c muxConfig, csrfStore *CSRFStore, gateway Gatewayer) http.Ha _, walletAPIEnabled := c.enabledAPISets[EndpointsWallet] + userAgent, err := c.health.DaemonUserAgent.Build() + if err != nil { + wh.Error500(w, err.Error()) + return + } + wh.SendJSONOr500(logger, w, HealthResponse{ BlockchainMetadata: BlockchainMetadata{ BlockchainMetadata: readable.NewBlockchainMetadata(health.BlockchainMetadata), TimeSinceLastBlock: wh.FromDuration(timeSinceLastBlock), }, - Version: c.buildInfo, + Version: c.health.BuildInfo, + CoinName: c.health.CoinName, + DaemonUserAgent: userAgent, OpenConnections: health.OpenConnections, Uptime: wh.FromDuration(health.Uptime), CSRFEnabled: csrfStore.Enabled, diff --git a/src/api/health_test.go b/src/api/health_test.go index 7590d0a0ae..f328b6a1f9 100644 --- a/src/api/health_test.go +++ b/src/api/health_test.go @@ -16,6 +16,7 @@ import ( "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" "github.com/skycoin/skycoin/src/readable" + "github.com/skycoin/skycoin/src/util/useragent" "github.com/skycoin/skycoin/src/visor" ) @@ -113,7 +114,14 @@ func TestHealthHandler(t *testing.T) { Commit: "abcdef", Branch: "develop", } - tc.cfg.buildInfo = buildInfo + tc.cfg.health.BuildInfo = buildInfo + + tc.cfg.health.CoinName = "skycoin" + tc.cfg.health.DaemonUserAgent = useragent.Data{ + Coin: "skycoin", + Version: "0.25.0", + Remark: "test", + } health := &daemon.Health{ BlockchainMetadata: metadata, @@ -157,6 +165,9 @@ func TestHealthHandler(t *testing.T) { require.Equal(t, buildInfo.Branch, r.Version.Branch) require.Equal(t, health.Uptime, r.Uptime.Duration) + require.Equal(t, "skycoin", r.CoinName) + require.Equal(t, "skycoin:0.25.0(test)", r.DaemonUserAgent) + require.Equal(t, health.OpenConnections, r.OpenConnections) require.Equal(t, unconfirmed, r.BlockchainMetadata.Unconfirmed) diff --git a/src/api/http.go b/src/api/http.go index 82aa2cb244..ed30c2e1ed 100644 --- a/src/api/http.go +++ b/src/api/http.go @@ -25,6 +25,7 @@ import ( "github.com/skycoin/skycoin/src/util/file" wh "github.com/skycoin/skycoin/src/util/http" "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skycoin/src/util/useragent" ) var ( @@ -77,13 +78,20 @@ type Config struct { ReadTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration - BuildInfo readable.BuildInfo + Health HealthConfig HostWhitelist []string EnabledAPISets map[string]struct{} Username string Password string } +// HealthConfig configuration data exposed in /health +type HealthConfig struct { + BuildInfo readable.BuildInfo + CoinName string + DaemonUserAgent useragent.Data +} + type muxConfig struct { host string appLoc string @@ -91,11 +99,11 @@ type muxConfig struct { enableJSON20RPC bool enableUnversionedAPI bool disableCSP bool - buildInfo readable.BuildInfo enabledAPISets map[string]struct{} hostWhitelist []string username string password string + health HealthConfig } // HTTPResponse represents the http response struct @@ -195,7 +203,7 @@ func create(host string, c Config, gateway Gatewayer) (*Server, error) { enableJSON20RPC: c.EnableJSON20RPC, enableUnversionedAPI: c.EnableUnversionedAPI, disableCSP: c.DisableCSP, - buildInfo: c.BuildInfo, + health: c.Health, enabledAPISets: c.EnabledAPISets, hostWhitelist: c.HostWhitelist, username: c.Username, @@ -427,7 +435,7 @@ func newServerMux(c muxConfig, gateway Gatewayer, csrfStore *CSRFStore, rpc *web csrfHandlerV1("/csrf", getCSRFToken(csrfStore)) // csrf is always available, regardless of the API set // Status endpoints - webHandlerV1("/version", versionHandler(c.buildInfo)) // version is always available, regardless of the API set + webHandlerV1("/version", versionHandler(c.health.BuildInfo)) // version is always available, regardless of the API set webHandlerV1("/health", forAPISet(healthHandler(c, csrfStore, gateway), []string{EndpointsRead, EndpointsStatus})) // Wallet endpoints diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 1fbdb9727b..a4b8c54c25 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -31,6 +31,7 @@ import ( "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/util/droplet" "github.com/skycoin/skycoin/src/util/fee" + "github.com/skycoin/skycoin/src/util/useragent" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/wallet" ) @@ -5788,6 +5789,11 @@ func checkHealthResponse(t *testing.T, r *api.HealthResponse) { require.NotEmpty(t, r.BlockchainMetadata.Head.Time) require.NotEmpty(t, r.Version.Version) require.True(t, r.Uptime.Duration > time.Duration(0)) + require.NotEmpty(t, r.CoinName) + require.NotEmpty(t, r.DaemonUserAgent) + + _, err := useragent.Parse(r.DaemonUserAgent) + require.NoError(t, err) } func TestStableHealth(t *testing.T) { @@ -5810,6 +5816,13 @@ func TestStableHealth(t *testing.T) { require.NotEmpty(t, r.Version.Commit) require.NotEmpty(t, r.Version.Branch) + coinName := os.Getenv("COIN") + require.Equal(t, coinName, r.CoinName) + require.Equal(t, fmt.Sprintf("%s:%s", coinName, r.Version.Version), r.DaemonUserAgent) + + _, err = useragent.Parse(r.DaemonUserAgent) + require.NoError(t, err) + require.Equal(t, useCSRF(t), r.CSRFEnabled) require.True(t, r.CSPEnabled) require.True(t, r.WalletAPIEnabled) diff --git a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden index 5e98314401..8a99a3e7f2 100644 --- a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden @@ -8,7 +8,8 @@ "timestamp": 1431574528, "fee": 2265261, "version": 0, - "tx_body_hash": "0a610a34a8408effe8f2f70e4a85a3a8f4aca923f43e10a8a6e08cf410d7a35d" + "tx_body_hash": "0a610a34a8408effe8f2f70e4a85a3a8f4aca923f43e10a8a6e08cf410d7a35d", + "ux_hash": "058d1d0a22be7b9f5567a236866836a87d922760581832cfb8bfbd8b337d64b1" }, "unspents": 218, "unconfirmed": 0, @@ -19,6 +20,8 @@ "commit": "", "branch": "" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, "uptime": "0s", "csrf_enabled": true, diff --git a/src/cli/integration/testdata/status-csrf-enabled.golden b/src/cli/integration/testdata/status-csrf-enabled.golden index 77dcc4ef05..17ed42d4a2 100644 --- a/src/cli/integration/testdata/status-csrf-enabled.golden +++ b/src/cli/integration/testdata/status-csrf-enabled.golden @@ -20,6 +20,8 @@ "commit": "", "branch": "" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, "uptime": "0s", "csrf_enabled": true, diff --git a/src/cli/integration/testdata/status-no-unconfirmed.golden b/src/cli/integration/testdata/status-no-unconfirmed.golden index b2e6275475..7e5d1c7cd6 100644 --- a/src/cli/integration/testdata/status-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-no-unconfirmed.golden @@ -20,6 +20,8 @@ "commit": "", "branch": "" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, "uptime": "0s", "csrf_enabled": false, diff --git a/src/cli/integration/testdata/status.golden b/src/cli/integration/testdata/status.golden index be4eb2f1ef..aa2bb08f22 100644 --- a/src/cli/integration/testdata/status.golden +++ b/src/cli/integration/testdata/status.golden @@ -20,6 +20,8 @@ "commit": "", "branch": "" }, + "coin": "skycoin", + "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, "uptime": "0s", "csrf_enabled": false, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 7b4a6d6828..cc08551954 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -87,7 +87,7 @@ func NewConfig() Config { } // preprocess preprocess for config -func (cfg *Config) preprocess() Config { +func (cfg *Config) preprocess() (Config, error) { config := *cfg if config.Daemon.LocalhostOnly { if config.Daemon.Address == "" { @@ -120,7 +120,16 @@ func (cfg *Config) preprocess() Config { } } - return config + userAgent, err := config.Daemon.UserAgent.Build() + if err != nil { + return Config{}, err + } + if userAgent == "" { + return Config{}, errors.New("user agent is required") + } + config.Daemon.userAgent = userAgent + + return config, nil } // DaemonConfig configuration for the Daemon @@ -181,7 +190,8 @@ type DaemonConfig struct { // nolint: golint // Default "trusted" peers DefaultConnections []string // User agent (sent in introduction messages) - UserAgent string + UserAgent useragent.Data + userAgent string // parsed from UserAgent in preprocess() } // NewDaemonConfig creates daemon config @@ -304,7 +314,11 @@ type Daemon struct { // NewDaemon returns a Daemon with primitives allocated func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { - config = config.preprocess() + config, err := config.preprocess() + if err != nil { + return nil, err + } + vs, err := visor.NewVisor(config.Visor, db) if err != nil { return nil, err @@ -410,7 +424,7 @@ func (dm *Daemon) Run() error { defer logger.Info("Daemon closed") defer close(dm.done) - logger.Infof("Daemon UserAgent is %s", dm.Config.UserAgent) + logger.Infof("Daemon UserAgent is %s", dm.Config.userAgent) errC := make(chan error, 5) var wg sync.WaitGroup @@ -973,7 +987,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { dm.expectingIntroductions.Add(a, time.Now().UTC()) logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.UserAgent) + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) if err := dm.pool.Pool.SendMessage(a, m); err != nil { logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 0dffaddd49..3240e44e6a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -251,6 +251,9 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey ci if len(userAgent) > useragent.MaxLen { logger.Panicf("user agent %q exceeds max len %d", userAgent, useragent.MaxLen) } + if userAgent == "" { + logger.Panic("user agent is required") + } userAgentSerialized := encoder.SerializeString(userAgent) diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 119413a990..dd4d4dba5d 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -12,6 +12,7 @@ import ( "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/util/useragent" ) func TestIntroductionMessage(t *testing.T) { @@ -309,7 +310,10 @@ func TestIntroductionMessage(t *testing.T) { d.On("DaemonConfig").Return(DaemonConfig{ ProtocolVersion: int32(tc.mockValue.protocolVersion), MinProtocolVersion: int32(tc.mockValue.minProtocolVersion), - UserAgent: "skycoin:0.24.1", + UserAgent: useragent.Data{ + Coin: "skycoin", + Version: "0.24.1", + }, }) d.On("Mirror").Return(tc.mockValue.mirror) d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 2aba95ba40..f50483eed7 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -123,7 +123,7 @@ type NodeConfig struct { // Remark to include in user agent sent in the wire protocol introduction UserAgentRemark string - userAgent string + userAgent useragent.Data // Logging ColorLog bool @@ -352,12 +352,11 @@ func (c *Config) postProcess() error { Remark: c.Node.UserAgentRemark, } - userAgent, err := userAgentData.Build() - if err != nil { + if _, err := userAgentData.Build(); err != nil { return err } - c.Node.userAgent = userAgent + c.Node.userAgent = userAgentData apiSets, err := buildAPISets(c.Node) if err != nil { diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 18f628f45d..871b0a7c5c 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -416,10 +416,14 @@ func (c *Coin) createGUI(d *daemon.Daemon, host string) (*api.Server, error) { IdleTimeout: c.config.Node.HTTPIdleTimeout, EnabledAPISets: c.config.Node.enabledAPISets, HostWhitelist: c.config.Node.hostWhitelist, - BuildInfo: readable.BuildInfo{ - Version: c.config.Build.Version, - Commit: c.config.Build.Commit, - Branch: c.config.Build.Branch, + Health: api.HealthConfig{ + BuildInfo: readable.BuildInfo{ + Version: c.config.Build.Version, + Commit: c.config.Build.Commit, + Branch: c.config.Build.Branch, + }, + CoinName: c.config.Node.CoinName, + DaemonUserAgent: c.config.Node.userAgent, }, Username: c.config.Node.WebInterfaceUsername, Password: c.config.Node.WebInterfacePassword, From 0838d279d2ed8a07b20b22613910c401664adccc Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 10:40:57 +0800 Subject: [PATCH 283/399] VerifySignedHash fixups --- include/skyerrors.h | 2 +- lib/cgo/libsky_error.go | 54 ++++++++++++++--------------- lib/cgo/tests/check_cipher.crypto.c | 8 ++--- src/cipher/crypto.go | 20 +++++------ src/cipher/crypto_test.go | 28 +++++++++++++++ 5 files changed, 69 insertions(+), 43 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 98f4d51529..24764198a2 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -49,7 +49,7 @@ #define SKY_ErrInvalidBytesLength 0x02000015 #define SKY_ErrInvalidPubKey 0x02000016 #define SKY_ErrInvalidSecKey 0x02000017 -#define SKY_ErrInvalidSigForPubKey 0x02000018 +#define SKY_ErrInvalidSigPubKeyRecovery 0x02000018 #define SKY_ErrInvalidSecKeyHex 0x02000019 #define SKY_ErrInvalidAddressForSig 0x0200001A #define SKY_ErrInvalidHashForSig 0x0200001B diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index b100c97abd..d9d6b9f8f3 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -111,8 +111,8 @@ const ( SKY_ErrInvalidPubKey // SKY_ErrInvalidSecKey Invalid public key SKY_ErrInvalidSecKey - // SKY_ErrInvalidSigForPubKey Invalig sig: PubKey recovery failed - SKY_ErrInvalidSigForPubKey + // SKY_ErrInvalidSigPubKeyRecovery Invalig sig: PubKey recovery failed + SKY_ErrInvalidSigPubKeyRecovery // SKY_ErrInvalidSecKeyHex Invalid SecKey: not valid hex SKY_ErrInvalidSecKeyHex // nolint megacheck // SKY_ErrInvalidAddressForSig Invalid sig: address does not match output address @@ -397,31 +397,31 @@ var ( ErrorBadHandle: SKY_BAD_HANDLE, ErrorUnknown: SKY_ERROR, // cipher - cipher.ErrAddressInvalidLength: SKY_ErrAddressInvalidLength, - cipher.ErrAddressInvalidChecksum: SKY_ErrAddressInvalidChecksum, - cipher.ErrAddressInvalidVersion: SKY_ErrAddressInvalidVersion, - cipher.ErrAddressInvalidPubKey: SKY_ErrAddressInvalidPubKey, - cipher.ErrAddressInvalidFirstByte: SKY_ErrAddressInvalidFirstByte, - cipher.ErrAddressInvalidLastByte: SKY_ErrAddressInvalidLastByte, - encoder.ErrBufferUnderflow: SKY_ErrBufferUnderflow, - encoder.ErrInvalidOmitEmpty: SKY_ErrInvalidOmitEmpty, - cipher.ErrInvalidLengthPubKey: SKY_ErrInvalidLengthPubKey, - cipher.ErrPubKeyFromNullSecKey: SKY_ErrPubKeyFromNullSecKey, - cipher.ErrPubKeyFromBadSecKey: SKY_ErrPubKeyFromBadSecKey, - cipher.ErrInvalidLengthSecKey: SKY_ErrInvalidLengthSecKey, - cipher.ErrECHDInvalidPubKey: SKY_ErrECHDInvalidPubKey, - cipher.ErrECHDInvalidSecKey: SKY_ErrECHDInvalidSecKey, - cipher.ErrInvalidLengthSig: SKY_ErrInvalidLengthSig, - cipher.ErrInvalidLengthRipemd160: SKY_ErrInvalidLengthRipemd160, - cipher.ErrInvalidLengthSHA256: SKY_ErrInvalidLengthSHA256, - base58.ErrInvalidBase58Char: SKY_ErrInvalidBase58Char, - base58.ErrInvalidBase58String: SKY_ErrInvalidBase58String, - base58.ErrInvalidBase58Length: SKY_ErrInvalidBase58Length, - cipher.ErrInvalidHexLength: SKY_ErrInvalidHexLength, - cipher.ErrInvalidBytesLength: SKY_ErrInvalidBytesLength, - cipher.ErrInvalidPubKey: SKY_ErrInvalidPubKey, - cipher.ErrInvalidSecKey: SKY_ErrInvalidSecKey, - cipher.ErrInvalidSigForPubKey: SKY_ErrInvalidSigForPubKey, + cipher.ErrAddressInvalidLength: SKY_ErrAddressInvalidLength, + cipher.ErrAddressInvalidChecksum: SKY_ErrAddressInvalidChecksum, + cipher.ErrAddressInvalidVersion: SKY_ErrAddressInvalidVersion, + cipher.ErrAddressInvalidPubKey: SKY_ErrAddressInvalidPubKey, + cipher.ErrAddressInvalidFirstByte: SKY_ErrAddressInvalidFirstByte, + cipher.ErrAddressInvalidLastByte: SKY_ErrAddressInvalidLastByte, + encoder.ErrBufferUnderflow: SKY_ErrBufferUnderflow, + encoder.ErrInvalidOmitEmpty: SKY_ErrInvalidOmitEmpty, + cipher.ErrInvalidLengthPubKey: SKY_ErrInvalidLengthPubKey, + cipher.ErrPubKeyFromNullSecKey: SKY_ErrPubKeyFromNullSecKey, + cipher.ErrPubKeyFromBadSecKey: SKY_ErrPubKeyFromBadSecKey, + cipher.ErrInvalidLengthSecKey: SKY_ErrInvalidLengthSecKey, + cipher.ErrECHDInvalidPubKey: SKY_ErrECHDInvalidPubKey, + cipher.ErrECHDInvalidSecKey: SKY_ErrECHDInvalidSecKey, + cipher.ErrInvalidLengthSig: SKY_ErrInvalidLengthSig, + cipher.ErrInvalidLengthRipemd160: SKY_ErrInvalidLengthRipemd160, + cipher.ErrInvalidLengthSHA256: SKY_ErrInvalidLengthSHA256, + base58.ErrInvalidBase58Char: SKY_ErrInvalidBase58Char, + base58.ErrInvalidBase58String: SKY_ErrInvalidBase58String, + base58.ErrInvalidBase58Length: SKY_ErrInvalidBase58Length, + cipher.ErrInvalidHexLength: SKY_ErrInvalidHexLength, + cipher.ErrInvalidBytesLength: SKY_ErrInvalidBytesLength, + cipher.ErrInvalidPubKey: SKY_ErrInvalidPubKey, + cipher.ErrInvalidSecKey: SKY_ErrInvalidSecKey, + cipher.ErrInvalidSigPubKeyRecovery: SKY_ErrInvalidSigPubKeyRecovery, // Removed in ea0aafbffb76 // cipher.ErrInvalidSecKeyHex: SKY_ErrInvalidSecKeyHex, cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index b8282c0a4d..8b3914d63b 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -519,7 +519,7 @@ Test(cipher_crypto, TestChkSig) { // Empty sig should be invalid memset(&sig, 0, sizeof(sig)); errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); - cr_assert(errorcode == SKY_ErrInvalidSigForPubKey); + cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); // Random sigs should not pass int i; @@ -570,7 +570,7 @@ Test(cipher_crypto, TestChkSig) { cr_assert(errorcode == SKY_ErrInvalidAddressForSig); } -Test(cipher_crypto, TestSignHash) { +Test(cipher_crypto, TestSignHash) { cipher__PubKey pk, pk2; cipher__SecKey sk; cipher__Address addr; @@ -649,7 +649,7 @@ Test(cipher_crypto, TestPubKeyFromSig) { memset(&sig, 0, sizeof(sig)); errorcode = SKY_cipher_PubKeyFromSig(&sig, &h, &pk2); - cr_assert(errorcode == SKY_ErrInvalidSigForPubKey); + cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); } Test(cipher_crypto, TestVerifySignature) { @@ -672,7 +672,7 @@ Test(cipher_crypto, TestVerifySignature) { memset(&sig2, 0, sizeof(sig2)); errorcode = SKY_cipher_VerifySignature(&pk, &sig2, &h); - cr_assert(errorcode == SKY_ErrInvalidSigForPubKey); + cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); errorcode = SKY_cipher_VerifySignature(&pk, &sig, &h2); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index 1f5a998569..bdac6fc366 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -55,12 +55,12 @@ var ( ErrInvalidSecKey = errors.New("Invalid secret key") // ErrInvalidSig Invalid signature ErrInvalidSig = errors.New("Invalid signature") - // ErrInvalidSigForPubKey Invalid sig: PubKey recovery failed - ErrInvalidSigForPubKey = errors.New("Invalid sig: PubKey recovery failed") - // ErrInvalidAddressForSig Invalid sig: address does not match output address - ErrInvalidAddressForSig = errors.New("Invalid sig: address does not match output address") + // ErrInvalidSigPubKeyRecovery could not recover pubkey from sig + ErrInvalidSigPubKeyRecovery = errors.New("Failed to recover pubkey from signature") + // ErrInvalidAddressForSig the address derived from the pubkey recovered from the signature does not match a provided address + ErrInvalidAddressForSig = errors.New("Address does not match recovered signing address") // ErrInvalidHashForSig Signature invalid for hash - ErrInvalidHashForSig = errors.New("Invalid sig: invalid for hash") + ErrInvalidHashForSig = errors.New("Signature not valid for hash") // ErrPubKeyRecoverMismatch Recovered pubkey does not match pubkey ErrPubKeyRecoverMismatch = errors.New("Recovered pubkey does not match pubkey") // ErrInvalidSigInvalidPubKey VerifySignature, secp256k1.VerifyPubkey failed @@ -160,7 +160,7 @@ func MustPubKeyFromSecKey(seckey SecKey) PubKey { func PubKeyFromSig(sig Sig, hash SHA256) (PubKey, error) { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { - return PubKey{}, ErrInvalidSigForPubKey + return PubKey{}, ErrInvalidSigPubKeyRecovery } return NewPubKey(rawPubKey) } @@ -400,7 +400,7 @@ func MustSignHash(hash SHA256, sec SecKey) Sig { func ChkSig(address Address, hash SHA256, sig Sig) error { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { - return ErrInvalidSigForPubKey + return ErrInvalidSigPubKeyRecovery } pubKey, err := NewPubKey(rawPubKey) @@ -425,11 +425,9 @@ func ChkSig(address Address, hash SHA256, sig Sig) error { func VerifySignedHash(sig Sig, hash SHA256) error { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { - return ErrInvalidSigForPubKey + return ErrInvalidSigPubKeyRecovery } if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey) != 1 { - // If this occurs, secp256k1 is bugged - log.Printf("Recovered public key is not valid for signed hash") return ErrInvalidHashForSig } return nil @@ -439,7 +437,7 @@ func VerifySignedHash(sig Sig, hash SHA256) error { func VerifySignature(pubkey PubKey, sig Sig, hash SHA256) error { pubkeyRec, err := PubKeyFromSig(sig, hash) //recovered pubkey if err != nil { - return ErrInvalidSigForPubKey + return ErrInvalidSigPubKeyRecovery } if pubkeyRec != pubkey { return ErrPubKeyRecoverMismatch diff --git a/src/cipher/crypto_test.go b/src/cipher/crypto_test.go index 4fc5dee5c4..693a6520c4 100644 --- a/src/cipher/crypto_test.go +++ b/src/cipher/crypto_test.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/hex" "errors" + "fmt" "testing" "github.com/stretchr/testify/require" @@ -701,3 +702,30 @@ func TestSecKeyPubKeyNull(t *testing.T) { require.False(t, sk.Null()) require.False(t, pk.Null()) } + +func TestVerifySignedHash(t *testing.T) { + h := SumSHA256(randBytes(t, 256)) + fmt.Println("hash:", h.Hex()) + + _, sk := GenerateKeyPair() + fmt.Println("sk:", sk.Hex()) + + sig := MustSignHash(h, sk) + fmt.Println("sig:", sig.Hex()) + + err := VerifySignedHash(sig, h) + require.NoError(t, err) + + // Fails with ErrInvalidHashForSig + badSigHex := "71f2c01516fe696328e79bcf464eb0db374b63d494f7a307d1e77114f18581d7a81eed5275a9e04a336292dd2fd16977d9bef2a54ea3161d0876603d00c53bc9dd" + badSig := MustSigFromHex(badSigHex) + err = VerifySignedHash(badSig, h) + require.Equal(t, ErrInvalidHashForSig, err) + + // Fails with ErrInvalidSigPubKeyRecovery + badSig = sig + badSig[0] = 0xE3 + fmt.Println("badSig:", badSig.Hex()) + err = VerifySignedHash(badSig, h) + require.Equal(t, ErrInvalidSigPubKeyRecovery, err) +} From 14e17f76c9f034f5b1e14c37ca2362afc223b5f2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 11:50:31 +0800 Subject: [PATCH 284/399] Rename sig verification methods --- lib/cgo/cipher.crypto.go | 12 +++--- lib/cgo/tests/check_cipher.crypto.c | 28 ++++++------- lib/cgo/tests/cipher.testsuite.c | 4 +- src/cipher/crypto.go | 62 ++++++++++++++-------------- src/cipher/crypto_test.go | 59 +++++++++++--------------- src/cipher/secp256k1-go/secp256k1.go | 22 +++++++--- src/cipher/testsuite/testsuite.go | 8 ++-- src/coin/block.go | 2 +- src/coin/transactions.go | 2 +- src/coin/transactions_test.go | 10 ++--- src/visor/blockchain.go | 4 +- src/visor/blockchain_verify_test.go | 2 +- 12 files changed, 108 insertions(+), 107 deletions(-) diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index 6ee5515710..584ef87f8f 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -189,13 +189,13 @@ func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 return } -//export SKY_cipher_ChkSig -func SKY_cipher_ChkSig(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { +//export SKY_cipher_VerifySignatureForAddress +func SKY_cipher_VerifySignatureForAddress(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { address := inplaceAddress(_address) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) - err := cipher.ChkSig(*address, *hash, *sig) + err := cipher.VerifySignatureForAddress(*address, *hash, *sig) ____error_code = libErrorCode(err) return } @@ -210,13 +210,13 @@ func SKY_cipher_VerifySignedHash(_sig *C.cipher__Sig, _hash *C.cipher__SHA256) ( return } -//export SKY_cipher_VerifySignature -func SKY_cipher_VerifySignature(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { +//export SKY_cipher_VerifySignatureForPubKey +func SKY_cipher_VerifySignatureForPubKey(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { pubkey := (*cipher.PubKey)(unsafe.Pointer(_pubkey)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) - err := cipher.VerifySignature(*pubkey, *sig, *hash) + err := cipher.VerifySignatureForPubKey(*pubkey, *sig, *hash) ____error_code = libErrorCode(err) return } diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 8b3914d63b..ee25eae35b 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -491,7 +491,7 @@ Test(cipher_crypto, TestSigHex) { } // FIXME: Split in multiple test cases so as to catch panic at the right place -Test(cipher_crypto, TestChkSig) { +Test(cipher_crypto, TestVerifySignatureForAddress) { cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__Address addr, addr2; @@ -513,12 +513,12 @@ Test(cipher_crypto, TestChkSig) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); // Empty sig should be invalid memset(&sig, 0, sizeof(sig)); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); // Random sigs should not pass @@ -526,7 +526,7 @@ Test(cipher_crypto, TestChkSig) { for (i = 0; i < 100; i++) { randBytes(&b, 65); SKY_cipher_NewSig(b, &sig); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode != SKY_OK); // One of many error codes } @@ -534,11 +534,11 @@ Test(cipher_crypto, TestChkSig) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h2); SKY_cipher_SignHash(&h2, &sk, &sig2); - errorcode = SKY_cipher_ChkSig(&addr, &h2, &sig2); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h2, &sig2); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig2); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_ChkSig(&addr, &h2, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h2, &sig); cr_assert(errorcode != SKY_OK); // One of many error codes // Different secret keys should not create same sig @@ -547,9 +547,9 @@ Test(cipher_crypto, TestChkSig) { memset(&h, 0, sizeof(h)); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_ChkSig(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig2); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); @@ -557,16 +557,16 @@ Test(cipher_crypto, TestChkSig) { SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_ChkSig(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig2); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); // Bad address should be invalid - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig2); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_ChkSig(&addr2, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); } @@ -589,7 +589,7 @@ Test(cipher_crypto, TestSignHash) { cr_assert(errorcode == SKY_OK); memset((void *) &sig2, 0, 65); cr_assert(not(eq(u8[65], sig2, sig))); - errorcode = SKY_cipher_ChkSig(&addr, &h, &sig); + errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); errorcode = SKY_cipher_PubKeyFromSig(&sig, &h, &pk2); diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 297b08178b..975f69e907 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -463,8 +463,8 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { GoUint32 err = SKY_cipher_VerifySignature(&p, sig, h); cr_assert(err == SKY_OK, "SKY_cipher_VerifySignature failed: error=%d dataset=%d hashidx=%d", err, i, j); - err = SKY_cipher_ChkSig(&addr1, h, sig); - cr_assert(err == SKY_OK, "SKY_cipher_ChkSig failed: error=%d dataset=%d hashidx=%d", err, i, j); + err = SKY_cipher_VerifySignatureForAddress(&addr1, h, sig); + cr_assert(err == SKY_OK, "SKY_cipher_VerifySignatureForAddress failed: error=%d dataset=%d hashidx=%d", err, i, j); err = SKY_cipher_VerifySignedHash(sig, h); cr_assert(err == SKY_OK, "SKY_cipher_VerifySignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index bdac6fc366..e2d2986058 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -369,13 +369,13 @@ func SignHash(hash SHA256, sec SecKey) (Sig, error) { // make sure that the signature is valid pubkey, err := PubKeyFromSig(sig, hash) if err != nil { - log.Panic("MustSignHash error: pubkey from sig recovery failure") + log.Panic("SignHash error: pubkey from sig recovery failure") } - if VerifySignature(pubkey, sig, hash) != nil { - log.Panic("MustSignHash error: secp256k1.Sign returned non-null invalid non-null signature") + if VerifySignatureForPubKey(pubkey, sig, hash) != nil { + log.Panic("SignHash error: secp256k1.Sign returned non-null invalid non-null signature") } - if ChkSig(AddressFromPubKey(pubkey), hash, sig) != nil { - log.Panic("MustSignHash error: ChkSig failed for signature") + if VerifySignatureForAddress(AddressFromPubKey(pubkey), hash, sig) != nil { + log.Panic("SignHash error: VerifySignatureForAddress failed for signature") } } @@ -391,13 +391,13 @@ func MustSignHash(hash SHA256, sec SecKey) Sig { return sig } -// ChkSig checks whether PubKey corresponding to address hash signed hash +// VerifySignatureForAddress checks whether PubKey corresponding to address hash signed hash // - recovers the PubKey from sig and hash // - fail if PubKey cannot be be recovered // - computes the address from the PubKey // - fail if recovered address does not match PubKey hash // - verify that signature is valid for hash for PubKey -func ChkSig(address Address, hash SHA256, sig Sig) error { +func VerifySignatureForAddress(address Address, hash SHA256, sig Sig) error { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { return ErrInvalidSigPubKeyRecovery @@ -419,23 +419,9 @@ func ChkSig(address Address, hash SHA256, sig Sig) error { return nil } -// VerifySignedHash this only checks that the signature can be converted to a public key -// Since there is no pubkey or address argument, it cannot check that the -// signature is valid in that context. -func VerifySignedHash(sig Sig, hash SHA256) error { - rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) - if rawPubKey == nil { - return ErrInvalidSigPubKeyRecovery - } - if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey) != 1 { - return ErrInvalidHashForSig - } - return nil -} - -// VerifySignature verifies that hash was signed by PubKey -func VerifySignature(pubkey PubKey, sig Sig, hash SHA256) error { - pubkeyRec, err := PubKeyFromSig(sig, hash) //recovered pubkey +// VerifySignatureForPubKey verifies that hash was signed by PubKey +func VerifySignatureForPubKey(pubkey PubKey, sig Sig, hash SHA256) error { + pubkeyRec, err := PubKeyFromSig(sig, hash) // recovered pubkey if err != nil { return ErrInvalidSigPubKeyRecovery } @@ -445,7 +431,7 @@ func VerifySignature(pubkey PubKey, sig Sig, hash SHA256) error { if secp256k1.VerifyPubkey(pubkey[:]) != 1 { if DebugLevel2 { if secp256k1.VerifySignature(hash[:], sig[:], pubkey[:]) == 1 { - log.Panic("VerifySignature warning, ") + log.Panic("VerifySignatureForPubKey warning, invalid pubkey is valid for signature") } } return ErrInvalidSigInvalidPubKey @@ -459,6 +445,20 @@ func VerifySignature(pubkey PubKey, sig Sig, hash SHA256) error { return nil } +// VerifySignedHash this only checks that the signature can be converted to a public key +// Since there is no pubkey or address argument, it cannot check that the +// signature is valid in that context. +func VerifySignedHash(sig Sig, hash SHA256) error { + rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) + if rawPubKey == nil { + return ErrInvalidSigPubKeyRecovery + } + if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey) != 1 { + return ErrInvalidHashForSig + } + return nil +} + // GenerateKeyPair creates key pair func GenerateKeyPair() (PubKey, SecKey) { public, secret := secp256k1.GenerateKeyPair() @@ -647,23 +647,23 @@ func CheckSecKeyHash(seckey SecKey, hash SHA256) error { // check pubkey recovered from sig recoveredPubkey, err := PubKeyFromSig(sig, hash) if err != nil { - return fmt.Errorf("impossible error, CheckSecKey, pubkey recovery from signature failed: %v", err) + return fmt.Errorf("impossible error, CheckSecKeyHash, pubkey recovery from signature failed: %v", err) } if pubkey != recoveredPubkey { return ErrPubKeyFromSecKeyMismatch } // verify produced signature - err = VerifySignature(pubkey, sig, hash) + err = VerifySignatureForPubKey(pubkey, sig, hash) if err != nil { - return fmt.Errorf("impossible error, CheckSecKey, verify signature failed for sig: %v", err) + return fmt.Errorf("impossible error, CheckSecKeyHash, VerifySignatureForPubKey failed for sig: %v", err) } - // verify ChkSig + // verify VerifySignatureForAddress addr := AddressFromPubKey(pubkey) - err = ChkSig(addr, hash, sig) + err = VerifySignatureForAddress(addr, hash, sig) if err != nil { - return fmt.Errorf("impossible error CheckSecKey, ChkSig Failed, should not get this far: %v", err) + return fmt.Errorf("impossible error CheckSecKeyHash, VerifySignatureForAddress Failed, should not get this far: %v", err) } // verify VerifySignedHash diff --git a/src/cipher/crypto_test.go b/src/cipher/crypto_test.go index 693a6520c4..156b45b8c7 100644 --- a/src/cipher/crypto_test.go +++ b/src/cipher/crypto_test.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "encoding/hex" "errors" - "fmt" "testing" "github.com/stretchr/testify/require" @@ -404,7 +403,7 @@ func TestSigHex(t *testing.T) { require.Equal(t, p2.Hex(), h) } -func TestChkSig(t *testing.T) { +func TestVerifySignatureForAddress(t *testing.T) { p, s := GenerateKeyPair() require.NoError(t, p.Verify()) require.NoError(t, s.Verify()) @@ -413,19 +412,19 @@ func TestChkSig(t *testing.T) { b := randBytes(t, 256) h := SumSHA256(b) sig := MustSignHash(h, s) - require.NoError(t, ChkSig(a, h, sig)) + require.NoError(t, VerifySignatureForAddress(a, h, sig)) // Empty sig should be invalid - require.Error(t, ChkSig(a, h, Sig{})) + require.Error(t, VerifySignatureForAddress(a, h, Sig{})) // Random sigs should not pass for i := 0; i < 100; i++ { - require.Error(t, ChkSig(a, h, MustNewSig(randBytes(t, 65)))) + require.Error(t, VerifySignatureForAddress(a, h, MustNewSig(randBytes(t, 65)))) } // Sig for one hash does not work for another hash h2 := SumSHA256(randBytes(t, 256)) sig2 := MustSignHash(h2, s) - require.NoError(t, ChkSig(a, h2, sig2)) - require.Error(t, ChkSig(a, h, sig2)) - require.Error(t, ChkSig(a, h2, sig)) + require.NoError(t, VerifySignatureForAddress(a, h2, sig2)) + require.Error(t, VerifySignatureForAddress(a, h, sig2)) + require.Error(t, VerifySignatureForAddress(a, h2, sig)) // Different secret keys should not create same sig p2, s2 := GenerateKeyPair() @@ -433,19 +432,19 @@ func TestChkSig(t *testing.T) { h = SHA256{} sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, ChkSig(a, h, sig)) - require.NoError(t, ChkSig(a2, h, sig2)) + require.NoError(t, VerifySignatureForAddress(a, h, sig)) + require.NoError(t, VerifySignatureForAddress(a2, h, sig2)) require.NotEqual(t, sig, sig2) h = SumSHA256(randBytes(t, 256)) sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, ChkSig(a, h, sig)) - require.NoError(t, ChkSig(a2, h, sig2)) + require.NoError(t, VerifySignatureForAddress(a, h, sig)) + require.NoError(t, VerifySignatureForAddress(a2, h, sig2)) require.NotEqual(t, sig, sig2) // Bad address should be invalid - require.Error(t, ChkSig(a, h, sig2)) - require.Error(t, ChkSig(a2, h, sig)) + require.Error(t, VerifySignatureForAddress(a, h, sig2)) + require.Error(t, VerifySignatureForAddress(a2, h, sig)) } func TestSignHash(t *testing.T) { @@ -455,8 +454,8 @@ func TestSignHash(t *testing.T) { sig, err := SignHash(h, s) require.NoError(t, err) require.NotEqual(t, sig, Sig{}) - require.NoError(t, ChkSig(a, h, sig)) - require.NoError(t, VerifySignature(p, sig, h)) + require.NoError(t, VerifySignatureForAddress(a, h, sig)) + require.NoError(t, VerifySignatureForPubKey(p, sig, h)) p2, err := PubKeyFromSig(sig, h) require.NoError(t, err) @@ -472,7 +471,7 @@ func TestMustSignHash(t *testing.T) { h := SumSHA256(randBytes(t, 256)) sig := MustSignHash(h, s) require.NotEqual(t, sig, Sig{}) - require.NoError(t, ChkSig(a, h, sig)) + require.NoError(t, VerifySignatureForAddress(a, h, sig)) require.Panics(t, func() { MustSignHash(h, SecKey{}) @@ -518,17 +517,17 @@ func TestMustPubKeyFromSig(t *testing.T) { }) } -func TestVerifySignature(t *testing.T) { +func TestVerifySignatureForPubKey(t *testing.T) { p, s := GenerateKeyPair() h := SumSHA256(randBytes(t, 256)) h2 := SumSHA256(randBytes(t, 256)) sig := MustSignHash(h, s) - require.NoError(t, VerifySignature(p, sig, h)) - require.Error(t, VerifySignature(p, Sig{}, h)) - require.Error(t, VerifySignature(p, sig, h2)) + require.NoError(t, VerifySignatureForPubKey(p, sig, h)) + require.Error(t, VerifySignatureForPubKey(p, Sig{}, h)) + require.Error(t, VerifySignatureForPubKey(p, sig, h2)) p2, _ := GenerateKeyPair() - require.Error(t, VerifySignature(p2, sig, h)) - require.Error(t, VerifySignature(PubKey{}, sig, h)) + require.Error(t, VerifySignatureForPubKey(p2, sig, h)) + require.Error(t, VerifySignatureForPubKey(PubKey{}, sig, h)) } func TestGenerateKeyPair(t *testing.T) { @@ -704,14 +703,8 @@ func TestSecKeyPubKeyNull(t *testing.T) { } func TestVerifySignedHash(t *testing.T) { - h := SumSHA256(randBytes(t, 256)) - fmt.Println("hash:", h.Hex()) - - _, sk := GenerateKeyPair() - fmt.Println("sk:", sk.Hex()) - - sig := MustSignHash(h, sk) - fmt.Println("sig:", sig.Hex()) + h := MustSHA256FromHex("127e9b0d6b71cecd0363b366413f0f19fcd924ae033513498e7486570ff2a1c8") + sig := MustSigFromHex("63c035b0c95d0c5744fc1c0bdf38af02cef2d2f65a8f923732ab44e436f8a491216d9ab5ff795e3144f4daee37077b8b9db54d2ba3a3df8d4992f06bb21f724401") err := VerifySignedHash(sig, h) require.NoError(t, err) @@ -723,9 +716,7 @@ func TestVerifySignedHash(t *testing.T) { require.Equal(t, ErrInvalidHashForSig, err) // Fails with ErrInvalidSigPubKeyRecovery - badSig = sig - badSig[0] = 0xE3 - fmt.Println("badSig:", badSig.Hex()) + badSig = MustSigFromHex("63c035b0c95d0c5744fc1c0bdf39af02cef2d2f65a8f923732ab44e436f8a491216d9ab5ff795e3144f4daee37077b8b9db54d2ba3a3df8d4992f06bb21f724401") err = VerifySignedHash(badSig, h) require.Equal(t, ErrInvalidSigPubKeyRecovery, err) } diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 9aa4634909..0e8ae4620c 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -12,6 +12,9 @@ import ( secp "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" ) +// DebugPrint enable debug print statements +var DebugPrint = false + //intenal, may fail //may return nil func pubkeyFromSeckey(seckey []byte) []byte { @@ -39,7 +42,6 @@ func pubkeyFromSeckey(seckey []byte) []byte { } if ret := VerifyPubkey(pubkey); ret != 1 { - log.Printf("seckey= %s", hex.EncodeToString(seckey)) log.Printf("pubkey= %s", hex.EncodeToString(pubkey)) log.Panicf("ERROR: pubkey verification failed, for deterministic. ret=%d", ret) @@ -168,7 +170,9 @@ new_seckey: log.Panic() } if secp.SeckeyIsValid(seckey) != 1 { - log.Printf("generateDeterministicKeyPair, secp.SeckeyIsValid fail") + if DebugPrint { + log.Printf("generateDeterministicKeyPair, secp.SeckeyIsValid fail") + } goto new_seckey //regen } @@ -360,7 +364,7 @@ func VerifyPubkey(pubkey []byte) int { return 1 //valid } -// VerifySignatureValidity renames ChkSignatureValidity +// VerifySignatureValidity renames VerifySignatureForAddressnatureValidity func VerifySignatureValidity(sig []byte) int { //64+1 if len(sig) != 65 { @@ -466,7 +470,9 @@ func RecoverPubkey(msg []byte, sig []byte) []byte { recid) if ret != 1 { - log.Printf("RecoverPubkey: code %d", ret) + if DebugPrint { + log.Printf("RecoverPubkey: code %d", ret) + } return nil } //var pubkey2 []byte = pubkey1.Bytes() //compressed @@ -494,11 +500,15 @@ func ECDH(pub []byte, sec []byte) []byte { } if VerifySeckey(sec) != 1 { - log.Printf("Invalid Seckey") + if DebugPrint { + log.Printf("Invalid Seckey") + } } if ret := VerifyPubkey(pub); ret != 1 { - log.Printf("Invalid Pubkey, %d", ret) + if DebugPrint { + log.Printf("Invalid Pubkey, %d", ret) + } return nil } diff --git a/src/cipher/testsuite/testsuite.go b/src/cipher/testsuite/testsuite.go index c9639b8206..b4e0c42ac3 100644 --- a/src/cipher/testsuite/testsuite.go +++ b/src/cipher/testsuite/testsuite.go @@ -250,14 +250,14 @@ func ValidateSeedData(seedData *SeedTestData, inputData *InputTestData) error { return errors.New("provided signature is null") } - err := cipher.VerifySignature(p, sig, h) + err := cipher.VerifySignatureForPubKey(p, sig, h) if err != nil { - return fmt.Errorf("cipher.VerifySignature failed: %v", err) + return fmt.Errorf("cipher.VerifySignatureForPubKey failed: %v", err) } - err = cipher.ChkSig(addr1, h, sig) + err = cipher.VerifySignatureForAddress(addr1, h, sig) if err != nil { - return fmt.Errorf("cipher.ChkSig failed: %v", err) + return fmt.Errorf("cipher.VerifySignatureForAddress failed: %v", err) } err = cipher.VerifySignedHash(sig, h) diff --git a/src/coin/block.go b/src/coin/block.go index 10513c756f..eea0695786 100644 --- a/src/coin/block.go +++ b/src/coin/block.go @@ -52,7 +52,7 @@ type SignedBlock struct { // VerifySignature verifies that the block is signed by pubkey func (b SignedBlock) VerifySignature(pubkey cipher.PubKey) error { - return cipher.VerifySignature(pubkey, b.Sig, b.Block.HashHeader()) + return cipher.VerifySignatureForPubKey(pubkey, b.Sig, b.HashHeader()) } // NewBlock creates new block. diff --git a/src/coin/transactions.go b/src/coin/transactions.go index 07af3c18d5..5b852383d7 100644 --- a/src/coin/transactions.go +++ b/src/coin/transactions.go @@ -165,7 +165,7 @@ func (txn Transaction) VerifyInput(uxIn UxArray) error { // Check signatures against unspent address for i := range txn.In { hash := cipher.AddSHA256(txn.InnerHash, txn.In[i]) // use inner hash, not outer hash - err := cipher.ChkSig(uxIn[i].Body.Address, hash, txn.Sigs[i]) + err := cipher.VerifySignatureForAddress(uxIn[i].Body.Address, hash, txn.Sigs[i]) if err != nil { return errors.New("Signature not valid for output being spent") } diff --git a/src/coin/transactions_test.go b/src/coin/transactions_test.go index 5ee7cf2b49..ed80a90a02 100644 --- a/src/coin/transactions_test.go +++ b/src/coin/transactions_test.go @@ -112,7 +112,7 @@ func TestTransactionVerify(t *testing.T) { // Invalid signature, empty tx = makeTransaction(t) tx.Sigs[0] = cipher.Sig{} - testutil.RequireError(t, tx.Verify(), "Invalid sig: PubKey recovery failed") + testutil.RequireError(t, tx.Verify(), "Failed to recover pubkey from signature") // We can't check here for other invalid signatures: // - Signatures signed by someone else, spending coins they don't own // - Signature is for wrong hash @@ -262,10 +262,10 @@ func TestTransactionSignInputs(t *testing.T) { a := cipher.AddressFromPubKey(p) p = cipher.MustPubKeyFromSecKey(s2) a2 := cipher.AddressFromPubKey(p) - require.Nil(t, cipher.ChkSig(a, cipher.AddSHA256(h, tx.In[0]), tx.Sigs[0])) - require.Nil(t, cipher.ChkSig(a2, cipher.AddSHA256(h, tx.In[1]), tx.Sigs[1])) - require.NotNil(t, cipher.ChkSig(a, h, tx.Sigs[1])) - require.NotNil(t, cipher.ChkSig(a2, h, tx.Sigs[0])) + require.Nil(t, cipher.VerifySignatureForAddress(a, cipher.AddSHA256(h, tx.In[0]), tx.Sigs[0])) + require.Nil(t, cipher.VerifySignatureForAddress(a2, cipher.AddSHA256(h, tx.In[1]), tx.Sigs[1])) + require.NotNil(t, cipher.VerifySignatureForAddress(a, h, tx.Sigs[1])) + require.NotNil(t, cipher.VerifySignatureForAddress(a2, h, tx.Sigs[0])) } func TestTransactionHash(t *testing.T) { diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index 08729322ae..67990a1326 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -683,7 +683,7 @@ func (bc Blockchain) TransactionFee(tx *dbutil.Tx, headTime uint64) coin.FeeCalc // VerifySignature checks that BlockSigs state correspond with coin.Blockchain state // and that all signatures are valid. func (bc *Blockchain) VerifySignature(block *coin.SignedBlock) error { - err := cipher.VerifySignature(bc.cfg.Pubkey, block.Sig, block.HashHeader()) + err := block.VerifySignature(bc.cfg.Pubkey) if err != nil { logger.Errorf("Signature verification failed: %v", err) } @@ -711,7 +711,7 @@ func (bc *Blockchain) WalkChain(workers int, f func(*dbutil.Tx, *coin.SignedBloc if err := bc.db.View("WalkChain verify blocks", func(tx *dbutil.Tx) error { for b := range signedBlockC { if err := f(tx, b); err != nil { - // if err := cipher.VerifySignature(bc.cfg.Pubkey, sh.sig, sh.hash); err != nil { + // if err := cipher.VerifySignatureForPubKey(bc.cfg.Pubkey, sh.sig, sh.hash); err != nil { // logger.Errorf("Signature verification failed: %v", err) select { case errC <- err: diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 6a7b698b84..54a4120012 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -149,7 +149,7 @@ func makeTransactionForChain(t *testing.T, tx *dbutil.Tx, bc *Blockchain, ux coi require.Equal(t, len(txn.Sigs), 1) - err = cipher.ChkSig(ux.Body.Address, cipher.AddSHA256(txn.HashInner(), txn.In[0]), txn.Sigs[0]) + err = cipher.VerifySignatureForAddress(ux.Body.Address, cipher.AddSHA256(txn.HashInner(), txn.In[0]), txn.Sigs[0]) require.NoError(t, err) txn.UpdateHeader() From 404c04ceee5ce5bf97f87f4b53299acd327d73ae Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 15:03:14 +0800 Subject: [PATCH 285/399] Fix test --- src/api/integration/integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 1fbdb9727b..a2875cc107 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -428,7 +428,7 @@ func TestStableVerifyTransaction(t *testing.T) { txn: badSignatureTxn, golden: "verify-transaction-invalid-bad-sig.golden", errCode: http.StatusUnprocessableEntity, - errMsg: "Transaction violates hard constraint: Invalid sig: invalid for hash", + errMsg: "Transaction violates hard constraint: Signature not valid for hash", }, } From 5636df55a75d7a72998a7dfbd612fcca1c08c2b2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 15:48:18 +0800 Subject: [PATCH 286/399] Fix tests --- lib/cgo/tests/check_cipher.crypto.c | 10 +++++----- lib/cgo/tests/cipher.testsuite.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index ee25eae35b..9a9d6bcfaf 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -667,22 +667,22 @@ Test(cipher_crypto, TestVerifySignature) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h2); SKY_cipher_SignHash(&h, &sk, &sig); - errorcode = SKY_cipher_VerifySignature(&pk, &sig, &h); + errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig, &h); cr_assert(errorcode == SKY_OK); memset(&sig2, 0, sizeof(sig2)); - errorcode = SKY_cipher_VerifySignature(&pk, &sig2, &h); + errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig2, &h); cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); - errorcode = SKY_cipher_VerifySignature(&pk, &sig, &h2); + errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig, &h2); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); SKY_cipher_GenerateKeyPair(&pk2, &sk2); - errorcode = SKY_cipher_VerifySignature(&pk2, &sig, &h); + errorcode = SKY_cipher_VerifySignatureForPubKey(&pk2, &sig, &h); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); memset(&pk2, 0, sizeof(pk2)); - errorcode = SKY_cipher_VerifySignature(&pk2, &sig, &h); + errorcode = SKY_cipher_VerifySignatureForPubKey(&pk2, &sig, &h); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); } diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 975f69e907..7b81e96c3a 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -460,9 +460,9 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { mem_actual.size = mem_expect.size = sizeof(cipher__Sig); cr_assert(ne(mem, mem_actual, mem_expect), "%d-th provided signature for %d-th data set must not be null", j, i); - GoUint32 err = SKY_cipher_VerifySignature(&p, sig, h); + GoUint32 err = SKY_cipher_VerifySignatureForPubKey(&p, sig, h); cr_assert(err == SKY_OK, - "SKY_cipher_VerifySignature failed: error=%d dataset=%d hashidx=%d", err, i, j); + "SKY_cipher_VerifySignatureForPubKey failed: error=%d dataset=%d hashidx=%d", err, i, j); err = SKY_cipher_VerifySignatureForAddress(&addr1, h, sig); cr_assert(err == SKY_OK, "SKY_cipher_VerifySignatureForAddress failed: error=%d dataset=%d hashidx=%d", err, i, j); err = SKY_cipher_VerifySignedHash(sig, h); From bda6f1e55df1b47a2f4f095b7a3e0781ef44b161 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 17:38:51 +0800 Subject: [PATCH 287/399] Accept POST for endpoint with potentially long query strings --- CHANGELOG.md | 1 + src/api/README.md | 13 +++- src/api/address.go | 2 +- src/api/address_test.go | 8 +-- src/api/blockchain.go | 2 +- src/api/blockchain_test.go | 45 ++++++++++++-- src/api/client.go | 64 ++++++++++--------- src/api/csrf_test.go | 2 +- src/api/http.go | 3 +- src/api/integration/integration_test.go | 4 +- src/api/outputs.go | 2 +- src/api/outputs_test.go | 35 ++++++++++- src/api/spend.go | 2 +- src/api/spend_test.go | 4 +- src/api/transaction.go | 4 +- src/api/transaction_test.go | 51 +++++++++++---- src/api/wallet.go | 6 +- src/api/wallet_test.go | 83 +++++++++++++++++-------- 18 files changed, 235 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e096609f..11e8869f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateWallet` renamed to `cli walletCreate` - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. +- `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string ### Removed diff --git a/src/api/README.md b/src/api/README.md index 02fc9fc226..03767eb64c 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -386,11 +386,14 @@ API sets: `READ` ``` URI: /api/v1/balance -Method: GET +Method: GET, POST Args: addrs: comma-separated list of addresses. must contain at least one address ``` +Returns the cumulative and individual balances of one or more addresses. +The `POST` method can be used if many addresses need to be queried. + Example: ```sh @@ -450,7 +453,7 @@ API sets: `READ` ``` URI: /api/v1/outputs -Method: GET +Method: GET, POST Args: addrs: address list, joined with "," hashes: hash list, joined with "," @@ -464,6 +467,8 @@ and `"incoming_outputs"` are outputs that will be created by an unconfirmed tran The current head block header is returned as `"head"`. +The `POST` method can be used if many addresses or hashes need to be queried. + Example: ```sh @@ -1895,7 +1900,7 @@ API sets: `READ` ``` URI: /api/v1/transactions -Method: GET +Method: GET, POST Args: addrs: Comma seperated addresses [optional, returns all transactions if no address is provided] confirmed: Whether the transactions should be confirmed [optional, must be 0 or 1; if not provided, returns all] @@ -1908,6 +1913,8 @@ If the transaction is confirmed, the calculated hours are the hours the transact If the transaction is unconfirmed, the calculated hours are based upon the current system time, and are approximately equal to the hours the output would have if it become confirmed immediately. +The `POST` method can be used if many addresses need to be queried. + To get address related confirmed transactions: ```sh diff --git a/src/api/address.go b/src/api/address.go index 1efa0c26fb..adb28bbfeb 100644 --- a/src/api/address.go +++ b/src/api/address.go @@ -27,7 +27,7 @@ func addressVerifyHandler(w http.ResponseWriter, r *http.Request) { return } - if r.Header.Get("Content-Type") != "application/json" { + if r.Header.Get("Content-Type") != ContentTypeJSON { resp := NewHTTPErrorResponse(http.StatusUnsupportedMediaType, "") writeHTTPResponse(w, resp) return diff --git a/src/api/address_test.go b/src/api/address_test.go index 05f7a7c6e5..2e2284e4e8 100644 --- a/src/api/address_test.go +++ b/src/api/address_test.go @@ -36,7 +36,7 @@ func TestVerifyAddress(t *testing.T) { { name: "415 - Unsupported Media Type", method: http.MethodPost, - contentType: "application/x-www-form-urlencoded", + contentType: ContentTypeForm, status: http.StatusUnsupportedMediaType, httpResponse: NewHTTPErrorResponse(http.StatusUnsupportedMediaType, ""), }, @@ -44,7 +44,7 @@ func TestVerifyAddress(t *testing.T) { { name: "400 - EOF", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "EOF"), }, @@ -52,7 +52,7 @@ func TestVerifyAddress(t *testing.T) { { name: "400 - Missing address", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpBody: "{}", httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "address is required"), @@ -106,7 +106,7 @@ func TestVerifyAddress(t *testing.T) { contentType := tc.contentType if contentType == "" { - contentType = "application/json" + contentType = ContentTypeJSON } req.Header.Set("Content-Type", contentType) diff --git a/src/api/blockchain.go b/src/api/blockchain.go index 80f6d2db41..ff90feab51 100644 --- a/src/api/blockchain.go +++ b/src/api/blockchain.go @@ -206,7 +206,7 @@ func blockHandler(gateway Gatewayer) http.HandlerFunc { // verbose [bool] func blocksHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { + if r.Method != http.MethodGet && r.Method != http.MethodPost { wh.Error405(w) return } diff --git a/src/api/blockchain_test.go b/src/api/blockchain_test.go index afc0bc0327..54c8c4aa9b 100644 --- a/src/api/blockchain_test.go +++ b/src/api/blockchain_test.go @@ -1,6 +1,7 @@ package api import ( + "io" "net/http" "net/http/httptest" "net/url" @@ -553,7 +554,7 @@ func TestGetBlock(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, nil) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: true, @@ -622,7 +623,7 @@ func TestGetBlocks(t *testing.T) { }{ { name: "405", - method: http.MethodPost, + method: http.MethodDelete, status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, @@ -915,6 +916,32 @@ func TestGetBlocks(t *testing.T) { }, }, }, + + { + name: "200 seqs POST", + method: http.MethodPost, + status: http.StatusOK, + body: &httpBody{ + Seqs: "1,2,3", + }, + seqs: []uint64{1, 2, 3}, + gatewayGetBlocksResult: []coin.SignedBlock{{}}, + response: &readable.Blocks{ + Blocks: []readable.Block{ + readable.Block{ + Head: readable.BlockHeader{ + Hash: "7b8ec8dd836b564f0c85ad088fc744de820345204e154bc1503e04e9d6fdd9f1", + PreviousHash: "0000000000000000000000000000000000000000000000000000000000000000", + BodyHash: "0000000000000000000000000000000000000000000000000000000000000000", + UxHash: "0000000000000000000000000000000000000000000000000000000000000000", + }, + Body: readable.BlockBody{ + Transactions: []readable.Transaction{}, + }, + }, + }, + }, + }, } for _, tc := range tt { @@ -944,13 +971,23 @@ func TestGetBlocks(t *testing.T) { v.Add("seqs", tc.body.Seqs) } } + + var reqBody io.Reader if len(v) > 0 { - endpoint += "?" + v.Encode() + if tc.method == http.MethodPost { + reqBody = strings.NewReader(v.Encode()) + } else { + endpoint += "?" + v.Encode() + } } - req, err := http.NewRequest(tc.method, endpoint, nil) + req, err := http.NewRequest(tc.method, endpoint, reqBody) require.NoError(t, err) + if tc.method == http.MethodPost { + req.Header.Set("Content-Type", ContentTypeForm) + } + csrfStore := &CSRFStore{ Enabled: true, } diff --git a/src/api/client.go b/src/api/client.go index c61646d58e..cf1ccfd4f9 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -22,6 +22,11 @@ const ( dialTimeout = 60 * time.Second httpClientTimeout = 120 * time.Second tlsHandshakeTimeout = 60 * time.Second + + // ContentTypeJSON json content type header + ContentTypeJSON = "application/json" + // ContentTypeForm form data content type header + ContentTypeForm = "application/x-www-form-urlencoded" ) // ClientError is used for non-200 API responses @@ -136,9 +141,9 @@ func (c *Client) get(endpoint string) (*http.Response, error) { return c.HTTPClient.Do(req) } -// PostForm makes a POST request to an endpoint with body of "application/x-www-form-urlencoded" formated data. +// PostForm makes a POST request to an endpoint with body of ContentTypeForm formated data. func (c *Client) PostForm(endpoint string, body io.Reader, obj interface{}) error { - return c.post(endpoint, "application/x-www-form-urlencoded", body, obj) + return c.Post(endpoint, ContentTypeForm, body, obj) } // PostJSON makes a POST request to an endpoint with body of json data. @@ -148,11 +153,11 @@ func (c *Client) PostJSON(endpoint string, reqObj, respObj interface{}) error { return err } - return c.post(endpoint, "application/json", bytes.NewReader(body), respObj) + return c.Post(endpoint, ContentTypeJSON, bytes.NewReader(body), respObj) } -// post makes a POST request to an endpoint. -func (c *Client) post(endpoint string, contentType string, body io.Reader, obj interface{}) error { +// Post makes a POST request to an endpoint. +func (c *Client) Post(endpoint string, contentType string, body io.Reader, obj interface{}) error { csrf, err := c.CSRF() if err != nil { return err @@ -226,8 +231,8 @@ func (c *Client) PostJSONV2(endpoint string, reqObj, respObj interface{}) (bool, req.Header.Set(CSRFHeaderName, csrf) } - req.Header.Set("Content-Type", "application/json") - req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", ContentTypeJSON) + req.Header.Set("Accept", ContentTypeJSON) resp, err := c.HTTPClient.Do(req) if err != nil { @@ -337,10 +342,11 @@ func (c *Client) Outputs() (*readable.UnspentOutputsSummary, error) { func (c *Client) OutputsForAddresses(addrs []string) (*readable.UnspentOutputsSummary, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) - endpoint := "/api/v1/outputs?" + v.Encode() + + endpoint := "/api/v1/outputs" var o readable.UnspentOutputsSummary - if err := c.Get(endpoint, &o); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &o); err != nil { return nil, err } return &o, nil @@ -350,10 +356,10 @@ func (c *Client) OutputsForAddresses(addrs []string) (*readable.UnspentOutputsSu func (c *Client) OutputsForHashes(hashes []string) (*readable.UnspentOutputsSummary, error) { v := url.Values{} v.Add("hashes", strings.Join(hashes, ",")) - endpoint := "/api/v1/outputs?" + v.Encode() + endpoint := "/api/v1/outputs" var o readable.UnspentOutputsSummary - if err := c.Get(endpoint, &o); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &o); err != nil { return nil, err } return &o, nil @@ -431,10 +437,10 @@ func (c *Client) Blocks(seqs []uint64) (*readable.Blocks, error) { v := url.Values{} v.Add("seqs", strings.Join(sSeqs, ",")) - endpoint := "/api/v1/blocks?" + v.Encode() + endpoint := "/api/v1/blocks" var b readable.Blocks - if err := c.Get(endpoint, &b); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &b); err != nil { return nil, err } return &b, nil @@ -450,10 +456,10 @@ func (c *Client) BlocksVerbose(seqs []uint64) (*readable.BlocksVerbose, error) { v := url.Values{} v.Add("seqs", strings.Join(sSeqs, ",")) v.Add("verbose", "1") - endpoint := "/api/v1/blocks?" + v.Encode() + endpoint := "/api/v1/blocks" var b readable.BlocksVerbose - if err := c.Get(endpoint, &b); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &b); err != nil { return nil, err } return &b, nil @@ -537,10 +543,10 @@ func (c *Client) BlockchainProgress() (*readable.BlockchainProgress, error) { func (c *Client) Balance(addrs []string) (*BalanceResponse, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) - endpoint := "/api/v1/balance?" + v.Encode() + endpoint := "/api/v1/balance" var b BalanceResponse - if err := c.Get(endpoint, &b); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &b); err != nil { return nil, err } return &b, nil @@ -918,10 +924,10 @@ func (c *Client) TransactionEncoded(txid string) (*TransactionEncodedResponse, e func (c *Client) Transactions(addrs []string) ([]readable.TransactionWithStatus, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatus - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil @@ -932,10 +938,10 @@ func (c *Client) ConfirmedTransactions(addrs []string) ([]readable.TransactionWi v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) v.Add("confirmed", "true") - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatus - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil @@ -946,10 +952,10 @@ func (c *Client) UnconfirmedTransactions(addrs []string) ([]readable.Transaction v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) v.Add("confirmed", "false") - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatus - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil @@ -960,10 +966,10 @@ func (c *Client) TransactionsVerbose(addrs []string) ([]readable.TransactionWith v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) v.Add("verbose", "1") - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatusVerbose - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil @@ -975,10 +981,10 @@ func (c *Client) ConfirmedTransactionsVerbose(addrs []string) ([]readable.Transa v.Add("addrs", strings.Join(addrs, ",")) v.Add("confirmed", "true") v.Add("verbose", "1") - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatusVerbose - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil @@ -990,10 +996,10 @@ func (c *Client) UnconfirmedTransactionsVerbose(addrs []string) ([]readable.Tran v.Add("addrs", strings.Join(addrs, ",")) v.Add("confirmed", "false") v.Add("verbose", "1") - endpoint := "/api/v1/transactions?" + v.Encode() + endpoint := "/api/v1/transactions" var r []readable.TransactionWithStatusVerbose - if err := c.Get(endpoint, &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(v.Encode()), &r); err != nil { return nil, err } return r, nil diff --git a/src/api/csrf_test.go b/src/api/csrf_test.go index 7e68ef6e63..6789190430 100644 --- a/src/api/csrf_test.go +++ b/src/api/csrf_test.go @@ -111,7 +111,7 @@ func TestCSRF(t *testing.T) { req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) if csrfToken != "" { req.Header.Set("X-CSRF-Token", csrfToken) diff --git a/src/api/http.go b/src/api/http.go index 82aa2cb244..03983bf7fa 100644 --- a/src/api/http.go +++ b/src/api/http.go @@ -131,7 +131,7 @@ func writeHTTPResponse(w http.ResponseWriter, resp HTTPResponse) { return } - w.Header().Add("Content-Type", "application/json") + w.Header().Add("Content-Type", ContentTypeJSON) if resp.Error == nil { w.WriteHeader(http.StatusOK) @@ -208,6 +208,7 @@ func create(host string, c Config, gateway Gatewayer) (*Server, error) { ReadTimeout: c.ReadTimeout, WriteTimeout: c.WriteTimeout, IdleTimeout: c.IdleTimeout, + // MaxHeaderBytes: http.DefaultMaxHeaderBytes, // adjust this to allow longer GET queries } return &Server{ diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 1fbdb9727b..0cf81c2ed3 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -5719,7 +5719,7 @@ func TestDisableWalletAPI(t *testing.T) { name: "create transaction", method: http.MethodPost, endpoint: "/api/v1/wallet/transaction", - contentType: "application/json", + contentType: api.ContentTypeJSON, json: func() interface{} { return api.CreateTransactionRequest{ HoursSelection: api.HoursSelection{ @@ -5753,7 +5753,7 @@ func TestDisableWalletAPI(t *testing.T) { err = c.Get(tc.endpoint, nil) case http.MethodPost: switch tc.contentType { - case "application/json": + case api.ContentTypeJSON: err = c.PostJSON(tc.endpoint, tc.json(), nil) default: err = c.PostForm(tc.endpoint, tc.body(), nil) diff --git a/src/api/outputs.go b/src/api/outputs.go index d0ab95ac5e..5e4cfadcd0 100644 --- a/src/api/outputs.go +++ b/src/api/outputs.go @@ -21,7 +21,7 @@ import ( // Both filters cannot be specified. func outputsHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { + if r.Method != http.MethodGet && r.Method != http.MethodPost { wh.Error405(w) return } diff --git a/src/api/outputs_test.go b/src/api/outputs_test.go index c9ddacf9b3..94f8735358 100644 --- a/src/api/outputs_test.go +++ b/src/api/outputs_test.go @@ -3,6 +3,7 @@ package api import ( "encoding/json" "errors" + "io" "net/http" "net/http/httptest" "net/url" @@ -38,7 +39,7 @@ func TestGetOutputsHandler(t *testing.T) { }{ { name: "405", - method: http.MethodPost, + method: http.MethodDelete, status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, @@ -88,6 +89,25 @@ func TestGetOutputsHandler(t *testing.T) { IncomingOutputs: readable.UnspentOutputs{}, }, }, + { + name: "200 - OK POST", + method: http.MethodPost, + status: http.StatusOK, + getUnspentOutputsResponse: &visor.UnspentOutputsSummary{ + HeadBlock: &coin.SignedBlock{}, + }, + httpResponse: &readable.UnspentOutputsSummary{ + Head: readable.BlockHeader{ + Hash: "7b8ec8dd836b564f0c85ad088fc744de820345204e154bc1503e04e9d6fdd9f1", + PreviousHash: "0000000000000000000000000000000000000000000000000000000000000000", + BodyHash: "0000000000000000000000000000000000000000000000000000000000000000", + UxHash: "0000000000000000000000000000000000000000000000000000000000000000", + }, + HeadOutputs: readable.UnspentOutputs{}, + OutgoingOutputs: readable.UnspentOutputs{}, + IncomingOutputs: readable.UnspentOutputs{}, + }, + }, } for _, tc := range tt { @@ -106,13 +126,22 @@ func TestGetOutputsHandler(t *testing.T) { } } + var reqBody io.Reader if len(v) > 0 { - endpoint += "?" + v.Encode() + if tc.method == http.MethodPost { + reqBody = strings.NewReader(v.Encode()) + } else { + endpoint += "?" + v.Encode() + } } - req, err := http.NewRequest(tc.method, endpoint, nil) + req, err := http.NewRequest(tc.method, endpoint, reqBody) require.NoError(t, err) + if tc.method == http.MethodPost { + req.Header.Set("Content-Type", ContentTypeForm) + } + rr := httptest.NewRecorder() handler := newServerMux(defaultMuxConfig(), gateway, &CSRFStore{}, nil) handler.ServeHTTP(rr, req) diff --git a/src/api/spend.go b/src/api/spend.go index 8e790cea08..3e47a94a6f 100644 --- a/src/api/spend.go +++ b/src/api/spend.go @@ -476,7 +476,7 @@ func createTransactionHandler(gateway Gatewayer) http.HandlerFunc { return } - if r.Header.Get("Content-Type") != "application/json" { + if r.Header.Get("Content-Type") != ContentTypeJSON { wh.Error415(w) return } diff --git a/src/api/spend_test.go b/src/api/spend_test.go index e18a71da62..d9d623c338 100644 --- a/src/api/spend_test.go +++ b/src/api/spend_test.go @@ -131,7 +131,7 @@ func TestCreateTransaction(t *testing.T) { name: "415", method: http.MethodPost, status: http.StatusUnsupportedMediaType, - contentType: "application/x-www-form-urlencoded", + contentType: ContentTypeForm, err: "415 Unsupported Media Type", }, @@ -862,7 +862,7 @@ func TestCreateTransaction(t *testing.T) { contentType := tc.contentType if contentType == "" { - contentType = "application/json" + contentType = ContentTypeJSON } req.Header.Add("Content-Type", contentType) diff --git a/src/api/transaction.go b/src/api/transaction.go index 41e1653b2d..140bf12fb1 100644 --- a/src/api/transaction.go +++ b/src/api/transaction.go @@ -255,7 +255,7 @@ func NewTransactionsWithStatusVerbose(txns []visor.Transaction, inputs [][]visor // verbose: [bool] include verbose transaction input data func transactionsHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { + if r.Method != http.MethodGet && r.Method != http.MethodPost { wh.Error405(w) return } @@ -491,7 +491,7 @@ func verifyTxnHandler(gateway Gatewayer) http.HandlerFunc { return } - if r.Header.Get("Content-Type") != "application/json" { + if r.Header.Get("Content-Type") != ContentTypeJSON { resp := NewHTTPErrorResponse(http.StatusUnsupportedMediaType, "") writeHTTPResponse(w, resp) return diff --git a/src/api/transaction_test.go b/src/api/transaction_test.go index 170875c686..fc3944bd2e 100644 --- a/src/api/transaction_test.go +++ b/src/api/transaction_test.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "encoding/json" "errors" + "io" "math" "net/http" "net/http/httptest" @@ -1019,7 +1020,7 @@ func TestGetTransactions(t *testing.T) { }{ { name: "405", - method: http.MethodPost, + method: http.MethodDelete, status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, @@ -1135,11 +1136,27 @@ func TestGetTransactions(t *testing.T) { }, httpResponse: []readable.TransactionWithStatusVerbose{}, }, + + { + name: "200 POST", + method: http.MethodPost, + status: http.StatusOK, + httpBody: &httpBody{ + addrs: addrsStr, + confirmed: "true", + }, + getTransactionsArg: []visor.TxFilter{ + visor.NewAddrsFilter(addrs), + visor.NewConfirmedTxFilter(true), + }, + getTransactionsResponse: []visor.Transaction{}, + httpResponse: []readable.TransactionWithStatus{}, + }, } for _, tc := range tt { - endpoint := "/api/v1/transactions" t.Run(tc.name, func(t *testing.T) { + endpoint := "/api/v1/transactions" gateway := &MockGatewayer{} // Custom argument matching function for matching TxFilter args @@ -1209,13 +1226,23 @@ func TestGetTransactions(t *testing.T) { v.Add("verbose", tc.httpBody.verbose) } } + + var reqBody io.Reader if len(v) > 0 { - endpoint += "?" + v.Encode() + if tc.method == http.MethodPost { + reqBody = strings.NewReader(v.Encode()) + } else { + endpoint += "?" + v.Encode() + } } - req, err := http.NewRequest(tc.method, endpoint, nil) + req, err := http.NewRequest(tc.method, endpoint, reqBody) require.NoError(t, err) + if tc.method == http.MethodPost { + req.Header.Set("Content-Type", ContentTypeForm) + } + csrfStore := &CSRFStore{ Enabled: true, } @@ -1343,7 +1370,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "400 - EOF", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "EOF"), }, @@ -1357,7 +1384,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "400 - Invalid transaction: Not enough buffer data to deserialize", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpBody: `{"wrongKey":"wrongValue"}`, httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "decode transaction failed: Invalid transaction: Not enough buffer data to deserialize"), @@ -1365,7 +1392,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "400 - encoding/hex: odd length hex string", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpBody: `{"encoded_transaction":"aab"}`, httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "decode transaction failed: encoding/hex: odd length hex string"), @@ -1373,7 +1400,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "400 - deserialization error", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusBadRequest, httpBody: string(invalidTxnBodyJSON), httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "decode transaction failed: Invalid transaction: Not enough buffer data to deserialize"), @@ -1381,7 +1408,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "422 - txn sends to empty address", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusUnprocessableEntity, httpBody: string(invalidTxnEmptyAddressBodyJSON), gatewayVerifyTxnVerboseArg: invalidTxnEmptyAddress.txn, @@ -1400,7 +1427,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "500 - internal server error", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusInternalServerError, httpBody: string(validTxnBodyJSON), gatewayVerifyTxnVerboseArg: txnAndInputs.txn, @@ -1412,7 +1439,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "422 - txn is confirmed", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusUnprocessableEntity, httpBody: string(validTxnBodyJSON), gatewayVerifyTxnVerboseArg: txnAndInputs.txn, @@ -1431,7 +1458,7 @@ func TestVerifyTransaction(t *testing.T) { { name: "200", method: http.MethodPost, - contentType: "application/json", + contentType: ContentTypeJSON, status: http.StatusOK, httpBody: string(validTxnBodyJSON), gatewayVerifyTxnVerboseArg: txnAndInputs.txn, diff --git a/src/api/wallet.go b/src/api/wallet.go index 8a31ba57e2..1ffaeebb78 100644 --- a/src/api/wallet.go +++ b/src/api/wallet.go @@ -128,12 +128,12 @@ func walletBalanceHandler(gateway Gatewayer) http.HandlerFunc { // Returns the balance of one or more addresses, both confirmed and predicted. The predicted // balance is the confirmed balance minus the pending spends. // URI: /api/v1/balance -// Method: GET +// Method: GET, POST // Args: // addrs: command separated list of addresses [required] func balanceHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { + if r.Method != http.MethodGet && r.Method != http.MethodPost { wh.Error405(w) return } @@ -949,7 +949,7 @@ func walletRecoverHandler(gateway Gatewayer) http.HandlerFunc { return } - if r.Header.Get("Content-Type") != "application/json" { + if r.Header.Get("Content-Type") != ContentTypeJSON { resp := NewHTTPErrorResponse(http.StatusUnsupportedMediaType, "") writeHTTPResponse(w, resp) return diff --git a/src/api/wallet_test.go b/src/api/wallet_test.go index 66f801b65e..5fd2773b30 100644 --- a/src/api/wallet_test.go +++ b/src/api/wallet_test.go @@ -3,6 +3,7 @@ package api import ( "bytes" "errors" + "io" "math" "net/http" "net/http/httptest" @@ -45,7 +46,7 @@ func TestGetBalanceHandler(t *testing.T) { }{ { name: "405", - method: http.MethodPost, + method: http.MethodDelete, status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, @@ -137,6 +138,27 @@ func TestGetBalanceHandler(t *testing.T) { }, httpResponse: readable.BalancePair{}, }, + { + name: "200 - OK POST", + method: http.MethodPost, + status: http.StatusOK, + err: "200 - OK", + httpBody: &httpBody{ + addrs: validAddr, + }, + getBalanceOfAddrsArg: []cipher.Address{address}, + getBalanceOfAddrsResponse: []wallet.BalancePair{ + { + Confirmed: wallet.Balance{Coins: 0, Hours: 0}, + Predicted: wallet.Balance{Coins: 0, Hours: 0}, + }, + { + Confirmed: wallet.Balance{Coins: 0, Hours: 0}, + Predicted: wallet.Balance{Coins: 0, Hours: 0}, + }, + }, + httpResponse: readable.BalancePair{}, + }, } for _, tc := range tt { @@ -152,13 +174,22 @@ func TestGetBalanceHandler(t *testing.T) { } } + var reqBody io.Reader if len(v) > 0 { - endpoint += "?" + v.Encode() + if tc.method == http.MethodPost { + reqBody = strings.NewReader(v.Encode()) + } else { + endpoint += "?" + v.Encode() + } } - req, err := http.NewRequest(tc.method, endpoint, nil) + req, err := http.NewRequest(tc.method, endpoint, reqBody) require.NoError(t, err) + if tc.method == http.MethodPost { + req.Header.Set("Content-Type", ContentTypeForm) + } + rr := httptest.NewRecorder() handler := newServerMux(defaultMuxConfig(), gateway, &CSRFStore{}, nil) handler.ServeHTTP(rr, req) @@ -601,7 +632,7 @@ func TestWalletSpendHandler(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: !tc.csrfDisabled, @@ -869,7 +900,7 @@ func TestWalletBalanceHandler(t *testing.T) { } req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: true, @@ -1014,7 +1045,7 @@ func TestUpdateWalletLabelHandler(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: true, @@ -1534,7 +1565,7 @@ func TestWalletCreateHandler(t *testing.T) { } req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) require.NoError(t, err) csrfStore := &CSRFStore{ @@ -1657,7 +1688,7 @@ func TestWalletNewSeed(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: true, @@ -1811,7 +1842,7 @@ func TestGetWalletSeed(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: !tc.csrfDisabled, @@ -2025,7 +2056,7 @@ func TestWalletNewAddressesHandler(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: !tc.csrfDisabled, @@ -2408,7 +2439,7 @@ func TestWalletUnloadHandler(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: !tc.csrfDisabled, @@ -2561,7 +2592,7 @@ func TestEncryptWallet(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: true, @@ -2744,7 +2775,7 @@ func TestDecryptWallet(t *testing.T) { req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Type", ContentTypeForm) csrfStore := &CSRFStore{ Enabled: !tc.csrfDisabled, @@ -2843,7 +2874,7 @@ func TestWalletRecover(t *testing.T) { name: "method not allowed", method: http.MethodGet, status: http.StatusMethodNotAllowed, - contentType: "application/json", + contentType: ContentTypeJSON, httpBody: toJSON(t, WalletRecoverRequest{}), httpResponse: NewHTTPErrorResponse(http.StatusMethodNotAllowed, "Method Not Allowed"), }, @@ -2851,7 +2882,7 @@ func TestWalletRecover(t *testing.T) { name: "wrong content-type", method: http.MethodPost, status: http.StatusUnsupportedMediaType, - contentType: "application/x-www-form-urlencoded", + contentType: ContentTypeForm, httpBody: toJSON(t, WalletRecoverRequest{}), httpResponse: NewHTTPErrorResponse(http.StatusUnsupportedMediaType, "Unsupported Media Type"), }, @@ -2859,7 +2890,7 @@ func TestWalletRecover(t *testing.T) { name: "empty json body", method: http.MethodPost, status: http.StatusBadRequest, - contentType: "application/json", + contentType: ContentTypeJSON, httpBody: "", httpResponse: NewHTTPErrorResponse(http.StatusBadRequest, "EOF"), }, @@ -2867,7 +2898,7 @@ func TestWalletRecover(t *testing.T) { name: "id missing", method: http.MethodPost, status: http.StatusBadRequest, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ Seed: "fooseed", }, @@ -2877,7 +2908,7 @@ func TestWalletRecover(t *testing.T) { name: "seed missing", method: http.MethodPost, status: http.StatusBadRequest, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", }, @@ -2887,7 +2918,7 @@ func TestWalletRecover(t *testing.T) { name: "wallet not encrypted", method: http.MethodPost, status: http.StatusBadRequest, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2901,7 +2932,7 @@ func TestWalletRecover(t *testing.T) { name: "wallet seed wrong", method: http.MethodPost, status: http.StatusBadRequest, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2915,7 +2946,7 @@ func TestWalletRecover(t *testing.T) { name: "wallet does not exist", method: http.MethodPost, status: http.StatusNotFound, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2929,7 +2960,7 @@ func TestWalletRecover(t *testing.T) { name: "wallet api disabled", method: http.MethodPost, status: http.StatusForbidden, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2943,7 +2974,7 @@ func TestWalletRecover(t *testing.T) { name: "wallet other error", method: http.MethodPost, status: http.StatusInternalServerError, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2957,7 +2988,7 @@ func TestWalletRecover(t *testing.T) { name: "ok, no password", method: http.MethodPost, status: http.StatusOK, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -2973,7 +3004,7 @@ func TestWalletRecover(t *testing.T) { name: "ok, password", method: http.MethodPost, status: http.StatusOK, - contentType: "application/json", + contentType: ContentTypeJSON, req: &WalletRecoverRequest{ ID: "foo", Seed: "fooseed", @@ -3009,7 +3040,7 @@ func TestWalletRecover(t *testing.T) { contentType := tc.contentType if contentType == "" { - contentType = "application/json" + contentType = ContentTypeJSON } req.Header.Set("Content-Type", contentType) From 75ec497c01f95c8a8e65b7f535093d35ddccc8ac Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 20 Oct 2018 19:45:00 +0800 Subject: [PATCH 288/399] Install pinned golangci-lint in travis --- .travis.yml | 2 ++ ci-scripts/install-golangci-lint.sh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 ci-scripts/install-golangci-lint.sh diff --git a/.travis.yml b/.travis.yml index 4d18a7e886..7ea8650932 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,8 @@ install: - cd $GOPATH/src/github.com/skycoin/skycoin - go get -t ./... - make install-linters + # Install pinned golangci-lint, overriding the latest version install by make install-linters + - VERSION=1.10.2 ./ci-scripts/install-golangci-lint.sh - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -qq g++-6 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; echo 'Available versions (gcc)' && brew list --versions gcc ; brew list gcc@6 &>/dev/null || brew install gcc@6 ; fi - make install-deps-libc diff --git a/ci-scripts/install-golangci-lint.sh b/ci-scripts/install-golangci-lint.sh new file mode 100755 index 0000000000..6c796c7dc5 --- /dev/null +++ b/ci-scripts/install-golangci-lint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +if [ -z "$VERSION" ]; then + echo "VERSION must be set" + exit 1 +fi + +# binary will be $GOPATH/bin/golangci-lint +curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v$VERSION + +# or install it into ./bin/ +curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z + +# In alpine linux (as it does not come with curl by default) +wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z + +golangci-lint --version From f60b86af213ea70ebc78ff53b6dcef55585422bf Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sat, 20 Oct 2018 17:50:06 -0400 Subject: [PATCH 289/399] [lib] refs #1191 - Get errorFromLibCode. Use it in fee calculator callback [====] Synthesis: Tested: 138 | Passing: 138 | Failing: 0 | Crashing: 0 --- lib/cgo/coin.block.go | 6 +++++- lib/cgo/libsky_error.go | 44 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/cgo/coin.block.go b/lib/cgo/coin.block.go index be7f7cafe6..23419f2006 100644 --- a/lib/cgo/coin.block.go +++ b/lib/cgo/coin.block.go @@ -29,7 +29,11 @@ func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher_ if result == SKY_OK { return uint64(fee), nil } else { - return 0, errors.New("Error calculating fee") + err := errorFromLibCode(uint32(result)) + if err == nil { + err = errors.New("Error in libskycoin fee calculator") + } + return 0, err } } diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index bea289fd1d..b5a62f17e6 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -66,7 +66,6 @@ const ( SKY_PKG_WALLET ) -//nolint megacheck // Error codes defined in cipher package //nolint megacheck const ( @@ -638,6 +637,49 @@ func libErrorCode(err error) uint32 { return SKY_ERROR } +func errorFromLibCode(errcode uint32) error { + if err, exists := codeToErrorMap[errcode]; exists { + return err + } + + // FIXME: Be more specific and encode type, sub-error in error code + err := errors.New("libskycoin error") + if errcode == SKY_WalletLoadError { + return cli.WalletLoadError{} + } + if errcode == SKY_WalletSaveError { + return cli.WalletSaveError{} + } + if errcode == SKY_ErrHistoryDBCorrupted { + return historydb.NewErrHistoryDBCorrupted(err) + } + if errcode == SKY_ErrUxOutNotExist { + return historydb.ErrUxOutNotExist{UxID: ""} + } + if errcode == SKY_ErrUnspentNotExist { + return blockdb.ErrUnspentNotExist{UxID: ""} + } + if errcode == SKY_ErrMissingSignature { + return blockdb.NewErrMissingSignature(nil) + } + if errcode == SKY_ErrCreateBucketFailed { + return dbutil.ErrCreateBucketFailed{Bucket: "", Err: nil} + } + if errcode == SKY_ErrBucketNotExist { + return dbutil.ErrBucketNotExist{Bucket: ""} + } + if errcode == SKY_ErrTxnViolatesHardConstraint { + return visor.ErrTxnViolatesHardConstraint{Err: err} + } + if errcode == SKY_ErrTxnViolatesSoftConstraint { + return visor.ErrTxnViolatesSoftConstraint{Err: err} + } + if errcode == SKY_ErrTxnViolatesUserConstraint { + return visor.ErrTxnViolatesUserConstraint{Err: err} + } + return nil +} + func init() { // Init reverse error code map for _err := range errorToCodeMap { From 6eb14bfb51b3b65a4fa9abb3db5a481d28ff5bce Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 21 Oct 2018 11:06:57 +0800 Subject: [PATCH 290/399] Redo renames --- lib/cgo/cipher.crypto.go | 12 +++---- lib/cgo/libsky_error.go | 4 +-- lib/cgo/tests/check_cipher.crypto.c | 40 +++++++++++----------- lib/cgo/tests/cipher.testsuite.c | 8 ++--- src/cipher/crypto.go | 44 ++++++++++++------------- src/cipher/crypto_test.go | 44 ++++++++++++------------- src/cipher/secp256k1-go/secp256_test.go | 14 ++++---- src/cipher/secp256k1-go/secp256k1.go | 14 ++++---- src/cipher/testsuite/testsuite.go | 8 ++--- src/coin/block.go | 2 +- src/coin/transactions.go | 2 +- src/coin/transactions_test.go | 8 ++--- src/consensus/blockstat.go | 2 +- src/visor/blockchain.go | 4 +-- src/visor/blockchain_verify_test.go | 2 +- 15 files changed, 104 insertions(+), 104 deletions(-) diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index 584ef87f8f..f746dc17cc 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -189,13 +189,13 @@ func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 return } -//export SKY_cipher_VerifySignatureForAddress -func SKY_cipher_VerifySignatureForAddress(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { +//export SKY_cipher_VerifyAddressSignedHash +func SKY_cipher_VerifyAddressSignedHash(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { address := inplaceAddress(_address) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) - err := cipher.VerifySignatureForAddress(*address, *hash, *sig) + err := cipher.VerifyAddressSignedHash(*address, *hash, *sig) ____error_code = libErrorCode(err) return } @@ -210,13 +210,13 @@ func SKY_cipher_VerifySignedHash(_sig *C.cipher__Sig, _hash *C.cipher__SHA256) ( return } -//export SKY_cipher_VerifySignatureForPubKey -func SKY_cipher_VerifySignatureForPubKey(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { +//export SKY_cipher_VerifyPubKeySignedHash +func SKY_cipher_VerifyPubKeySignedHash(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { pubkey := (*cipher.PubKey)(unsafe.Pointer(_pubkey)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) - err := cipher.VerifySignatureForPubKey(*pubkey, *sig, *hash) + err := cipher.VerifyPubKeySignedHash(*pubkey, *sig, *hash) ____error_code = libErrorCode(err) return } diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index d9d6b9f8f3..aac026eb00 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -121,9 +121,9 @@ const ( SKY_ErrInvalidHashForSig // SKY_ErrPubKeyRecoverMismatch Recovered pubkey does not match pubkey SKY_ErrPubKeyRecoverMismatch - // SKY_ErrInvalidSigInvalidPubKey VerifySignature, secp256k1.VerifyPubkey failed + // SKY_ErrInvalidSigInvalidPubKey VerifySignedHash, secp256k1.VerifyPubkey failed SKY_ErrInvalidSigInvalidPubKey - // SKY_ErrInvalidSigValidity VerifySignature, VerifySignatureValidity failed + // SKY_ErrInvalidSigValidity VerifySignedHash, VerifySignedHashValidity failed SKY_ErrInvalidSigValidity // SKY_ErrInvalidSigForMessage Invalid signature for this message SKY_ErrInvalidSigForMessage diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 9a9d6bcfaf..4029a91fe7 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -491,7 +491,7 @@ Test(cipher_crypto, TestSigHex) { } // FIXME: Split in multiple test cases so as to catch panic at the right place -Test(cipher_crypto, TestVerifySignatureForAddress) { +Test(cipher_crypto, TestVerifyAddressSignedHash) { cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__Address addr, addr2; @@ -513,12 +513,12 @@ Test(cipher_crypto, TestVerifySignatureForAddress) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); // Empty sig should be invalid memset(&sig, 0, sizeof(sig)); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); // Random sigs should not pass @@ -526,7 +526,7 @@ Test(cipher_crypto, TestVerifySignatureForAddress) { for (i = 0; i < 100; i++) { randBytes(&b, 65); SKY_cipher_NewSig(b, &sig); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode != SKY_OK); // One of many error codes } @@ -534,11 +534,11 @@ Test(cipher_crypto, TestVerifySignatureForAddress) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h2); SKY_cipher_SignHash(&h2, &sk, &sig2); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h2, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h2, &sig2); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig2); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h2, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h2, &sig); cr_assert(errorcode != SKY_OK); // One of many error codes // Different secret keys should not create same sig @@ -547,9 +547,9 @@ Test(cipher_crypto, TestVerifySignatureForAddress) { memset(&h, 0, sizeof(h)); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig2); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); @@ -557,16 +557,16 @@ Test(cipher_crypto, TestVerifySignatureForAddress) { SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig2); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); // Bad address should be invalid - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig2); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr2, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); } @@ -589,7 +589,7 @@ Test(cipher_crypto, TestSignHash) { cr_assert(errorcode == SKY_OK); memset((void *) &sig2, 0, 65); cr_assert(not(eq(u8[65], sig2, sig))); - errorcode = SKY_cipher_VerifySignatureForAddress(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); cr_assert(errorcode == SKY_OK); errorcode = SKY_cipher_PubKeyFromSig(&sig, &h, &pk2); @@ -652,7 +652,7 @@ Test(cipher_crypto, TestPubKeyFromSig) { cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); } -Test(cipher_crypto, TestVerifySignature) { +Test(cipher_crypto, TestVerifySignedHash) { cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__SHA256 h, h2; @@ -667,22 +667,22 @@ Test(cipher_crypto, TestVerifySignature) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h2); SKY_cipher_SignHash(&h, &sk, &sig); - errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig, &h); + errorcode = SKY_cipher_VerifyPubKeySignedHash(&pk, &sig, &h); cr_assert(errorcode == SKY_OK); memset(&sig2, 0, sizeof(sig2)); - errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig2, &h); + errorcode = SKY_cipher_VerifyPubKeySignedHash(&pk, &sig2, &h); cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); - errorcode = SKY_cipher_VerifySignatureForPubKey(&pk, &sig, &h2); + errorcode = SKY_cipher_VerifyPubKeySignedHash(&pk, &sig, &h2); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); SKY_cipher_GenerateKeyPair(&pk2, &sk2); - errorcode = SKY_cipher_VerifySignatureForPubKey(&pk2, &sig, &h); + errorcode = SKY_cipher_VerifyPubKeySignedHash(&pk2, &sig, &h); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); memset(&pk2, 0, sizeof(pk2)); - errorcode = SKY_cipher_VerifySignatureForPubKey(&pk2, &sig, &h); + errorcode = SKY_cipher_VerifyPubKeySignedHash(&pk2, &sig, &h); cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); } diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 7b81e96c3a..cfb796deff 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -460,11 +460,11 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { mem_actual.size = mem_expect.size = sizeof(cipher__Sig); cr_assert(ne(mem, mem_actual, mem_expect), "%d-th provided signature for %d-th data set must not be null", j, i); - GoUint32 err = SKY_cipher_VerifySignatureForPubKey(&p, sig, h); + GoUint32 err = SKY_cipher_VerifyPubKeySignedHash(&p, sig, h); cr_assert(err == SKY_OK, - "SKY_cipher_VerifySignatureForPubKey failed: error=%d dataset=%d hashidx=%d", err, i, j); - err = SKY_cipher_VerifySignatureForAddress(&addr1, h, sig); - cr_assert(err == SKY_OK, "SKY_cipher_VerifySignatureForAddress failed: error=%d dataset=%d hashidx=%d", err, i, j); + "SKY_cipher_VerifyPubKeySignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); + err = SKY_cipher_VerifyAddressSignedHash(&addr1, h, sig); + cr_assert(err == SKY_OK, "SKY_cipher_VerifyAddressSignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); err = SKY_cipher_VerifySignedHash(sig, h); cr_assert(err == SKY_OK, "SKY_cipher_VerifySignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index e2d2986058..97fc5c2686 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -63,10 +63,10 @@ var ( ErrInvalidHashForSig = errors.New("Signature not valid for hash") // ErrPubKeyRecoverMismatch Recovered pubkey does not match pubkey ErrPubKeyRecoverMismatch = errors.New("Recovered pubkey does not match pubkey") - // ErrInvalidSigInvalidPubKey VerifySignature, secp256k1.VerifyPubkey failed - ErrInvalidSigInvalidPubKey = errors.New("VerifySignature, secp256k1.VerifyPubkey failed") - // ErrInvalidSigValidity VerifySignature, VerifySignatureValidity failed - ErrInvalidSigValidity = errors.New("VerifySignature, VerifySignatureValidity failed") + // ErrInvalidSigInvalidPubKey VerifySignedHash, secp256k1.VerifyPubkey failed + ErrInvalidSigInvalidPubKey = errors.New("VerifySignedHash, secp256k1.VerifyPubkey failed") + // ErrInvalidSigValidity VerifySignedHash, VerifySignedHashValidity failed + ErrInvalidSigValidity = errors.New("VerifySignedHash, VerifySignedHashValidity failed") // ErrInvalidSigForMessage Invalid signature for this message ErrInvalidSigForMessage = errors.New("Invalid signature for this message") // ErrInvalidSecKyVerification Seckey secp256k1 verification failed @@ -371,11 +371,11 @@ func SignHash(hash SHA256, sec SecKey) (Sig, error) { if err != nil { log.Panic("SignHash error: pubkey from sig recovery failure") } - if VerifySignatureForPubKey(pubkey, sig, hash) != nil { + if VerifyPubKeySignedHash(pubkey, sig, hash) != nil { log.Panic("SignHash error: secp256k1.Sign returned non-null invalid non-null signature") } - if VerifySignatureForAddress(AddressFromPubKey(pubkey), hash, sig) != nil { - log.Panic("SignHash error: VerifySignatureForAddress failed for signature") + if VerifyAddressSignedHash(AddressFromPubKey(pubkey), hash, sig) != nil { + log.Panic("SignHash error: VerifyAddressSignedHash failed for signature") } } @@ -391,13 +391,13 @@ func MustSignHash(hash SHA256, sec SecKey) Sig { return sig } -// VerifySignatureForAddress checks whether PubKey corresponding to address hash signed hash +// VerifyAddressSignedHash checks whether PubKey corresponding to address hash signed hash // - recovers the PubKey from sig and hash // - fail if PubKey cannot be be recovered // - computes the address from the PubKey // - fail if recovered address does not match PubKey hash // - verify that signature is valid for hash for PubKey -func VerifySignatureForAddress(address Address, hash SHA256, sig Sig) error { +func VerifyAddressSignedHash(address Address, hash SHA256, sig Sig) error { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { return ErrInvalidSigPubKeyRecovery @@ -412,15 +412,15 @@ func VerifySignatureForAddress(address Address, hash SHA256, sig Sig) error { return ErrInvalidAddressForSig } - if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey[:]) != 1 { + if secp256k1.VerifySignedHash(hash[:], sig[:], rawPubKey[:]) != 1 { return ErrInvalidHashForSig } return nil } -// VerifySignatureForPubKey verifies that hash was signed by PubKey -func VerifySignatureForPubKey(pubkey PubKey, sig Sig, hash SHA256) error { +// VerifyPubKeySignedHash verifies that hash was signed by PubKey +func VerifyPubKeySignedHash(pubkey PubKey, sig Sig, hash SHA256) error { pubkeyRec, err := PubKeyFromSig(sig, hash) // recovered pubkey if err != nil { return ErrInvalidSigPubKeyRecovery @@ -430,16 +430,16 @@ func VerifySignatureForPubKey(pubkey PubKey, sig Sig, hash SHA256) error { } if secp256k1.VerifyPubkey(pubkey[:]) != 1 { if DebugLevel2 { - if secp256k1.VerifySignature(hash[:], sig[:], pubkey[:]) == 1 { - log.Panic("VerifySignatureForPubKey warning, invalid pubkey is valid for signature") + if secp256k1.VerifySignedHash(hash[:], sig[:], pubkey[:]) == 1 { + log.Panic("VerifyPubKeySignedHash warning, invalid pubkey is valid for signature") } } return ErrInvalidSigInvalidPubKey } - if secp256k1.VerifySignatureValidity(sig[:]) != 1 { + if secp256k1.VerifySignedHashValidity(sig[:]) != 1 { return ErrInvalidSigValidity } - if secp256k1.VerifySignature(hash[:], sig[:], pubkey[:]) != 1 { + if secp256k1.VerifySignedHash(hash[:], sig[:], pubkey[:]) != 1 { return ErrInvalidSigForMessage } return nil @@ -453,7 +453,7 @@ func VerifySignedHash(sig Sig, hash SHA256) error { if rawPubKey == nil { return ErrInvalidSigPubKeyRecovery } - if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey) != 1 { + if secp256k1.VerifySignedHash(hash[:], sig[:], rawPubKey) != 1 { return ErrInvalidHashForSig } return nil @@ -654,16 +654,16 @@ func CheckSecKeyHash(seckey SecKey, hash SHA256) error { } // verify produced signature - err = VerifySignatureForPubKey(pubkey, sig, hash) + err = VerifyPubKeySignedHash(pubkey, sig, hash) if err != nil { - return fmt.Errorf("impossible error, CheckSecKeyHash, VerifySignatureForPubKey failed for sig: %v", err) + return fmt.Errorf("impossible error, CheckSecKeyHash, VerifyPubKeySignedHash failed for sig: %v", err) } - // verify VerifySignatureForAddress + // verify VerifyAddressSignedHash addr := AddressFromPubKey(pubkey) - err = VerifySignatureForAddress(addr, hash, sig) + err = VerifyAddressSignedHash(addr, hash, sig) if err != nil { - return fmt.Errorf("impossible error CheckSecKeyHash, VerifySignatureForAddress Failed, should not get this far: %v", err) + return fmt.Errorf("impossible error CheckSecKeyHash, VerifyAddressSignedHash Failed, should not get this far: %v", err) } // verify VerifySignedHash diff --git a/src/cipher/crypto_test.go b/src/cipher/crypto_test.go index 156b45b8c7..306f142be1 100644 --- a/src/cipher/crypto_test.go +++ b/src/cipher/crypto_test.go @@ -403,7 +403,7 @@ func TestSigHex(t *testing.T) { require.Equal(t, p2.Hex(), h) } -func TestVerifySignatureForAddress(t *testing.T) { +func TestVerifyAddressSignedHash(t *testing.T) { p, s := GenerateKeyPair() require.NoError(t, p.Verify()) require.NoError(t, s.Verify()) @@ -412,19 +412,19 @@ func TestVerifySignatureForAddress(t *testing.T) { b := randBytes(t, 256) h := SumSHA256(b) sig := MustSignHash(h, s) - require.NoError(t, VerifySignatureForAddress(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a, h, sig)) // Empty sig should be invalid - require.Error(t, VerifySignatureForAddress(a, h, Sig{})) + require.Error(t, VerifyAddressSignedHash(a, h, Sig{})) // Random sigs should not pass for i := 0; i < 100; i++ { - require.Error(t, VerifySignatureForAddress(a, h, MustNewSig(randBytes(t, 65)))) + require.Error(t, VerifyAddressSignedHash(a, h, MustNewSig(randBytes(t, 65)))) } // Sig for one hash does not work for another hash h2 := SumSHA256(randBytes(t, 256)) sig2 := MustSignHash(h2, s) - require.NoError(t, VerifySignatureForAddress(a, h2, sig2)) - require.Error(t, VerifySignatureForAddress(a, h, sig2)) - require.Error(t, VerifySignatureForAddress(a, h2, sig)) + require.NoError(t, VerifyAddressSignedHash(a, h2, sig2)) + require.Error(t, VerifyAddressSignedHash(a, h, sig2)) + require.Error(t, VerifyAddressSignedHash(a, h2, sig)) // Different secret keys should not create same sig p2, s2 := GenerateKeyPair() @@ -432,19 +432,19 @@ func TestVerifySignatureForAddress(t *testing.T) { h = SHA256{} sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, VerifySignatureForAddress(a, h, sig)) - require.NoError(t, VerifySignatureForAddress(a2, h, sig2)) + require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a2, h, sig2)) require.NotEqual(t, sig, sig2) h = SumSHA256(randBytes(t, 256)) sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, VerifySignatureForAddress(a, h, sig)) - require.NoError(t, VerifySignatureForAddress(a2, h, sig2)) + require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a2, h, sig2)) require.NotEqual(t, sig, sig2) // Bad address should be invalid - require.Error(t, VerifySignatureForAddress(a, h, sig2)) - require.Error(t, VerifySignatureForAddress(a2, h, sig)) + require.Error(t, VerifyAddressSignedHash(a, h, sig2)) + require.Error(t, VerifyAddressSignedHash(a2, h, sig)) } func TestSignHash(t *testing.T) { @@ -454,8 +454,8 @@ func TestSignHash(t *testing.T) { sig, err := SignHash(h, s) require.NoError(t, err) require.NotEqual(t, sig, Sig{}) - require.NoError(t, VerifySignatureForAddress(a, h, sig)) - require.NoError(t, VerifySignatureForPubKey(p, sig, h)) + require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyPubKeySignedHash(p, sig, h)) p2, err := PubKeyFromSig(sig, h) require.NoError(t, err) @@ -471,7 +471,7 @@ func TestMustSignHash(t *testing.T) { h := SumSHA256(randBytes(t, 256)) sig := MustSignHash(h, s) require.NotEqual(t, sig, Sig{}) - require.NoError(t, VerifySignatureForAddress(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a, h, sig)) require.Panics(t, func() { MustSignHash(h, SecKey{}) @@ -517,17 +517,17 @@ func TestMustPubKeyFromSig(t *testing.T) { }) } -func TestVerifySignatureForPubKey(t *testing.T) { +func TestVerifyPubKeySignedHash(t *testing.T) { p, s := GenerateKeyPair() h := SumSHA256(randBytes(t, 256)) h2 := SumSHA256(randBytes(t, 256)) sig := MustSignHash(h, s) - require.NoError(t, VerifySignatureForPubKey(p, sig, h)) - require.Error(t, VerifySignatureForPubKey(p, Sig{}, h)) - require.Error(t, VerifySignatureForPubKey(p, sig, h2)) + require.NoError(t, VerifyPubKeySignedHash(p, sig, h)) + require.Error(t, VerifyPubKeySignedHash(p, Sig{}, h)) + require.Error(t, VerifyPubKeySignedHash(p, sig, h2)) p2, _ := GenerateKeyPair() - require.Error(t, VerifySignatureForPubKey(p2, sig, h)) - require.Error(t, VerifySignatureForPubKey(PubKey{}, sig, h)) + require.Error(t, VerifyPubKeySignedHash(p2, sig, h)) + require.Error(t, VerifyPubKeySignedHash(PubKey{}, sig, h)) } func TestGenerateKeyPair(t *testing.T) { diff --git a/src/cipher/secp256k1-go/secp256_test.go b/src/cipher/secp256k1-go/secp256_test.go index 35970a7968..c5a0517e86 100644 --- a/src/cipher/secp256k1-go/secp256_test.go +++ b/src/cipher/secp256k1-go/secp256_test.go @@ -133,7 +133,7 @@ func Test_verify_functions(t *testing.T) { if VerifyPubkey(pubkey) == 0 { t.Fail() } - if VerifySignature(hash, sig, pubkey) == 0 { + if VerifySignedHash(hash, sig, pubkey) == 0 { t.Fail() } _ = sig @@ -189,7 +189,7 @@ func Test_Secp256_02(t *testing.T) { t.Fatal("Recovered pubkey does not match") } - ret := VerifySignature(msg, sig, pubkey1) + ret := VerifySignedHash(msg, sig, pubkey1) if ret != 1 { t.Fatal("Signature invalid") } @@ -204,7 +204,7 @@ func Test_Secp256_02a(t *testing.T) { if sig == nil { t.Fatal("Signature nil") } - ret := VerifySignature(msg, sig, pubkey1) + ret := VerifySignedHash(msg, sig, pubkey1) if ret != 1 { t.Fatal("Signature invalid") } @@ -291,11 +291,11 @@ func Test_Secp256_06a_alt0(t *testing.T) { t.Fail() } - if pubkey2 != nil && VerifySignature(msg, sig, pubkey2) != 1 { + if pubkey2 != nil && VerifySignedHash(msg, sig, pubkey2) != 1 { t.Fail() } - if VerifySignature(msg, sig, pubkey1) == 1 { + if VerifySignedHash(msg, sig, pubkey1) == 1 { t.Fail() } } @@ -316,11 +316,11 @@ func Test_Secp256_06b(t *testing.T) { t.Fail() } - if pubkey2 != nil && VerifySignature(msg, sig, pubkey2) != 1 { + if pubkey2 != nil && VerifySignedHash(msg, sig, pubkey2) != 1 { t.Fail() } - if VerifySignature(msg, sig, pubkey1) == 1 { + if VerifySignedHash(msg, sig, pubkey1) == 1 { t.Fail() } } diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 0e8ae4620c..36a70fc1f4 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -364,8 +364,8 @@ func VerifyPubkey(pubkey []byte) int { return 1 //valid } -// VerifySignatureValidity renames VerifySignatureForAddressnatureValidity -func VerifySignatureValidity(sig []byte) int { +// VerifySignedHashValidity renames VerifyAddressSignedHashnatureValidity +func VerifySignedHashValidity(sig []byte) int { //64+1 if len(sig) != 65 { log.Fatal("1") @@ -386,17 +386,17 @@ func VerifySignatureValidity(sig []byte) int { return 1 } -// VerifySignature for compressed signatures, does not need pubkey +// VerifySignedHash for compressed signatures, does not need pubkey // Rename SignatureChk -func VerifySignature(msg []byte, sig []byte, pubkey1 []byte) int { +func VerifySignedHash(msg []byte, sig []byte, pubkey1 []byte) int { if msg == nil || sig == nil || pubkey1 == nil { - log.Panic("VerifySignature, ERROR: invalid input, nils") + log.Panic("VerifySignedHash, ERROR: invalid input, nils") } if len(sig) != 65 { - log.Panic("VerifySignature, invalid signature length") + log.Panic("VerifySignedHash, invalid signature length") } if len(pubkey1) != 33 { - log.Panic("VerifySignature, invalid pubkey length") + log.Panic("VerifySignedHash, invalid pubkey length") } //malleability check: diff --git a/src/cipher/testsuite/testsuite.go b/src/cipher/testsuite/testsuite.go index b4e0c42ac3..5f1e8b86c6 100644 --- a/src/cipher/testsuite/testsuite.go +++ b/src/cipher/testsuite/testsuite.go @@ -250,14 +250,14 @@ func ValidateSeedData(seedData *SeedTestData, inputData *InputTestData) error { return errors.New("provided signature is null") } - err := cipher.VerifySignatureForPubKey(p, sig, h) + err := cipher.VerifyPubKeySignedHash(p, sig, h) if err != nil { - return fmt.Errorf("cipher.VerifySignatureForPubKey failed: %v", err) + return fmt.Errorf("cipher.VerifyPubKeySignedHash failed: %v", err) } - err = cipher.VerifySignatureForAddress(addr1, h, sig) + err = cipher.VerifyAddressSignedHash(addr1, h, sig) if err != nil { - return fmt.Errorf("cipher.VerifySignatureForAddress failed: %v", err) + return fmt.Errorf("cipher.VerifyAddressSignedHash failed: %v", err) } err = cipher.VerifySignedHash(sig, h) diff --git a/src/coin/block.go b/src/coin/block.go index eea0695786..9f7e899b6e 100644 --- a/src/coin/block.go +++ b/src/coin/block.go @@ -52,7 +52,7 @@ type SignedBlock struct { // VerifySignature verifies that the block is signed by pubkey func (b SignedBlock) VerifySignature(pubkey cipher.PubKey) error { - return cipher.VerifySignatureForPubKey(pubkey, b.Sig, b.HashHeader()) + return cipher.VerifyPubKeySignedHash(pubkey, b.Sig, b.HashHeader()) } // NewBlock creates new block. diff --git a/src/coin/transactions.go b/src/coin/transactions.go index 5b852383d7..ce9020b015 100644 --- a/src/coin/transactions.go +++ b/src/coin/transactions.go @@ -165,7 +165,7 @@ func (txn Transaction) VerifyInput(uxIn UxArray) error { // Check signatures against unspent address for i := range txn.In { hash := cipher.AddSHA256(txn.InnerHash, txn.In[i]) // use inner hash, not outer hash - err := cipher.VerifySignatureForAddress(uxIn[i].Body.Address, hash, txn.Sigs[i]) + err := cipher.VerifyAddressSignedHash(uxIn[i].Body.Address, hash, txn.Sigs[i]) if err != nil { return errors.New("Signature not valid for output being spent") } diff --git a/src/coin/transactions_test.go b/src/coin/transactions_test.go index ed80a90a02..75374ec8f2 100644 --- a/src/coin/transactions_test.go +++ b/src/coin/transactions_test.go @@ -262,10 +262,10 @@ func TestTransactionSignInputs(t *testing.T) { a := cipher.AddressFromPubKey(p) p = cipher.MustPubKeyFromSecKey(s2) a2 := cipher.AddressFromPubKey(p) - require.Nil(t, cipher.VerifySignatureForAddress(a, cipher.AddSHA256(h, tx.In[0]), tx.Sigs[0])) - require.Nil(t, cipher.VerifySignatureForAddress(a2, cipher.AddSHA256(h, tx.In[1]), tx.Sigs[1])) - require.NotNil(t, cipher.VerifySignatureForAddress(a, h, tx.Sigs[1])) - require.NotNil(t, cipher.VerifySignatureForAddress(a2, h, tx.Sigs[0])) + require.Nil(t, cipher.VerifyAddressSignedHash(a, cipher.AddSHA256(h, tx.In[0]), tx.Sigs[0])) + require.Nil(t, cipher.VerifyAddressSignedHash(a2, cipher.AddSHA256(h, tx.In[1]), tx.Sigs[1])) + require.NotNil(t, cipher.VerifyAddressSignedHash(a, h, tx.Sigs[1])) + require.NotNil(t, cipher.VerifyAddressSignedHash(a2, h, tx.Sigs[0])) } func TestTransactionHash(t *testing.T) { diff --git a/src/consensus/blockstat.go b/src/consensus/blockstat.go index 19f71bf35b..5672b67bc4 100644 --- a/src/consensus/blockstat.go +++ b/src/consensus/blockstat.go @@ -473,7 +473,7 @@ func (self *BlockStatQueue) try_append_to_BlockStatQueue( // Use a superficial, quick test here. A thorough check will be // done later in this function. - if secp256k1.VerifySignatureValidity(blockPtr.Sig[:]) != 1 { + if secp256k1.VerifySignedHashValidity(blockPtr.Sig[:]) != 1 { return 4 // Error } diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index 67990a1326..a6577a08c9 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -685,7 +685,7 @@ func (bc Blockchain) TransactionFee(tx *dbutil.Tx, headTime uint64) coin.FeeCalc func (bc *Blockchain) VerifySignature(block *coin.SignedBlock) error { err := block.VerifySignature(bc.cfg.Pubkey) if err != nil { - logger.Errorf("Signature verification failed: %v", err) + logger.Errorf("Blockchain signature verification failed for block %d: %v", block.Head.BkSeq, err) } return err } @@ -711,7 +711,7 @@ func (bc *Blockchain) WalkChain(workers int, f func(*dbutil.Tx, *coin.SignedBloc if err := bc.db.View("WalkChain verify blocks", func(tx *dbutil.Tx) error { for b := range signedBlockC { if err := f(tx, b); err != nil { - // if err := cipher.VerifySignatureForPubKey(bc.cfg.Pubkey, sh.sig, sh.hash); err != nil { + // if err := cipher.VerifyPubKeySignedHash(bc.cfg.Pubkey, sh.sig, sh.hash); err != nil { // logger.Errorf("Signature verification failed: %v", err) select { case errC <- err: diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 54a4120012..10252221c9 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -149,7 +149,7 @@ func makeTransactionForChain(t *testing.T, tx *dbutil.Tx, bc *Blockchain, ux coi require.Equal(t, len(txn.Sigs), 1) - err = cipher.VerifySignatureForAddress(ux.Body.Address, cipher.AddSHA256(txn.HashInner(), txn.In[0]), txn.Sigs[0]) + err = cipher.VerifyAddressSignedHash(ux.Body.Address, cipher.AddSHA256(txn.HashInner(), txn.In[0]), txn.Sigs[0]) require.NoError(t, err) txn.UpdateHeader() From 5e9726c0825631c1f7e9d154b0787fa098a3e7db Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 21 Oct 2018 11:34:46 +0800 Subject: [PATCH 291/399] Add libc TestVerifySignedHash --- lib/cgo/libsky_error.go | 2 +- lib/cgo/tests/check_cipher.crypto.c | 38 +++++++++++++++++++++++++++- lib/cgo/tests/check_cipher.hash.c | 32 +++++++++++------------ src/cipher/crypto.go | 14 +++++----- src/cipher/secp256k1-go/secp256k1.go | 15 +++++------ src/consensus/blockstat.go | 2 +- 6 files changed, 69 insertions(+), 34 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index aac026eb00..8dcc288bad 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -123,7 +123,7 @@ const ( SKY_ErrPubKeyRecoverMismatch // SKY_ErrInvalidSigInvalidPubKey VerifySignedHash, secp256k1.VerifyPubkey failed SKY_ErrInvalidSigInvalidPubKey - // SKY_ErrInvalidSigValidity VerifySignedHash, VerifySignedHashValidity failed + // SKY_ErrInvalidSigValidity VerifySignedHash, VerifySignatureValidity failed SKY_ErrInvalidSigValidity // SKY_ErrInvalidSigForMessage Invalid signature for this message SKY_ErrInvalidSigForMessage diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 4029a91fe7..bfaee8cd54 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -652,7 +652,7 @@ Test(cipher_crypto, TestPubKeyFromSig) { cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); } -Test(cipher_crypto, TestVerifySignedHash) { +Test(cipher_crypto, TestVerifyPubKeySignedHash) { cipher__PubKey pk, pk2; cipher__SecKey sk, sk2; cipher__SHA256 h, h2; @@ -686,6 +686,42 @@ Test(cipher_crypto, TestVerifySignedHash) { cr_assert(errorcode == SKY_ErrPubKeyRecoverMismatch); } +Test(cipher_crypto, TestVerifySignedHash) { + cipher__SHA256 h; + cipher__Sig sig, badSig1, badSig2; + GoString hS, sigS, badSig1S, badSig2S; + int error; + + hS.p = "127e9b0d6b71cecd0363b366413f0f19fcd924ae033513498e7486570ff2a1c8"; + hS.n = strlen(hS.p); + error = SKY_cipher_SHA256FromHex(hS, &h); + cr_assert(error == SKY_OK); + + sigS.p = "63c035b0c95d0c5744fc1c0bdf38af02cef2d2f65a8f923732ab44e436f8a491216d9ab5ff795e3144f4daee37077b8b9db54d2ba3a3df8d4992f06bb21f724401"; + sigS.n = strlen(sigS.p); + error = SKY_cipher_SigFromHex(sigS, &sig); + cr_assert(error == SKY_OK); + + badSig1S.p = "71f2c01516fe696328e79bcf464eb0db374b63d494f7a307d1e77114f18581d7a81eed5275a9e04a336292dd2fd16977d9bef2a54ea3161d0876603d00c53bc9dd"; + badSig1S.n = strlen(badSig1S.p); + error = SKY_cipher_SigFromHex(badSig1S, &badSig1); + cr_assert(error == SKY_OK); + + badSig2S.p = "63c035b0c95d0c5744fc1c0bdf39af02cef2d2f65a8f923732ab44e436f8a491216d9ab5ff795e3144f4daee37077b8b9db54d2ba3a3df8d4992f06bb21f724401"; + badSig2S.n = strlen(badSig2S.p); + error = SKY_cipher_SigFromHex(badSig2S, &badSig2); + cr_assert(error == SKY_OK); + + error = SKY_cipher_VerifySignedHash(&sig, &h); + cr_assert(error == SKY_OK); + + error = SKY_cipher_VerifySignedHash(&badSig1, &h); + cr_assert(error == SKY_ErrInvalidHashForSig); + + error = SKY_cipher_VerifySignedHash(&badSig2, &h); + cr_assert(error == SKY_ErrInvalidSigPubKeyRecovery); +} + Test(cipher_crypto, TestGenerateKeyPair) { cipher__PubKey pk; cipher__SecKey sk; diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 41749c5483..339b488314 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -121,7 +121,7 @@ Test(cipher_hash,TestSHA256Hex){ cipher__SHA256 h2; - error = SKY_cipher_SHA256FromHex(s, &h2 ); + error = SKY_cipher_SHA256FromHex(s, &h2); cr_assert(error == SKY_OK); cr_assert(eq(u8[32],h,h2)); @@ -135,7 +135,7 @@ Test(cipher_hash,TestSHA256Hex){ Test(cipher_hash,TestSHA256KnownValue){ - typedef struct + typedef struct { char *input; char *output; @@ -309,35 +309,35 @@ Test(cipher_hash,TestMerkle){ // 2 hashes should be Addcipher__SHA256 of them hashes.len = 2; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 3 hashes should be Add(Add()) hashes.len = 3; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &zero, &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &zero, &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 4 hashes should be Add(Add()) hashes.len = 4; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); // 5 hashes hashes.len = 5; - SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); - SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out3); - SKY_cipher_AddSHA256(&hashlist[4], &zero, &out1); - SKY_cipher_AddSHA256(&zero, &zero, &out2); - SKY_cipher_AddSHA256(&out1, &out2, &out4); - SKY_cipher_AddSHA256(&out3, &out4, &out); + SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1); + SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out3); + SKY_cipher_AddSHA256(&hashlist[4], &zero, &out1); + SKY_cipher_AddSHA256(&zero, &zero, &out2); + SKY_cipher_AddSHA256(&out1, &out2, &out4); + SKY_cipher_AddSHA256(&out3, &out4, &out); SKY_cipher_Merkle(&hashes, &h); cr_assert(eq(u8[32], out, h)); } diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index 97fc5c2686..1372c8b4d8 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -65,8 +65,8 @@ var ( ErrPubKeyRecoverMismatch = errors.New("Recovered pubkey does not match pubkey") // ErrInvalidSigInvalidPubKey VerifySignedHash, secp256k1.VerifyPubkey failed ErrInvalidSigInvalidPubKey = errors.New("VerifySignedHash, secp256k1.VerifyPubkey failed") - // ErrInvalidSigValidity VerifySignedHash, VerifySignedHashValidity failed - ErrInvalidSigValidity = errors.New("VerifySignedHash, VerifySignedHashValidity failed") + // ErrInvalidSigValidity VerifySignedHash, VerifySignatureValidity failed + ErrInvalidSigValidity = errors.New("VerifySignedHash, VerifySignatureValidity failed") // ErrInvalidSigForMessage Invalid signature for this message ErrInvalidSigForMessage = errors.New("Invalid signature for this message") // ErrInvalidSecKyVerification Seckey secp256k1 verification failed @@ -412,7 +412,7 @@ func VerifyAddressSignedHash(address Address, hash SHA256, sig Sig) error { return ErrInvalidAddressForSig } - if secp256k1.VerifySignedHash(hash[:], sig[:], rawPubKey[:]) != 1 { + if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey[:]) != 1 { return ErrInvalidHashForSig } @@ -430,16 +430,16 @@ func VerifyPubKeySignedHash(pubkey PubKey, sig Sig, hash SHA256) error { } if secp256k1.VerifyPubkey(pubkey[:]) != 1 { if DebugLevel2 { - if secp256k1.VerifySignedHash(hash[:], sig[:], pubkey[:]) == 1 { + if secp256k1.VerifySignature(hash[:], sig[:], pubkey[:]) == 1 { log.Panic("VerifyPubKeySignedHash warning, invalid pubkey is valid for signature") } } return ErrInvalidSigInvalidPubKey } - if secp256k1.VerifySignedHashValidity(sig[:]) != 1 { + if secp256k1.VerifySignatureValidity(sig[:]) != 1 { return ErrInvalidSigValidity } - if secp256k1.VerifySignedHash(hash[:], sig[:], pubkey[:]) != 1 { + if secp256k1.VerifySignature(hash[:], sig[:], pubkey[:]) != 1 { return ErrInvalidSigForMessage } return nil @@ -453,7 +453,7 @@ func VerifySignedHash(sig Sig, hash SHA256) error { if rawPubKey == nil { return ErrInvalidSigPubKeyRecovery } - if secp256k1.VerifySignedHash(hash[:], sig[:], rawPubKey) != 1 { + if secp256k1.VerifySignature(hash[:], sig[:], rawPubKey) != 1 { return ErrInvalidHashForSig } return nil diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 36a70fc1f4..9f9a4f0a82 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -364,8 +364,8 @@ func VerifyPubkey(pubkey []byte) int { return 1 //valid } -// VerifySignedHashValidity renames VerifyAddressSignedHashnatureValidity -func VerifySignedHashValidity(sig []byte) int { +// VerifySignatureValidity renames VerifyAddressSignedHashnatureValidity +func VerifySignatureValidity(sig []byte) int { //64+1 if len(sig) != 65 { log.Fatal("1") @@ -386,17 +386,16 @@ func VerifySignedHashValidity(sig []byte) int { return 1 } -// VerifySignedHash for compressed signatures, does not need pubkey -// Rename SignatureChk -func VerifySignedHash(msg []byte, sig []byte, pubkey1 []byte) int { +// VerifySignature for compressed signatures, does not need pubkey +func VerifySignature(msg []byte, sig []byte, pubkey1 []byte) int { if msg == nil || sig == nil || pubkey1 == nil { - log.Panic("VerifySignedHash, ERROR: invalid input, nils") + log.Panic("VerifySignature, ERROR: invalid input, nils") } if len(sig) != 65 { - log.Panic("VerifySignedHash, invalid signature length") + log.Panic("VerifySignature, invalid signature length") } if len(pubkey1) != 33 { - log.Panic("VerifySignedHash, invalid pubkey length") + log.Panic("VerifySignature, invalid pubkey length") } //malleability check: diff --git a/src/consensus/blockstat.go b/src/consensus/blockstat.go index 5672b67bc4..19f71bf35b 100644 --- a/src/consensus/blockstat.go +++ b/src/consensus/blockstat.go @@ -473,7 +473,7 @@ func (self *BlockStatQueue) try_append_to_BlockStatQueue( // Use a superficial, quick test here. A thorough check will be // done later in this function. - if secp256k1.VerifySignedHashValidity(blockPtr.Sig[:]) != 1 { + if secp256k1.VerifySignatureValidity(blockPtr.Sig[:]) != 1 { return 4 // Error } From 2025f45b32b08b72361c9fe5b02bf3e2717ccae0 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 21 Oct 2018 11:49:12 +0800 Subject: [PATCH 292/399] Swap hash,sig args in VerifyAddressSignedHash --- lib/cgo/cipher.crypto.go | 4 ++-- lib/cgo/tests/check_cipher.crypto.c | 26 +++++++++++------------ lib/cgo/tests/cipher.testsuite.c | 2 +- src/cipher/crypto.go | 9 ++++---- src/cipher/crypto_test.go | 28 ++++++++++++------------- src/cipher/secp256k1-go/secp256_test.go | 14 ++++++------- src/cipher/secp256k1-go/secp256k1.go | 2 +- src/cipher/testsuite/testsuite.go | 2 +- src/coin/transactions.go | 2 +- src/coin/transactions_test.go | 8 +++---- src/visor/blockchain_verify_test.go | 2 +- 11 files changed, 49 insertions(+), 50 deletions(-) diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index f746dc17cc..52b05de7f3 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -190,12 +190,12 @@ func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 } //export SKY_cipher_VerifyAddressSignedHash -func SKY_cipher_VerifyAddressSignedHash(_address *C.cipher__Address, _hash *C.cipher__SHA256, _sig *C.cipher__Sig) (____error_code uint32) { +func SKY_cipher_VerifyAddressSignedHash(_address *C.cipher__Address, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { address := inplaceAddress(_address) hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) sig := (*cipher.Sig)(unsafe.Pointer(_sig)) - err := cipher.VerifyAddressSignedHash(*address, *hash, *sig) + err := cipher.VerifyAddressSignedHash(*address, *sig, *hash) ____error_code = libErrorCode(err) return } diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index bfaee8cd54..7f01aecb3a 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -513,12 +513,12 @@ Test(cipher_crypto, TestVerifyAddressSignedHash) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode == SKY_OK); // Empty sig should be invalid memset(&sig, 0, sizeof(sig)); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode == SKY_ErrInvalidSigPubKeyRecovery); // Random sigs should not pass @@ -526,7 +526,7 @@ Test(cipher_crypto, TestVerifyAddressSignedHash) { for (i = 0; i < 100; i++) { randBytes(&b, 65); SKY_cipher_NewSig(b, &sig); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode != SKY_OK); // One of many error codes } @@ -534,11 +534,11 @@ Test(cipher_crypto, TestVerifyAddressSignedHash) { randBytes(&b, 256); SKY_cipher_SumSHA256(b, &h2); SKY_cipher_SignHash(&h2, &sk, &sig2); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h2, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig2, &h2); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig2, &h); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h2, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h2); cr_assert(errorcode != SKY_OK); // One of many error codes // Different secret keys should not create same sig @@ -547,9 +547,9 @@ Test(cipher_crypto, TestVerifyAddressSignedHash) { memset(&h, 0, sizeof(h)); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &sig2, &h); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); @@ -557,16 +557,16 @@ Test(cipher_crypto, TestVerifyAddressSignedHash) { SKY_cipher_SumSHA256(b, &h); SKY_cipher_SignHash(&h, &sk, &sig); SKY_cipher_SignHash(&h, &sk2, &sig2); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode == SKY_OK); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &sig2, &h); cr_assert(errorcode == SKY_OK); cr_assert(not(eq(u8[65], sig, sig2))); // Bad address should be invalid - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig2); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig2, &h); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr2, &sig, &h); cr_assert(errorcode == SKY_ErrInvalidAddressForSig); } @@ -589,7 +589,7 @@ Test(cipher_crypto, TestSignHash) { cr_assert(errorcode == SKY_OK); memset((void *) &sig2, 0, 65); cr_assert(not(eq(u8[65], sig2, sig))); - errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &h, &sig); + errorcode = SKY_cipher_VerifyAddressSignedHash(&addr, &sig, &h); cr_assert(errorcode == SKY_OK); errorcode = SKY_cipher_PubKeyFromSig(&sig, &h, &pk2); diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index cfb796deff..944c2a4872 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -463,7 +463,7 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { GoUint32 err = SKY_cipher_VerifyPubKeySignedHash(&p, sig, h); cr_assert(err == SKY_OK, "SKY_cipher_VerifyPubKeySignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); - err = SKY_cipher_VerifyAddressSignedHash(&addr1, h, sig); + err = SKY_cipher_VerifyAddressSignedHash(&addr1, sig, h); cr_assert(err == SKY_OK, "SKY_cipher_VerifyAddressSignedHash failed: error=%d dataset=%d hashidx=%d", err, i, j); err = SKY_cipher_VerifySignedHash(sig, h); cr_assert(err == SKY_OK, diff --git a/src/cipher/crypto.go b/src/cipher/crypto.go index 1372c8b4d8..073b0566e8 100644 --- a/src/cipher/crypto.go +++ b/src/cipher/crypto.go @@ -39,8 +39,7 @@ var ( // ErrPubKeyFromNullSecKey Attempt to load null seckey, unsafe ErrPubKeyFromNullSecKey = errors.New("Attempt to load null seckey, unsafe") // ErrPubKeyFromBadSecKey PubKeyFromSecKey, pubkey recovery failed. Function - ErrPubKeyFromBadSecKey = errors.New("PubKeyFromSecKey, pubkey recovery failed. Function " + - "assumes seckey is valid. Check seckey") + ErrPubKeyFromBadSecKey = errors.New("PubKeyFromSecKey, pubkey recovery failed. Function assumes seckey is valid. Check seckey") // ErrInvalidLengthSecKey Invalid secret key length ErrInvalidLengthSecKey = errors.New("Invalid secret key length") // ErrECHDInvalidPubKey ECDH invalid pubkey input @@ -374,7 +373,7 @@ func SignHash(hash SHA256, sec SecKey) (Sig, error) { if VerifyPubKeySignedHash(pubkey, sig, hash) != nil { log.Panic("SignHash error: secp256k1.Sign returned non-null invalid non-null signature") } - if VerifyAddressSignedHash(AddressFromPubKey(pubkey), hash, sig) != nil { + if VerifyAddressSignedHash(AddressFromPubKey(pubkey), sig, hash) != nil { log.Panic("SignHash error: VerifyAddressSignedHash failed for signature") } } @@ -397,7 +396,7 @@ func MustSignHash(hash SHA256, sec SecKey) Sig { // - computes the address from the PubKey // - fail if recovered address does not match PubKey hash // - verify that signature is valid for hash for PubKey -func VerifyAddressSignedHash(address Address, hash SHA256, sig Sig) error { +func VerifyAddressSignedHash(address Address, sig Sig, hash SHA256) error { rawPubKey := secp256k1.RecoverPubkey(hash[:], sig[:]) if rawPubKey == nil { return ErrInvalidSigPubKeyRecovery @@ -661,7 +660,7 @@ func CheckSecKeyHash(seckey SecKey, hash SHA256) error { // verify VerifyAddressSignedHash addr := AddressFromPubKey(pubkey) - err = VerifyAddressSignedHash(addr, hash, sig) + err = VerifyAddressSignedHash(addr, sig, hash) if err != nil { return fmt.Errorf("impossible error CheckSecKeyHash, VerifyAddressSignedHash Failed, should not get this far: %v", err) } diff --git a/src/cipher/crypto_test.go b/src/cipher/crypto_test.go index 306f142be1..8d0afecd9d 100644 --- a/src/cipher/crypto_test.go +++ b/src/cipher/crypto_test.go @@ -412,19 +412,19 @@ func TestVerifyAddressSignedHash(t *testing.T) { b := randBytes(t, 256) h := SumSHA256(b) sig := MustSignHash(h, s) - require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a, sig, h)) // Empty sig should be invalid - require.Error(t, VerifyAddressSignedHash(a, h, Sig{})) + require.Error(t, VerifyAddressSignedHash(a, Sig{}, h)) // Random sigs should not pass for i := 0; i < 100; i++ { - require.Error(t, VerifyAddressSignedHash(a, h, MustNewSig(randBytes(t, 65)))) + require.Error(t, VerifyAddressSignedHash(a, MustNewSig(randBytes(t, 65)), h)) } // Sig for one hash does not work for another hash h2 := SumSHA256(randBytes(t, 256)) sig2 := MustSignHash(h2, s) - require.NoError(t, VerifyAddressSignedHash(a, h2, sig2)) - require.Error(t, VerifyAddressSignedHash(a, h, sig2)) - require.Error(t, VerifyAddressSignedHash(a, h2, sig)) + require.NoError(t, VerifyAddressSignedHash(a, sig2, h2)) + require.Error(t, VerifyAddressSignedHash(a, sig2, h)) + require.Error(t, VerifyAddressSignedHash(a, sig, h2)) // Different secret keys should not create same sig p2, s2 := GenerateKeyPair() @@ -432,19 +432,19 @@ func TestVerifyAddressSignedHash(t *testing.T) { h = SHA256{} sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, VerifyAddressSignedHash(a, h, sig)) - require.NoError(t, VerifyAddressSignedHash(a2, h, sig2)) + require.NoError(t, VerifyAddressSignedHash(a, sig, h)) + require.NoError(t, VerifyAddressSignedHash(a2, sig2, h)) require.NotEqual(t, sig, sig2) h = SumSHA256(randBytes(t, 256)) sig = MustSignHash(h, s) sig2 = MustSignHash(h, s2) - require.NoError(t, VerifyAddressSignedHash(a, h, sig)) - require.NoError(t, VerifyAddressSignedHash(a2, h, sig2)) + require.NoError(t, VerifyAddressSignedHash(a, sig, h)) + require.NoError(t, VerifyAddressSignedHash(a2, sig2, h)) require.NotEqual(t, sig, sig2) // Bad address should be invalid - require.Error(t, VerifyAddressSignedHash(a, h, sig2)) - require.Error(t, VerifyAddressSignedHash(a2, h, sig)) + require.Error(t, VerifyAddressSignedHash(a, sig2, h)) + require.Error(t, VerifyAddressSignedHash(a2, sig, h)) } func TestSignHash(t *testing.T) { @@ -454,7 +454,7 @@ func TestSignHash(t *testing.T) { sig, err := SignHash(h, s) require.NoError(t, err) require.NotEqual(t, sig, Sig{}) - require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a, sig, h)) require.NoError(t, VerifyPubKeySignedHash(p, sig, h)) p2, err := PubKeyFromSig(sig, h) @@ -471,7 +471,7 @@ func TestMustSignHash(t *testing.T) { h := SumSHA256(randBytes(t, 256)) sig := MustSignHash(h, s) require.NotEqual(t, sig, Sig{}) - require.NoError(t, VerifyAddressSignedHash(a, h, sig)) + require.NoError(t, VerifyAddressSignedHash(a, sig, h)) require.Panics(t, func() { MustSignHash(h, SecKey{}) diff --git a/src/cipher/secp256k1-go/secp256_test.go b/src/cipher/secp256k1-go/secp256_test.go index c5a0517e86..35970a7968 100644 --- a/src/cipher/secp256k1-go/secp256_test.go +++ b/src/cipher/secp256k1-go/secp256_test.go @@ -133,7 +133,7 @@ func Test_verify_functions(t *testing.T) { if VerifyPubkey(pubkey) == 0 { t.Fail() } - if VerifySignedHash(hash, sig, pubkey) == 0 { + if VerifySignature(hash, sig, pubkey) == 0 { t.Fail() } _ = sig @@ -189,7 +189,7 @@ func Test_Secp256_02(t *testing.T) { t.Fatal("Recovered pubkey does not match") } - ret := VerifySignedHash(msg, sig, pubkey1) + ret := VerifySignature(msg, sig, pubkey1) if ret != 1 { t.Fatal("Signature invalid") } @@ -204,7 +204,7 @@ func Test_Secp256_02a(t *testing.T) { if sig == nil { t.Fatal("Signature nil") } - ret := VerifySignedHash(msg, sig, pubkey1) + ret := VerifySignature(msg, sig, pubkey1) if ret != 1 { t.Fatal("Signature invalid") } @@ -291,11 +291,11 @@ func Test_Secp256_06a_alt0(t *testing.T) { t.Fail() } - if pubkey2 != nil && VerifySignedHash(msg, sig, pubkey2) != 1 { + if pubkey2 != nil && VerifySignature(msg, sig, pubkey2) != 1 { t.Fail() } - if VerifySignedHash(msg, sig, pubkey1) == 1 { + if VerifySignature(msg, sig, pubkey1) == 1 { t.Fail() } } @@ -316,11 +316,11 @@ func Test_Secp256_06b(t *testing.T) { t.Fail() } - if pubkey2 != nil && VerifySignedHash(msg, sig, pubkey2) != 1 { + if pubkey2 != nil && VerifySignature(msg, sig, pubkey2) != 1 { t.Fail() } - if VerifySignedHash(msg, sig, pubkey1) == 1 { + if VerifySignature(msg, sig, pubkey1) == 1 { t.Fail() } } diff --git a/src/cipher/secp256k1-go/secp256k1.go b/src/cipher/secp256k1-go/secp256k1.go index 9f9a4f0a82..75165f9264 100644 --- a/src/cipher/secp256k1-go/secp256k1.go +++ b/src/cipher/secp256k1-go/secp256k1.go @@ -364,7 +364,7 @@ func VerifyPubkey(pubkey []byte) int { return 1 //valid } -// VerifySignatureValidity renames VerifyAddressSignedHashnatureValidity +// VerifySignatureValidity verifies a signature is well formed and not malleable func VerifySignatureValidity(sig []byte) int { //64+1 if len(sig) != 65 { diff --git a/src/cipher/testsuite/testsuite.go b/src/cipher/testsuite/testsuite.go index 5f1e8b86c6..eeb62c5320 100644 --- a/src/cipher/testsuite/testsuite.go +++ b/src/cipher/testsuite/testsuite.go @@ -255,7 +255,7 @@ func ValidateSeedData(seedData *SeedTestData, inputData *InputTestData) error { return fmt.Errorf("cipher.VerifyPubKeySignedHash failed: %v", err) } - err = cipher.VerifyAddressSignedHash(addr1, h, sig) + err = cipher.VerifyAddressSignedHash(addr1, sig, h) if err != nil { return fmt.Errorf("cipher.VerifyAddressSignedHash failed: %v", err) } diff --git a/src/coin/transactions.go b/src/coin/transactions.go index ce9020b015..638c2c9e88 100644 --- a/src/coin/transactions.go +++ b/src/coin/transactions.go @@ -165,7 +165,7 @@ func (txn Transaction) VerifyInput(uxIn UxArray) error { // Check signatures against unspent address for i := range txn.In { hash := cipher.AddSHA256(txn.InnerHash, txn.In[i]) // use inner hash, not outer hash - err := cipher.VerifyAddressSignedHash(uxIn[i].Body.Address, hash, txn.Sigs[i]) + err := cipher.VerifyAddressSignedHash(uxIn[i].Body.Address, txn.Sigs[i], hash) if err != nil { return errors.New("Signature not valid for output being spent") } diff --git a/src/coin/transactions_test.go b/src/coin/transactions_test.go index 75374ec8f2..b7d5965cac 100644 --- a/src/coin/transactions_test.go +++ b/src/coin/transactions_test.go @@ -262,10 +262,10 @@ func TestTransactionSignInputs(t *testing.T) { a := cipher.AddressFromPubKey(p) p = cipher.MustPubKeyFromSecKey(s2) a2 := cipher.AddressFromPubKey(p) - require.Nil(t, cipher.VerifyAddressSignedHash(a, cipher.AddSHA256(h, tx.In[0]), tx.Sigs[0])) - require.Nil(t, cipher.VerifyAddressSignedHash(a2, cipher.AddSHA256(h, tx.In[1]), tx.Sigs[1])) - require.NotNil(t, cipher.VerifyAddressSignedHash(a, h, tx.Sigs[1])) - require.NotNil(t, cipher.VerifyAddressSignedHash(a2, h, tx.Sigs[0])) + require.NoError(t, cipher.VerifyAddressSignedHash(a, tx.Sigs[0], cipher.AddSHA256(h, tx.In[0]))) + require.NoError(t, cipher.VerifyAddressSignedHash(a2, tx.Sigs[1], cipher.AddSHA256(h, tx.In[1]))) + require.Error(t, cipher.VerifyAddressSignedHash(a, tx.Sigs[1], h)) + require.Error(t, cipher.VerifyAddressSignedHash(a2, tx.Sigs[0], h)) } func TestTransactionHash(t *testing.T) { diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 10252221c9..9b8d8413bf 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -149,7 +149,7 @@ func makeTransactionForChain(t *testing.T, tx *dbutil.Tx, bc *Blockchain, ux coi require.Equal(t, len(txn.Sigs), 1) - err = cipher.VerifyAddressSignedHash(ux.Body.Address, cipher.AddSHA256(txn.HashInner(), txn.In[0]), txn.Sigs[0]) + err = cipher.VerifyAddressSignedHash(ux.Body.Address, txn.Sigs[0], cipher.AddSHA256(txn.HashInner(), txn.In[0])) require.NoError(t, err) txn.UpdateHeader() From c71069d7034773dd1a14a38157f95c38f2234daf Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 21 Oct 2018 04:14:06 +0000 Subject: [PATCH 293/399] [damon] refs #735 - Update list of daemon errors --- src/daemon/errors.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index f80cde5815..584dcf3c2b 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -7,7 +7,7 @@ import ( var errorByCode = [...]error{ nil, - ErrDisconnectInvalidVersion, + ErrDisconnectVersionNotSupported, ErrDisconnectIntroductionTimeout, ErrDisconnectVersionSendFailed, ErrDisconnectIsBlacklisted, @@ -16,16 +16,25 @@ var errorByCode = [...]error{ ErrDisconnectIdle, ErrDisconnectNoIntroduction, ErrDisconnectIPLimitReached, - ErrDisconnectOtherError, + ErrDisconnectIncomprehensibleError, + ErrDisconnectMaxOutgoingConnectionsReached, + ErrDisconnectBlockchainPubkeyNotMatched, + ErrDisconnectInvalidExtraData, + ErrDisconnectPeerlistFull, + ErrOutgoingConnectionsDisabled, + ErrRecvReject, + ErrSendReject, gnet.ErrDisconnectReadFailed, gnet.ErrDisconnectWriteFailed, gnet.ErrDisconnectSetReadDeadlineFailed, gnet.ErrDisconnectInvalidMessageLength, gnet.ErrDisconnectMalformedMessage, gnet.ErrDisconnectUnknownMessage, - nil, // gnet.ErrDisconnectWriteQueueFull, + gnet.ErrWriteQueueFull, gnet.ErrDisconnectUnexpectedError, + gnet.ErrNoReachableConnections, gnet.ErrConnectionPoolClosed, + gnet.ErrPoolEmpty, pex.ErrPeerlistFull, pex.ErrInvalidAddress, pex.ErrNoLocalhost, From 96699b05a9e0fe06dfda47cabb478c151a03189a Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 21 Oct 2018 00:21:16 -0400 Subject: [PATCH 294/399] [daemon] refs #735 - Update hex dumps of RJCT message --- src/daemon/messages_example_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index ebb91d41fd..5f6b496304 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -799,9 +799,9 @@ func ExampleRejectMessage() { defer gnet.EraseMessages() setupMsgEncoding() - rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, []byte{}) + rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, cipher.PubKey{}) message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") - fmt.Println("RejectWithPeersMessage:") + fmt.Println("RejectMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) err := NewFromIterator(gnet.EncodeMessage(message), &mai, w) @@ -809,11 +809,11 @@ func ExampleRejectMessage() { fmt.Println(err) } // Output: - // RejectWithPeersMessage: + // RejectMessage: // 0x0000 | 31 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 54 ....................................... Prefix // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix - // 0x000c | 0c 00 00 00 ....................................... ErrorCode + // 0x000c | 13 00 00 00 ....................................... ErrorCode // 0x0010 | 1d 00 00 00 45 78 61 6d 70 6c 65 52 65 6a 65 63 // 0x0020 | 74 57 69 74 68 50 65 65 72 73 4d 65 73 73 61 67 // 0x0030 | 65 ................................................ Reason From 02f7ab34f4131daeb75ab77abfa9800d6d36f9bc Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 22 Oct 2018 20:30:18 +0800 Subject: [PATCH 295/399] DisconnectMessage sent and working --- src/daemon/daemon.go | 41 ++++++---- src/daemon/errors.go | 1 - src/daemon/gnet/message.go | 47 +---------- src/daemon/messages.go | 120 +++++++++------------------- src/daemon/messages_example_test.go | 6 +- 5 files changed, 66 insertions(+), 149 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 4c462771eb..dd31bc8482 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -219,6 +219,7 @@ type Daemoner interface { SendMessage(addr string, msg gnet.Message) error BroadcastMessage(msg gnet.Message) error Disconnect(addr string, r gnet.DisconnectReason) error + DisconnectNow(addr string, r gnet.DisconnectReason) error IsDefaultConnection(addr string) bool IsMaxDefaultConnectionsReached() (bool, error) PexConfig() pex.Config @@ -504,6 +505,8 @@ func (dm *Daemon) Run() error { } }() + forceDisconnect := time.Tick(time.Second * 10) + loop: for { elapser.CheckForDone() @@ -511,6 +514,12 @@ loop: case <-dm.quit: break loop + case <-forceDisconnect: + logger.Critical().Warning("Force disconnecting from port 6002 peer") + if err := dm.Disconnect("127.0.0.1:6002", pex.ErrBlacklistedAddress); err != nil { + logger.Critical().WithError(err).Error("Forced disconnect from port 6002 peer failed") + } + case <-cullInvalidTicker.C: // Remove connections that failed to complete the handshake elapser.Register("cullInvalidTicker") @@ -1083,20 +1092,15 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { logger.Warningf("Failed to send %s to %s: %v", reflect.TypeOf(r.Message), r.Addr, r.Error) return } - switch r.Message.(type) { - case SendingTxnsMessage: - dm.announcedTxns.add(r.Message.(SendingTxnsMessage).GetFiltered()) - case DisconnectPeerMessage: - // If message was sent successfully and disconnection follows - // since the other end should eventually disconnect after processing it - // then it's safe at this point to close connection to peer - dpm := r.Message.(DisconnectPeerMessage) - address := dpm.PeerAddress() - reason := dpm.ErrorReason() - if err := dm.Disconnect(address, reason); err != nil { - logger.WithError(reason).WithField("addr", address).Warning("Failed to disconnect peer") + + if m, ok := r.Message.(SendingTxnsMessage); ok { + dm.announcedTxns.add(m.GetFiltered()) + } + + if m, ok := r.Message.(*DisconnectMessage); ok { + if err := dm.DisconnectNow(r.Addr, gnet.DisconnectReason(m.reason)); err != nil { + logger.WithError(err).WithField("addr", r.Addr).Warning("Failed to disconnect peer") } - default: } } @@ -1351,9 +1355,16 @@ func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { return dm.pool.Pool.BroadcastMessage(msg) } -// Disconnect removes a connection from the pool by address, and passes a Disconnection to -// the DisconnectCallback +// Disconnect sends a DisconnectMessage to a peer. After the DisconnectMessage is sent, the peer is disconnected. +// This allows all pending messages to be sent. Any message queued after a DisconnectMessage is unlikely to be sent +// the peer (but possible). func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { + return dm.SendMessage(addr, NewDisconnectMessage(r)) +} + +// DisconnectNow disconnects from a peer immediately without sending a DisconnectMessage. Any pending messages +// will not be sent to the peer. +func (dm *Daemon) DisconnectNow(addr string, r gnet.DisconnectReason) error { return dm.pool.Pool.Disconnect(addr, r) } diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 584dcf3c2b..ce0fb62f42 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -23,7 +23,6 @@ var errorByCode = [...]error{ ErrDisconnectPeerlistFull, ErrOutgoingConnectionsDisabled, ErrRecvReject, - ErrSendReject, gnet.ErrDisconnectReadFailed, gnet.ErrDisconnectWriteFailed, gnet.ErrDisconnectSetReadDeadlineFailed, diff --git a/src/daemon/gnet/message.go b/src/daemon/gnet/message.go index fd144b127e..2cff2033e3 100644 --- a/src/daemon/gnet/message.go +++ b/src/daemon/gnet/message.go @@ -24,50 +24,6 @@ func MessagePrefixFromString(prefix string) MessagePrefix { return p } -/* - Need to use bytes type - - need to get rid of interface message type - - need to store abstract function pointer - - need to invoke the abstract message pointer - -Operations -- store a function signature (variable?) -- store a function -- - -*/ - -/* -Message Type needs to embody multiple types of struct data -- each type must have a response function -- the second parameter of each response function is different for each type -*/ - -/* -func Call(m map[string]interface{}, name string, params ... interface{}) (result []reflect.Value, err error) { -    f = reflect.ValueOf(m[name]) -    if len(params) != f.Type().NumIn() { -        err = errors.New("The number of params is not adapted.") -        return -    } -    in := make([]reflect.Value, len(params)) -    for k, param := range params { -        in[k] = reflect.ValueOf(param) -    } -    result = f[name].Call(in) -    return -} -Call(funcs, "foo") -Call(funcs, "bar", 1, 2, 3) - -func foobar() { - // bla...bla...bla... -} -funcs := map[string]func() {"foobar":foobar} -funcs["foobar"]() - -*/ - // Message message interface type Message interface { // State is user-defined application state that is attached to the @@ -107,8 +63,7 @@ func RegisterMessage(prefix MessagePrefix, msg interface{}) { copy(id[:], prefix[:]) _, exists := MessageIDReverseMap[id] if exists { - logger.Panicf("Attempted to register message prefix %s twice", - string(id[:])) + logger.Panicf("Attempted to register message prefix %s twice", string(id[:])) } _, exists = MessageIDMap[t] if exists { diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 1900ad7770..c824c3491e 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" "net" - "reflect" "strings" "time" @@ -18,12 +17,8 @@ import ( ) var ( - // Every rejection message prefix must start with "RJCT" prefix - rejectPrefix = [...]byte{82, 74, 67, 84} // ErrRecvReject disconnect since peer sent RJCT message ErrRecvReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") - // ErrSendReject disconnect since RJCT message was sent to peer - ErrSendReject gnet.DisconnectReason = errors.New("Disconnect: Reject message sent to peer") ) // Message represent a packet to be serialized over the network by @@ -65,7 +60,7 @@ func getMessageConfigs() []MessageConfig { NewMessageConfig("GETT", GetTxnsMessage{}), NewMessageConfig("GIVT", GiveTxnsMessage{}), NewMessageConfig("ANNT", AnnounceTxnsMessage{}), - NewMessageConfig("RJCT", RejectMessage{}), + NewMessageConfig("RJCT", DisconnectMessage{}), } } @@ -363,22 +358,24 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // Process an event queued by Handle() func (intro *IntroductionMessage) Process(d Daemoner) { - d.RemoveFromExpectingIntroductions(intro.c.Addr) - if intro.validationError != nil { - if intro.validationError == pex.ErrPeerlistFull { - peers := d.RandomExchangeable(d.PexConfig().ReplyCount) - givpMsg := NewGivePeersMessage(peers) - if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Error("Send GivePeersMessage failed") - } - rjctMsg := NewRejectMessage(intro, pex.ErrPeerlistFull, "") - if err := d.SendMessage(intro.c.Addr, rjctMsg); err != nil { - logger.Errorf("Send RejectMessage to %s failed: %v", intro.c.Addr, err) - } + if intro.validationError == pex.ErrPeerlistFull { + peers := d.RandomExchangeable(d.PexConfig().ReplyCount) + givpMsg := NewGivePeersMessage(peers) + if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { + logger.WithError(err).WithField("addr", intro.c.Addr).Error("Send GivePeersMessage failed") } + if err := d.Disconnect(intro.c.Addr, pex.ErrPeerlistFull); err != nil { + logger.WithError(err).WithField("addr", intro.c.Addr).Error("Disconnect") + } + } + + d.RemoveFromExpectingIntroductions(intro.c.Addr) + + if intro.validationError != nil { return } + // Add the remote peer with their chosen listening port a := intro.c.Addr @@ -443,72 +440,38 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err return nil } -// DisconnectPeerMessage sent to peer immediately before disconnection -type DisconnectPeerMessage interface { - // PeerAddress to disconnect - PeerAddress() string - // ErrorReason leading to disconnection - ErrorReason() gnet.DisconnectReason -} +// DisconnectMessage sent to a peer before disconnecting, indicating the reason for disconnect +type DisconnectMessage struct { + c *gnet.MessageContext `enc:"-"` + reason gnet.DisconnectReason `enc:"-"` -// RejectMessage sent to inform peers of a protocol failure. -// Whenever possible the node should send back prior to this -// other message including data useful for peer recovery, especially -// before disconnecting it -// -// Must never Reject a Reject message (infinite loop) -type RejectMessage struct { - // Prefix of the (previous) message that's been rejected - TargetPrefix gnet.MessagePrefix // Error code - ErrorCode uint32 - // Reason message. Included only in very particular cases - Reason string + ReasonCode uint32 + // Reserved for future use - Reserved []byte - c *gnet.MessageContext `enc:"-"` + Reserved []byte `enc:",omitempty"` } -// NewRejectMessage creates message sent to reject previously received message -func NewRejectMessage(msg gnet.Message, err error, reason string) *RejectMessage { - t := reflect.Indirect(reflect.ValueOf(msg)).Type() - prefix, exists := gnet.MessageIDMap[t] - if !exists { - logger.Panicf("Rejecting unknown message type %s", t) +// NewDisconnectMessage creates message sent to reject previously received message +func NewDisconnectMessage(reason gnet.DisconnectReason) *DisconnectMessage { + return &DisconnectMessage{ + reason: reason, + ReasonCode: GetErrorCode(reason), + Reserved: nil, } - // Infinite loop. Never reject RJCT message - if reflect.DeepEqual(prefix[:], rejectPrefix[:]) { - logger.WithField("gnetmsg", prefix).Panicf("Message type %s may not be rejected", t) - } - - return &RejectMessage{ - TargetPrefix: prefix, - ErrorCode: GetErrorCode(err), - Reason: reason, - Reserved: nil, - } -} - -// PeerAddress extracted from message context -func (rpm *RejectMessage) PeerAddress() string { - return rpm.c.Addr -} - -// ErrorReason disconnect peer after sending RejectMessage -func (rpm *RejectMessage) ErrorReason() gnet.DisconnectReason { - return ErrSendReject } // Handle an event queued by Handle() -func (rpm *RejectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - rpm.c = mc - return daemon.(Daemoner).RecordMessageEvent(rpm, mc) +func (dm *DisconnectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { + dm.c = mc + return daemon.(Daemoner).RecordMessageEvent(dm, mc) } // Process Recover from message rejection state -func (rpm *RejectMessage) Process(d Daemoner) { - if err := d.Disconnect(rpm.c.Addr, ErrRecvReject); err != nil { - logger.WithError(err).WithField("addr", rpm.c.Addr).Warning("Failed to disconnect peer") +func (dm *DisconnectMessage) Process(d Daemoner) { + logger.Critical().WithField("addr", dm.c.Addr).Infof("DisconnectMessage received, reason: %d", dm.ReasonCode) + if err := d.DisconnectNow(dm.c.Addr, gnet.DisconnectReason(errors.New("TODO - a reason"))); err != nil { + logger.WithError(err).WithField("addr", dm.c.Addr).Warning("DisconnectNow") } } @@ -528,19 +491,13 @@ func NewGetBlocksMessage(lastBlock uint64, requestedBlocks uint64) *GetBlocksMes } // Handle handles message -func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, - daemon interface{}) error { +func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gbm.c = mc return daemon.(Daemoner).RecordMessageEvent(gbm, mc) } // Process should send number to be requested, with request func (gbm *GetBlocksMessage) Process(d Daemoner) { - // TODO -- we need the sig to be sent with the block, but only the master - // can sign blocks. Thus the sig needs to be stored with the block. - if d.DaemonConfig().DisableNetworking { - return - } // Record this as this peer's highest block d.RecordPeerHeight(gbm.c.Addr, gbm.LastBlock) // Fetch and return signed blocks since LastBlock @@ -583,11 +540,6 @@ func (gbm *GiveBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{} // Process process message func (gbm *GiveBlocksMessage) Process(d Daemoner) { - if d.DaemonConfig().DisableNetworking { - logger.Critical().Info("Visor disabled, ignoring GiveBlocksMessage") - return - } - // These DB queries are not performed in a transaction for performance reasons. // It is not necessary that the blocks be executed together in a single transaction. diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 5f6b496304..5ccd5654d5 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -800,8 +800,8 @@ func ExampleRejectMessage() { setupMsgEncoding() rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, cipher.PubKey{}) - message := NewRejectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") - fmt.Println("RejectMessage:") + message := NewDisconnectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") + fmt.Println("DisconnectMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) err := NewFromIterator(gnet.EncodeMessage(message), &mai, w) @@ -809,7 +809,7 @@ func ExampleRejectMessage() { fmt.Println(err) } // Output: - // RejectMessage: + // DisconnectMessage: // 0x0000 | 31 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 54 ....................................... Prefix // 0x0008 | 49 4e 54 52 ....................................... TargetPrefix From de57f75953711a2ca0603d629b83e6123404b1b2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 23 Oct 2018 21:33:36 +0800 Subject: [PATCH 296/399] WIP DisconnectMessage --- CHANGELOG.md | 2 +- include/skyerrors.h | 1 - lib/cgo/libsky_error.go | 3 - src/daemon/daemon.go | 102 ++++++++++------------------- src/daemon/errors.go | 139 +++++++++++++++++++++++----------------- src/daemon/gnet/pool.go | 39 +++++------ src/daemon/messages.go | 100 ++++++++++++----------------- src/daemon/pool.go | 10 ++- src/daemon/storage.go | 5 +- 9 files changed, 180 insertions(+), 221 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17119abb29..7d037b2a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,6 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once ### Changed - Add blockchain pubkey in introduction message, it would close the connection if the pubkey is not matched, but would accept it if pubkey is not provided. -- Reply to `INTR` message with `GIVP` + `RJCT` on pex pool overflow - CLI tool uses the REST API instead of the deprecated webrpc API to communicate with the node - `cli status` return value is now the response from `GET /api/v1/health`, which changes some fields - `/api/v1/network/` endpoints will return an empty array for array values instead of `null` @@ -80,6 +79,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateWallet` renamed to `cli walletCreate` - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. +- Send new `DISC` disconnect packet to peer before disconnecting ### Removed diff --git a/include/skyerrors.h b/include/skyerrors.h index 98f4d51529..a89d55049e 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -105,7 +105,6 @@ #define SKY_ErrMaxDefaultConnectionsReached 0x06000010 #define SKY_ErrDisconnectVersionNotSupported 0x06000011 #define SKY_ErrDisconnectIntroductionTimeout 0x06000012 -#define SKY_ErrDisconnectVersionSendFailed 0x06000013 #define SKY_ErrDisconnectIsBlacklisted 0x06000014 #define SKY_ErrDisconnectSelf 0x06000015 #define SKY_ErrDisconnectConnectedTwice 0x06000016 diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index b100c97abd..cf69472dd1 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -228,8 +228,6 @@ const ( SKY_ErrDisconnectVersionNotSupported // SKY_ErrDisconnectIntroductionTimeout timeout SKY_ErrDisconnectIntroductionTimeout - // SKY_ErrDisconnectVersionSendFailed version send failed - SKY_ErrDisconnectVersionSendFailed // SKY_ErrDisconnectIsBlacklisted is blacklisted SKY_ErrDisconnectIsBlacklisted // SKY_ErrDisconnectSelf self connnect @@ -474,7 +472,6 @@ var ( gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, - daemon.ErrDisconnectVersionSendFailed: SKY_ErrDisconnectVersionSendFailed, daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index dd31bc8482..13be24baeb 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -22,37 +22,6 @@ import ( ) var ( - // ErrDisconnectVersionNotSupported version is below minimum supported version - ErrDisconnectVersionNotSupported gnet.DisconnectReason = errors.New("Version is below minimum supported version") - // ErrDisconnectIntroductionTimeout timeout - ErrDisconnectIntroductionTimeout gnet.DisconnectReason = errors.New("Version timeout") - // ErrDisconnectVersionSendFailed version send failed - ErrDisconnectVersionSendFailed gnet.DisconnectReason = errors.New("Version send failed") - // ErrDisconnectIsBlacklisted is blacklisted - ErrDisconnectIsBlacklisted gnet.DisconnectReason = errors.New("Blacklisted") - // ErrDisconnectSelf self connnect - ErrDisconnectSelf gnet.DisconnectReason = errors.New("Self connect") - // ErrDisconnectConnectedTwice connect twice - ErrDisconnectConnectedTwice gnet.DisconnectReason = errors.New("Already connected") - // ErrDisconnectIdle idle - ErrDisconnectIdle gnet.DisconnectReason = errors.New("Idle") - // ErrDisconnectNoIntroduction no introduction - ErrDisconnectNoIntroduction gnet.DisconnectReason = errors.New("First message was not an Introduction") - // ErrDisconnectIPLimitReached ip limit reached - ErrDisconnectIPLimitReached gnet.DisconnectReason = errors.New("Maximum number of connections for this IP was reached") - // ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered - // e.g. net.Conn.Addr() returns an invalid ip:port - ErrDisconnectIncomprehensibleError gnet.DisconnectReason = errors.New("Incomprehensible error") - // ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed - ErrDisconnectMaxOutgoingConnectionsReached gnet.DisconnectReason = errors.New("Maximum outgoing connections was reached") - // ErrDisconnectBlockchainPubkeyNotMatched is returned when the blockchain pubkey in introduction does not match - ErrDisconnectBlockchainPubkeyNotMatched gnet.DisconnectReason = errors.New("Blockchain pubkey in Introduction message is not matched ") - // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. - // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey - ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") - // ErrDisconnectPeerlistFull no space in peers pool - ErrDisconnectPeerlistFull gnet.DisconnectReason = errors.New("No space in device pex") - // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") @@ -505,8 +474,6 @@ func (dm *Daemon) Run() error { } }() - forceDisconnect := time.Tick(time.Second * 10) - loop: for { elapser.CheckForDone() @@ -514,12 +481,6 @@ loop: case <-dm.quit: break loop - case <-forceDisconnect: - logger.Critical().Warning("Force disconnecting from port 6002 peer") - if err := dm.Disconnect("127.0.0.1:6002", pex.ErrBlacklistedAddress); err != nil { - logger.Critical().WithError(err).Error("Forced disconnect from port 6002 peer failed") - } - case <-cullInvalidTicker.C: // Remove connections that failed to complete the handshake elapser.Register("cullInvalidTicker") @@ -547,7 +508,17 @@ loop: // Remove connections that haven't said anything in a while elapser.Register("clearStaleConnectionsTicker") if !dm.Config.DisableNetworking { - dm.pool.clearStaleConnections() + conns, err := dm.pool.getStaleConnections() + if err != nil { + logger.WithError(err).Error("getStaleConnections failed") + continue + } + + for _, addr := range conns { + if err := dm.Disconnect(addr, ErrDisconnectIdle); err != nil { + logger.WithError(err).WithField("addr", addr).Error("Disconnect") + } + } } case <-idleCheckTicker.C: @@ -831,32 +802,29 @@ func (dm *Daemon) handleConnectionError(c ConnectionError) { dm.pex.IncreaseRetryTimes(c.Addr) } -// Removes unsolicited connections who haven't sent a version +// cullInvalidConnections removes unsolicited connections who haven't sent a version func (dm *Daemon) cullInvalidConnections() { - // This method only handles the erroneous people from the DHT, but not - // malicious nodes now := time.Now().UTC() - addrs, err := dm.expectingIntroductions.CullInvalidConns( - func(addr string, t time.Time) (bool, error) { - conned, err := dm.pool.Pool.IsConnExist(addr) - if err != nil { - return false, err - } + addrs, err := dm.expectingIntroductions.CullInvalidConns(func(addr string, t time.Time) (bool, error) { + conned, err := dm.pool.Pool.IsConnExist(addr) + if err != nil { + return false, err + } - // Do not remove trusted peers - if dm.isTrustedPeer(addr) { - return false, nil - } + // Do not remove trusted peers + if dm.isTrustedPeer(addr) { + return false, nil + } - if !conned { - return true, nil - } + if !conned { + return true, nil + } - if t.Add(dm.Config.IntroductionWait).Before(now) { - return true, nil - } - return false, nil - }) + if t.Add(dm.Config.IntroductionWait).Before(now) { + return true, nil + } + return false, nil + }) if err != nil { logger.Errorf("expectingIntroduction cull invalid connections failed: %v", err) @@ -872,7 +840,7 @@ func (dm *Daemon) cullInvalidConnections() { if exist { logger.Infof("Removing %s for not sending a version", a) - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { + if err := dm.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { logger.Error(err) return } @@ -909,12 +877,10 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { // We have to check at process time and not record time because // Introduction message does not update ExpectingIntroductions until its // Process() is called - // _, needsIntro := self.expectingIntroductions[e.Context.Addr] - // if needsIntro { if dm.needsIntro(e.Context.Addr) { _, isIntro := e.Message.(*IntroductionMessage) if !isIntro { - if err := dm.pool.Pool.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { + if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } } @@ -947,7 +913,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { if dm.ipCountMaxed(a) { logger.Infof("Max connections for %s reached, disconnecting", a) - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIPLimitReached); err != nil { + if err := dm.Disconnect(a, ErrDisconnectIPLimitReached); err != nil { logger.WithError(err).WithField("addr", a).Error("Disconnect") } return @@ -965,7 +931,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { if n > dm.Config.OutgoingMax { logger.Warningf("max outgoing connections is reached, disconnecting %v", a) - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { + if err := dm.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { logger.WithError(err).WithField("addr", a).Error("Disconnect") } return @@ -1099,7 +1065,7 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { if m, ok := r.Message.(*DisconnectMessage); ok { if err := dm.DisconnectNow(r.Addr, gnet.DisconnectReason(m.reason)); err != nil { - logger.WithError(err).WithField("addr", r.Addr).Warning("Failed to disconnect peer") + logger.WithError(err).WithField("addr", r.Addr).Warning("DisconnectNow") } } } diff --git a/src/daemon/errors.go b/src/daemon/errors.go index ce0fb62f42..2d39764746 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -1,78 +1,97 @@ package daemon import ( + "errors" + "github.com/skycoin/skycoin/src/daemon/gnet" - "github.com/skycoin/skycoin/src/daemon/pex" ) -var errorByCode = [...]error{ - nil, - ErrDisconnectVersionNotSupported, - ErrDisconnectIntroductionTimeout, - ErrDisconnectVersionSendFailed, - ErrDisconnectIsBlacklisted, - ErrDisconnectSelf, - ErrDisconnectConnectedTwice, - ErrDisconnectIdle, - ErrDisconnectNoIntroduction, - ErrDisconnectIPLimitReached, - ErrDisconnectIncomprehensibleError, - ErrDisconnectMaxOutgoingConnectionsReached, - ErrDisconnectBlockchainPubkeyNotMatched, - ErrDisconnectInvalidExtraData, - ErrDisconnectPeerlistFull, - ErrOutgoingConnectionsDisabled, - ErrRecvReject, - gnet.ErrDisconnectReadFailed, - gnet.ErrDisconnectWriteFailed, - gnet.ErrDisconnectSetReadDeadlineFailed, - gnet.ErrDisconnectInvalidMessageLength, - gnet.ErrDisconnectMalformedMessage, - gnet.ErrDisconnectUnknownMessage, - gnet.ErrWriteQueueFull, - gnet.ErrDisconnectUnexpectedError, - gnet.ErrNoReachableConnections, - gnet.ErrConnectionPoolClosed, - gnet.ErrPoolEmpty, - pex.ErrPeerlistFull, - pex.ErrInvalidAddress, - pex.ErrNoLocalhost, - pex.ErrNotExternalIP, - pex.ErrPortTooLow, - pex.ErrBlacklistedAddress} +var ( + // ErrDisconnectVersionNotSupported version is below minimum supported version + ErrDisconnectVersionNotSupported gnet.DisconnectReason = errors.New("Version is below minimum supported version") + // ErrDisconnectIntroductionTimeout timeout + ErrDisconnectIntroductionTimeout gnet.DisconnectReason = errors.New("Introduction timeout") + // ErrDisconnectIsBlacklisted is blacklisted + ErrDisconnectIsBlacklisted gnet.DisconnectReason = errors.New("Blacklisted") + // ErrDisconnectSelf self connnect + ErrDisconnectSelf gnet.DisconnectReason = errors.New("Self connect") + // ErrDisconnectConnectedTwice connect twice + ErrDisconnectConnectedTwice gnet.DisconnectReason = errors.New("Already connected") + // ErrDisconnectIdle idle + ErrDisconnectIdle gnet.DisconnectReason = errors.New("Idle") + // ErrDisconnectNoIntroduction no introduction + ErrDisconnectNoIntroduction gnet.DisconnectReason = errors.New("First message was not an Introduction") + // ErrDisconnectIPLimitReached ip limit reached + ErrDisconnectIPLimitReached gnet.DisconnectReason = errors.New("Maximum number of connections for this IP was reached") + // ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered + // e.g. net.Conn.Addr() returns an invalid ip:port + ErrDisconnectIncomprehensibleError gnet.DisconnectReason = errors.New("Incomprehensible error") + // ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed + ErrDisconnectMaxOutgoingConnectionsReached gnet.DisconnectReason = errors.New("Maximum outgoing connections was reached") + // ErrDisconnectBlockchainPubkeyNotMatched is returned when the blockchain pubkey in introduction does not match + ErrDisconnectBlockchainPubkeyNotMatched gnet.DisconnectReason = errors.New("Blockchain pubkey does not match") + // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. + // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey + ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data in message") + // ErrDisconnectPeerlistFull no space in peers pool + ErrDisconnectPeerlistFull gnet.DisconnectReason = errors.New("Peerlist is full") + // ErrDisconnectReceivedDisconnect received a DisconnectMessage + ErrDisconnectReceivedDisconnect gnet.DisconnectReason = errors.New("Received DisconnectMessage") + // ErrDisconnectUnknownReason used when mapping an unknown reason code to an error. Is not sent over the network. + ErrDisconnectUnknownReason gnet.DisconnectReason = errors.New("Unknown DisconnectReason") + + disconnectReasonCodes = map[gnet.DisconnectReason]uint16{ + ErrDisconnectUnknownReason: 0, -var errorCodeByError map[error]uint32 + ErrDisconnectVersionNotSupported: 1, + ErrDisconnectIntroductionTimeout: 2, + ErrDisconnectIsBlacklisted: 4, + ErrDisconnectSelf: 5, + ErrDisconnectConnectedTwice: 6, + ErrDisconnectIdle: 7, + ErrDisconnectNoIntroduction: 8, + ErrDisconnectIPLimitReached: 9, + ErrDisconnectIncomprehensibleError: 10, + ErrDisconnectMaxOutgoingConnectionsReached: 11, + ErrDisconnectBlockchainPubkeyNotMatched: 12, + ErrDisconnectInvalidExtraData: 13, + ErrDisconnectPeerlistFull: 14, + ErrDisconnectReceivedDisconnect: 16, -var initErrorCodeMap = func() { - errorCodeByError = make(map[error]uint32) - for i, err := range errorByCode { - errorCodeByError[err] = uint32(i) + gnet.ErrDisconnectReadFailed: 1001, + gnet.ErrDisconnectWriteFailed: 1002, + gnet.ErrDisconnectSetReadDeadlineFailed: 1003, + gnet.ErrDisconnectInvalidMessageLength: 1004, + gnet.ErrDisconnectMalformedMessage: 1005, + gnet.ErrDisconnectUnknownMessage: 1006, + gnet.ErrDisconnectUnexpectedError: 1007, } -} -// ErrorCodeUnknown is used on unexpected error condition detected -const ErrorCodeUnknown = 0xFFFFFFFF + disconnectCodeReasons map[uint16]gnet.DisconnectReason +) -// Success error code -const Success = 0 +func init() { + disconnectCodeReasons = make(map[uint16]gnet.DisconnectReason, len(disconnectReasonCodes)) -// GetError Retrieve error object by corresponding error code -func GetError(code uint32) error { - if code < uint32(len(errorByCode)) { - return errorByCode[code] + for r, c := range disconnectReasonCodes { + if c == 0 { + panic("disconnect code 0 is reserved") + } + + disconnectCodeReasons[c] = r } - return nil } -// GetErrorCode Retrieve error code representing corresponding error object -func GetErrorCode(err error) uint32 { - if code, exists := errorCodeByError[err]; exists { - return code - } - return ErrorCodeUnknown +// DisconnectReasonToCode maps a gnet.DisconnectReason to a 16-byte code +func DisconnectReasonToCode(r gnet.DisconnectReason) uint16 { + return disconnectReasonCodes[r] } -func init() { - initErrorCodeMap() - initErrorCodeMap = nil +// DisconnectCodeToReason maps a disconnect code to a gnet.DisconnectReason +func DisconnectCodeToReason(c uint16) gnet.DisconnectReason { + r, ok := disconnectCodeReasons[c] + if !ok { + return ErrDisconnectUnknownReason + } + return r } diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 3af93b4be3..2bf74563f8 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -15,6 +15,8 @@ import ( "io" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/daemon/strand" "github.com/skycoin/skycoin/src/util/elapse" @@ -38,7 +40,7 @@ var ( // ErrDisconnectWriteFailed write faile ErrDisconnectWriteFailed DisconnectReason = errors.New("Write failed") // ErrDisconnectSetReadDeadlineFailed set read deadline failed - ErrDisconnectSetReadDeadlineFailed = errors.New("SetReadDeadline failed") + ErrDisconnectSetReadDeadlineFailed DisconnectReason = errors.New("SetReadDeadline failed") // ErrDisconnectInvalidMessageLength invalid message length ErrDisconnectInvalidMessageLength DisconnectReason = errors.New("Invalid message length") // ErrDisconnectMalformedMessage malformed message @@ -661,7 +663,7 @@ func (pool *ConnectionPool) IsConnExist(addr string) (bool, error) { } return nil }); err != nil { - return false, fmt.Errorf("Check connection existence failed: %v ", err) + return false, err } return exist, nil @@ -783,7 +785,12 @@ func (pool *ConnectionPool) Connect(address string) error { // Disconnect removes a connection from the pool by address, and passes a Disconnection to // the DisconnectCallback func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { - if err := pool.strand("Disconnect", func() error { + return pool.strand("Disconnect", func() error { + logger.WithFields(logrus.Fields{ + "addr": addr, + "reason": r.Error(), + }).Info("Disconnecting") + exist := pool.disconnect(addr) // checks if the address is default node address @@ -797,11 +804,7 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { } return nil - }); err != nil { - return err - } - - return nil + }) } func (pool *ConnectionPool) disconnect(addr string) bool { @@ -810,8 +813,6 @@ func (pool *ConnectionPool) disconnect(addr string) bool { return false } - // TODO -- send disconnect reason packet - delete(pool.pool, conn.ID) delete(pool.addresses, addr) delete(pool.defaultConnections, addr) @@ -932,7 +933,6 @@ func (pool *ConnectionPool) BroadcastMessage(msg Message) error { // first return value. Otherwise, error will be nil and DisconnectReason will // be the value returned from the message handler. func (pool *ConnectionPool) receiveMessage(c *Connection, msg []byte) error { - m, err := convertToMessage(c.ID, msg, pool.Config.DebugPrint) if err != nil { return err @@ -967,11 +967,11 @@ func (pool *ConnectionPool) SendPings(rate time.Duration, msg Message) error { return nil } -// ClearStaleConnections removes connections that have not sent a message in too long -func (pool *ConnectionPool) ClearStaleConnections(idleLimit time.Duration, reason DisconnectReason) error { +// GetStaleConnections returns connections that have been idle for longer than idleLimit +func (pool *ConnectionPool) GetStaleConnections(idleLimit time.Duration) ([]string, error) { now := Now() - idleConns := []string{} - if err := pool.strand("ClearStaleConnections", func() error { + var idleConns []string + if err := pool.strand("GetStaleConnections", func() error { for _, conn := range pool.pool { if conn.LastReceived.Add(idleLimit).Before(now) { idleConns = append(idleConns, conn.Addr()) @@ -979,15 +979,10 @@ func (pool *ConnectionPool) ClearStaleConnections(idleLimit time.Duration, reaso } return nil }); err != nil { - return err + return nil, err } - for _, a := range idleConns { - if err := pool.Disconnect(a, reason); err != nil { - logger.WithError(err).WithField("addr", a).Warning("Error in disconnecting from stale connection") - } - } - return nil + return idleConns, nil } // Now returns the current UTC time diff --git a/src/daemon/messages.go b/src/daemon/messages.go index c824c3491e..79d815fb78 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -9,6 +9,8 @@ import ( "strings" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" @@ -16,11 +18,6 @@ import ( "github.com/skycoin/skycoin/src/util/iputil" ) -var ( - // ErrRecvReject disconnect since peer sent RJCT message - ErrRecvReject gnet.DisconnectReason = errors.New("Disconnect: Message rejected by peer") -) - // Message represent a packet to be serialized over the network by // the gnet encoder. // They must implement the gnet.Message interface @@ -60,7 +57,7 @@ func getMessageConfigs() []MessageConfig { NewMessageConfig("GETT", GetTxnsMessage{}), NewMessageConfig("GIVT", GiveTxnsMessage{}), NewMessageConfig("ANNT", AnnounceTxnsMessage{}), - NewMessageConfig("RJCT", DisconnectMessage{}), + NewMessageConfig("DISC", DisconnectMessage{}), } } @@ -229,16 +226,14 @@ func (gpm *GivePeersMessage) Process(d Daemoner) { // IntroductionMessage jan IntroductionMessage is sent on first connect by both parties type IntroductionMessage struct { - // Mirror is a random value generated on client startup that is used - // to identify self-connections + c *gnet.MessageContext `enc:"-"` + + // Mirror is a random value generated on client startup that is used to identify self-connections Mirror uint32 // Port is the port that this client is listening on Port uint16 // Protocol version Version int32 - c *gnet.MessageContext `enc:"-"` - // We validate the message in Handle() and cache the result for Process() - validationError error `enc:"-"` // skip it during encoding // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. // Currently it contains the blockchain pubkey but will accept a client that does not provide it. Extra []byte `enc:",omitempty"` @@ -258,15 +253,22 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey ci // need to control the DisconnectReason sent back to gnet. We still implement // Process(), where we do modifications that are not threadsafe func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { + intro.c = mc + return d.RecordMessageEvent(intro, mc) +} + +// Process an event queued by Handle() +func (intro *IntroductionMessage) Process(d Daemoner) { d := daemon.(Daemoner) + d.RemoveFromExpectingIntroductions(intro.c.Addr) + + var port uint16 + err := func() error { // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { logger.Infof("Remote mirror value %v matches ours", intro.Mirror) - if err := d.Disconnect(mc.Addr, ErrDisconnectSelf); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } return ErrDisconnectSelf } @@ -274,9 +276,6 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa dc := d.DaemonConfig() if intro.Version < dc.MinProtocolVersion { logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.Version, dc.MinProtocolVersion) - if err := d.Disconnect(mc.Addr, ErrDisconnectVersionNotSupported); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } return ErrDisconnectVersionNotSupported } @@ -306,7 +305,9 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // only solicited connection can be added to exchange peer list, because accepted // connection may not have an incoming port - ip, port, err := iputil.SplitAddr(mc.Addr) + var ip string + var err error + ip, port, err = iputil.SplitAddr(mc.Addr) if err != nil { // This should never happen, but the program should still work if it does logger.Errorf("Invalid Addr() for connection: %s", mc.Addr) @@ -316,20 +317,6 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return ErrDisconnectIncomprehensibleError } - // Checks if the introduction message is from outgoing connection. - // It's outgoing connection if port == intro.Port, as the incoming - // connection's port is a random port, it's different from the port - // in introduction message. - if port == intro.Port { - if err := d.SetHasIncomingPort(mc.Addr); err != nil { - logger.Errorf("Failed to set peer has incoming port status, %v", err) - } - } else { - if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { - logger.Errorf("Failed to add peer: %v", err) - } - } - // Disconnect if connected twice to the same peer (judging by ip:mirror) knownPort, exists := d.GetMirrorPort(mc.Addr, intro.Mirror) if exists { @@ -342,39 +329,29 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return nil }() - intro.validationError = err - intro.c = mc - if err != nil { d.IncreaseRetryTimes(mc.Addr) - d.RemoveFromExpectingIntroductions(mc.Addr) - return err - } - err = d.RecordMessageEvent(intro, mc) - d.ResetRetryTimes(mc.Addr) - return err -} - -// Process an event queued by Handle() -func (intro *IntroductionMessage) Process(d Daemoner) { - if intro.validationError == pex.ErrPeerlistFull { - peers := d.RandomExchangeable(d.PexConfig().ReplyCount) - givpMsg := NewGivePeersMessage(peers) - if err := d.SendMessage(intro.c.Addr, givpMsg); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Error("Send GivePeersMessage failed") + if err := d.Disconnect(intro.c.Addr, err); err != nil { + logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") } + } - if err := d.Disconnect(intro.c.Addr, pex.ErrPeerlistFull); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Error("Disconnect") + // Checks if the introduction message is from outgoing connection. + // It's outgoing connection if port == intro.Port, as the incoming + // connection's port is a random port, it's different from the port + // in introduction message. + if port == intro.Port { + if err := d.SetHasIncomingPort(mc.Addr); err != nil { + logger.Errorf("Failed to set peer has incoming port status, %v", err) + } + } else { + if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { + logger.Errorf("Failed to add peer: %v", err) } } - d.RemoveFromExpectingIntroductions(intro.c.Addr) - - if intro.validationError != nil { - return - } + d.ResetRetryTimes(mc.Addr) // Add the remote peer with their chosen listening port a := intro.c.Addr @@ -456,7 +433,7 @@ type DisconnectMessage struct { func NewDisconnectMessage(reason gnet.DisconnectReason) *DisconnectMessage { return &DisconnectMessage{ reason: reason, - ReasonCode: GetErrorCode(reason), + ReasonCode: DisconnectReasonToCode(reason), Reserved: nil, } } @@ -469,7 +446,12 @@ func (dm *DisconnectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // Process Recover from message rejection state func (dm *DisconnectMessage) Process(d Daemoner) { - logger.Critical().WithField("addr", dm.c.Addr).Infof("DisconnectMessage received, reason: %d", dm.ReasonCode) + logger.Critical().WithFields(logrus.Fields{ + "addr": dm.c.Addr, + "code": dm.ReasonCode, + "reason": DisconnectCodeToReason(dm.ReasonCode), + "note": dm.Note, + }).Infof("DisconnectMessage received") if err := d.DisconnectNow(dm.c.Addr, gnet.DisconnectReason(errors.New("TODO - a reason"))); err != nil { logger.WithError(err).WithField("addr", dm.c.Addr).Warning("DisconnectNow") } diff --git a/src/daemon/pool.go b/src/daemon/pool.go index 93b330f3e9..1b1d02330b 100644 --- a/src/daemon/pool.go +++ b/src/daemon/pool.go @@ -93,16 +93,14 @@ func (pool *Pool) RunOffline() error { return pool.Pool.RunOffline() } -// Send a ping if our last message sent was over pingRate ago +// sendPings send a ping if our last message sent was over pingRate ago func (pool *Pool) sendPings() { if err := pool.Pool.SendPings(pool.Config.PingRate, &PingMessage{}); err != nil { logger.WithError(err).Error("sendPings failed") } } -// Removes connections that have not sent a message in too long -func (pool *Pool) clearStaleConnections() { - if err := pool.Pool.ClearStaleConnections(pool.Config.IdleLimit, ErrDisconnectIdle); err != nil { - logger.WithError(err).Error("clearStaleConnections failed") - } +// getStaleConnections returns connections that have been idle for longer than idleLimit +func (pool *Pool) getStaleConnections() ([]string, error) { + return pool.Pool.GetStaleConnections(pool.Config.IdleLimit) } diff --git a/src/daemon/storage.go b/src/daemon/storage.go index 2d66bffcf1..781a0a027b 100644 --- a/src/daemon/storage.go +++ b/src/daemon/storage.go @@ -51,10 +51,13 @@ func (s *ExpectIntroductions) CullInvalidConns(f CullMatchFunc) ([]string, error if ok { addrs = append(addrs, addr) - delete(s.value, addr) } } + for _, addr := range addrs { + delete(s.value, addr) + } + return addrs, nil } From edf445b07f331f7356e43b24ed139ec0ac4da59f Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 14:13:49 +0800 Subject: [PATCH 297/399] Update docs for /network/connection --- src/api/README.md | 94 ++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/src/api/README.md b/src/api/README.md index 2916ae7932..f0c9b2378f 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -1524,9 +1524,9 @@ API sets: `INSECURE_WALLET_SEED` URI: /api/v2/wallet/recover Method: POST Args: - id: wallet id - seed: wallet seed - password: [optional] password to encrypt the recovered wallet with + id: wallet id + seed: wallet seed + password: [optional] password to encrypt the recovered wallet with ``` Recovers an encrypted wallet by providing the wallet seed. @@ -1543,28 +1543,28 @@ Result: ```json { - "data": { - "meta": { - "coin": "skycoin", - "filename": "2017_11_25_e5fb.wlt", - "label": "test", - "type": "deterministic", - "version": "0.2", - "crypto_type": "", - "timestamp": 1511640884, - "encrypted": false - }, - "entries": [ - { - "address": "2HTnQe3ZupkG6k8S81brNC3JycGV2Em71F2", - "public_key": "0316ff74a8004adf9c71fa99808ee34c3505ee73c5cf82aa301d17817da3ca33b1" - }, - { - "address": "SMnCGfpt7zVXm8BkRSFMLeMRA6LUu3Ewne", - "public_key": "02539528248a1a2c4f0b73233491103ca83b40249dac3ae9eee9a10b9f9debd9a3" - } - ] - } + "data": { + "meta": { + "coin": "skycoin", + "filename": "2017_11_25_e5fb.wlt", + "label": "test", + "type": "deterministic", + "version": "0.2", + "crypto_type": "", + "timestamp": 1511640884, + "encrypted": false + }, + "entries": [ + { + "address": "2HTnQe3ZupkG6k8S81brNC3JycGV2Em71F2", + "public_key": "0316ff74a8004adf9c71fa99808ee34c3505ee73c5cf82aa301d17817da3ca33b1" + }, + { + "address": "SMnCGfpt7zVXm8BkRSFMLeMRA6LUu3Ewne", + "public_key": "02539528248a1a2c4f0b73233491103ca83b40249dac3ae9eee9a10b9f9debd9a3" + } + ] + } } ``` @@ -1850,9 +1850,9 @@ Method: POST Content-Type: application/json Body: {"rawtx": "hex-encoded serialized transaction string"} Errors: - 400 - Bad input - 500 - Other - 503 - Network unavailable (transaction failed to broadcast) + 400 - Bad input + 500 - Other + 503 - Network unavailable (transaction failed to broadcast) ``` Broadcasts a hex-encoded, serialized transaction to the network. @@ -3575,7 +3575,8 @@ Result: "introduced": true, "mirror": 719118746, "height": 181, - "listen_port": 6000 + "listen_port": 6000, + "user_agent": "skycoin:0.25.0" } ``` @@ -3608,7 +3609,8 @@ Result: "introduced": true, "mirror": 1338939619, "height": 180, - "listen_port": 20002 + "listen_port": 20002, + "user_agent": "skycoin:0.25.0" }, { "id": 109548, @@ -3619,7 +3621,8 @@ Result: "introduced": true, "mirror": 719118746, "height": 182, - "listen_port": 6000 + "listen_port": 6000, + "user_agent": "skycoin:0.25.0" }, { "id": 99115, @@ -3630,7 +3633,8 @@ Result: "introduced": true, "mirror": 1931713869, "height": 180, - "listen_port": 6000 + "listen_port": 6000, + "user_agent": "" } ] } @@ -3777,19 +3781,19 @@ To replicate the same behavior as `/api/v1/spend`, use the following request bod ```json { - "hours_selection": { - "type": "auto", - "mode": "share", - "share_factor": "0.5", - }, - "wallet": { - "id": "$wallet_id", - "password": "$password" - }, - "to": [{ - "address": "$dst", - "coins": "$coins" - }] + "hours_selection": { + "type": "auto", + "mode": "share", + "share_factor": "0.5", + }, + "wallet": { + "id": "$wallet_id", + "password": "$password" + }, + "to": [{ + "address": "$dst", + "coins": "$coins" + }] } ``` From 3a38892b20bbba9244871654518d302c458c7bfa Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 14:59:44 +0800 Subject: [PATCH 298/399] Move IntroductionMessage.Handle logic to Prcess; add all connections to /api/v1/network/connections --- CHANGELOG.md | 1 + src/api/gateway.go | 2 + src/api/mock_gatewayer_test.go | 46 +++++++++ src/api/network.go | 20 +++- src/api/network_test.go | 169 ++++++++++++++++++++++++++++--- src/daemon/errors.go | 8 -- src/daemon/gateway.go | 36 ++++++- src/daemon/messages.go | 104 ++++++++----------- src/daemon/mock_daemoner_test.go | 14 +++ 9 files changed, 310 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d037b2a55..1966cd2ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. - Send new `DISC` disconnect packet to peer before disconnecting +- `/api/v1/network/connections` now returns both outgoing and incoming connections by default. Previously it returned only outgoing connections. A `type` parameter is added to filter by outgoing or incoming connections. ### Removed diff --git a/src/api/gateway.go b/src/api/gateway.go index 5bb56dd8c9..3b185dca68 100644 --- a/src/api/gateway.go +++ b/src/api/gateway.go @@ -44,7 +44,9 @@ type Gatewayer interface { GetBlockchainMetadata() (*visor.BlockchainMetadata, error) GetBlockchainProgress() (*daemon.BlockchainProgress, error) GetConnection(addr string) (*daemon.Connection, error) + GetConnections() ([]daemon.Connection, error) GetOutgoingConnections() ([]daemon.Connection, error) + GetIncomingConnections() ([]daemon.Connection, error) GetDefaultConnections() []string GetTrustConnections() []string GetExchgConnection() []string diff --git a/src/api/mock_gatewayer_test.go b/src/api/mock_gatewayer_test.go index 7dcdd90eb1..ffdad5ad92 100644 --- a/src/api/mock_gatewayer_test.go +++ b/src/api/mock_gatewayer_test.go @@ -394,6 +394,29 @@ func (_m *MockGatewayer) GetConnection(addr string) (*daemon.Connection, error) return r0, r1 } +// GetConnections provides a mock function with given fields: +func (_m *MockGatewayer) GetConnections() ([]daemon.Connection, error) { + ret := _m.Called() + + var r0 []daemon.Connection + if rf, ok := ret.Get(0).(func() []daemon.Connection); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]daemon.Connection) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetDefaultConnections provides a mock function with given fields: func (_m *MockGatewayer) GetDefaultConnections() []string { ret := _m.Called() @@ -449,6 +472,29 @@ func (_m *MockGatewayer) GetHealth() (*daemon.Health, error) { return r0, r1 } +// GetIncomingConnections provides a mock function with given fields: +func (_m *MockGatewayer) GetIncomingConnections() ([]daemon.Connection, error) { + ret := _m.Called() + + var r0 []daemon.Connection + if rf, ok := ret.Get(0).(func() []daemon.Connection); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]daemon.Connection) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetLastBlocks provides a mock function with given fields: num func (_m *MockGatewayer) GetLastBlocks(num uint64) ([]coin.SignedBlock, error) { ret := _m.Called(num) diff --git a/src/api/network.go b/src/api/network.go index 768e329daa..557c5a82cd 100644 --- a/src/api/network.go +++ b/src/api/network.go @@ -64,6 +64,7 @@ func NewConnections(dconns []daemon.Connection) Connections { // connectionsHandler returns all outgoing connections // URI: /api/v1/network/connections // Method: GET +// Args: type [optional] either outgoing or incoming func connectionsHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { @@ -71,13 +72,28 @@ func connectionsHandler(gateway Gatewayer) http.HandlerFunc { return } - dcnxs, err := gateway.GetOutgoingConnections() + var conns []daemon.Connection + var err error + + typ := r.FormValue("type") + switch typ { + case "": + conns, err = gateway.GetConnections() + case "outgoing": + conns, err = gateway.GetOutgoingConnections() + case "incoming": + conns, err = gateway.GetIncomingConnections() + default: + wh.Error400(w, "invalid type") + return + } + if err != nil { wh.Error500(w, err.Error()) return } - wh.SendJSONOr500(logger, w, NewConnections(dcnxs)) + wh.SendJSONOr500(logger, w, NewConnections(conns)) } } diff --git a/src/api/network_test.go b/src/api/network_test.go index eb8224a17a..d44d31f08f 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -126,13 +126,18 @@ func TestConnection(t *testing.T) { func TestConnections(t *testing.T) { tt := []struct { - name string - method string - status int - err string - gatewayGetSolicitedConnectionsResult []daemon.Connection - gatewayGetSolicitedConnectionsError error - result Connections + name string + method string + typ string + status int + err string + gatewayGetConnectionsResult []daemon.Connection + gatewayGetConnectionsError error + gatewayGetOutgoingConnectionsResult []daemon.Connection + gatewayGetOutgoingConnectionsError error + gatewayGetIncomingConnectionsResult []daemon.Connection + gatewayGetIncomingConnectionsError error + result Connections }{ { name: "405", @@ -140,12 +145,21 @@ func TestConnections(t *testing.T) { status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, + { - name: "200", + name: "400 bad type", + method: http.MethodGet, + typ: "foo", + status: http.StatusBadRequest, + err: "400 Bad Request - invalid type", + }, + + { + name: "200 all connections", method: http.MethodGet, status: http.StatusOK, err: "", - gatewayGetSolicitedConnectionsResult: []daemon.Connection{ + gatewayGetConnectionsResult: []daemon.Connection{ { ID: 1, Addr: "127.0.0.1", @@ -157,6 +171,17 @@ func TestConnections(t *testing.T) { ListenPort: 9877, Height: 1234, }, + { + ID: 3, + Addr: "127.1.1.1", + LastSent: 88888, + LastReceived: 9999999, + Outgoing: false, + Introduced: true, + Mirror: 9877, + ListenPort: 9877, + Height: 1235, + }, }, result: Connections{ Connections: []readable.Connection{ @@ -171,23 +196,137 @@ func TestConnections(t *testing.T) { ListenPort: 9877, Height: 1234, }, + { + ID: 3, + Addr: "127.1.1.1", + LastSent: 88888, + LastReceived: 9999999, + Outgoing: false, + Introduced: true, + Mirror: 9877, + ListenPort: 9877, + Height: 1235, + }, }, }, }, { - name: "500 - GetOutgoingConnections failed", - method: http.MethodGet, - status: http.StatusInternalServerError, - err: "500 Internal Server Error - GetOutgoingConnections failed", - gatewayGetSolicitedConnectionsError: errors.New("GetOutgoingConnections failed"), + name: "200 outgoing connections", + method: http.MethodGet, + typ: "outgoing", + status: http.StatusOK, + err: "", + gatewayGetOutgoingConnectionsResult: []daemon.Connection{ + { + ID: 1, + Addr: "127.0.0.1", + LastSent: 99999, + LastReceived: 1111111, + Outgoing: true, + Introduced: true, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + }, + }, + result: Connections{ + Connections: []readable.Connection{ + { + ID: 1, + Addr: "127.0.0.1", + LastSent: 99999, + LastReceived: 1111111, + Outgoing: true, + Introduced: true, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + }, + }, + }, + }, + + { + name: "200 incoming connections", + method: http.MethodGet, + typ: "incoming", + status: http.StatusOK, + err: "", + gatewayGetIncomingConnectionsResult: []daemon.Connection{ + { + ID: 1, + Addr: "127.0.0.1", + LastSent: 99999, + LastReceived: 1111111, + Outgoing: false, + Introduced: true, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + }, + }, + result: Connections{ + Connections: []readable.Connection{ + { + ID: 1, + Addr: "127.0.0.1", + LastSent: 99999, + LastReceived: 1111111, + Outgoing: false, + Introduced: true, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + }, + }, + }, + }, + + { + name: "500 - GetConnections failed", + method: http.MethodGet, + status: http.StatusInternalServerError, + err: "500 Internal Server Error - GetConnections failed", + gatewayGetConnectionsError: errors.New("GetConnections failed"), + }, + + { + name: "500 - GetOutgoingConnections failed", + method: http.MethodGet, + typ: "outgoing", + status: http.StatusInternalServerError, + err: "500 Internal Server Error - GetOutgoingConnections failed", + gatewayGetOutgoingConnectionsError: errors.New("GetOutgoingConnections failed"), + }, + + { + name: "500 - GetIncomingConnections failed", + method: http.MethodGet, + typ: "incoming", + status: http.StatusInternalServerError, + err: "500 Internal Server Error - GetIncomingConnections failed", + gatewayGetIncomingConnectionsError: errors.New("GetIncomingConnections failed"), }, } + for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { endpoint := "/api/v1/network/connections" gateway := &MockGatewayer{} - gateway.On("GetOutgoingConnections").Return(tc.gatewayGetSolicitedConnectionsResult, tc.gatewayGetSolicitedConnectionsError) + gateway.On("GetConnections").Return(tc.gatewayGetConnectionsResult, tc.gatewayGetConnectionsError) + gateway.On("GetOutgoingConnections").Return(tc.gatewayGetOutgoingConnectionsResult, tc.gatewayGetOutgoingConnectionsError) + gateway.On("GetIncomingConnections").Return(tc.gatewayGetIncomingConnectionsResult, tc.gatewayGetIncomingConnectionsError) + + v := url.Values{} + if tc.typ != "" { + v.Add("type", tc.typ) + } + + ve := v.Encode() + if ve != "" { + endpoint += "?" + ve + } req, err := http.NewRequest(tc.method, endpoint, nil) require.NoError(t, err) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 2d39764746..f3f3ba543f 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -72,14 +72,6 @@ var ( func init() { disconnectCodeReasons = make(map[uint16]gnet.DisconnectReason, len(disconnectReasonCodes)) - - for r, c := range disconnectReasonCodes { - if c == 0 { - panic("disconnect code 0 is reserved") - } - - disconnectCodeReasons[c] = r - } } // DisconnectReasonToCode maps a gnet.DisconnectReason to a 16-byte code diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index e60a0b0b6e..1af5d26f89 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -101,17 +101,43 @@ type Connection struct { Height uint64 } +// GetConnections returns all connections +func (gw *Gateway) GetConnections() ([]Connection, error) { + var conns []Connection + var err error + gw.strand("GetConnections", func() { + conns, err = gw.getConnections(func(c gnet.Connection) bool { + return true + }) + }) + return conns, err +} + // GetOutgoingConnections returns solicited (outgoing) connections func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { var conns []Connection var err error gw.strand("GetOutgoingConnections", func() { - conns, err = gw.getOutgoingConnections() + conns, err = gw.getConnections(func(c gnet.Connection) bool { + return c.Solicited + }) }) return conns, err } -func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { +// GetIncomingConnections returns unsolicited (incoming) connections +func (gw *Gateway) GetIncomingConnections() ([]Connection, error) { + var conns []Connection + var err error + gw.strand("GetIncomingConnections", func() { + conns, err = gw.getConnections(func(c gnet.Connection) bool { + return !c.Solicited + }) + }) + return conns, err +} + +func (gw *Gateway) getConnections(flt func(c gnet.Connection) bool) ([]Connection, error) { if gw.d.pool.Pool == nil { return nil, nil } @@ -125,7 +151,7 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { conns := make([]Connection, 0, len(cs)) for _, c := range cs { - if c.Solicited { + if flt(c) { conn := gw.newConnection(&c) if conn != nil { conns = append(conns, *conn) @@ -865,7 +891,9 @@ func (gw *Gateway) GetHealth() (*Health, error) { return } - conns, err := gw.getOutgoingConnections() + conns, err := gw.getConnections(func(c gnet.Connection) bool { + return true + }) if err != nil { return } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 79d815fb78..ec01925331 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -254,126 +254,109 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey ci // Process(), where we do modifications that are not threadsafe func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { intro.c = mc - return d.RecordMessageEvent(intro, mc) + return daemon.(Daemoner).RecordMessageEvent(intro, mc) } // Process an event queued by Handle() func (intro *IntroductionMessage) Process(d Daemoner) { - d := daemon.(Daemoner) + addr := intro.c.Addr - d.RemoveFromExpectingIntroductions(intro.c.Addr) + d.RemoveFromExpectingIntroductions(addr) + var ip string var port uint16 - err := func() error { + if err := func() error { + var err error + ip, port, err = iputil.SplitAddr(addr) + if err != nil { + // This should never happen, but the program should still work if it does + logger.WithField("addr", addr).Error("Invalid addr") + return ErrDisconnectIncomprehensibleError + } + // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { - logger.Infof("Remote mirror value %v matches ours", intro.Mirror) + logger.WithField("addr", addr).Infof("Remote mirror value %d matches ours", intro.Mirror) return ErrDisconnectSelf } // Disconnect if peer version is not within the supported range dc := d.DaemonConfig() if intro.Version < dc.MinProtocolVersion { - logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.Version, dc.MinProtocolVersion) + logger.WithField("addr", addr).Infof("protocol version %d below minimum supported protocol version %d. Disconnecting.", intro.Version, dc.MinProtocolVersion) return ErrDisconnectVersionNotSupported } - logger.Infof("%s verified for version %d", mc.Addr, intro.Version) - // v25 Checks the blockchain pubkey, would accept message with no Pubkey // v26 would check the blockchain pubkey and reject if not matched or not provided if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.Infof("Extra data length does not meet the minimum requirement") - if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } + logger.WithField("addr", addr).Infof("Extra data length does not meet the minimum requirement") return ErrDisconnectInvalidExtraData } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) if d.BlockchainPubkey() != bcPubKey { - logger.Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) - if err := d.Disconnect(mc.Addr, ErrDisconnectBlockchainPubkeyNotMatched); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } + logger.WithField("addr", addr).Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) return ErrDisconnectBlockchainPubkeyNotMatched } } - // only solicited connection can be added to exchange peer list, because accepted - // connection may not have an incoming port - var ip string - var err error - ip, port, err = iputil.SplitAddr(mc.Addr) - if err != nil { - // This should never happen, but the program should still work if it does - logger.Errorf("Invalid Addr() for connection: %s", mc.Addr) - if err := d.Disconnect(mc.Addr, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } - return ErrDisconnectIncomprehensibleError - } - // Disconnect if connected twice to the same peer (judging by ip:mirror) - knownPort, exists := d.GetMirrorPort(mc.Addr, intro.Mirror) + knownPort, exists := d.GetMirrorPort(addr, intro.Mirror) if exists { - logger.Infof("%s is already connected on port %d", mc.Addr, knownPort) - if err := d.Disconnect(mc.Addr, ErrDisconnectConnectedTwice); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } + logger.WithField("addr", addr).Infof("Already connected on port %d", knownPort) return ErrDisconnectConnectedTwice } - return nil - }() - if err != nil { - d.IncreaseRetryTimes(mc.Addr) - - if err := d.Disconnect(intro.c.Addr, err); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") + return nil + }(); err != nil { + d.IncreaseRetryTimes(addr) + if err := d.Disconnect(addr, err); err != nil { + logger.WithField("addr", addr).WithError(err).Warning("Disconnect") } + return } + // Add the remote peer with their chosen listening port // Checks if the introduction message is from outgoing connection. // It's outgoing connection if port == intro.Port, as the incoming // connection's port is a random port, it's different from the port // in introduction message. if port == intro.Port { - if err := d.SetHasIncomingPort(mc.Addr); err != nil { - logger.Errorf("Failed to set peer has incoming port status, %v", err) + if err := d.SetHasIncomingPort(addr); err != nil { + logger.WithField("addr", addr).WithError(err).Error("SetHasIncomingPort failed") } } else { if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { - logger.Errorf("Failed to add peer: %v", err) + logger.WithField("addr", addr).WithError(err).Errorf("AddPeer failed") } } - d.ResetRetryTimes(mc.Addr) - - // Add the remote peer with their chosen listening port - a := intro.c.Addr - // Record their listener, to avoid double connections - err := d.RecordConnectionMirror(a, intro.Mirror) + err := d.RecordConnectionMirror(addr, intro.Mirror) if err != nil { // This should never happen, but the program should not allow itself // to be corrupted in case it does - logger.Errorf("Invalid port for connection %s", a) - if err := d.Disconnect(intro.c.Addr, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") + logger.WithField("addr", addr).WithError(err).Errorf("Invalid port for connection") + d.IncreaseRetryTimes(addr) + if err := d.Disconnect(addr, ErrDisconnectIncomprehensibleError); err != nil { + logger.WithField("addr", addr).WithError(err).Warning("Disconnect") } return } + logger.WithField("addr", addr).Infof("Peer verified for protocol version %d", intro.Version) + + d.ResetRetryTimes(addr) + // Request blocks immediately after they're confirmed - err = d.RequestBlocksFromAddr(intro.c.Addr) - if err == nil { - logger.Debugf("Successfully requested blocks from %s", intro.c.Addr) + if err := d.RequestBlocksFromAddr(addr); err != nil { + logger.WithField("addr", addr).WithError(err).Warning("RequestBlocksFromAddr failed") } else { - logger.Warning(err) + logger.WithField("addr", addr).Debug("Successfully requested blocks from peer") } // Announce unconfirmed txns @@ -423,7 +406,7 @@ type DisconnectMessage struct { reason gnet.DisconnectReason `enc:"-"` // Error code - ReasonCode uint32 + ReasonCode uint16 // Reserved for future use Reserved []byte `enc:",omitempty"` @@ -450,9 +433,8 @@ func (dm *DisconnectMessage) Process(d Daemoner) { "addr": dm.c.Addr, "code": dm.ReasonCode, "reason": DisconnectCodeToReason(dm.ReasonCode), - "note": dm.Note, }).Infof("DisconnectMessage received") - if err := d.DisconnectNow(dm.c.Addr, gnet.DisconnectReason(errors.New("TODO - a reason"))); err != nil { + if err := d.DisconnectNow(dm.c.Addr, ErrDisconnectReceivedDisconnect); err != nil { logger.WithError(err).WithField("addr", dm.c.Addr).Warning("DisconnectNow") } } diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index bb54805a00..cf8cf722c5 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -114,6 +114,20 @@ func (_m *MockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { return r0 } +// DisconnectNow provides a mock function with given fields: addr, r +func (_m *MockDaemoner) DisconnectNow(addr string, r gnet.DisconnectReason) error { + ret := _m.Called(addr, r) + + var r0 error + if rf, ok := ret.Get(0).(func(string, gnet.DisconnectReason) error); ok { + r0 = rf(addr, r) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // ExecuteSignedBlock provides a mock function with given fields: b func (_m *MockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { ret := _m.Called(b) From 223368cb90a360b235cca9cc7facdc8af7f93723 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 15:25:22 +0800 Subject: [PATCH 299/399] Log Disconnect --- src/daemon/daemon.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 13be24baeb..74c8a5c1de 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -10,6 +10,8 @@ import ( "sync" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" @@ -1325,6 +1327,10 @@ func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { // This allows all pending messages to be sent. Any message queued after a DisconnectMessage is unlikely to be sent // the peer (but possible). func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { + logger.WithFields(logrus.Fields{ + "addr": addr, + "reason": r, + }).Debug("Sending DisconnectMessage") return dm.SendMessage(addr, NewDisconnectMessage(r)) } From 36c55f4a9a15e672e4d81b043703c91c718fb010 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 16:30:56 +0800 Subject: [PATCH 300/399] Fix tests --- include/skyerrors.h | 2 +- lib/cgo/libsky_error.go | 54 +++++++------- src/api/README.md | 6 +- src/daemon/announced_txns.go | 44 ------------ src/daemon/daemon.go | 5 ++ src/daemon/errors.go | 24 ++++--- src/daemon/gnet/dispatcher.go | 16 ++++- src/daemon/gnet/message.go | 8 +-- src/daemon/gnet/pool.go | 2 +- src/daemon/messages.go | 108 ++++++++++++++-------------- src/daemon/messages_example_test.go | 6 +- src/daemon/messages_test.go | 72 ++++++++++--------- src/daemon/storage.go | 37 ++++++++++ 13 files changed, 200 insertions(+), 184 deletions(-) delete mode 100644 src/daemon/announced_txns.go diff --git a/include/skyerrors.h b/include/skyerrors.h index a89d55049e..3342a6c59a 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -111,7 +111,7 @@ #define SKY_ErrDisconnectIdle 0x06000017 #define SKY_ErrDisconnectNoIntroduction 0x06000018 #define SKY_ErrDisconnectIPLimitReached 0x06000019 -#define SKY_ErrDisconnectIncomprehensibleError 0x0600001A +#define SKY_ErrDisconnectUnexpectedError 0x0600001A #define SKY_ErrDisconnectMaxDefaultConnectionReached 0x0600001B #define SKY_ErrDisconnectMaxOutgoingConnectionsReached 0x0600001C #define SKY_ConnectionError 0x0600001D diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index cf69472dd1..5f914923e3 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -240,8 +240,8 @@ const ( SKY_ErrDisconnectNoIntroduction // SKY_ErrDisconnectIPLimitReached ip limit reached SKY_ErrDisconnectIPLimitReached - // SKY_ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered - SKY_ErrDisconnectIncomprehensibleError + // SKY_ErrDisconnectUnexpectedError this is returned when a seemingly impossible error is encountered + SKY_ErrDisconnectUnexpectedError // SKY_ErrDisconnectMaxDefaultConnectionReached Maximum number of default connections was reached SKY_ErrDisconnectMaxDefaultConnectionReached // nolint megacheck // SKY_ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed @@ -454,31 +454,31 @@ var ( // daemon // Removed in 34ad39ddb350 // gnet.ErrMaxDefaultConnectionsReached: SKY_ErrMaxDefaultConnectionsReached, - pex.ErrPeerlistFull: SKY_ErrPeerlistFull, - pex.ErrInvalidAddress: SKY_ErrInvalidAddress, - pex.ErrNoLocalhost: SKY_ErrNoLocalhost, - pex.ErrNotExternalIP: SKY_ErrNotExternalIP, - pex.ErrPortTooLow: SKY_ErrPortTooLow, - pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, - gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, - gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, - gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, - gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, - gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, - gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, - gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, - gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, - gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, - gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, - daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, - daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, - daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, - daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, - daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, - daemon.ErrDisconnectIdle: SKY_ErrDisconnectIdle, - daemon.ErrDisconnectNoIntroduction: SKY_ErrDisconnectNoIntroduction, - daemon.ErrDisconnectIPLimitReached: SKY_ErrDisconnectIPLimitReached, - daemon.ErrDisconnectIncomprehensibleError: SKY_ErrDisconnectIncomprehensibleError, + pex.ErrPeerlistFull: SKY_ErrPeerlistFull, + pex.ErrInvalidAddress: SKY_ErrInvalidAddress, + pex.ErrNoLocalhost: SKY_ErrNoLocalhost, + pex.ErrNotExternalIP: SKY_ErrNotExternalIP, + pex.ErrPortTooLow: SKY_ErrPortTooLow, + pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, + gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, + gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, + gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, + gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, + gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, + gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, + gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, + gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, + gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, + gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, + daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, + daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, + daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, + daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, + daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, + daemon.ErrDisconnectIdle: SKY_ErrDisconnectIdle, + daemon.ErrDisconnectNoIntroduction: SKY_ErrDisconnectNoIntroduction, + daemon.ErrDisconnectIPLimitReached: SKY_ErrDisconnectIPLimitReached, + daemon.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, // Removed // daemon.ErrDisconnectMaxDefaultConnectionReached: SKY_ErrDisconnectMaxDefaultConnectionReached, daemon.ErrDisconnectMaxOutgoingConnectionsReached: SKY_ErrDisconnectMaxOutgoingConnectionsReached, diff --git a/src/api/README.md b/src/api/README.md index 02fc9fc226..0a7ac5d22a 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3584,8 +3584,12 @@ API sets: `STATUS`, `READ` ``` URI: /api/v1/network/connections Method: GET +Args: + type: [optional] "outgoing" or "incoming" ``` +Returns all connections if `type` is not specified, otherwise filters connection by the `type` category. + Example: ```sh @@ -3624,7 +3628,7 @@ Result: "address": "185.120.34.60:6000", "last_sent": 1520675754, "last_received": 1520675754, - "outgoing": false, + "outgoing": true, "introduced": true, "mirror": 1931713869, "height": 180, diff --git a/src/daemon/announced_txns.go b/src/daemon/announced_txns.go deleted file mode 100644 index b6ca110f6e..0000000000 --- a/src/daemon/announced_txns.go +++ /dev/null @@ -1,44 +0,0 @@ -package daemon - -import ( - "sync" - "time" - - "github.com/skycoin/skycoin/src/cipher" -) - -type announcedTxnsCache struct { - sync.Mutex - cache map[cipher.SHA256]int64 -} - -func newAnnouncedTxnsCache() *announcedTxnsCache { - return &announcedTxnsCache{ - cache: make(map[cipher.SHA256]int64), - } -} - -func (c *announcedTxnsCache) add(txns []cipher.SHA256) { - c.Lock() - defer c.Unlock() - - t := time.Now().UTC().UnixNano() - for _, txn := range txns { - c.cache[txn] = t - } -} - -func (c *announcedTxnsCache) flush() map[cipher.SHA256]int64 { - c.Lock() - defer c.Unlock() - - if len(c.cache) == 0 { - return nil - } - - cache := c.cache - - c.cache = make(map[cipher.SHA256]int64) - - return cache -} diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 74c8a5c1de..742b27a617 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -986,6 +986,11 @@ func (dm *Daemon) ipCountMaxed(addr string) bool { return true } + // The IP count doesn't apply to localhost addresses + if iputil.IsLocalhost(ip) { + return false + } + if cnt, ok := dm.ipCounts.Get(ip); ok { return cnt >= dm.Config.IPCountsMax } diff --git a/src/daemon/errors.go b/src/daemon/errors.go index f3f3ba543f..b74d936cae 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -23,9 +23,9 @@ var ( ErrDisconnectNoIntroduction gnet.DisconnectReason = errors.New("First message was not an Introduction") // ErrDisconnectIPLimitReached ip limit reached ErrDisconnectIPLimitReached gnet.DisconnectReason = errors.New("Maximum number of connections for this IP was reached") - // ErrDisconnectIncomprehensibleError this is returned when a seemingly impossible error is encountered + // ErrDisconnectUnexpectedError this is returned when a seemingly impossible error is encountered // e.g. net.Conn.Addr() returns an invalid ip:port - ErrDisconnectIncomprehensibleError gnet.DisconnectReason = errors.New("Incomprehensible error") + ErrDisconnectUnexpectedError gnet.DisconnectReason = errors.New("Unexpected error") // ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed ErrDisconnectMaxOutgoingConnectionsReached gnet.DisconnectReason = errors.New("Maximum outgoing connections was reached") // ErrDisconnectBlockchainPubkeyNotMatched is returned when the blockchain pubkey in introduction does not match @@ -45,18 +45,18 @@ var ( ErrDisconnectVersionNotSupported: 1, ErrDisconnectIntroductionTimeout: 2, - ErrDisconnectIsBlacklisted: 4, - ErrDisconnectSelf: 5, - ErrDisconnectConnectedTwice: 6, - ErrDisconnectIdle: 7, - ErrDisconnectNoIntroduction: 8, - ErrDisconnectIPLimitReached: 9, - ErrDisconnectIncomprehensibleError: 10, + ErrDisconnectIsBlacklisted: 3, + ErrDisconnectSelf: 4, + ErrDisconnectConnectedTwice: 5, + ErrDisconnectIdle: 6, + ErrDisconnectNoIntroduction: 7, + ErrDisconnectIPLimitReached: 8, + ErrDisconnectUnexpectedError: 9, ErrDisconnectMaxOutgoingConnectionsReached: 11, ErrDisconnectBlockchainPubkeyNotMatched: 12, ErrDisconnectInvalidExtraData: 13, ErrDisconnectPeerlistFull: 14, - ErrDisconnectReceivedDisconnect: 16, + ErrDisconnectReceivedDisconnect: 15, gnet.ErrDisconnectReadFailed: 1001, gnet.ErrDisconnectWriteFailed: 1002, @@ -72,6 +72,10 @@ var ( func init() { disconnectCodeReasons = make(map[uint16]gnet.DisconnectReason, len(disconnectReasonCodes)) + + for r, c := range disconnectReasonCodes { + disconnectCodeReasons[c] = r + } } // DisconnectReasonToCode maps a gnet.DisconnectReason to a 16-byte code diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index 001da78719..5bdd9fec45 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -31,6 +31,16 @@ func sendMessage(conn net.Conn, msg Message, timeout time.Duration) error { return sendByteMessage(conn, m, timeout) } +func msgIDStringSafe(msgID [4]byte) string { + for _, c := range msgID { + if c < ' ' || c > '~' { + return "" + } + } + + return string(msgID[:]) +} + // Event handler that is called after a Connection sends a complete message func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { msgID := [4]byte{} @@ -38,6 +48,11 @@ func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { return nil, errors.New("Not enough data to read msg id") } copy(msgID[:], msg[:len(msgID)]) + + if debugPrint { + logger.Debugf("Received %s message", msgIDStringSafe(msgID)) + } + msg = msg[len(msgID):] t, succ := MessageIDReverseMap[msgID] if !succ { @@ -50,7 +65,6 @@ func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { var m Message v := reflect.New(t) - //logger.Debugf("Giving %d bytes to the decoder", len(msg)) used, err := deserializeMessage(msg, v) if err != nil { return nil, err diff --git a/src/daemon/gnet/message.go b/src/daemon/gnet/message.go index 2cff2033e3..d47821004f 100644 --- a/src/daemon/gnet/message.go +++ b/src/daemon/gnet/message.go @@ -26,12 +26,8 @@ func MessagePrefixFromString(prefix string) MessagePrefix { // Message message interface type Message interface { - // State is user-defined application state that is attached to the - // Dispatcher. - // Return a non-nil error from handle only if you've disconnected the - // client. You don't have to return the DisconnectReason but that may - // be the most convenient. If error is not nil, event buffer processing - // is aborted. + // State is user-defined application state that is attached to the Dispatcher. + // If a non-nil error is returned, the connection will be disconnected. Handle(context *MessageContext, state interface{}) error } diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 2bf74563f8..7972079a68 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -788,7 +788,7 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { return pool.strand("Disconnect", func() error { logger.WithFields(logrus.Fields{ "addr": addr, - "reason": r.Error(), + "reason": r, }).Info("Disconnecting") exist := pool.disconnect(addr) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index ec01925331..91c76a5b73 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -263,56 +263,8 @@ func (intro *IntroductionMessage) Process(d Daemoner) { d.RemoveFromExpectingIntroductions(addr) - var ip string - var port uint16 - - if err := func() error { - var err error - ip, port, err = iputil.SplitAddr(addr) - if err != nil { - // This should never happen, but the program should still work if it does - logger.WithField("addr", addr).Error("Invalid addr") - return ErrDisconnectIncomprehensibleError - } - - // Disconnect if this is a self connection (we have the same mirror value) - if intro.Mirror == d.Mirror() { - logger.WithField("addr", addr).Infof("Remote mirror value %d matches ours", intro.Mirror) - return ErrDisconnectSelf - } - - // Disconnect if peer version is not within the supported range - dc := d.DaemonConfig() - if intro.Version < dc.MinProtocolVersion { - logger.WithField("addr", addr).Infof("protocol version %d below minimum supported protocol version %d. Disconnecting.", intro.Version, dc.MinProtocolVersion) - return ErrDisconnectVersionNotSupported - } - - // v25 Checks the blockchain pubkey, would accept message with no Pubkey - // v26 would check the blockchain pubkey and reject if not matched or not provided - if len(intro.Extra) > 0 { - var bcPubKey cipher.PubKey - if len(intro.Extra) < len(bcPubKey) { - logger.WithField("addr", addr).Infof("Extra data length does not meet the minimum requirement") - return ErrDisconnectInvalidExtraData - } - copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) - - if d.BlockchainPubkey() != bcPubKey { - logger.WithField("addr", addr).Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) - return ErrDisconnectBlockchainPubkeyNotMatched - } - } - - // Disconnect if connected twice to the same peer (judging by ip:mirror) - knownPort, exists := d.GetMirrorPort(addr, intro.Mirror) - if exists { - logger.WithField("addr", addr).Infof("Already connected on port %d", knownPort) - return ErrDisconnectConnectedTwice - } - - return nil - }(); err != nil { + ip, port, err := intro.verify(d) + if err != nil { d.IncreaseRetryTimes(addr) if err := d.Disconnect(addr, err); err != nil { logger.WithField("addr", addr).WithError(err).Warning("Disconnect") @@ -336,13 +288,12 @@ func (intro *IntroductionMessage) Process(d Daemoner) { } // Record their listener, to avoid double connections - err := d.RecordConnectionMirror(addr, intro.Mirror) - if err != nil { + if err := d.RecordConnectionMirror(addr, intro.Mirror); err != nil { // This should never happen, but the program should not allow itself // to be corrupted in case it does logger.WithField("addr", addr).WithError(err).Errorf("Invalid port for connection") d.IncreaseRetryTimes(addr) - if err := d.Disconnect(addr, ErrDisconnectIncomprehensibleError); err != nil { + if err := d.Disconnect(addr, ErrDisconnectUnexpectedError); err != nil { logger.WithField("addr", addr).WithError(err).Warning("Disconnect") } return @@ -365,6 +316,55 @@ func (intro *IntroductionMessage) Process(d Daemoner) { } } +func (intro *IntroductionMessage) verify(d Daemoner) (string, uint16, error) { + addr := intro.c.Addr + + ip, port, err := iputil.SplitAddr(addr) + if err != nil { + // This should never happen, but the program should still work if it does + logger.WithField("addr", addr).Error("Invalid addr") + return "", 0, ErrDisconnectUnexpectedError + } + + // Disconnect if this is a self connection (we have the same mirror value) + if intro.Mirror == d.Mirror() { + logger.WithField("addr", addr).Infof("Remote mirror value %d matches ours", intro.Mirror) + return "", 0, ErrDisconnectSelf + } + + // Disconnect if peer version is not within the supported range + dc := d.DaemonConfig() + if intro.Version < dc.MinProtocolVersion { + logger.WithField("addr", addr).Infof("protocol version %d below minimum supported protocol version %d. Disconnecting.", intro.Version, dc.MinProtocolVersion) + return "", 0, ErrDisconnectVersionNotSupported + } + + // v25 Checks the blockchain pubkey, would accept message with no Pubkey + // v26 would check the blockchain pubkey and reject if not matched or not provided + if len(intro.Extra) > 0 { + var bcPubKey cipher.PubKey + if len(intro.Extra) < len(bcPubKey) { + logger.WithField("addr", addr).Infof("Extra data length does not meet the minimum requirement") + return "", 0, ErrDisconnectInvalidExtraData + } + copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) + + if d.BlockchainPubkey() != bcPubKey { + logger.WithField("addr", addr).Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) + return "", 0, ErrDisconnectBlockchainPubkeyNotMatched + } + } + + // Disconnect if connected twice to the same peer (judging by ip:mirror) + knownPort, exists := d.GetMirrorPort(addr, intro.Mirror) + if exists { + logger.WithField("addr", addr).Infof("Already connected on port %d", knownPort) + return "", 0, ErrDisconnectConnectedTwice + } + + return ip, port, nil +} + // PingMessage Sent to keep a connection alive. A PongMessage is sent in reply. type PingMessage struct { c *gnet.MessageContext `enc:"-"` @@ -409,7 +409,7 @@ type DisconnectMessage struct { ReasonCode uint16 // Reserved for future use - Reserved []byte `enc:",omitempty"` + Reserved []byte } // NewDisconnectMessage creates message sent to reject previously received message diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 5ccd5654d5..5e6d43cd7e 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -795,12 +795,11 @@ func ExampleAnnounceTxnsMessage() { // 0x004c | } -func ExampleRejectMessage() { +func ExampleDisconnectMessage() { defer gnet.EraseMessages() setupMsgEncoding() - rejectedMessage := NewIntroductionMessage(0x0123456, 0x789ABCD, 6000, cipher.PubKey{}) - message := NewDisconnectMessage(rejectedMessage, gnet.ErrDisconnectWriteFailed, "ExampleRejectWithPeersMessage") + message := NewDisconnectMessage(ErrDisconnectIdle) fmt.Println("DisconnectMessage:") var mai = NewMessagesAnnotationsIterator(message) w := bufio.NewWriter(os.Stdout) @@ -808,7 +807,6 @@ func ExampleRejectMessage() { if err != nil { fmt.Println(err) } - // Output: // DisconnectMessage: // 0x0000 | 31 00 00 00 ....................................... Length // 0x0004 | 52 4a 43 54 ....................................... Prefix diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 314b6fa0c5..e31b94a611 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -1,6 +1,7 @@ package daemon import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -61,10 +62,9 @@ func TestIntroductionMessage(t *testing.T) { }, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, + Mirror: 10001, + Port: 6000, + Version: 1, }, err: nil, }, @@ -80,11 +80,10 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, - Extra: pubkey[:], + Mirror: 10001, + Port: 6000, + Version: 1, + Extra: pubkey[:], }, err: nil, }, @@ -100,11 +99,10 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, - Extra: pubkey[:], + Mirror: 10001, + Port: 6000, + Version: 1, + Extra: pubkey[:], }, err: nil, }, @@ -120,11 +118,10 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, - Extra: append(pubkey[:], []byte("additional data")...), + Mirror: 10001, + Port: 6000, + Version: 1, + Extra: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -141,11 +138,10 @@ func TestIntroductionMessage(t *testing.T) { disconnectReason: ErrDisconnectBlockchainPubkeyNotMatched, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, - Extra: pubkey2[:], + Mirror: 10001, + Port: 6000, + Version: 1, + Extra: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -162,16 +158,16 @@ func TestIntroductionMessage(t *testing.T) { disconnectReason: ErrDisconnectInvalidExtraData, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - validationError: nil, - Extra: []byte("invalid extra data"), + Mirror: 10001, + Port: 6000, + Version: 1, + Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, { name: "Disconnect self connection", + addr: "12.12.12.12:6000", mockValue: daemonMockValue{ mirror: 10000, disconnectReason: ErrDisconnectSelf, @@ -183,6 +179,7 @@ func TestIntroductionMessage(t *testing.T) { }, { name: "Version below minimum supported version", + addr: "12.12.12.12:6000", mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, @@ -201,7 +198,7 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - disconnectReason: ErrDisconnectIncomprehensibleError, + disconnectReason: ErrDisconnectUnexpectedError, pubkey: pubkey, }, intro: &IntroductionMessage{ @@ -209,7 +206,7 @@ func TestIntroductionMessage(t *testing.T) { Version: 1, Port: 6000, }, - err: ErrDisconnectIncomprehensibleError, + err: ErrDisconnectUnexpectedError, }, { name: "incomming connection", @@ -227,10 +224,9 @@ func TestIntroductionMessage(t *testing.T) { addPeerErr: nil, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 1, - Port: 6000, - validationError: nil, + Mirror: 10001, + Version: 1, + Port: 6000, }, }, { @@ -281,7 +277,13 @@ func TestIntroductionMessage(t *testing.T) { d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) err := tc.intro.Handle(mc, d) + require.NoError(t, err) + + ip, port, err := tc.intro.verify(d) require.Equal(t, tc.err, err) + if err == nil { + require.Equal(t, tc.addr, fmt.Sprintf("%s:%d", ip, port)) + } }) } } diff --git a/src/daemon/storage.go b/src/daemon/storage.go index 781a0a027b..7e56358640 100644 --- a/src/daemon/storage.go +++ b/src/daemon/storage.go @@ -4,6 +4,7 @@ import ( "sync" "time" + "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/daemon/pex" ) @@ -290,3 +291,39 @@ func (s *IPCount) Get(ip string) (int, bool) { v, ok := s.value[ip] return v, ok } + +type announcedTxnsCache struct { + sync.Mutex + cache map[cipher.SHA256]int64 +} + +func newAnnouncedTxnsCache() *announcedTxnsCache { + return &announcedTxnsCache{ + cache: make(map[cipher.SHA256]int64), + } +} + +func (c *announcedTxnsCache) add(txns []cipher.SHA256) { + c.Lock() + defer c.Unlock() + + t := time.Now().UTC().UnixNano() + for _, txn := range txns { + c.cache[txn] = t + } +} + +func (c *announcedTxnsCache) flush() map[cipher.SHA256]int64 { + c.Lock() + defer c.Unlock() + + if len(c.cache) == 0 { + return nil + } + + cache := c.cache + + c.cache = make(map[cipher.SHA256]int64) + + return cache +} From cdae76f82bdabbf6cabab51b9d501b92587237cf Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 17:00:09 +0800 Subject: [PATCH 301/399] Fixups --- lib/cgo/libsky_error.go | 3 --- src/daemon/errors.go | 1 - src/daemon/gnet/pool.go | 2 -- 3 files changed, 6 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index d779508aa7..f529f3fb01 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -214,8 +214,6 @@ const ( SKY_ErrDisconnectMalformedMessage // SKY_ErrDisconnectUnknownMessage unknow message SKY_ErrDisconnectUnknownMessage - // SKY_ErrDisconnectUnexpectedError unexpected error - SKY_ErrDisconnectUnexpectedError // SKY_ErrConnectionPoolClosed error message indicates the connection pool is closed SKY_ErrConnectionPoolClosed // SKY_ErrWriteQueueFull write queue is full @@ -466,7 +464,6 @@ var ( gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, - gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, diff --git a/src/daemon/errors.go b/src/daemon/errors.go index b74d936cae..814dca4c5e 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -64,7 +64,6 @@ var ( gnet.ErrDisconnectInvalidMessageLength: 1004, gnet.ErrDisconnectMalformedMessage: 1005, gnet.ErrDisconnectUnknownMessage: 1006, - gnet.ErrDisconnectUnexpectedError: 1007, } disconnectCodeReasons map[uint16]gnet.DisconnectReason diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 7972079a68..1a32c41432 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -47,8 +47,6 @@ var ( ErrDisconnectMalformedMessage DisconnectReason = errors.New("Malformed message body") // ErrDisconnectUnknownMessage unknow message ErrDisconnectUnknownMessage DisconnectReason = errors.New("Unknown message ID") - // ErrDisconnectUnexpectedError unexpected error - ErrDisconnectUnexpectedError DisconnectReason = errors.New("Unexpected error encountered") // ErrConnectionPoolClosed error message indicates the connection pool is closed ErrConnectionPoolClosed = errors.New("Connection pool is closed") // ErrWriteQueueFull write queue is full From 5bff194dee8e8c349bdccaf25cf04a3aaa28424a Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 17:15:54 +0800 Subject: [PATCH 302/399] Separate incoming/outgoing in /health --- CHANGELOG.md | 1 + cmd/cli/README.md | 2 ++ src/api/README.md | 2 ++ src/api/health.go | 6 +++++- src/daemon/gateway.go | 24 ++++++++++++++++++------ 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37bb958b05..f1ce255d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Send new `DISC` disconnect packet to peer before disconnecting - `/api/v1/network/connections` now returns both outgoing and incoming connections by default. Previously it returned only outgoing connections. A `type` parameter is added to filter by outgoing or incoming connections. - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` +- `/api/v1/health` `"open_connections"` value now includes incoming connections. Added `"outgoing_connections"` and `"incoming_connections"` fields to separate the two. ### Removed diff --git a/cmd/cli/README.md b/cmd/cli/README.md index 2f1c70f979..25d547155c 100644 --- a/cmd/cli/README.md +++ b/cmd/cli/README.md @@ -1631,6 +1631,8 @@ $ skycoin-cli status "branch": "develop" }, "open_connections": 8, + "outgoing_connections": 5, + "incoming_connections": 3, "uptime": "4h1m23.697072461s", "csrf_enabled": true, "csp_enabled": true, diff --git a/src/api/README.md b/src/api/README.md index cada670a03..c881ff6f9f 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -224,6 +224,8 @@ Response: "branch": "develop" }, "open_connections": 8, + "outgoing_connections": 5, + "incoming_connections": 3, "uptime": "6m30.629057248s", "csrf_enabled": true, "csp_enabled": true, diff --git a/src/api/health.go b/src/api/health.go index f08559971e..92257e30f0 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -20,6 +20,8 @@ type HealthResponse struct { BlockchainMetadata BlockchainMetadata `json:"blockchain"` Version readable.BuildInfo `json:"version"` OpenConnections int `json:"open_connections"` + OutgoingConnections int `json:"outgoing_connections"` + IncomingConnections int `json:"incoming_connections"` Uptime wh.Duration `json:"uptime"` CSRFEnabled bool `json:"csrf_enabled"` CSPEnabled bool `json:"csp_enabled"` @@ -57,7 +59,9 @@ func healthHandler(c muxConfig, csrfStore *CSRFStore, gateway Gatewayer) http.Ha TimeSinceLastBlock: wh.FromDuration(timeSinceLastBlock), }, Version: c.buildInfo, - OpenConnections: health.OpenConnections, + OpenConnections: health.OutgoingConnections + health.IncomingConnections, + OutgoingConnections: health.OutgoingConnections, + IncomingConnections: health.IncomingConnections, Uptime: wh.FromDuration(health.Uptime), CSRFEnabled: csrfStore.Enabled, CSPEnabled: !c.disableCSP, diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 1af5d26f89..3b991c2611 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -875,9 +875,10 @@ func (gw *Gateway) GetAddressCount() (uint64, error) { // Health is returned by the /health endpoint type Health struct { - BlockchainMetadata visor.BlockchainMetadata - OpenConnections int - Uptime time.Duration + BlockchainMetadata visor.BlockchainMetadata + OutgoingConnections int + IncomingConnections int + Uptime time.Duration } // GetHealth returns statistics about the running node @@ -898,10 +899,21 @@ func (gw *Gateway) GetHealth() (*Health, error) { return } + outgoingConns := 0 + incomingConns := 0 + for _, c := range conns { + if c.Solicited { + outgoingConns++ + } else { + incomingConns++ + } + } + health = &Health{ - BlockchainMetadata: *metadata, - OpenConnections: len(conns), - Uptime: time.Since(gw.v.StartedAt), + BlockchainMetadata: *metadata, + OutgoingConnections: outgoingConns, + IncomingConnections: incomingConns, + Uptime: time.Since(gw.v.StartedAt), } }) From 3f85a8d999c77a22adaa37e9f2efdb7f903c2cf1 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 24 Oct 2018 17:19:02 +0800 Subject: [PATCH 303/399] Update test --- src/api/health_test.go | 11 +++++++---- src/api/integration/integration_test.go | 6 ++++++ src/daemon/gateway.go | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/api/health_test.go b/src/api/health_test.go index 7590d0a0ae..0bcf8e966f 100644 --- a/src/api/health_test.go +++ b/src/api/health_test.go @@ -116,9 +116,10 @@ func TestHealthHandler(t *testing.T) { tc.cfg.buildInfo = buildInfo health := &daemon.Health{ - BlockchainMetadata: metadata, - OpenConnections: 3, - Uptime: time.Second * 4, + BlockchainMetadata: metadata, + OutgoingConnections: 3, + IncomingConnections: 2, + Uptime: time.Second * 4, } gateway := &MockGatewayer{} @@ -157,7 +158,9 @@ func TestHealthHandler(t *testing.T) { require.Equal(t, buildInfo.Branch, r.Version.Branch) require.Equal(t, health.Uptime, r.Uptime.Duration) - require.Equal(t, health.OpenConnections, r.OpenConnections) + require.Equal(t, health.OutgoingConnections, r.OutgoingConnections) + require.Equal(t, health.IncomingConnections, r.IncomingConnections) + require.Equal(t, health.OutgoingConnections+health.IncomingConnections, r.OpenConnections) require.Equal(t, unconfirmed, r.BlockchainMetadata.Unconfirmed) require.Equal(t, unspents, r.BlockchainMetadata.Unspents) diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index a2875cc107..e14a51dd54 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -5803,6 +5803,8 @@ func TestStableHealth(t *testing.T) { checkHealthResponse(t, r) require.Equal(t, 0, r.OpenConnections) + require.Equal(t, 0, r.IncomingConnections) + require.Equal(t, 0, r.OutgoingConnections) require.True(t, r.BlockchainMetadata.TimeSinceLastBlock.Duration > time.Duration(0)) @@ -5832,10 +5834,14 @@ func TestLiveHealth(t *testing.T) { if liveDisableNetworking(t) { require.Equal(t, 0, r.OpenConnections) + require.Equal(t, 0, r.OutgoingConnections) + require.Equal(t, 0, r.IncomingConnections) } else { require.NotEqual(t, 0, r.OpenConnections) } + require.Equal(t, r.OutgoingConnections+r.IncomingConnections, r.OpenConnections) + // The TimeSinceLastBlock can be any value, including negative values, due to clock skew // The live node is not necessarily run with the commit and branch ldflags, so don't check them } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 3b991c2611..08d66147e2 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -902,7 +902,7 @@ func (gw *Gateway) GetHealth() (*Health, error) { outgoingConns := 0 incomingConns := 0 for _, c := range conns { - if c.Solicited { + if c.Outgoing { outgoingConns++ } else { incomingConns++ From d6c97234743926f916d891fadd27b9c462618638 Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Wed, 24 Oct 2018 17:49:05 -0400 Subject: [PATCH 304/399] Add a warning when decrypting a wallet --- .../password-dialog.component.html | 2 +- .../password-dialog.component.scss | 4 ++++ .../password-dialog.component.ts | 1 + .../wallet-detail/wallet-detail.component.ts | 17 +++++------------ src/gui/static/src/assets/i18n/en.json | 1 + 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.html b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.html index 2cf211c33c..f8855d956d 100644 --- a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.html +++ b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.html @@ -1,5 +1,5 @@ -

{{ data.description }}

+

{{ data.description | translate }}

diff --git a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.scss b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.scss index 2dacc419b6..ec05c939ff 100644 --- a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.scss +++ b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.scss @@ -11,6 +11,10 @@ line-height: 1.5; } +.-warning { + color: $red; +} + .link { font-size: 13px; width: 100%; diff --git a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.ts b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.ts index 484ff20165..004468abd3 100644 --- a/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.ts +++ b/src/gui/static/src/app/components/layout/password-dialog/password-dialog.component.ts @@ -31,6 +31,7 @@ export class PasswordDialogComponent implements OnInit, OnDestroy { this.data = Object.assign({ confirm: false, description: null, + warning: false, title: null, wallet: null, }, data || {}); diff --git a/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts b/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts index 547349af2a..e7fa379347 100644 --- a/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts +++ b/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts @@ -7,7 +7,6 @@ import { QrCodeComponent } from '../../../layout/qr-code/qr-code.component'; import { PasswordDialogComponent } from '../../../layout/password-dialog/password-dialog.component'; import { MatSnackBar } from '@angular/material'; import { showSnackbarError } from '../../../../utils/errors'; -import { TranslateService } from '@ngx-translate/core'; import { NumberOfAddressesComponent } from '../number-of-addresses/number-of-addresses'; @Component({ @@ -15,25 +14,17 @@ import { NumberOfAddressesComponent } from '../number-of-addresses/number-of-add templateUrl: './wallet-detail.component.html', styleUrls: ['./wallet-detail.component.scss'], }) -export class WalletDetailComponent implements OnInit, OnDestroy { +export class WalletDetailComponent implements OnDestroy { @Input() wallet: Wallet; - private encryptionWarning: string; private HowManyAddresses: number; constructor( private dialog: MatDialog, private walletService: WalletService, - private snackbar: MatSnackBar, - private translateService: TranslateService, + private snackbar: MatSnackBar ) { } - ngOnInit() { - this.translateService.get('wallet.new.encrypt-warning').subscribe(msg => { - this.encryptionWarning = msg; - }); - } - ngOnDestroy() { this.snackbar.dismiss(); } @@ -71,8 +62,10 @@ export class WalletDetailComponent implements OnInit, OnDestroy { }; if (!this.wallet.encrypted) { - config.data['description'] = this.encryptionWarning; + config.data['description'] = 'wallet.new.encrypt-warning'; } else { + config.data['description'] = 'wallet.decrypt-warning'; + config.data['warning'] = true; config.data['wallet'] = this.wallet; } diff --git a/src/gui/static/src/assets/i18n/en.json b/src/gui/static/src/assets/i18n/en.json index a6473fb6e0..965f49328b 100644 --- a/src/gui/static/src/assets/i18n/en.json +++ b/src/gui/static/src/assets/i18n/en.json @@ -96,6 +96,7 @@ "hide-empty": "Hide Empty", "encrypt": "Encrypt Wallet", "decrypt": "Decrypt Wallet", + "decrypt-warning": "Warning: for security reasons, it is not recommended to keep the wallets unencrypted. Caution is advised.", "edit": "Edit Wallet", "add": "Add Wallet", "load": "Load Wallet", From fa32e8d686907bf5398487c1aa3cba39f2817c01 Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Wed, 24 Oct 2018 19:04:28 -0400 Subject: [PATCH 305/399] Fix lint errors --- .../pages/wallets/wallet-detail/wallet-detail.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts b/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts index e7fa379347..ec92d72139 100644 --- a/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts +++ b/src/gui/static/src/app/components/pages/wallets/wallet-detail/wallet-detail.component.ts @@ -22,7 +22,7 @@ export class WalletDetailComponent implements OnDestroy { constructor( private dialog: MatDialog, private walletService: WalletService, - private snackbar: MatSnackBar + private snackbar: MatSnackBar, ) { } ngOnDestroy() { From 585529d88ef3d158578b75a5204099c4ff2d451f Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 25 Oct 2018 14:52:34 +0800 Subject: [PATCH 306/399] Update docs --- src/api/blockchain.go | 2 +- src/api/client.go | 22 +++++++++++----------- src/api/outputs.go | 2 +- src/api/transaction.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/blockchain.go b/src/api/blockchain.go index ff90feab51..8155127b10 100644 --- a/src/api/blockchain.go +++ b/src/api/blockchain.go @@ -197,7 +197,7 @@ func blockHandler(gateway Gatewayer) http.HandlerFunc { // or an explicit list of sequences. // If using start and end, the block sequences include both the start and end point. // Explicit sequences cannot be combined with start and end. -// Method: GET +// Method: GET, POST // URI: /api/v1/blocks // Args: // start [int] diff --git a/src/api/client.go b/src/api/client.go index cf1ccfd4f9..b35478fa2f 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -338,7 +338,7 @@ func (c *Client) Outputs() (*readable.UnspentOutputsSummary, error) { return &o, nil } -// OutputsForAddresses makes a request to GET /api/v1/outputs?addrs=xxx +// OutputsForAddresses makes a request to POST /api/v1/outputs?addrs=xxx func (c *Client) OutputsForAddresses(addrs []string) (*readable.UnspentOutputsSummary, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -352,7 +352,7 @@ func (c *Client) OutputsForAddresses(addrs []string) (*readable.UnspentOutputsSu return &o, nil } -// OutputsForHashes makes a request to GET /api/v1/outputs?hashes=zzz +// OutputsForHashes makes a request to POST /api/v1/outputs?hashes=zzz func (c *Client) OutputsForHashes(hashes []string) (*readable.UnspentOutputsSummary, error) { v := url.Values{} v.Add("hashes", strings.Join(hashes, ",")) @@ -428,7 +428,7 @@ func (c *Client) BlockBySeqVerbose(seq uint64) (*readable.BlockVerbose, error) { return &b, nil } -// Blocks makes a request to GET /api/v1/blocks?seqs= +// Blocks makes a request to POST /api/v1/blocks?seqs= func (c *Client) Blocks(seqs []uint64) (*readable.Blocks, error) { sSeqs := make([]string, len(seqs)) for i, x := range seqs { @@ -446,7 +446,7 @@ func (c *Client) Blocks(seqs []uint64) (*readable.Blocks, error) { return &b, nil } -// BlocksVerbose makes a request to GET /api/v1/blocks?verbose=1&start=&end= +// BlocksVerbose makes a request to POST /api/v1/blocks?verbose=1&seqs= func (c *Client) BlocksVerbose(seqs []uint64) (*readable.BlocksVerbose, error) { sSeqs := make([]string, len(seqs)) for i, x := range seqs { @@ -539,7 +539,7 @@ func (c *Client) BlockchainProgress() (*readable.BlockchainProgress, error) { return &b, nil } -// Balance makes a request to GET /api/v1/balance?addrs=xxx +// Balance makes a request to POST /api/v1/balance?addrs=xxx func (c *Client) Balance(addrs []string) (*BalanceResponse, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -920,7 +920,7 @@ func (c *Client) TransactionEncoded(txid string) (*TransactionEncodedResponse, e return &r, nil } -// Transactions makes a request to GET /api/v1/transactions +// Transactions makes a request to POST /api/v1/transactions func (c *Client) Transactions(addrs []string) ([]readable.TransactionWithStatus, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -933,7 +933,7 @@ func (c *Client) Transactions(addrs []string) ([]readable.TransactionWithStatus, return r, nil } -// ConfirmedTransactions makes a request to GET /api/v1/transactions?confirmed=true +// ConfirmedTransactions makes a request to POST /api/v1/transactions?confirmed=true func (c *Client) ConfirmedTransactions(addrs []string) ([]readable.TransactionWithStatus, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -947,7 +947,7 @@ func (c *Client) ConfirmedTransactions(addrs []string) ([]readable.TransactionWi return r, nil } -// UnconfirmedTransactions makes a request to GET /api/v1/transactions?confirmed=false +// UnconfirmedTransactions makes a request to POST /api/v1/transactions?confirmed=false func (c *Client) UnconfirmedTransactions(addrs []string) ([]readable.TransactionWithStatus, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -961,7 +961,7 @@ func (c *Client) UnconfirmedTransactions(addrs []string) ([]readable.Transaction return r, nil } -// TransactionsVerbose makes a request to GET /api/v1/transactions?verbose=1 +// TransactionsVerbose makes a request to POST /api/v1/transactions?verbose=1 func (c *Client) TransactionsVerbose(addrs []string) ([]readable.TransactionWithStatusVerbose, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -975,7 +975,7 @@ func (c *Client) TransactionsVerbose(addrs []string) ([]readable.TransactionWith return r, nil } -// ConfirmedTransactionsVerbose makes a request to GET /api/v1/transactions?confirmed=true&verbose=1 +// ConfirmedTransactionsVerbose makes a request to POST /api/v1/transactions?confirmed=true&verbose=1 func (c *Client) ConfirmedTransactionsVerbose(addrs []string) ([]readable.TransactionWithStatusVerbose, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) @@ -990,7 +990,7 @@ func (c *Client) ConfirmedTransactionsVerbose(addrs []string) ([]readable.Transa return r, nil } -// UnconfirmedTransactionsVerbose makes a request to GET /api/v1/transactions?confirmed=false&verbose=1 +// UnconfirmedTransactionsVerbose makes a request to POST /api/v1/transactions?confirmed=false&verbose=1 func (c *Client) UnconfirmedTransactionsVerbose(addrs []string) ([]readable.TransactionWithStatusVerbose, error) { v := url.Values{} v.Add("addrs", strings.Join(addrs, ",")) diff --git a/src/api/outputs.go b/src/api/outputs.go index 5e4cfadcd0..93b81c10f0 100644 --- a/src/api/outputs.go +++ b/src/api/outputs.go @@ -12,7 +12,7 @@ import ( // outputsHandler returns UxOuts filtered by a set of addresses or a set of hashes // URI: /api/v1/outputs -// Method: GET +// Method: GET, POST // Args: // addrs: comma-separated list of addresses // hashes: comma-separated list of uxout hashes diff --git a/src/api/transaction.go b/src/api/transaction.go index 140bf12fb1..e44e33bfd0 100644 --- a/src/api/transaction.go +++ b/src/api/transaction.go @@ -247,7 +247,7 @@ func NewTransactionsWithStatusVerbose(txns []visor.Transaction, inputs [][]visor } // Returns transactions that match the filters. -// Method: GET +// Method: GET, POST // URI: /api/v1/transactions // Args: // addrs: Comma separated addresses [optional, returns all transactions if no address provided] From 2a30b1d8c7068b72439c86cf2f11848796e4c71e Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 25 Oct 2018 22:49:27 +0800 Subject: [PATCH 307/399] WIP: INTR not always received first --- src/daemon/daemon.go | 139 ++++++++++++++++--------------- src/daemon/errors.go | 1 + src/daemon/gnet/pool.go | 44 ++++++---- src/daemon/messages.go | 4 +- src/daemon/messages_test.go | 2 +- src/daemon/mock_daemoner_test.go | 4 +- src/daemon/storage.go | 40 ++++----- src/daemon/storage_test.go | 4 +- 8 files changed, 132 insertions(+), 106 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 742b27a617..9572a12cc3 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -26,6 +26,8 @@ import ( var ( // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") + // ErrNetworkingDisabled is returned if networking is disabled + ErrNetworkingDisabled = errors.New("Networking is disabled") logger = logging.MustGetLogger("daemon") ) @@ -213,7 +215,7 @@ type Daemoner interface { RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error RecordConnectionMirror(addr string, mirror uint32) error GetMirrorPort(addr string, mirror uint32) (uint16, bool) - RemoveFromExpectingIntroductions(addr string) + ConnectionIntroduced(addr string) RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error } @@ -235,13 +237,14 @@ type Daemon struct { // Cache of reported peer blockchain heights Heights *peerBlockchainHeights - // Separate index of outgoing connections. The pool aggregates all - // connections. - outgoingConnections *OutgoingConnections + // Separate index of outgoing connections. The pool aggregates all connections + outgoingConnections *StringSet // Number of connections waiting to be formed or timeout pendingConnections *PendingConnections - // Keep track of unsolicited clients who should notify us of their version + // Keep track of connections that have not sent an introduction expectingIntroductions *ExpectIntroductions + // Keep track of connections that have sent an introduction + introducedConnections *StringSet // Keep track of a connection's mirror value, to avoid double // connections (one to their listener, and one to our listener) // Maps from addr to mirror value @@ -293,20 +296,18 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { Heights: newPeerBlockchainHeights(), expectingIntroductions: NewExpectIntroductions(), + introducedConnections: NewStringSet(config.Pool.MaxConnections + 8), connectionMirrors: NewConnectionMirrors(), mirrorConnections: NewMirrorConnections(), ipCounts: NewIPCount(), - // TODO -- if there are performance problems from blocking chans, - // Its because we are connecting to more things than OutgoingMax - // if we have private peers - onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), - onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), - connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), - outgoingConnections: NewOutgoingConnections(config.Daemon.OutgoingMax), - pendingConnections: NewPendingConnections(config.Daemon.PendingMax), - messageEvents: make(chan MessageEvent, config.Pool.EventChannelSize), - quit: make(chan struct{}), - done: make(chan struct{}), + onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), + onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), + connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), + outgoingConnections: NewStringSet(config.Daemon.OutgoingMax), + pendingConnections: NewPendingConnections(config.Daemon.PendingMax), + messageEvents: make(chan MessageEvent, config.Pool.EventChannelSize), + quit: make(chan struct{}), + done: make(chan struct{}), } d.Gateway = NewGateway(config.Gateway, d) @@ -502,7 +503,7 @@ loop: } m := NewGetPeersMessage() - if err := dm.pool.Pool.BroadcastMessage(m); err != nil { + if err := dm.BroadcastMessage(m); err != nil { logger.Error(err) } @@ -643,9 +644,9 @@ loop: case <-blocksRequestTicker.C: elapser.Register("blocksRequestTicker") - if err := dm.RequestBlocks(); err != nil { - logger.WithError(err).Warning("RequestBlocks failed") - } + // if err := dm.RequestBlocks(); err != nil { + // logger.WithError(err).Warning("RequestBlocks failed") + // } case <-blocksAnnounceTicker.C: elapser.Register("blocksAnnounceTicker") @@ -880,8 +881,8 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { // Introduction message does not update ExpectingIntroductions until its // Process() is called if dm.needsIntro(e.Context.Addr) { - _, isIntro := e.Message.(*IntroductionMessage) - if !isIntro { + if _, isIntro := e.Message.(*IntroductionMessage); !isIntro { + logger.WithField("addr", e.Context.Addr).Infof("First message should be IntroductionMessage but is %T", e.Message) if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } @@ -895,9 +896,9 @@ func (dm *Daemon) onConnect(e ConnectEvent) { a := e.Addr if e.Solicited { - logger.Infof("Connected to peer: %s (outgoing)", a) + logger.WithField("addr", a).Info("Connected to peer (outgoing)") } else { - logger.Infof("Connected to peer: %s (incoming)", a) + logger.WithField("addr", a).Info("Connected to peer (incoming)") } dm.pendingConnections.Remove(a) @@ -914,7 +915,7 @@ func (dm *Daemon) onConnect(e ConnectEvent) { } if dm.ipCountMaxed(a) { - logger.Infof("Max connections for %s reached, disconnecting", a) + logger.WithField("addr", a).Info("Max connections reached, disconnecting") if err := dm.Disconnect(a, ErrDisconnectIPLimitReached); err != nil { logger.WithError(err).WithField("addr", a).Error("Disconnect") } @@ -927,12 +928,12 @@ func (dm *Daemon) onConnect(e ConnectEvent) { // Disconnect if the max outgoing connections is reached n, err := dm.pool.Pool.OutgoingConnectionsNum() if err != nil { - logger.WithError(err).Error("get outgoing connections number failed") + logger.WithError(err).Error("Pool.OutgoingConnectionsNum failed") return } if n > dm.Config.OutgoingMax { - logger.Warningf("max outgoing connections is reached, disconnecting %v", a) + logger.WithField("addr", a).Warningf("Max outgoing connections is reached, disconnecting") if err := dm.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { logger.WithError(err).WithField("addr", a).Error("Disconnect") } @@ -943,18 +944,25 @@ func (dm *Daemon) onConnect(e ConnectEvent) { } dm.expectingIntroductions.Add(a, time.Now().UTC()) - logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) + logger.WithFields(logrus.Fields{ + "addr": a, + "mirror": dm.Messages.Mirror, + }).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey) - if err := dm.pool.Pool.SendMessage(a, m); err != nil { - logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) + if err := dm.SendMessage(a, m); err != nil { + logger.WithError(err).WithField("addr", a).Error("Send IntroductionMessage failed") } } func (dm *Daemon) onDisconnect(e DisconnectEvent) { - logger.Infof("%s disconnected because: %v", e.Addr, e.Reason) + logger.WithFields(logrus.Fields{ + "reason": e.Reason, + "addr": e.Addr, + }).Info("daemon.onDisconnect") dm.outgoingConnections.Remove(e.Addr) dm.expectingIntroductions.Remove(e.Addr) + dm.introducedConnections.Remove(e.Addr) dm.Heights.Remove(e.Addr) dm.removeIPCount(e.Addr) dm.removeConnectionMirror(e.Addr) @@ -1051,7 +1059,7 @@ func (dm *Daemon) removeConnectionMirror(addr string) { func (dm *Daemon) GetMirrorPort(addr string, mirror uint32) (uint16, bool) { ip, _, err := iputil.SplitAddr(addr) if err != nil { - logger.Warningf("getMirrorPort called with invalid addr: %v", err) + logger.WithError(err).WithField("addr", addr).Warning("getMirrorPort called with invalid addr") return 0, false } return dm.mirrorConnections.Get(mirror, ip) @@ -1079,8 +1087,8 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { // RequestBlocks Sends a GetBlocksMessage to all connections func (dm *Daemon) RequestBlocks() error { - if dm.Config.DisableOutgoingConnections { - return nil + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } headSeq, ok, err := dm.HeadBkSeq() @@ -1093,7 +1101,7 @@ func (dm *Daemon) RequestBlocks() error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - err = dm.pool.Pool.BroadcastMessage(m) + err = dm.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast GetBlocksMessage failed: %v", err) } @@ -1103,8 +1111,8 @@ func (dm *Daemon) RequestBlocks() error { // AnnounceBlocks sends an AnnounceBlocksMessage to all connections func (dm *Daemon) AnnounceBlocks() error { - if dm.Config.DisableOutgoingConnections { - return nil + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } headSeq, ok, err := dm.HeadBkSeq() @@ -1117,7 +1125,7 @@ func (dm *Daemon) AnnounceBlocks() error { m := NewAnnounceBlocksMessage(headSeq) - err = dm.pool.Pool.BroadcastMessage(m) + err = dm.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast AnnounceBlocksMessage failed: %v", err) } @@ -1127,8 +1135,8 @@ func (dm *Daemon) AnnounceBlocks() error { // AnnounceAllTxns announces local unconfirmed transactions func (dm *Daemon) AnnounceAllTxns() error { - if dm.Config.DisableOutgoingConnections { - return nil + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } // Get local unconfirmed transaction hashes. @@ -1142,7 +1150,7 @@ func (dm *Daemon) AnnounceAllTxns() error { for _, hs := range hashesSet { m := NewAnnounceTxnsMessage(hs) - if err = dm.pool.Pool.BroadcastMessage(m); err != nil { + if err = dm.BroadcastMessage(m); err != nil { break } } @@ -1181,8 +1189,8 @@ func divideHashes(hashes []cipher.SHA256, n int) [][]cipher.SHA256 { // AnnounceTxns announces given transaction hashes. func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { - if dm.Config.DisableOutgoingConnections { - return nil + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } if len(txns) == 0 { @@ -1191,7 +1199,7 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { m := NewAnnounceTxnsMessage(txns) - err := dm.pool.Pool.BroadcastMessage(m) + err := dm.BroadcastMessage(m) if err != nil { logger.Debugf("Broadcast AnnounceTxnsMessage failed: %v", err) } @@ -1201,8 +1209,8 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { // RequestBlocksFromAddr sends a GetBlocksMessage to one connected address func (dm *Daemon) RequestBlocksFromAddr(addr string) error { - if dm.Config.DisableOutgoingConnections { - return errors.New("Outgoing connections disabled") + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } headSeq, ok, err := dm.visor.HeadBkSeq() @@ -1214,15 +1222,14 @@ func (dm *Daemon) RequestBlocksFromAddr(addr string) error { } m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - - return dm.pool.Pool.SendMessage(addr, m) + return dm.SendMessage(addr, m) } // ResendUnconfirmedTxns resends all unconfirmed transactions and returns the hashes that were successfully rebroadcast. // It does not return an error if broadcasting fails. func (dm *Daemon) ResendUnconfirmedTxns() ([]cipher.SHA256, error) { - if dm.Config.DisableOutgoingConnections { - return nil, nil + if dm.Config.DisableNetworking { + return nil, ErrNetworkingDisabled } txns, err := dm.visor.GetAllUnconfirmedTransactions() @@ -1243,8 +1250,8 @@ func (dm *Daemon) ResendUnconfirmedTxns() ([]cipher.SHA256, error) { // BroadcastTransaction broadcasts a single transaction to all peers. func (dm *Daemon) BroadcastTransaction(t coin.Transaction) error { - if dm.Config.DisableOutgoingConnections { - return ErrOutgoingConnectionsDisabled + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } l, err := dm.pool.Pool.Size() @@ -1255,8 +1262,8 @@ func (dm *Daemon) BroadcastTransaction(t coin.Transaction) error { logger.Debugf("BroadcastTransaction to %d conns", l) m := NewGiveTxnsMessage(coin.Transactions{t}) - if err := dm.pool.Pool.BroadcastMessage(m); err != nil { - logger.WithError(err).Error("BroadcastTransaction Pool.BroadcastMessage failed") + if err := dm.BroadcastMessage(m); err != nil { + logger.WithError(err).Error("BroadcastTransaction: BroadcastMessage failed") return err } @@ -1271,8 +1278,8 @@ func (dm *Daemon) BroadcastTransaction(t coin.Transaction) error { // TODO -- refactor this method -- it should either always create a block and maybe broadcast it, // or use a database transaction to rollback block publishing if broadcast failed (however, this will cause a slow DB write) func (dm *Daemon) CreateAndPublishBlock() (*coin.SignedBlock, error) { - if dm.Config.DisableOutgoingConnections { - return nil, errors.New("Outgoing connections disabled") + if dm.Config.DisableNetworking { + return nil, ErrNetworkingDisabled } sb, err := dm.visor.CreateAndExecuteBlock() @@ -1287,12 +1294,12 @@ func (dm *Daemon) CreateAndPublishBlock() (*coin.SignedBlock, error) { // Sends a signed block to all connections. func (dm *Daemon) broadcastBlock(sb coin.SignedBlock) error { - if dm.Config.DisableOutgoingConnections { - return nil + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled } m := NewGiveBlocksMessage([]coin.SignedBlock{sb}) - return dm.pool.Pool.BroadcastMessage(m) + return dm.BroadcastMessage(m) } // Mirror returns the message mirror @@ -1310,22 +1317,24 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { return dm.Config.BlockchainPubkey } -// RemoveFromExpectingIntroductions removes the peer from expect introduction pool -func (dm *Daemon) RemoveFromExpectingIntroductions(addr string) { +// ConnectionIntroduced moves the peer from expecting introduction status to introduced status +func (dm *Daemon) ConnectionIntroduced(addr string) { dm.expectingIntroductions.Remove(addr) + dm.introducedConnections.Add(addr) } // Implements pooler interface -// SendMessage sends a Message to a Connection and pushes the result onto the -// SendResults channel. +// SendMessage sends a Message to a Connection and pushes the result onto the SendResults channel. func (dm *Daemon) SendMessage(addr string, msg gnet.Message) error { return dm.pool.Pool.SendMessage(addr, msg) } -// BroadcastMessage sends a Message to all connections in the Pool. +// BroadcastMessage sends a Message to all introduced connections in the pool func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { - return dm.pool.Pool.BroadcastMessage(msg) + return dm.pool.Pool.BroadcastMessage(msg, func(c *gnet.Connection) bool { + return dm.introducedConnections.Get(c.Addr()) + }) } // Disconnect sends a DisconnectMessage to a peer. After the DisconnectMessage is sent, the peer is disconnected. diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 814dca4c5e..a26b4517ec 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -64,6 +64,7 @@ var ( gnet.ErrDisconnectInvalidMessageLength: 1004, gnet.ErrDisconnectMalformedMessage: 1005, gnet.ErrDisconnectUnknownMessage: 1006, + gnet.ErrDisconnectShutdown: 1007, } disconnectCodeReasons map[uint16]gnet.DisconnectReason diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 1a32c41432..05f5076582 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -37,7 +37,7 @@ const ( var ( // ErrDisconnectReadFailed also includes a remote closed socket ErrDisconnectReadFailed DisconnectReason = errors.New("Read failed") - // ErrDisconnectWriteFailed write faile + // ErrDisconnectWriteFailed write failed ErrDisconnectWriteFailed DisconnectReason = errors.New("Write failed") // ErrDisconnectSetReadDeadlineFailed set read deadline failed ErrDisconnectSetReadDeadlineFailed DisconnectReason = errors.New("SetReadDeadline failed") @@ -45,8 +45,10 @@ var ( ErrDisconnectInvalidMessageLength DisconnectReason = errors.New("Invalid message length") // ErrDisconnectMalformedMessage malformed message ErrDisconnectMalformedMessage DisconnectReason = errors.New("Malformed message body") - // ErrDisconnectUnknownMessage unknow message + // ErrDisconnectUnknownMessage unknown message ErrDisconnectUnknownMessage DisconnectReason = errors.New("Unknown message ID") + // ErrDisconnectShutdown shutting down the client + ErrDisconnectShutdown DisconnectReason = errors.New("Shutdown") // ErrConnectionPoolClosed error message indicates the connection pool is closed ErrConnectionPoolClosed = errors.New("Connection pool is closed") // ErrWriteQueueFull write queue is full @@ -54,8 +56,8 @@ var ( // ErrNoReachableConnections when broadcasting a message, no connections were available to send a message to ErrNoReachableConnections = errors.New("All pool connections are unreachable at this time") // ErrPoolEmpty when broadcasting a message, the connection pool was empty - ErrPoolEmpty = errors.New("Connection pool is empty") - // Logger + ErrPoolEmpty = errors.New("Connection pool is empty after filtering connections") + logger = logging.MustGetLogger("gnet") ) @@ -789,7 +791,7 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { "reason": r, }).Info("Disconnecting") - exist := pool.disconnect(addr) + exist := pool.disconnect(addr, r) // checks if the address is default node address if _, ok := pool.Config.defaultConnections[addr]; ok { @@ -805,7 +807,7 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { }) } -func (pool *ConnectionPool) disconnect(addr string) bool { +func (pool *ConnectionPool) disconnect(addr string, r DisconnectReason) bool { conn, ok := pool.addresses[addr] if !ok { return false @@ -817,7 +819,7 @@ func (pool *ConnectionPool) disconnect(addr string) bool { if err := conn.Close(); err != nil { logger.Errorf("conn.Close() error address=%s: %v", addr, err) } else { - logger.Debugf("Disconnected from %s", addr) + logger.WithField("reason", r).Debugf("Disconnected from %s", addr) } return true @@ -827,7 +829,7 @@ func (pool *ConnectionPool) disconnect(addr string) bool { func (pool *ConnectionPool) disconnectAll() { for _, conn := range pool.pool { addr := conn.Addr() - pool.disconnect(addr) + pool.disconnect(addr, ErrDisconnectShutdown) } } @@ -893,31 +895,45 @@ func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { }) } -// BroadcastMessage sends a Message to all connections in the Pool. -func (pool *ConnectionPool) BroadcastMessage(msg Message) error { +// BroadcastMessage sends a Message to all connections in the Pool, optionally filtered by `flt` +func (pool *ConnectionPool) BroadcastMessage(msg Message, flt func(c *Connection) bool) error { if pool.Config.DebugPrint { logger.Debugf("Broadcast, Msg Type: %s", reflect.TypeOf(msg)) } - fullWriteQueue := []string{} + fullWriteQueue := 0 + sent := 0 + acceptable := 0 + if err := pool.strand("BroadcastMessage", func() error { if len(pool.pool) == 0 { return ErrPoolEmpty } for _, conn := range pool.pool { + if flt != nil && !flt(conn) { + continue + } + + acceptable++ + select { case conn.WriteQueue <- msg: + sent++ default: - logger.Critical().Infof("Write queue full for address %s", conn.Addr()) - fullWriteQueue = append(fullWriteQueue, conn.Addr()) + logger.Critical().WithField("addr", conn.Addr()).Info("Write queue full") + fullWriteQueue++ } } - if len(fullWriteQueue) == len(pool.pool) { + if fullWriteQueue == acceptable { return ErrNoReachableConnections } + if sent == 0 { + return ErrPoolEmpty + } + return nil }); err != nil { return err diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 91c76a5b73..d322af9638 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -261,7 +261,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa func (intro *IntroductionMessage) Process(d Daemoner) { addr := intro.c.Addr - d.RemoveFromExpectingIntroductions(addr) + d.ConnectionIntroduced(addr) ip, port, err := intro.verify(d) if err != nil { @@ -307,7 +307,7 @@ func (intro *IntroductionMessage) Process(d Daemoner) { if err := d.RequestBlocksFromAddr(addr); err != nil { logger.WithField("addr", addr).WithError(err).Warning("RequestBlocksFromAddr failed") } else { - logger.WithField("addr", addr).Debug("Successfully requested blocks from peer") + logger.WithField("addr", addr).Debug("Requested blocks from peer") } // Announce unconfirmed txns diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index e31b94a611..59a3e2d1e2 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -272,7 +272,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) d.On("IncreaseRetryTimes", tc.addr) - d.On("RemoveFromExpectingIntroductions", tc.addr) + d.On("ConnectionIntroduced", tc.addr) d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index cf8cf722c5..138252ed7b 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -407,8 +407,8 @@ func (_m *MockDaemoner) RecordPeerHeight(addr string, height uint64) { _m.Called(addr, height) } -// RemoveFromExpectingIntroductions provides a mock function with given fields: addr -func (_m *MockDaemoner) RemoveFromExpectingIntroductions(addr string) { +// ConnectionIntroduced provides a mock function with given fields: addr +func (_m *MockDaemoner) ConnectionIntroduced(addr string) { _m.Called(addr) } diff --git a/src/daemon/storage.go b/src/daemon/storage.go index 7e56358640..3bb617886e 100644 --- a/src/daemon/storage.go +++ b/src/daemon/storage.go @@ -31,6 +31,14 @@ func (s *ExpectIntroductions) Add(addr string, tm time.Time) { s.value[addr] = tm } +// Get returns the time of specific address +func (s *ExpectIntroductions) Get(addr string) (time.Time, bool) { + s.Lock() + defer s.Unlock() + t, ok := s.value[addr] + return t, ok +} + // Remove removes connection func (s *ExpectIntroductions) Remove(addr string) { s.Lock() @@ -62,14 +70,6 @@ func (s *ExpectIntroductions) CullInvalidConns(f CullMatchFunc) ([]string, error return addrs, nil } -// Get returns the time of speicific address -func (s *ExpectIntroductions) Get(addr string) (time.Time, bool) { - s.Lock() - defer s.Unlock() - t, ok := s.value[addr] - return t, ok -} - // ConnectionMirrors records mirror for connection type ConnectionMirrors struct { value map[string]uint32 @@ -105,35 +105,35 @@ func (s *ConnectionMirrors) Remove(addr string) { delete(s.value, addr) } -// OutgoingConnections records the outgoing connections -type OutgoingConnections struct { +// StringSet existence set for string values +type StringSet struct { value map[string]struct{} sync.Mutex } -// NewOutgoingConnections create OutgoingConnection instance -func NewOutgoingConnections(max int) *OutgoingConnections { - return &OutgoingConnections{ - value: make(map[string]struct{}, max), +// NewStringSet create StringSet +func NewStringSet(size int) *StringSet { + return &StringSet{ + value: make(map[string]struct{}, size), } } // Add records connection -func (s *OutgoingConnections) Add(addr string) { +func (s *StringSet) Add(addr string) { s.Lock() defer s.Unlock() s.value[addr] = struct{}{} } // Remove remove connection -func (s *OutgoingConnections) Remove(addr string) { +func (s *StringSet) Remove(addr string) { s.Lock() defer s.Unlock() delete(s.value, addr) } // Get returns if connection is outgoing -func (s *OutgoingConnections) Get(addr string) bool { +func (s *StringSet) Get(addr string) bool { s.Lock() defer s.Unlock() _, ok := s.value[addr] @@ -141,7 +141,7 @@ func (s *OutgoingConnections) Get(addr string) bool { } // Len returns the outgoing connections count -func (s *OutgoingConnections) Len() int { +func (s *StringSet) Len() int { s.Lock() defer s.Unlock() return len(s.value) @@ -154,9 +154,9 @@ type PendingConnections struct { } // NewPendingConnections creates new PendingConnections instance -func NewPendingConnections(maxConn int) *PendingConnections { +func NewPendingConnections(size int) *PendingConnections { return &PendingConnections{ - value: make(map[string]pex.Peer, maxConn), + value: make(map[string]pex.Peer, size), } } diff --git a/src/daemon/storage_test.go b/src/daemon/storage_test.go index ecd99d702b..9b30714bae 100644 --- a/src/daemon/storage_test.go +++ b/src/daemon/storage_test.go @@ -96,8 +96,8 @@ func TestConnectionMirrors(t *testing.T) { require.False(t, ok) } -func TestOutgoingConnections(t *testing.T) { - oc := NewOutgoingConnections(3) +func TestStringSet(t *testing.T) { + oc := NewStringSet(3) n := oc.Len() require.Equal(t, 0, n) From 0ffb6b79833ec880c84e625bd30c061757437562 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 26 Oct 2018 21:31:46 +0800 Subject: [PATCH 308/399] Refactor daemon storage into single state machine --- CHANGELOG.md | 1 + src/daemon/daemon.go | 308 ++++++++------------ src/daemon/gateway.go | 131 ++++----- src/daemon/gnet/pool.go | 44 +-- src/daemon/heights.go | 93 ------ src/daemon/heights_test.go | 82 ------ src/daemon/messages.go | 66 +++-- src/daemon/pex/pex.go | 16 +- src/daemon/storage.go | 544 ++++++++++++++++++++++-------------- src/daemon/storage_test.go | 389 ++++++++++++++++---------- src/daemon/strand/strand.go | 25 +- src/readable/network.go | 39 ++- 12 files changed, 888 insertions(+), 850 deletions(-) delete mode 100644 src/daemon/heights.go delete mode 100644 src/daemon/heights_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ef219c509d..6e503929fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` +- `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"introduced"`. Added `"connected_at"` field. ### Removed diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 65948f7ecd..189922345f 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -4,12 +4,14 @@ Package daemon controls the networking layer of the skycoin daemon package daemon import ( - "bytes" "errors" + "fmt" "reflect" "sync" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" @@ -50,6 +52,10 @@ var ( // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") + // ErrDisconnectMirrorInUse mirror value is already in use by another connection with a matching base IP + ErrDisconnectMirrorInUse gnet.DisconnectReason = errors.New("Mirror value already in use") + // ErrDisconnectInvalidMirror mirror value is invalid + ErrDisconnectInvalidMirror gnet.DisconnectReason = errors.New("Mirror value is invalid") // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") @@ -237,9 +243,8 @@ type Daemoner interface { DaemonConfig() DaemonConfig BlockchainPubkey() cipher.PubKey RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error - RecordConnectionMirror(addr string, mirror uint32) error - GetMirrorPort(addr string, mirror uint32) (uint16, bool) - RemoveFromExpectingIntroductions(addr string) + GetMirrorPort(addr string, mirror uint32) uint16 + ConnectionIntroduced(addr string, m *IntroductionMessage) error RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error } @@ -258,42 +263,20 @@ type Daemon struct { // Cache of announced transactions that are flushed to the database periodically announcedTxns *announcedTxnsCache - // Cache of reported peer blockchain heights - Heights *peerBlockchainHeights - - // Separate index of outgoing connections. The pool aggregates all - // connections. - outgoingConnections *OutgoingConnections - // Number of connections waiting to be formed or timeout - pendingConnections *PendingConnections - // Keep track of unsolicited clients who should notify us of their version - expectingIntroductions *ExpectIntroductions - // Keep track of a connection's mirror value, to avoid double - // connections (one to their listener, and one to our listener) - // Maps from addr to mirror value - connectionMirrors *ConnectionMirrors - // Maps from mirror value to a map of ip (no port) - // We use a map of ip as value because multiple peers can have the same - // mirror (to avoid attacks enabled by our use of mirrors), - // but only one per base ip - mirrorConnections *MirrorConnections + // Cache of connection metadata + connections *Connections // Client connection callbacks onConnectEvent chan ConnectEvent // Client disconnection callbacks onDisconnectEvent chan DisconnectEvent // Connection failure events connectionErrors chan ConnectionError - // Tracking connections from the same base IP. Multiple connections - // from the same base IP are allowed but limited. - ipCounts *IPCount // Message handling queue messageEvents chan MessageEvent // quit channel quit chan struct{} // done channel done chan struct{} - // log buffer - LogBuff bytes.Buffer } // NewDaemon returns a Daemon with primitives allocated @@ -316,23 +299,17 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { visor: vs, announcedTxns: newAnnouncedTxnsCache(), - Heights: newPeerBlockchainHeights(), + connections: NewConnections(), - expectingIntroductions: NewExpectIntroductions(), - connectionMirrors: NewConnectionMirrors(), - mirrorConnections: NewMirrorConnections(), - ipCounts: NewIPCount(), // TODO -- if there are performance problems from blocking chans, // Its because we are connecting to more things than OutgoingMax // if we have private peers - onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), - onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), - connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), - outgoingConnections: NewOutgoingConnections(config.Daemon.OutgoingMax), - pendingConnections: NewPendingConnections(config.Daemon.PendingMax), - messageEvents: make(chan MessageEvent, config.Pool.EventChannelSize), - quit: make(chan struct{}), - done: make(chan struct{}), + onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), + onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), + connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), + messageEvents: make(chan MessageEvent, config.Pool.EventChannelSize), + quit: make(chan struct{}), + done: make(chan struct{}), } d.Gateway = NewGateway(config.Gateway, d) @@ -344,7 +321,7 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { // ConnectEvent generated when a client connects type ConnectEvent struct { - Addr string + Conn *gnet.Connection Solicited bool } @@ -551,8 +528,8 @@ loop: elapser.Register("outgoingConnectionsTicker") trustPeerNum := len(dm.pex.Trusted()) if !dm.Config.DisableOutgoingConnections && - dm.outgoingConnections.Len() < (dm.Config.OutgoingMax+trustPeerNum) && - dm.pendingConnections.Len() < dm.Config.PendingMax { + dm.connections.OutgoingLen() < (dm.Config.OutgoingMax+trustPeerNum) && + dm.connections.PendingLen() < dm.Config.PendingMax { dm.connectToRandomPeer() } @@ -687,7 +664,7 @@ loop: // GetListenPort returns the ListenPort for a given address. // If no port is found, 0 is returned. func (dm *Daemon) GetListenPort(addr string) uint16 { - m, ok := dm.connectionMirrors.Get(addr) + c, ok := dm.connections.Get(addr) if !ok { return 0 } @@ -698,11 +675,7 @@ func (dm *Daemon) GetListenPort(addr string) uint16 { return 0 } - p, ok := dm.mirrorConnections.Get(m, ip) - if !ok { - return 0 - } - return p + return dm.connections.GetMirrorPort(ip, c.Mirror) } // Connects to a given peer. Returns an error if no connection attempt was @@ -731,16 +704,23 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { return errors.New("Already connected") } - if _, ok := dm.pendingConnections.Get(p.Addr); ok { - return errors.New("Connection is pending") + c, ok := dm.connections.Get(p.Addr) + if ok && c.State == ConnectionStatePending { + errors.New("Connection is pending") } - cnt, ok := dm.ipCounts.Get(a) - if !dm.Config.LocalhostOnly && ok && cnt != 0 { + + cnt := dm.connections.GetIPCount(a) + if !dm.Config.LocalhostOnly && cnt != 0 { return errors.New("Already connected to a peer with this base IP") } - logger.Debugf("Trying to connect to %s", p.Addr) - dm.pendingConnections.Add(p) + logger.WithField("addr", p.Addr).Debug("Establishing outgoing conneciton") + + if _, err := dm.connections.AddPendingOutgoing(p.Addr); err != nil { + logger.Critical().WithError(err).WithField("addr", p.Addr).Error("AddPendingOutgoing failed") + return err + } + go func() { if err := dm.pool.Pool.Connect(p.Addr); err != nil { dm.connectionErrors <- ConnectionError{p.Addr, err} @@ -791,7 +771,7 @@ func (dm *Daemon) connectToRandomPeer() { // Check if the peer has public port if p.HasIncomingPort { // Try to connect the peer if it's ip:mirror does not exist - if _, exist := dm.GetMirrorPort(p.Addr, dm.Messages.Mirror); !exist { + if port := dm.GetMirrorPort(p.Addr, dm.Messages.Mirror); port == 0 { if err := dm.connectToPeer(p); err != nil { logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") } @@ -802,6 +782,7 @@ func (dm *Daemon) connectToRandomPeer() { if err := dm.connectToPeer(p); err != nil { logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") } + continue } } @@ -812,59 +793,42 @@ func (dm *Daemon) connectToRandomPeer() { } // We remove a peer from the Pex if we failed to connect -// TODO - On failure to connect, use exponential backoff, not peer list func (dm *Daemon) handleConnectionError(c ConnectionError) { - logger.Debugf("Failed to connect to %s with error: %v", c.Addr, c.Error) - dm.pendingConnections.Remove(c.Addr) + logger.WithField("addr", c.Addr).WithError(c.Error).Debug("handleConnectionError") + if err := dm.connections.Remove(c.Addr); err != nil { + logger.WithField("addr", c.Addr).WithError(err).Error("connections.Remove") + } + // TODO - On failure to connect, use exponential backoff, not peer list dm.pex.IncreaseRetryTimes(c.Addr) } -// Removes unsolicited connections who haven't sent a version +// Removes connections who haven't sent a version after connecting func (dm *Daemon) cullInvalidConnections() { - // This method only handles the erroneous people from the DHT, but not - // malicious nodes now := time.Now().UTC() - addrs, err := dm.expectingIntroductions.CullInvalidConns( - func(addr string, t time.Time) (bool, error) { - conned, err := dm.pool.Pool.IsConnExist(addr) - if err != nil { - return false, err - } - - // Do not remove trusted peers - if dm.isTrustedPeer(addr) { - return false, nil - } - - if !conned { - return true, nil - } - - if t.Add(dm.Config.IntroductionWait).Before(now) { - return true, nil - } + addrs, err := dm.connections.RemoveMatchedBy(func(c Connection) (bool, error) { + if c.State != ConnectionStateConnected { return false, nil - }) + } + + if c.ConnectedAt.Add(dm.Config.IntroductionWait).Before(now) { + return true, nil + } + return false, nil + }) if err != nil { - logger.Errorf("expectingIntroduction cull invalid connections failed: %v", err) + logger.WithError(err).Error("cullInvalidConnections failed") return } for _, a := range addrs { - exist, err := dm.pool.Pool.IsConnExist(a) - if err != nil { - logger.Error(err) - return + logger.WithField("addr", a).Infof("Disconnecting peer for not sending a version") + if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { + logger.WithError(err).WithField("addr", a).Error("Disconnect") } - if exist { - logger.Infof("Removing %s for not sending a version", a) - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { - logger.Error(err) - return - } + if !dm.isTrustedPeer(a) { dm.pex.RemovePeer(a) } } @@ -886,10 +850,13 @@ func (dm *Daemon) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) err return nil } -// check if the connection needs introduction message +// needsIntro check if the connection needs introduction message func (dm *Daemon) needsIntro(addr string) bool { - _, exist := dm.expectingIntroductions.Get(addr) - return exist + c, ok := dm.connections.Get(addr) + if !ok { + logger.WithField("addr", addr).Warning("needsIntro did not find a matching connection") + } + return ok && !c.HasIntroduced() } // Processes a queued AsyncMessage. @@ -903,6 +870,10 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { if dm.needsIntro(e.Context.Addr) { _, isIntro := e.Message.(*IntroductionMessage) if !isIntro { + logger.WithFields(logrus.Fields{ + "addr": e.Context.Addr, + "messageType": fmt.Sprintf("%T", e.Message), + }).Info("needsIntro but message is not IntroductionMessage") if err := dm.pool.Pool.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } @@ -913,19 +884,20 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { // Called when a ConnectEvent is processed off the onConnectEvent channel func (dm *Daemon) onConnect(e ConnectEvent) { - a := e.Addr + a := e.Conn.Addr() + direction := "incoming" if e.Solicited { - logger.Infof("Connected to peer: %s (outgoing)", a) - } else { - logger.Infof("Connected to peer: %s (incoming)", a) + direction = "outgoing" } - - dm.pendingConnections.Remove(a) + logger.WithFields(logrus.Fields{ + "addr": a, + "direction": direction, + }).Info("Connected to peer") exist, err := dm.pool.Pool.IsConnExist(a) if err != nil { - logger.Error(err) + logger.Critical().WithError(err).Error("IsConnExist failed") return } @@ -942,43 +914,56 @@ func (dm *Daemon) onConnect(e ConnectEvent) { return } - dm.recordIPCount(a) - if e.Solicited { // Disconnect if the max outgoing connections is reached n, err := dm.pool.Pool.OutgoingConnectionsNum() if err != nil { - logger.WithError(err).Error("get outgoing connections number failed") + logger.Critical().WithError(err).Error("OutgoingConnectionsNum failed") return } if n > dm.Config.OutgoingMax { - logger.Warningf("max outgoing connections is reached, disconnecting %v", a) + logger.WithField("addr", a).Warning("Max outgoing connections is reached, disconnecting") if err := dm.pool.Pool.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { logger.WithError(err).WithField("addr", a).Error("Disconnect") } return } + } - dm.outgoingConnections.Add(a) + // Update the connections state machine + c, err := dm.connections.Connected(e.Conn) + if err != nil { + logger.Critical().WithError(err).WithField("addr", a).Error("connections.Connected failed") + return + } + + // The connection should already be known as outgoing/solicited due to an earlier AddPendingOutgoing call. + // If they do not match, there is a flaw in the concept or implementation of the state machine. + if c.Outgoing != e.Solicited { + logger.Critical().Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") } - dm.expectingIntroductions.Add(a, time.Now().UTC()) - logger.Debugf("Sending introduction message to %s, mirror:%d", a, dm.Messages.Mirror) + logger.WithFields(logrus.Fields{ + "addr": a, + "mirror": dm.Messages.Mirror, + }).Debug("Sending introduction message") + m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey) if err := dm.pool.Pool.SendMessage(a, m); err != nil { - logger.Errorf("Send IntroductionMessage to %s failed: %v", a, err) + logger.WithField("addr", a).WithError(err).Error("Send IntroductionMessage failed") } } func (dm *Daemon) onDisconnect(e DisconnectEvent) { - logger.Infof("%s disconnected because: %v", e.Addr, e.Reason) + logger.WithFields(logrus.Fields{ + "addr": e.Addr, + "reason": e.Reason, + }).Info("onDisconnect") - dm.outgoingConnections.Remove(e.Addr) - dm.expectingIntroductions.Remove(e.Addr) - dm.Heights.Remove(e.Addr) - dm.removeIPCount(e.Addr) - dm.removeConnectionMirror(e.Addr) + if err := dm.connections.Remove(e.Addr); err != nil { + logger.WithError(err).WithField("addr", e.Addr).Error("connections.Remove failed") + } } // Triggered when an gnet.Connection terminates @@ -995,82 +980,32 @@ func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { } // Triggered when an gnet.Connection is connected -func (dm *Daemon) onGnetConnect(addr string, solicited bool) { - dm.onConnectEvent <- ConnectEvent{Addr: addr, Solicited: solicited} +func (dm *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) { + dm.onConnectEvent <- ConnectEvent{ + Conn: c, + Solicited: solicited, + } } // Returns whether the ipCount maximum has been reached func (dm *Daemon) ipCountMaxed(addr string) bool { ip, _, err := iputil.SplitAddr(addr) if err != nil { - logger.Warningf("ipCountMaxed called with invalid addr: %v", err) + logger.Critical().WithField("addr", addr).Error("ipCountMaxed called with invalid addr") return true } - if cnt, ok := dm.ipCounts.Get(ip); ok { - return cnt >= dm.Config.IPCountsMax - } - return false -} - -// Adds base IP to ipCount or returns error if max is reached -func (dm *Daemon) recordIPCount(addr string) { - ip, _, err := iputil.SplitAddr(addr) - if err != nil { - logger.Warningf("recordIPCount called with invalid addr: %v", err) - return - } - dm.ipCounts.Increase(ip) -} - -// Removes base IP from ipCount -func (dm *Daemon) removeIPCount(addr string) { - ip, _, err := iputil.SplitAddr(addr) - if err != nil { - logger.Warningf("removeIPCount called with invalid addr: %v", err) - return - } - dm.ipCounts.Decrease(ip) -} - -// RecordConnectionMirror adds addr + mirror to the connectionMirror mappings -func (dm *Daemon) RecordConnectionMirror(addr string, mirror uint32) error { - ip, port, err := iputil.SplitAddr(addr) - if err != nil { - logger.Warningf("RecordConnectionMirror called with invalid addr: %v", err) - return err - } - dm.connectionMirrors.Add(addr, mirror) - dm.mirrorConnections.Add(mirror, ip, port) - return nil -} - -// Removes an addr from the connectionMirror mappings -func (dm *Daemon) removeConnectionMirror(addr string) { - mirror, ok := dm.connectionMirrors.Get(addr) - if !ok { - return - } - ip, _, err := iputil.SplitAddr(addr) - if err != nil { - logger.Warningf("removeConnectionMirror called with invalid addr: %v", err) - return - } - - // remove ip from specific mirror - dm.mirrorConnections.Remove(mirror, ip) - - dm.connectionMirrors.Remove(addr) + return dm.connections.GetIPCount(ip) >= dm.Config.IPCountsMax } -// GetMirrorPort returns whether an addr+mirror's port and whether the port exists -func (dm *Daemon) GetMirrorPort(addr string, mirror uint32) (uint16, bool) { +// GetMirrorPort returns whether an addr+mirror's port. If port is 0 then it does not exist. +func (dm *Daemon) GetMirrorPort(addr string, mirror uint32) uint16 { ip, _, err := iputil.SplitAddr(addr) if err != nil { - logger.Warningf("getMirrorPort called with invalid addr: %v", err) - return 0, false + logger.WithError(err).WithField("addr", addr).Error("getMirrorPort called with invalid addr") + return 0 } - return dm.mirrorConnections.Get(mirror, ip) + return dm.connections.GetMirrorPort(ip, mirror) } // When an async message send finishes, its result is handled by this. @@ -1321,9 +1256,10 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { return dm.Config.BlockchainPubkey } -// RemoveFromExpectingIntroductions removes the peer from expect introduction pool -func (dm *Daemon) RemoveFromExpectingIntroductions(addr string) { - dm.expectingIntroductions.Remove(addr) +// ConnectionIntroduced removes the peer from expect introduction pool +func (dm *Daemon) ConnectionIntroduced(addr string, m *IntroductionMessage) error { + _, err := dm.connections.Introduced(addr, m) + return err } // Implements pooler interface @@ -1394,11 +1330,11 @@ func (dm *Daemon) ResetRetryTimes(addr string) { // Implements chain height store -// Record(addr string, height uint64) - // RecordPeerHeight records the height of specific peer func (dm *Daemon) RecordPeerHeight(addr string, height uint64) { - dm.Heights.Record(addr, height) + if err := dm.connections.SetHeight(addr, height); err != nil { + logger.Critical().WithError(err).WithField("addr", addr).Error("connections.SetHeight failed") + } } // Implements visorer interface diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index e60a0b0b6e..333aefabdf 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -9,7 +9,6 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" - "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/daemon/strand" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/dbutil" @@ -85,22 +84,6 @@ func (gw *Gateway) strand(name string, f func()) { } } -// Connection a connection's state within the daemon -type Connection struct { - ID int - Addr string - LastSent int64 - LastReceived int64 - // Whether the connection is from us to them (true, outgoing), - // or from them to us (false, incoming) - Outgoing bool - // Whether the client has identified their version, mirror etc - Introduced bool - Mirror uint32 - ListenPort uint16 - Height uint64 -} - // GetOutgoingConnections returns solicited (outgoing) connections func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { var conns []Connection @@ -116,20 +99,13 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { return nil, nil } - cs, err := gw.d.pool.Pool.GetConnections() - if err != nil { - logger.Error(err) - return nil, err - } + cs := gw.d.connections.All() - conns := make([]Connection, 0, len(cs)) + conns := make([]Connection, 0) for _, c := range cs { - if c.Solicited { - conn := gw.newConnection(&c) - if conn != nil { - conns = append(conns, *conn) - } + if c.Outgoing && c.State != ConnectionStatePending { + conns = append(conns, c) } } @@ -153,50 +129,17 @@ func (gw *Gateway) GetDefaultConnections() []string { // GetConnection returns a *Connection of specific address func (gw *Gateway) GetConnection(addr string) (*Connection, error) { - var conn *Connection - var err error + var c Connection + var exists bool gw.strand("GetConnection", func() { - if gw.d.pool.Pool == nil { - return - } - - var c *gnet.Connection - c, err = gw.d.pool.Pool.GetConnection(addr) - if err != nil { - logger.Error(err) - return - } - - conn = gw.newConnection(c) + c, exists = gw.d.connections.Get(addr) }) - return conn, err -} -func (gw *Gateway) newConnection(c *gnet.Connection) *Connection { - if c == nil { - return nil - } - - addr := c.Addr() - - mirror, exist := gw.d.connectionMirrors.Get(addr) - if !exist { - return nil + if !exists { + return nil, nil } - height, _ := gw.d.Heights.Get(addr) - - return &Connection{ - ID: c.ID, - Addr: addr, - LastSent: c.LastSent.Unix(), - LastReceived: c.LastReceived.Unix(), - Outgoing: gw.d.outgoingConnections.Get(addr), - Introduced: !gw.d.needsIntro(addr), - Mirror: mirror, - ListenPort: gw.d.GetListenPort(addr), - Height: height, - } + return &c, nil } // GetTrustConnections returns all trusted connections @@ -229,29 +172,67 @@ type BlockchainProgress struct { Peers []PeerBlockchainHeight } +// NewBlockchainProgress creates BlockchainProgress from the local head blockchain sequence number +// and a list of remote peers +func NewBlockchainProgress(headSeq uint64, conns []Connection) *BlockchainProgress { + peers := newPeerBlockchainHeights(conns) + + return &BlockchainProgress{ + Current: headSeq, + Highest: EstimateBlockchainHeight(headSeq, peers), + Peers: peers, + } +} + +// PeerBlockchainHeight records blockchain height for an address +type PeerBlockchainHeight struct { + Address string + Height uint64 +} + +func newPeerBlockchainHeights(conns []Connection) []PeerBlockchainHeight { + peers := make([]PeerBlockchainHeight, 0, len(conns)) + for _, c := range conns { + if c.State != ConnectionStatePending { + peers = append(peers, PeerBlockchainHeight{ + Address: c.Addr, + Height: c.Height, + }) + } + } + return peers +} + +// EstimateBlockchainHeight estimates the blockchain sync height. +// The highest height reported amongst all peers, and including the node itself, is returned. +func EstimateBlockchainHeight(headSeq uint64, peers []PeerBlockchainHeight) uint64 { + for _, c := range peers { + if c.Height > headSeq { + headSeq = c.Height + } + } + return headSeq +} + // GetBlockchainProgress returns a *BlockchainProgress func (gw *Gateway) GetBlockchainProgress() (*BlockchainProgress, error) { - var bcp *BlockchainProgress + var headSeq uint64 var err error + var conns []Connection gw.strand("GetBlockchainProgress", func() { - var headSeq uint64 headSeq, _, err = gw.v.HeadBkSeq() if err != nil { return } - bcp = &BlockchainProgress{ - Current: headSeq, - Highest: gw.d.Heights.Estimate(headSeq), - Peers: gw.d.Heights.All(), - } + conns = gw.d.connections.All() }) if err != nil { return nil, err } - return bcp, nil + return NewBlockchainProgress(headSeq, conns), nil } // ResendUnconfirmedTxns resents all unconfirmed transactions, returning the txids diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 3af93b4be3..8c448b3f1d 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -15,6 +15,8 @@ import ( "io" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/daemon/strand" "github.com/skycoin/skycoin/src/util/elapse" @@ -177,7 +179,7 @@ func (conn *Connection) Close() error { type DisconnectCallback func(addr string, reason DisconnectReason) // ConnectCallback triggered on client connect -type ConnectCallback func(addr string, solicited bool) +type ConnectCallback func(c *Connection, solicited bool) // ConnectionPool connection pool type ConnectionPool struct { @@ -277,7 +279,10 @@ loop: go func() { defer pool.wg.Done() if err := pool.handleConnection(conn, false); err != nil { - logger.Errorf("pool.handleConnection error: %v", err) + logger.WithFields(logrus.Fields{ + "addr": conn.RemoteAddr(), + "outgoing": false, + }).WithError(err).Error("pool.handleConnection") } }() } @@ -301,7 +306,7 @@ func (pool *ConnectionPool) processStrand() { return case req := <-pool.reqC: if err := req.Func(); err != nil { - logger.Errorf("req.Func %s failed: %v", req.Name, err) + logger.WithField("operation", req.Name).WithError(err).Errorf("strand req.Func failed") } } } @@ -401,14 +406,14 @@ func (pool *ConnectionPool) ListeningAddress() (net.Addr, error) { // Creates a Connection and begins its read and write loop func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) error { - defer logger.Debugf("Connection %s closed", conn.RemoteAddr()) + defer logger.WithField("addr", conn.RemoteAddr()).Debug("Connection closed") addr := conn.RemoteAddr().String() c, err := func() (c *Connection, err error) { defer func() { if err != nil { if closeErr := conn.Close(); closeErr != nil { - logger.Errorf("conn.Close() %s error: %v", addr, closeErr) + logger.WithError(closeErr).WithField("addr", addr).Error("conn.Close") } } }() @@ -435,7 +440,7 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro } if pool.Config.ConnectCallback != nil { - pool.Config.ConnectCallback(c.Addr(), solicited) + pool.Config.ConnectCallback(c, solicited) } msgC := make(chan []byte, 32) @@ -478,13 +483,12 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro select { case <-pool.quit: if err := conn.Close(); err != nil { - logger.Errorf("conn.Close() %s error: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("conn.Close") } case err = <-errC: + logger.WithError(err).WithField("addr", addr).Error("handleConnection failure") if err := pool.Disconnect(c.Addr(), err); err != nil { - logger.Errorf("Disconnect %s failed: %v", addr, err) - } else { - logger.Debugf("Disconnected from %s", addr) + logger.WithError(err).WithField("addr", addr).Error("Disconnect") } } close(qc) @@ -507,7 +511,7 @@ func (pool *ConnectionPool) readLoop(conn *Connection, msgChan chan []byte, qc c defer sendInMsgChanElapser.CheckForDone() for { - elapser.Register(fmt.Sprintf("readLoop address=%s", conn.Addr())) + elapser.Register(fmt.Sprintf("readLoop addr=%s", conn.Addr())) deadline := time.Time{} if pool.Config.ReadTimeout != 0 { deadline = time.Now().Add(pool.Config.ReadTimeout) @@ -764,7 +768,7 @@ func (pool *ConnectionPool) Connect(address string) error { return nil } - logger.Debugf("Making TCP Connection to %s", address) + logger.WithField("addr", address).Debugf("Making TCP connection") conn, err := net.DialTimeout("tcp", address, pool.Config.DialTimeout) if err != nil { return err @@ -774,7 +778,10 @@ func (pool *ConnectionPool) Connect(address string) error { go func() { defer pool.wg.Done() if err := pool.handleConnection(conn, true); err != nil { - logger.Errorf("pool.handleConnection error: %v", err) + logger.WithFields(logrus.Fields{ + "addr": conn.RemoteAddr(), + "outgoing": true, + }).WithError(err).Error("pool.handleConnection") } }() return nil @@ -784,6 +791,11 @@ func (pool *ConnectionPool) Connect(address string) error { // the DisconnectCallback func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { if err := pool.strand("Disconnect", func() error { + logger.WithFields(logrus.Fields{ + "addr": addr, + "reason": r, + }).Debug("Disconnecting") + exist := pool.disconnect(addr) // checks if the address is default node address @@ -816,11 +828,11 @@ func (pool *ConnectionPool) disconnect(addr string) bool { delete(pool.addresses, addr) delete(pool.defaultConnections, addr) if err := conn.Close(); err != nil { - logger.Errorf("conn.Close() error address=%s: %v", addr, err) - } else { - logger.Debugf("Disconnected from %s", addr) + logger.WithError(err).WithField("addr", addr).Error("conn.Close") } + logger.WithField("addr", addr).Debug("Closed connection and removed from pool") + return true } diff --git a/src/daemon/heights.go b/src/daemon/heights.go deleted file mode 100644 index abd208eea0..0000000000 --- a/src/daemon/heights.go +++ /dev/null @@ -1,93 +0,0 @@ -package daemon - -import ( - "sort" - "strings" - "sync" -) - -// PeerBlockchainHeight is a peer's IP address with their reported blockchain height -type PeerBlockchainHeight struct { - Address string - Height uint64 -} - -// peerBlockchainHeights tracks reported blockchain heights of peers -type peerBlockchainHeights struct { - // Peer-reported blockchain height. Use to estimate download progress - heights map[string]uint64 - sync.Mutex -} - -// newPeerBlockchainHeights creates a peerBlockchainHeights -func newPeerBlockchainHeights() *peerBlockchainHeights { - return &peerBlockchainHeights{ - heights: make(map[string]uint64), - } -} - -// Remove removes a connection from the records -func (p *peerBlockchainHeights) Remove(addr string) { - p.Lock() - defer p.Unlock() - - delete(p.heights, addr) -} - -// Record saves a peer-reported blockchain height -func (p *peerBlockchainHeights) Record(addr string, height uint64) { - p.Lock() - defer p.Unlock() - - p.heights[addr] = height -} - -// Estimate returns the blockchain length estimated from peer reports. -// The highest height reported amongst all peers, and including the node itself, -// is returned. -func (p *peerBlockchainHeights) Estimate(headSeq uint64) uint64 { - p.Lock() - defer p.Unlock() - - for _, seq := range p.heights { - if headSeq < seq { - headSeq = seq - } - } - - return headSeq -} - -// Get returns the height for a given address -func (p *peerBlockchainHeights) Get(addr string) (uint64, bool) { - p.Lock() - defer p.Unlock() - - height, ok := p.heights[addr] - return height, ok -} - -// All returns recorded peers' blockchain heights as an array. -// The array is sorted by address as strings. -func (p *peerBlockchainHeights) All() []PeerBlockchainHeight { - p.Lock() - defer p.Unlock() - - if len(p.heights) == 0 { - return []PeerBlockchainHeight{} - } - - peerHeights := make([]PeerBlockchainHeight, 0, len(p.heights)) - for addr, height := range p.heights { - peerHeights = append(peerHeights, PeerBlockchainHeight{ - Address: addr, - Height: height, - }) - } - - sort.Slice(peerHeights, func(i, j int) bool { - return strings.Compare(peerHeights[i].Address, peerHeights[j].Address) < 0 - }) - - return peerHeights -} diff --git a/src/daemon/heights_test.go b/src/daemon/heights_test.go deleted file mode 100644 index f3acd1dc7b..0000000000 --- a/src/daemon/heights_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package daemon - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestPeerBlockchainHeights(t *testing.T) { - p := newPeerBlockchainHeights() - - addr1 := "127.0.0.1:1234" - addr2 := "127.0.0.1:5678" - addr3 := "127.0.0.1:9999" - - require.Empty(t, p.heights) - p.Remove(addr1) - require.Empty(t, p.heights) - - e := p.Estimate(1) - require.Equal(t, uint64(1), e) - - e = p.Estimate(13) - require.Equal(t, uint64(13), e) - - p.Record(addr1, 10) - require.Len(t, p.heights, 1) - - records := p.All() - require.Len(t, records, 1) - require.Equal(t, PeerBlockchainHeight{ - Address: addr1, - Height: 10, - }, records[0]) - - p.Record(addr1, 11) - require.Len(t, p.heights, 1) - - records = p.All() - require.Len(t, records, 1) - require.Equal(t, PeerBlockchainHeight{ - Address: addr1, - Height: 11, - }, records[0]) - - e = p.Estimate(1) - require.Equal(t, uint64(11), e) - - e = p.Estimate(13) - require.Equal(t, uint64(13), e) - - p.Record(addr2, 12) - p.Record(addr3, 12) - require.Len(t, p.heights, 3) - - records = p.All() - require.Len(t, records, 3) - require.Equal(t, []PeerBlockchainHeight{ - { - Address: addr1, - Height: 11, - }, - { - Address: addr2, - Height: 12, - }, - { - Address: addr3, - Height: 12, - }, - }, records) - - e = p.Estimate(1) - require.Equal(t, uint64(12), e) - - e = p.Estimate(13) - require.Equal(t, uint64(13), e) - - p.Record(addr3, 24) - e = p.Estimate(13) - require.Equal(t, uint64(24), e) -} diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 829cd63f4c..e799db7a49 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -9,6 +9,8 @@ import ( "strings" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" @@ -88,9 +90,15 @@ type Messages struct { // NewMessages creates Messages func NewMessages(c MessagesConfig) *Messages { + // mirror cannot be zero + var mirror uint32 + for mirror == 0 { + mirror = rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32() + } + return &Messages{ Config: c, - Mirror: rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32(), + Mirror: mirror, } } @@ -274,7 +282,10 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return ErrDisconnectVersionNotSupported } - logger.Infof("%s verified for version %d", mc.Addr, intro.Version) + logger.WithFields(logrus.Fields{ + "addr": mc.Addr, + "protocolVersion": intro.Version, + }).Info("Peer protocol version accepted") // v25 Checks the blockchain pubkey, would accept message with no Pubkey // v26 would check the blockchain pubkey and reject if not matched or not provided @@ -325,8 +336,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } // Disconnect if connected twice to the same peer (judging by ip:mirror) - knownPort, exists := d.GetMirrorPort(mc.Addr, intro.Mirror) - if exists { + if knownPort := d.GetMirrorPort(mc.Addr, intro.Mirror); knownPort != 0 { logger.Infof("%s is already connected on port %d", mc.Addr, knownPort) if err := d.Disconnect(mc.Addr, ErrDisconnectConnectedTwice); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") @@ -341,7 +351,6 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa if err != nil { d.IncreaseRetryTimes(mc.Addr) - d.RemoveFromExpectingIntroductions(mc.Addr) return err } @@ -352,31 +361,36 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // Process an event queued by Handle() func (intro *IntroductionMessage) Process(d Daemoner) { - d.RemoveFromExpectingIntroductions(intro.c.Addr) if !intro.valid { return } - // Add the remote peer with their chosen listening port + a := intro.c.Addr - // Record their listener, to avoid double connections - err := d.RecordConnectionMirror(a, intro.Mirror) - if err != nil { - // This should never happen, but the program should not allow itself - // to be corrupted in case it does - logger.Errorf("Invalid port for connection %s", a) - if err := d.Disconnect(intro.c.Addr, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", intro.c.Addr).Warning("Disconnect") + if err := d.ConnectionIntroduced(a, intro); err != nil { + logger.WithError(err).WithField("addr", a).Warning("ConnectionIntroduced failed") + var reason gnet.DisconnectReason + switch err { + case ErrMirrorZero: + reason = ErrDisconnectInvalidMirror + case ErrConnectionIPMirrorAlreadyRegistered: + reason = ErrDisconnectMirrorInUse + default: + reason = ErrDisconnectIncomprehensibleError + } + + if err := d.Disconnect(a, reason); err != nil { + logger.WithError(err).WithField("addr", a).Warning("Disconnect") } + return } // Request blocks immediately after they're confirmed - err = d.RequestBlocksFromAddr(intro.c.Addr) - if err == nil { - logger.Debugf("Successfully requested blocks from %s", intro.c.Addr) + if err := d.RequestBlocksFromAddr(intro.c.Addr); err != nil { + logger.WithError(err).Warning("RequestBlocksFromAddr") } else { - logger.Warning(err) + logger.WithField("addr", intro.c.Addr).Debug("Requested blocks") } // Announce unconfirmed txns @@ -399,10 +413,10 @@ func (ping *PingMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err // Process Sends a PongMessage to the sender of PingMessage func (ping *PingMessage) Process(d Daemoner) { if d.DaemonConfig().LogPings { - logger.Debugf("Reply to ping from %s", ping.c.Addr) + logger.WithField("addr", ping.c.Addr).Debug("Replying to ping") } if err := d.SendMessage(ping.c.Addr, &PongMessage{}); err != nil { - logger.Errorf("Send PongMessage to %s failed: %v", ping.c.Addr, err) + logger.WithField("addr", ping.c.Addr).WithError(err).Error("Send PongMessage failed") } } @@ -415,7 +429,7 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err // There is nothing to do; gnet updates Connection.LastMessage internally // when this is received if daemon.(*Daemon).Config.LogPings { - logger.Debugf("Received pong from %s", mc.Addr) + logger.WithField("addr", mc.Addr).Debug("Received pong") } return nil } @@ -454,7 +468,7 @@ func (gbm *GetBlocksMessage) Process(d Daemoner) { // Fetch and return signed blocks since LastBlock blocks, err := d.GetSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) if err != nil { - logger.Infof("Get signed blocks failed: %v", err) + logger.WithError(err).Error("Get signed blocks failed") return } @@ -466,7 +480,7 @@ func (gbm *GetBlocksMessage) Process(d Daemoner) { m := NewGiveBlocksMessage(blocks) if err := d.SendMessage(gbm.c.Addr, m); err != nil { - logger.Errorf("Send GiveBlocksMessage to %s failed: %v", gbm.c.Addr, err) + logger.WithField("addr", gbm.c.Addr).WithError(err).Error("Send GiveBlocksMessage failed") } } @@ -650,7 +664,7 @@ func (atm *AnnounceTxnsMessage) Process(d Daemoner) { unknown, err := d.GetUnconfirmedUnknown(atm.Transactions) if err != nil { - logger.WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") + logger.WithField("addr", atm.c.Addr).WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") return } @@ -660,7 +674,7 @@ func (atm *AnnounceTxnsMessage) Process(d Daemoner) { m := NewGetTxnsMessage(unknown) if err := d.SendMessage(atm.c.Addr, m); err != nil { - logger.Errorf("Send GetTxnsMessage to %s failed: %v", atm.c.Addr, err) + logger.WithField("addr", atm.c.Addr).WithError(err).Errorf("Send GetTxnsMessage failed") } } diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index f17c9458de..b950c2b4d3 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -18,6 +18,7 @@ import ( "time" "github.com/cenkalti/backoff" + "github.com/sirupsen/logrus" "github.com/skycoin/skycoin/src/util/logging" ) @@ -123,13 +124,16 @@ func (peer *Peer) Seen() { // IncreaseRetryTimes adds the retry times func (peer *Peer) IncreaseRetryTimes() { peer.RetryTimes++ - logger.Debugf("Increase retry times of %v: %v", peer.Addr, peer.RetryTimes) + logger.WithFields(logrus.Fields{ + "addr": peer.Addr, + "retryTimes": peer.RetryTimes, + }).Debug("Increase retry times") } // ResetRetryTimes resets the retry time func (peer *Peer) ResetRetryTimes() { peer.RetryTimes = 0 - logger.Debugf("Reset retry times of %v", peer.Addr) + logger.WithField("addr", peer.Addr).Debug("Reset retry times") } // CanTry returns whether this peer is tryable base on the exponential backoff algorithm @@ -626,22 +630,22 @@ func backoffDownloadText(url string) (string, error) { b := backoff.NewExponentialBackOff() notify := func(err error, wait time.Duration) { - logger.Errorf("waiting %v to retry downloadText, error: %v", wait, err) + logger.WithError(err).WithField("waitTime", wait).Error("waiting to retry downloadText") } operation := func() error { - logger.Infof("Trying to download peers list from %s", url) + logger.WithField("url", url).Info("Trying to download peers list") var err error body, err = downloadText(url) return err } if err := backoff.RetryNotify(operation, b, notify); err != nil { - logger.Infof("Gave up dowloading peers list from %s: %v", url, err) + logger.WithField("url", url).WithError(err).Info("Gave up dowloading peers list") return "", err } - logger.Infof("Peers list downloaded from %s", url) + logger.WithField("url", url).Info("Peers list downloaded") return body, nil } diff --git a/src/daemon/storage.go b/src/daemon/storage.go index 2d66bffcf1..37a5192440 100644 --- a/src/daemon/storage.go +++ b/src/daemon/storage.go @@ -1,289 +1,421 @@ package daemon import ( + "errors" "sync" "time" - "github.com/skycoin/skycoin/src/daemon/pex" -) + "github.com/sirupsen/logrus" -// ExpectIntroductions records connections that are expecting introduction msg. -type ExpectIntroductions struct { - value map[string]time.Time - sync.Mutex -} + "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/util/iputil" +) -// CullMatchFunc function for checking if the connection need to be culled -type CullMatchFunc func(addr string, t time.Time) (bool, error) +// ConnectionState connection state in the state machine +type ConnectionState string -// NewExpectIntroductions creates a ExpectIntroduction instance -func NewExpectIntroductions() *ExpectIntroductions { - return &ExpectIntroductions{ - value: make(map[string]time.Time), - } -} +const ( + // ConnectionStatePending prior to establishing a connection + ConnectionStatePending ConnectionState = "pending" + // ConnectionStateConnected connected, but not introduced + ConnectionStateConnected ConnectionState = "connected" + // ConnectionStateIntroduced connection has introduced itself + ConnectionStateIntroduced ConnectionState = "introduced" +) -// Add adds expecting introduction connection -func (s *ExpectIntroductions) Add(addr string, tm time.Time) { - s.Lock() - defer s.Unlock() - s.value[addr] = tm -} +var ( + // ErrConnectionNotExist connection does not exist when performing an operation that requires it to exist + ErrConnectionNotExist = errors.New("Connection does not exist") + // ErrConnectionAlreadyRegistered connection already registered in Connections + ErrConnectionAlreadyRegistered = errors.New("Connection already registered") + // ErrConnectionIPMirrorAlreadyRegistered connection already registered for a given base IP and mirror + ErrConnectionIPMirrorAlreadyRegistered = errors.New("Connection already registered with this base IP and mirror") + // ErrMirrorZero mirror value is 0 + ErrMirrorZero = errors.New("Mirror cannot be 0") +) -// Remove removes connection -func (s *ExpectIntroductions) Remove(addr string) { - s.Lock() - defer s.Unlock() - delete(s.value, addr) +// Connection a connection's state within the daemon +type Connection struct { + GnetID int + LastSent time.Time + LastReceived time.Time + Addr string + ConnectionDetails +} + +// ConnectionDetails extra connection data +type ConnectionDetails struct { + State ConnectionState + Outgoing bool + ConnectedAt time.Time + Mirror uint32 + ListenPort uint16 + ProtocolVersion int32 + Height uint64 +} + +// HasIntroduced returns true if the connection has introduced +func (c ConnectionDetails) HasIntroduced() bool { + switch c.State { + case ConnectionStateIntroduced: + return true + default: + return false + } } -// CullInvalidConns cull connections that match the matchFunc -func (s *ExpectIntroductions) CullInvalidConns(f CullMatchFunc) ([]string, error) { - s.Lock() - defer s.Unlock() +func newConnection(c *connection) Connection { + if c == nil { + return Connection{} + } - var addrs []string - for addr, t := range s.value { - ok, err := f(addr, t) - if err != nil { - return nil, err - } + conn := Connection{ + Addr: c.addr, + ConnectionDetails: c.ConnectionDetails, + } - if ok { - addrs = append(addrs, addr) - delete(s.value, addr) - } + if c.gnetConnection != nil { + conn.GnetID = c.gnetConnection.ID + conn.LastSent = c.gnetConnection.LastSent + conn.LastReceived = c.gnetConnection.LastReceived } - return addrs, nil + return conn } -// Get returns the time of speicific address -func (s *ExpectIntroductions) Get(addr string) (time.Time, bool) { - s.Lock() - defer s.Unlock() - t, ok := s.value[addr] - return t, ok +type connection struct { + gnetConnection *gnet.Connection + addr string + ConnectionDetails } -// ConnectionMirrors records mirror for connection -type ConnectionMirrors struct { - value map[string]uint32 +// Connections manages a collection of Connection +type Connections struct { + conns map[string]*connection + mirrors map[uint32]map[string]uint16 + ipCounts map[string]int sync.Mutex } -// NewConnectionMirrors create ConnectionMirrors instance. -func NewConnectionMirrors() *ConnectionMirrors { - return &ConnectionMirrors{ - value: make(map[string]uint32), +// NewConnections creates Connections +func NewConnections() *Connections { + return &Connections{ + conns: make(map[string]*connection, 32), + mirrors: make(map[uint32]map[string]uint16, 32), + ipCounts: make(map[string]int, 32), } } -// Add adds connection mirror -func (s *ConnectionMirrors) Add(addr string, mirror uint32) { - s.Lock() - defer s.Unlock() - s.value[addr] = mirror -} +// AddPendingOutgoing adds a new pending outgoing connection +func (c *Connections) AddPendingOutgoing(addr string) (Connection, error) { + c.Lock() + defer c.Unlock() -// Get returns the mirror of connection -func (s *ConnectionMirrors) Get(addr string) (uint32, bool) { - s.Lock() - defer s.Unlock() - v, ok := s.value[addr] - return v, ok -} + ip, _, err := iputil.SplitAddr(addr) + if err != nil { + return Connection{}, err + } -// Remove remove connection mirror -func (s *ConnectionMirrors) Remove(addr string) { - s.Lock() - defer s.Unlock() - delete(s.value, addr) -} + c.ipCounts[ip]++ -// OutgoingConnections records the outgoing connections -type OutgoingConnections struct { - value map[string]struct{} - sync.Mutex + c.conns[addr] = &connection{ + addr: addr, + ConnectionDetails: ConnectionDetails{ + State: ConnectionStatePending, + Outgoing: true, + }, + } + + logger.WithField("addr", addr).Debug("AddPendingOutgoing") + + return newConnection(c.conns[addr]), nil } -// NewOutgoingConnections create OutgoingConnection instance -func NewOutgoingConnections(max int) *OutgoingConnections { - return &OutgoingConnections{ - value: make(map[string]struct{}, max), +// Connected the connection has connected +func (c *Connections) Connected(gnetConn *gnet.Connection) (Connection, error) { + c.Lock() + defer c.Unlock() + + addr := gnetConn.Addr() + + ip, _, err := iputil.SplitAddr(addr) + if err != nil { + return Connection{}, err } -} -// Add records connection -func (s *OutgoingConnections) Add(addr string) { - s.Lock() - defer s.Unlock() - s.value[addr] = struct{}{} -} + conn := c.conns[addr] -// Remove remove connection -func (s *OutgoingConnections) Remove(addr string) { - s.Lock() - defer s.Unlock() - delete(s.value, addr) -} + if conn == nil { + c.ipCounts[ip]++ -// Get returns if connection is outgoing -func (s *OutgoingConnections) Get(addr string) bool { - s.Lock() - defer s.Unlock() - _, ok := s.value[addr] - return ok -} + conn = &connection{ + addr: addr, + } -// Len returns the outgoing connections count -func (s *OutgoingConnections) Len() int { - s.Lock() - defer s.Unlock() - return len(s.value) -} + c.conns[addr] = conn + } else { + if addr != conn.addr { + err := errors.New("gnet.Connection.Addr does not match recorded Connection address") + logger.Critical().WithError(err).Error() + return Connection{}, err + } -// PendingConnections records pending connection peers -type PendingConnections struct { - value map[string]pex.Peer - sync.Mutex + if conn.State != ConnectionStatePending { + logger.Critical().WithField("state", conn.State).Warning("Transitioning to State connected but State is not pending") + } + } + + conn.gnetConnection = gnetConn + conn.ConnectedAt = time.Now().UTC() + conn.State = ConnectionStateConnected + + logger.WithFields(logrus.Fields{ + "addr": addr, + "outgoing": conn.Outgoing, + }).Debug("Connected") + + return newConnection(conn), nil } -// NewPendingConnections creates new PendingConnections instance -func NewPendingConnections(maxConn int) *PendingConnections { - return &PendingConnections{ - value: make(map[string]pex.Peer, maxConn), +// Introduced the connection has introduced itself +func (c *Connections) Introduced(addr string, m *IntroductionMessage) (Connection, error) { + c.Lock() + defer c.Unlock() + + ip, port, err := iputil.SplitAddr(addr) + if err != nil { + return Connection{}, err } -} -// Add adds pending connection -func (s *PendingConnections) Add(peer pex.Peer) { - s.Lock() - defer s.Unlock() - s.value[peer.Addr] = peer -} + if err := c.canUpdateMirror(ip, port, m.Mirror); err != nil { + return Connection{}, err + } + + conn := c.conns[addr] + if conn == nil { + return Connection{}, ErrConnectionNotExist + } + + if err := c.updateMirror(ip, port, m.Mirror); err != nil { + logger.WithError(err).Panic("updateMirror failed, but shouldn't") + } + + conn.State = ConnectionStateIntroduced + conn.Mirror = m.Mirror + conn.ListenPort = m.Port + conn.ProtocolVersion = m.Version -// Get returns pending connections -func (s *PendingConnections) Get(addr string) (pex.Peer, bool) { - s.Lock() - defer s.Unlock() - v, ok := s.value[addr] - return v, ok + logger.WithFields(logrus.Fields{ + "addr": addr, + "outgoing": conn.Outgoing, + }).Debug("Introduced") + + return newConnection(conn), nil } -// Remove removes pending connection -func (s *PendingConnections) Remove(addr string) { - s.Lock() - defer s.Unlock() - delete(s.value, addr) +// Get returns a connection by address +func (c *Connections) Get(addr string) (Connection, bool) { + c.Lock() + defer c.Unlock() + + conn, ok := c.conns[addr] + return newConnection(conn), ok } -// Len returns pending connection number -func (s *PendingConnections) Len() int { - s.Lock() - defer s.Unlock() - return len(s.value) +// modify modifies a connection. +// It is unsafe to modify the Mirror value with this method +func (c *Connections) modify(addr string, f func(c *ConnectionDetails) error) error { + conn := c.conns[addr] + if conn == nil { + return ErrConnectionNotExist + } + + cd := conn.ConnectionDetails + + if err := f(&cd); err != nil { + return err + } + + if cd.Mirror != conn.ConnectionDetails.Mirror { + logger.Panic("Connections.modify connection mirror value was changed") + } + + conn.ConnectionDetails = cd + + return nil } -// MirrorConnections records mirror connections -type MirrorConnections struct { - value map[uint32]map[string]uint16 - sync.Mutex +// SetHeight sets the height for a connection +func (c *Connections) SetHeight(addr string, height uint64) error { + c.Lock() + defer c.Unlock() + + return c.modify(addr, func(c *ConnectionDetails) error { + c.Height = height + return nil + }) } -// NewMirrorConnections create mirror connection instance -func NewMirrorConnections() *MirrorConnections { - return &MirrorConnections{ - value: make(map[uint32]map[string]uint16), +// GetMirrorPort returns the port matching a given IP address (without port) and mirror value +func (c *Connections) GetMirrorPort(ip string, mirror uint32) uint16 { + c.Lock() + defer c.Unlock() + + x := c.mirrors[mirror] + if x == nil { + return 0 } + + return x[ip] } -// Add adds mirror connection -func (s *MirrorConnections) Add(mirror uint32, ip string, port uint16) { - s.Lock() - defer s.Unlock() +func (c *Connections) updateMirror(ip string, port uint16, mirror uint32) error { + if mirror == 0 { + return ErrMirrorZero + } - if m, ok := s.value[mirror]; ok { - m[ip] = port - return + x := c.mirrors[mirror] + if x == nil { + x = make(map[string]uint16, 2) + } + if _, ok := x[ip]; ok { + return ErrConnectionIPMirrorAlreadyRegistered } + x[ip] = port - m := make(map[string]uint16) - m[ip] = port - s.value[mirror] = m + return nil } -// Get returns ip port of specific mirror -func (s *MirrorConnections) Get(mirror uint32, ip string) (uint16, bool) { - s.Lock() - defer s.Unlock() +func (c *Connections) canUpdateMirror(ip string, port uint16, mirror uint32) error { + if mirror == 0 { + return ErrMirrorZero + } + + x := c.mirrors[mirror] + if x == nil { + return nil + } - m, ok := s.value[mirror] - if ok { - port, exist := m[ip] - return port, exist + if _, ok := x[ip]; ok { + return ErrConnectionIPMirrorAlreadyRegistered } - return 0, false + return nil } -// Remove removes port of ip for specific mirror -func (s *MirrorConnections) Remove(mirror uint32, ip string) { - s.Lock() - defer s.Unlock() +// GetIPCount returns the number of connections for a given base IP (without port) +func (c *Connections) GetIPCount(ip string) int { + c.Lock() + defer c.Unlock() + return c.ipCounts[ip] +} - m, ok := s.value[mirror] - if ok { - delete(m, ip) - } +// Len returns number of connections +func (c *Connections) Len() int { + c.Lock() + defer c.Unlock() + return len(c.conns) } -// IPCount records connection number from the same base ip -type IPCount struct { - value map[string]int - sync.Mutex +// OutgoingLen returns number of outgoing connections +func (c *Connections) OutgoingLen() int { + c.Lock() + defer c.Unlock() + n := 0 + for _, conn := range c.conns { + if conn.Outgoing { + n++ + } + } + return n } -// NewIPCount returns IPCount instance -func NewIPCount() *IPCount { - return &IPCount{ - value: make(map[string]int), +// PendingLen returns the number of status pending connections +func (c *Connections) PendingLen() int { + c.Lock() + defer c.Unlock() + n := 0 + for _, conn := range c.conns { + if conn.State == ConnectionStatePending { + n++ + } } + return n +} + +// Remove removes connection. Returns an error if the addr is invalid. +// If a connection with this address does not exist, nothing happens. +func (c *Connections) Remove(addr string) error { + c.Lock() + defer c.Unlock() + return c.remove(addr) } -// Increase increases one for specific ip -func (s *IPCount) Increase(ip string) { - s.Lock() - defer s.Unlock() +func (c *Connections) remove(addr string) error { + ip, port, err := iputil.SplitAddr(addr) + if err != nil { + return err + } + + conn := c.conns[addr] + if conn != nil { + x, ok := c.mirrors[conn.Mirror] + if ok { + if x[ip] != port { + logger.Critical().WithField("addr", addr).Warning("Indexed IP+Mirror value found but the port doesn't match") + } + + delete(x, ip) + } - if c, ok := s.value[ip]; ok { - c++ - s.value[ip] = c - return + if len(x) == 0 { + delete(c.mirrors, conn.Mirror) + } + + if c.ipCounts[ip] > 0 { + c.ipCounts[ip]-- + } else { + logger.Critical().WithField("addr", addr).Warning("ipCount was already 0 when removing existing address") + } } - s.value[ip] = 1 + delete(c.conns, addr) + + return nil } -// Decrease decreases one for specific ip -func (s *IPCount) Decrease(ip string) { - s.Lock() - defer s.Unlock() +// RemoveMatchedBy remove connections that match the matchFunc and return them +func (c *Connections) RemoveMatchedBy(f func(c Connection) (bool, error)) ([]string, error) { + c.Lock() + defer c.Unlock() + + var addrs []string + for addr, conn := range c.conns { + if ok, err := f(newConnection(conn)); err != nil { + return nil, err + } else if ok { + addrs = append(addrs, addr) + } + } - if c, ok := s.value[ip]; ok { - if c <= 1 { - delete(s.value, ip) - return + for _, a := range addrs { + if err := c.remove(a); err != nil { + logger.WithError(err).Panic("Invalid address stored inside Connections") } - c-- - s.value[ip] = c } + + return addrs, nil } -// Get return ip count -func (s *IPCount) Get(ip string) (int, bool) { - s.Lock() - defer s.Unlock() - v, ok := s.value[ip] - return v, ok +// All returns a copy of all connections +func (c *Connections) All() []Connection { + c.Lock() + defer c.Unlock() + + conns := make([]Connection, 0, len(c.conns)) + for _, c := range c.conns { + conns = append(conns, newConnection(c)) + } + + return conns } diff --git a/src/daemon/storage_test.go b/src/daemon/storage_test.go index ecd99d702b..157e76dac6 100644 --- a/src/daemon/storage_test.go +++ b/src/daemon/storage_test.go @@ -1,38 +1,63 @@ package daemon import ( + "net" "sync" "testing" "time" "github.com/stretchr/testify/require" - "github.com/skycoin/skycoin/src/daemon/pex" + "github.com/skycoin/skycoin/src/daemon/gnet" ) -func TestExpectIntroductions(t *testing.T) { - ei := NewExpectIntroductions() +func TestGet(t *testing.T) { + conns := NewConnections() - _, ok := ei.Get("foo") - require.False(t, ok) + addr := "127.0.0.1:6060" + details := ConnectionDetails{ + Mirror: 99, + State: ConnectionStatePending, + ConnectedAt: time.Now().UTC(), + ListenPort: 10101, + Height: 1111, + } - tm := time.Now() - ei.Add("foo", tm) - tm2, ok := ei.Get("foo") - require.True(t, ok) - require.Equal(t, tm, tm2) + c, err := conns.Add(fakeGnetConn(addr), details) + require.NoError(t, err) + require.Equal(t, details, c.ConnectionDetails) + require.Equal(t, 111, c.GnetID) + require.NotEmpty(t, c.LastReceived) + require.NotEmpty(t, c.LastSent) - ei.Remove("foo") - _, ok = ei.Get("foo") - require.False(t, ok) + c2, ok := conns.Get(addr) + require.True(t, ok) + require.Equal(t, c, c2) } -func TestExpectIntroductionsCullInvalidConnections(t *testing.T) { - ei := NewExpectIntroductions() +func TestRemoveMatchedBy(t *testing.T) { + ei := NewConnections() + now := time.Now().UTC() - ei.Add("a", now) - ei.Add("b", now.Add(1)) - ei.Add("c", now.Add(2)) + + addr1 := "127.0.0.1:6060" + addr2 := "127.0.1.1:6061" + addr3 := "127.1.1.1:6062" + + _, err := ei.Add(fakeGnetConn(addr1), ConnectionDetails{ + ConnectedAt: now, + }) + require.NoError(t, err) + + _, err = ei.Add(fakeGnetConn(addr2), ConnectionDetails{ + ConnectedAt: now.Add(1), + }) + require.NoError(t, err) + + _, err = ei.Add(fakeGnetConn(addr3), ConnectionDetails{ + ConnectedAt: now.Add(2), + }) + require.NoError(t, err) wg := sync.WaitGroup{} vc := make(chan string, 3) @@ -40,8 +65,8 @@ func TestExpectIntroductionsCullInvalidConnections(t *testing.T) { wg.Add(2) go func() { defer wg.Done() - as, err := ei.CullInvalidConns(func(addr string, tm time.Time) (bool, error) { - if addr == "a" || addr == "b" { + as, err := ei.RemoveMatchedBy(func(c Connection) (bool, error) { + if c.Addr == addr1 || c.Addr == addr2 { return true, nil } return false, nil @@ -55,8 +80,8 @@ func TestExpectIntroductionsCullInvalidConnections(t *testing.T) { go func() { defer wg.Done() - as, err := ei.CullInvalidConns(func(addr string, tm time.Time) (bool, error) { - if addr == "c" { + as, err := ei.RemoveMatchedBy(func(c Connection) (bool, error) { + if c.Addr == addr3 { return true, nil } return false, nil @@ -72,161 +97,245 @@ func TestExpectIntroductionsCullInvalidConnections(t *testing.T) { wg.Wait() require.Equal(t, 3, len(vc)) - _, ok := ei.Get("a") + _, ok := ei.Get(addr1) require.False(t, ok) - _, ok = ei.Get("b") + _, ok = ei.Get(addr2) require.False(t, ok) - _, ok = ei.Get("c") + _, ok = ei.Get(addr3) require.False(t, ok) } -func TestConnectionMirrors(t *testing.T) { - cm := NewConnectionMirrors() - - _, ok := cm.Get("foo") - require.False(t, ok) - - cm.Add("foo", 10) - c, ok := cm.Get("foo") - require.True(t, ok) - require.Equal(t, uint32(10), c) +func TestMirrorConnections(t *testing.T) { + mc := NewConnections() - cm.Remove("foo") - _, ok = cm.Get("foo") - require.False(t, ok) -} + localhost := "127.0.0.1" + addr1 := "127.0.0.1:6060" + addr2 := "127.0.0.1:6061" + addr3 := "127.1.1.1:6060" -func TestOutgoingConnections(t *testing.T) { - oc := NewOutgoingConnections(3) + c := mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(0), c) - n := oc.Len() - require.Equal(t, 0, n) + _, err := mc.Add(fakeGnetConn(addr1), ConnectionDetails{ + Mirror: 99, + }) + require.NoError(t, err) - ok := oc.Get("foo") - require.False(t, ok) + c = mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(6060), c) - oc.Add("foo") - ok = oc.Get("foo") - require.True(t, ok) + err = mc.Remove(addr1) + require.NoError(t, err) - n = oc.Len() - require.Equal(t, 1, n) + c = mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(0), c) - oc.Add("foo") - ok = oc.Get("foo") - require.True(t, ok) + _, err = mc.Add(fakeGnetConn(addr2), ConnectionDetails{ + Mirror: 99, + }) + require.NoError(t, err) - n = oc.Len() - require.Equal(t, 1, n) + c = mc.GetMirrorPort(addr2, 99) + require.Equal(t, uint16(6061), c) - oc.Add("foo2") - ok = oc.Get("foo2") - require.True(t, ok) + _, err = mc.Add(fakeGnetConn(addr1), ConnectionDetails{ + Mirror: 99, + }) + require.Equal(t, ErrConnectionIPMirrorAlreadyRegistered, err) - n = oc.Len() - require.Equal(t, 2, n) + c = mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(6061), c) - oc.Remove("foo") - ok = oc.Get("foo") - require.False(t, ok) + _, err = mc.Add(fakeGnetConn(addr1), ConnectionDetails{ + Mirror: 999, + }) - n = oc.Len() - require.Equal(t, 1, n) -} + c = mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(6061), c) + c = mc.GetMirrorPort(localhost, 999) + require.Equal(t, uint16(6060), c) -func TestPendingConns(t *testing.T) { - pc := NewPendingConnections(3) + _, err = mc.Add(fakeGnetConn(addr3), ConnectionDetails{ + Mirror: 99, + }) + require.NoError(t, err) - n := pc.Len() - require.Equal(t, 0, n) + c = mc.GetMirrorPort("127.1.1.1", 99) + require.Equal(t, uint16(6060), c) - _, ok := pc.Get("foo") - require.False(t, ok) + err = mc.Remove(addr2) + require.NoError(t, err) - pc.Add(pex.Peer{Addr: "foo"}) - p, ok := pc.Get("foo") - require.Equal(t, pex.Peer{Addr: "foo"}, p) - require.True(t, ok) + c = mc.GetMirrorPort(localhost, 99) + require.Equal(t, uint16(0), c) + c = mc.GetMirrorPort(localhost, 999) + require.Equal(t, uint16(6060), c) - n = pc.Len() - require.Equal(t, 1, n) + err = mc.Remove(addr1) + require.NoError(t, err) - pc.Add(pex.Peer{Addr: "foo"}) - p, ok = pc.Get("foo") - require.Equal(t, pex.Peer{Addr: "foo"}, p) - require.True(t, ok) + c = mc.GetMirrorPort(localhost, 999) + require.Equal(t, uint16(0), c) - n = pc.Len() - require.Equal(t, 1, n) + err = mc.Remove(addr3) + require.NoError(t, err) - pc.Add(pex.Peer{Addr: "foo2"}) - p, ok = pc.Get("foo2") - require.Equal(t, pex.Peer{Addr: "foo2"}, p) - require.True(t, ok) - - n = pc.Len() - require.Equal(t, 2, n) + c = mc.GetMirrorPort("127.1.1.1", 99) + require.Equal(t, uint16(0), c) } -func TestMirrorConnections(t *testing.T) { - mc := NewMirrorConnections() - - _, ok := mc.Get(99, "foo") - require.False(t, ok) - - mc.Add(99, "foo", 10) - c, ok := mc.Get(99, "foo") - require.True(t, ok) - require.Equal(t, uint16(10), c) - - mc.Remove(99, "foo") - _, ok = mc.Get(99, "foo") - require.False(t, ok) +func TestIPCount(t *testing.T) { + ic := NewConnections() - mc.Add(99, "foo2", 10) - c, ok = mc.Get(99, "foo2") - require.True(t, ok) - require.Equal(t, uint16(10), c) + localhost := "127.0.0.1" + addr1 := "127.0.0.1:6060" + addr2 := "127.0.0.1:6061" - mc.Add(99, "foo", 10) - c, ok = mc.Get(99, "foo") - require.True(t, ok) - require.Equal(t, uint16(10), c) + require.Equal(t, 0, ic.GetIPCount(localhost)) + require.Equal(t, 0, ic.Len()) - mc.Remove(99, "foo2") - _, ok = mc.Get(99, "foo2") + _, ok := ic.Get(addr1) require.False(t, ok) - _, ok = mc.Get(99, "foo") - require.True(t, ok) + _, err := ic.Add(fakeGnetConn(addr1), ConnectionDetails{ + Mirror: 1, + }) + require.NoError(t, err) + require.Equal(t, 1, ic.GetIPCount(localhost)) + + _, err = ic.Add(fakeGnetConn(addr2), ConnectionDetails{ + Mirror: 2, + }) + require.NoError(t, err) + require.Equal(t, 2, ic.GetIPCount(localhost)) + + err = ic.Remove(addr1) + require.NoError(t, err) + require.Equal(t, 1, ic.GetIPCount(localhost)) + + err = ic.Remove(addr1) + require.NoError(t, err) + require.Equal(t, 1, ic.GetIPCount(localhost)) + + err = ic.Remove(addr2) + require.NoError(t, err) + require.Equal(t, 0, ic.GetIPCount(localhost)) } -func TestIPCount(t *testing.T) { - ic := NewIPCount() +func TestConnectionHeightsAll(t *testing.T) { + p := NewConnections() + + addr1 := "127.0.0.1:1234" + addr2 := "127.0.0.1:5678" + addr3 := "127.0.0.1:9999" + + require.Empty(t, p.conns) + err := p.Remove(addr1) + require.NoError(t, err) + require.Empty(t, p.conns) + require.Empty(t, p.mirrors) + require.Empty(t, p.ipCounts) + + e := p.EstimateHeight(1) + require.Equal(t, uint64(1), e) + + e = p.EstimateHeight(13) + require.Equal(t, uint64(13), e) + + _, err = p.Add(fakeGnetConn(addr1), ConnectionDetails{ + Height: 10, + Mirror: 1, + }) + require.NoError(t, err) + require.Len(t, p.conns, 1) + + records := p.All() + require.Len(t, records, 1) + require.Equal(t, addr1, records[0].Addr) + require.Equal(t, 10, records[0].Height) + + err = p.Modify(addr1, func(c *ConnectionDetails) error { + c.Height = 11 + return nil + }) + require.NoError(t, err) + require.Len(t, p.conns, 1) + + records = p.All() + require.Len(t, records, 1) + require.Equal(t, addr1, records[0].Addr) + require.Equal(t, 11, records[0].Height) + + e = p.EstimateHeight(1) + require.Equal(t, uint64(11), e) + + e = p.EstimateHeight(13) + require.Equal(t, uint64(13), e) + + _, err = p.Add(fakeGnetConn(addr2), ConnectionDetails{ + Height: 12, + Mirror: 2, + }) + require.NoError(t, err) + _, err = p.Add(fakeGnetConn(addr3), ConnectionDetails{ + Height: 12, + Mirror: 3, + }) + require.NoError(t, err) + require.Len(t, p.conns, 3) + require.Equal(t, 3, p.Len()) + + records = p.All() + require.Len(t, records, 3) + require.Equal(t, addr1, records[0].Addr) + require.Equal(t, 11, records[0].Height) + require.Equal(t, addr2, records[1].Addr) + require.Equal(t, 12, records[1].Height) + require.Equal(t, addr3, records[2].Addr) + require.Equal(t, 12, records[2].Height) + + e = p.EstimateHeight(1) + require.Equal(t, uint64(12), e) + + e = p.EstimateHeight(13) + require.Equal(t, uint64(13), e) + + _, err = p.Add(fakeGnetConn(addr3), ConnectionDetails{ + Height: 24, + Mirror: 4, + }) + require.NoError(t, err) + e = p.EstimateHeight(13) + require.Equal(t, uint64(24), e) +} - _, ok := ic.Get("foo") - require.False(t, ok) +func fakeGnetConn(addr string) *gnet.Connection { + return &gnet.Connection{ + ID: 111, + LastReceived: time.Now().UTC(), + LastSent: time.Now().UTC(), + Conn: fakeNetConn{ + remoteAddr: fakeNetAddr{ + addr: addr, + }, + }, + } +} - ic.Increase("foo") - n, ok := ic.Get("foo") - require.Equal(t, 1, n) - require.True(t, ok) +type fakeNetAddr struct { + net.Addr + addr string +} - for i := 0; i < 3; i++ { - ic.Decrease("foo") - n, ok = ic.Get("foo") - require.Equal(t, 0, n) - require.False(t, ok) - } +func (f fakeNetAddr) String() string { + return f.addr +} - for i := 0; i < 5; i++ { - ic.Increase("foo") - n, ok := ic.Get("foo") - require.Equal(t, i+1, n) - require.True(t, ok) - } +type fakeNetConn struct { + net.Conn + remoteAddr fakeNetAddr +} - n, ok = ic.Get("foo") - require.Equal(t, 5, n) - require.True(t, ok) +func (f fakeNetConn) RemoteAddr() net.Addr { + return f.remoteAddr } diff --git a/src/daemon/strand/strand.go b/src/daemon/strand/strand.go index 21882736aa..c66eb42972 100644 --- a/src/daemon/strand/strand.go +++ b/src/daemon/strand/strand.go @@ -9,6 +9,8 @@ package strand import ( "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/util/logging" ) @@ -38,7 +40,7 @@ type Request struct { // channel closes. func Strand(logger *logging.Logger, c chan Request, name string, f func() error, quit chan struct{}, quitErr error) error { if Debug { - logger.Debugf("Strand precall %s", name) + logger.WithField("operation", name).Debugf("Strand precall") } done := make(chan struct{}) @@ -69,32 +71,41 @@ func Strand(logger *logging.Logger, c chan Request, name string, f func() error, case <-done: return case <-t.C: - logger.Warningf("%s is taking longer than %s", name, threshold) + logger.WithFields(logrus.Fields{ + "operation": name, + "threshold": threshold, + }).Warning("Strand operation exceeded threshold") threshold *= 10 t.Reset(threshold) } t1 := time.Now() - logger.Infof("ELAPSED: %s", t1.Sub(t0)) + logger.WithField("elapsed", t1.Sub(t0)).Info() } }() if Debug { - logger.Debugf("Stranding %s", name) + logger.WithField("operation", name).Debug("Stranding") } err = f() // Log the error here so that the Request channel consumer doesn't need to if err != nil { - logger.Errorf("%s error: %v", name, err) + logger.WithError(err).WithField("operation", name).Error() } // Notify us if the function call took too long elapsed := time.Since(t) if elapsed > logDurationThreshold { - logger.Warningf("%s took %s", name, elapsed) + logger.WithFields(logrus.Fields{ + "operation": name, + "elapsed": elapsed, + }).Warning() } else if Debug { - logger.Debugf("%s took %s", name, elapsed) + logger.WithFields(logrus.Fields{ + "operation": name, + "elapsed": elapsed, + }).Debug() } return err diff --git a/src/readable/network.go b/src/readable/network.go index b2e09a5b6f..734f89ec79 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -6,29 +6,42 @@ import ( // Connection a connection's state within the daemon type Connection struct { - ID int `json:"id"` + GnetID int `json:"id"` Addr string `json:"address"` LastSent int64 `json:"last_sent"` LastReceived int64 `json:"last_received"` - // Whether the connection is from us to them (true, outgoing), - // or from them to us (false, incoming) - Outgoing bool `json:"outgoing"` - // Whether the client has identified their version, mirror etc - Introduced bool `json:"introduced"` - Mirror uint32 `json:"mirror"` - ListenPort uint16 `json:"listen_port"` - Height uint64 `json:"height"` + ConnectedAt int64 `json:"connected_at"` + Outgoing bool `json:"outgoing"` + State string `json:"state"` + Mirror uint32 `json:"mirror"` + ListenPort uint16 `json:"listen_port"` + Height uint64 `json:"height"` } // NewConnection copies daemon.Connection to a struct with json tags func NewConnection(c *daemon.Connection) Connection { + var lastSent int64 + var lastReceived int64 + var connectedAt int64 + + if !c.LastSent.IsZero() { + lastSent = c.LastSent.Unix() + } + if !c.LastReceived.IsZero() { + lastReceived = c.LastReceived.Unix() + } + if !c.ConnectedAt.IsZero() { + connectedAt = c.ConnectedAt.Unix() + } + return Connection{ - ID: c.ID, + GnetID: c.GnetID, Addr: c.Addr, - LastSent: c.LastSent, - LastReceived: c.LastReceived, + LastSent: lastSent, + LastReceived: lastReceived, + ConnectedAt: connectedAt, Outgoing: c.Outgoing, - Introduced: c.Introduced, + State: string(c.State), Mirror: c.Mirror, ListenPort: c.ListenPort, Height: c.Height, From f7bcd1031c14a812b3983bac89ac965ab65a57c0 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 15:44:27 +0800 Subject: [PATCH 309/399] Revise and fix tests --- src/api/README.md | 38 ++- src/api/integration/integration_test.go | 29 +- src/api/network_test.go | 59 ++-- src/daemon/{storage.go => connections.go} | 235 +++++++------- src/daemon/connections_test.go | 360 ++++++++++++++++++++++ src/daemon/daemon.go | 129 +++----- src/daemon/gateway.go | 98 +++++- src/daemon/gnet/pool_test.go | 30 +- src/daemon/messages.go | 54 ++-- src/daemon/messages_benchmark_test.go | 8 +- src/daemon/messages_example_test.go | 4 +- src/daemon/messages_test.go | 186 +++++------ src/daemon/mock_daemoner_test.go | 54 +--- src/daemon/pex/peerlist.go | 4 +- src/daemon/pex/pex.go | 14 +- src/daemon/pex/pex_test.go | 6 +- src/daemon/storage_test.go | 341 -------------------- src/readable/network.go | 22 +- src/util/iputil/iputil.go | 16 +- src/util/iputil/iputil_test.go | 9 +- 20 files changed, 850 insertions(+), 846 deletions(-) rename src/daemon/{storage.go => connections.go} (58%) create mode 100644 src/daemon/connections_test.go delete mode 100644 src/daemon/storage_test.go diff --git a/src/api/README.md b/src/api/README.md index b6d7e70939..943966b700 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3562,6 +3562,11 @@ Args: addr: ip:port address of a known connection ``` +Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. +The `"pending"` state is prior to connection establishment. +The `"connected"` state is after connection establishment, but before the introduction handshake has completed. +The `"introduced"` state is after the introduction handshake has completed. + Example: ```sh @@ -3576,8 +3581,9 @@ Result: "address": "176.9.84.75:6000", "last_sent": 1520675817, "last_received": 1520675817, + "connected_at": 1520675700, "outgoing": false, - "introduced": true, + "state": "introduced", "mirror": 719118746, "height": 181, "listen_port": 6000 @@ -3593,6 +3599,11 @@ URI: /api/v1/network/connections Method: GET ``` +Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. +The `"pending"` state is prior to connection establishment. +The `"connected"` state is after connection establishment, but before the introduction handshake has completed. +The `"introduced"` state is after the introduction handshake has completed. + Example: ```sh @@ -3609,33 +3620,36 @@ Result: "address": "139.162.161.41:20002", "last_sent": 1520675750, "last_received": 1520675750, + "connected_at": 1520675500, "outgoing": false, - "introduced": true, + "state": "introduced", "mirror": 1338939619, - "height": 180, - "listen_port": 20002 + "listen_port": 20002, + "height": 180 }, { "id": 109548, "address": "176.9.84.75:6000", "last_sent": 1520675751, "last_received": 1520675751, - "outgoing": false, - "introduced": true, - "mirror": 719118746, - "height": 182, - "listen_port": 6000 + "connected_at": 1520675751, + "state": "connected", + "outgoing": true, + "mirror": 0, + "listen_port": 6000, + "height": 0 }, { "id": 99115, "address": "185.120.34.60:6000", "last_sent": 1520675754, "last_received": 1520675754, + "connected_at": 1520673013, "outgoing": false, - "introduced": true, + "state": "introduced", "mirror": 1931713869, - "height": 180, - "listen_port": 6000 + "listen_port": 6000, + "height": 180 } ] } diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index a2875cc107..ba8dde3dac 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -27,6 +27,7 @@ import ( "github.com/skycoin/skycoin/src/api" "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/daemon" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/util/droplet" @@ -1829,19 +1830,43 @@ func TestLiveNetworkConnections(t *testing.T) { require.NotEmpty(t, connections.Connections) + checked := false + for _, cc := range connections.Connections { connection, err := c.NetworkConnection(cc.Addr) + + // The connection may have disconnected by now + if err != nil { + assertResponseError(t, err, http.StatusNotFound, "404 Not Found") + continue + } + require.NoError(t, err) require.NotEmpty(t, cc.Addr) require.Equal(t, cc.Addr, connection.Addr) - require.Equal(t, cc.ID, connection.ID) + require.Equal(t, cc.GnetID, connection.GnetID) require.Equal(t, cc.ListenPort, connection.ListenPort) require.Equal(t, cc.Mirror, connection.Mirror) - require.Equal(t, cc.Introduced, connection.Introduced) + + switch cc.State { + // If the connection was introduced it should stay introduced + case daemon.ConnectionStateIntroduced: + require.Equal(t, daemon.ConnectionStateIntroduced, connection.State) + // If the connection was connected it should stay connected or have become introduced + case daemon.ConnectionStateConnected: + require.NotEqual(t, daemon.ConnectionStatePending, connection.State) + } + require.Equal(t, cc.Outgoing, connection.Outgoing) require.True(t, cc.LastReceived <= connection.LastReceived) require.True(t, cc.LastSent <= connection.LastSent) + + checked = true } + + // This could unfortunately occur if a connection disappeared in between the two calls, + // which will require a test re-run. + require.True(t, checked, "Was not able to find any connection by address, despite finding connections when querying all") } func TestNetworkDefaultConnections(t *testing.T) { diff --git a/src/api/network_test.go b/src/api/network_test.go index eb8224a17a..09be74ca9c 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -8,6 +8,7 @@ import ( "net/url" "strings" "testing" + "time" "github.com/stretchr/testify/require" @@ -48,24 +49,28 @@ func TestConnection(t *testing.T) { err: "", addr: "addr", gatewayGetConnectionResult: &daemon.Connection{ - ID: 1, - Addr: "127.0.0.1", - LastSent: 99999, - LastReceived: 1111111, - Outgoing: true, - Introduced: true, - Mirror: 9876, - ListenPort: 9877, - Height: 1234, + Addr: "127.0.0.1:6061", + GnetConnectionDetails: daemon.GnetConnectionDetails{ + GnetID: 1, + LastSent: time.Unix(99999, 0), + LastReceived: time.Unix(1111111, 0), + }, + ConnectionDetails: daemon.ConnectionDetails{ + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + Mirror: 6789, + ListenPort: 9877, + Height: 1234, + }, }, result: &readable.Connection{ - ID: 1, - Addr: "127.0.0.1", + Addr: "127.0.0.1:6061", + GnetID: 1, LastSent: 99999, LastReceived: 1111111, Outgoing: true, - Introduced: true, - Mirror: 9876, + State: daemon.ConnectionStateIntroduced, + Mirror: 6789, ListenPort: 9877, Height: 1234, }, @@ -147,26 +152,30 @@ func TestConnections(t *testing.T) { err: "", gatewayGetSolicitedConnectionsResult: []daemon.Connection{ { - ID: 1, - Addr: "127.0.0.1", - LastSent: 99999, - LastReceived: 1111111, - Outgoing: true, - Introduced: true, - Mirror: 9876, - ListenPort: 9877, - Height: 1234, + Addr: "127.0.0.1:6061", + GnetConnectionDetails: daemon.GnetConnectionDetails{ + GnetID: 1, + LastSent: time.Unix(99999, 0), + LastReceived: time.Unix(1111111, 0), + }, + ConnectionDetails: daemon.ConnectionDetails{ + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + }, }, }, result: Connections{ Connections: []readable.Connection{ { - ID: 1, - Addr: "127.0.0.1", + Addr: "127.0.0.1:6061", + GnetID: 1, LastSent: 99999, LastReceived: 1111111, Outgoing: true, - Introduced: true, + State: daemon.ConnectionStateIntroduced, Mirror: 9876, ListenPort: 9877, Height: 1234, diff --git a/src/daemon/storage.go b/src/daemon/connections.go similarity index 58% rename from src/daemon/storage.go rename to src/daemon/connections.go index 37a5192440..5f70b30db4 100644 --- a/src/daemon/storage.go +++ b/src/daemon/connections.go @@ -2,16 +2,24 @@ package daemon import ( "errors" + "fmt" "sync" "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/util/iputil" ) // ConnectionState connection state in the state machine +// Connections have three states: "pending", "connected" and "introduced" +// A connection in the "pending" state has been selected to establish a TCP connection, +// but the connection has not been established yet. +// Only outgoing connections will ever be in the "pending" state; +// incoming connections begin at the "connected" state. +// A connection in the "connected" state has established a TCP connection, +// but has not completed the introduction handshake. +// A connection in the "introduced" state has completed the introduction handshake. type ConnectionState string const ( @@ -30,20 +38,9 @@ var ( ErrConnectionAlreadyRegistered = errors.New("Connection already registered") // ErrConnectionIPMirrorAlreadyRegistered connection already registered for a given base IP and mirror ErrConnectionIPMirrorAlreadyRegistered = errors.New("Connection already registered with this base IP and mirror") - // ErrMirrorZero mirror value is 0 - ErrMirrorZero = errors.New("Mirror cannot be 0") ) -// Connection a connection's state within the daemon -type Connection struct { - GnetID int - LastSent time.Time - LastReceived time.Time - Addr string - ConnectionDetails -} - -// ConnectionDetails extra connection data +// ConnectionDetails connection data managed by daemon type ConnectionDetails struct { State ConnectionState Outgoing bool @@ -64,29 +61,24 @@ func (c ConnectionDetails) HasIntroduced() bool { } } -func newConnection(c *connection) Connection { - if c == nil { - return Connection{} - } +type connection struct { + Addr string + ConnectionDetails +} - conn := Connection{ - Addr: c.addr, - ConnectionDetails: c.ConnectionDetails, +// ListenAddr returns the addr that connection listens on, if available +func (c *connection) ListenAddr() string { + if c.ListenPort == 0 { + return "" } - if c.gnetConnection != nil { - conn.GnetID = c.gnetConnection.ID - conn.LastSent = c.gnetConnection.LastSent - conn.LastReceived = c.gnetConnection.LastReceived + ip, _, err := iputil.SplitAddr(c.Addr) + if err != nil { + logger.Critical().WithError(err).WithField("addr", c.Addr).Error("connection.ListenAddr addr could not be split") + return "" } - return conn -} - -type connection struct { - gnetConnection *gnet.Connection - addr string - ConnectionDetails + return fmt.Sprintf("%s:%d", ip, c.ListenPort) } // Connections manages a collection of Connection @@ -106,41 +98,44 @@ func NewConnections() *Connections { } } -// AddPendingOutgoing adds a new pending outgoing connection -func (c *Connections) AddPendingOutgoing(addr string) (Connection, error) { +// pending adds a new pending outgoing connection +func (c *Connections) pending(addr string) (*connection, error) { c.Lock() defer c.Unlock() - ip, _, err := iputil.SplitAddr(addr) + ip, port, err := iputil.SplitAddr(addr) if err != nil { - return Connection{}, err + return nil, err + } + + if _, ok := c.conns[addr]; ok { + return nil, ErrConnectionAlreadyRegistered } c.ipCounts[ip]++ c.conns[addr] = &connection{ - addr: addr, + Addr: addr, ConnectionDetails: ConnectionDetails{ - State: ConnectionStatePending, - Outgoing: true, + State: ConnectionStatePending, + Outgoing: true, + ListenPort: port, }, } logger.WithField("addr", addr).Debug("AddPendingOutgoing") - return newConnection(c.conns[addr]), nil + return c.conns[addr], nil } -// Connected the connection has connected -func (c *Connections) Connected(gnetConn *gnet.Connection) (Connection, error) { +// connected the connection has connected +func (c *Connections) connected(addr string) (*connection, error) { c.Lock() defer c.Unlock() - addr := gnetConn.Addr() - ip, _, err := iputil.SplitAddr(addr) if err != nil { - return Connection{}, err + return nil, err } conn := c.conns[addr] @@ -149,23 +144,22 @@ func (c *Connections) Connected(gnetConn *gnet.Connection) (Connection, error) { c.ipCounts[ip]++ conn = &connection{ - addr: addr, + Addr: addr, } c.conns[addr] = conn } else { - if addr != conn.addr { + if addr != conn.Addr { err := errors.New("gnet.Connection.Addr does not match recorded Connection address") logger.Critical().WithError(err).Error() - return Connection{}, err + return nil, err } if conn.State != ConnectionStatePending { - logger.Critical().WithField("state", conn.State).Warning("Transitioning to State connected but State is not pending") + logger.Critical().WithField("state", conn.State).Warningf("Transitioning to State %q but State is not %q", ConnectionStateConnected, ConnectionStatePending) } } - conn.gnetConnection = gnetConn conn.ConnectedAt = time.Now().UTC() conn.State = ConnectionStateConnected @@ -174,68 +168,92 @@ func (c *Connections) Connected(gnetConn *gnet.Connection) (Connection, error) { "outgoing": conn.Outgoing, }).Debug("Connected") - return newConnection(conn), nil + return conn, nil } -// Introduced the connection has introduced itself -func (c *Connections) Introduced(addr string, m *IntroductionMessage) (Connection, error) { +// introduced the connection has introduced itself +func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connection, error) { c.Lock() defer c.Unlock() - ip, port, err := iputil.SplitAddr(addr) + ip, _, err := iputil.SplitAddr(addr) if err != nil { - return Connection{}, err - } - - if err := c.canUpdateMirror(ip, port, m.Mirror); err != nil { - return Connection{}, err + return nil, err } conn := c.conns[addr] if conn == nil { - return Connection{}, ErrConnectionNotExist + return nil, ErrConnectionNotExist + } + + listenPort := conn.ListenPort + if !conn.Outgoing { + listenPort = m.ListenPort } - if err := c.updateMirror(ip, port, m.Mirror); err != nil { + if conn.State != ConnectionStateConnected { + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "state": conn.State, + }).Warningf("Transitioning to State %q but State is not %q", ConnectionStateIntroduced, ConnectionStateConnected) + } + + if err := c.canUpdateMirror(ip, m.Mirror, listenPort); err != nil { + return nil, err + } + + // For outgoing connections, which are created by pending, + // the listen port is set from the addr's port number. + // Since we are connecting to it, it is presumed to be that peer's open listening port. + // A misbehaving peer could report a different ListenPort in their IntroductionMessage, + // but it shouldn't affect our records. + if conn.Outgoing && conn.ListenPort != m.ListenPort { + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "connListenPort": listenPort, + "messageListenPort": m.ListenPort, + }).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") + } + + if err := c.updateMirror(ip, m.Mirror, listenPort); err != nil { logger.WithError(err).Panic("updateMirror failed, but shouldn't") } conn.State = ConnectionStateIntroduced conn.Mirror = m.Mirror - conn.ListenPort = m.Port - conn.ProtocolVersion = m.Version + conn.ProtocolVersion = m.ProtocolVersion + conn.ListenPort = listenPort logger.WithFields(logrus.Fields{ "addr": addr, "outgoing": conn.Outgoing, }).Debug("Introduced") - return newConnection(conn), nil + return conn, nil } -// Get returns a connection by address -func (c *Connections) Get(addr string) (Connection, bool) { +// get returns a connection by address +func (c *Connections) get(addr string) *connection { c.Lock() defer c.Unlock() - conn, ok := c.conns[addr] - return newConnection(conn), ok + return c.conns[addr] } // modify modifies a connection. // It is unsafe to modify the Mirror value with this method -func (c *Connections) modify(addr string, f func(c *ConnectionDetails) error) error { +func (c *Connections) modify(addr string, f func(c *ConnectionDetails)) error { conn := c.conns[addr] if conn == nil { return ErrConnectionNotExist } + // copy and modify cd := conn.ConnectionDetails - if err := f(&cd); err != nil { - return err - } + f(&cd) + // compare to original if cd.Mirror != conn.ConnectionDetails.Mirror { logger.Panic("Connections.modify connection mirror value was changed") } @@ -250,47 +268,32 @@ func (c *Connections) SetHeight(addr string, height uint64) error { c.Lock() defer c.Unlock() - return c.modify(addr, func(c *ConnectionDetails) error { + return c.modify(addr, func(c *ConnectionDetails) { c.Height = height - return nil }) } -// GetMirrorPort returns the port matching a given IP address (without port) and mirror value -func (c *Connections) GetMirrorPort(ip string, mirror uint32) uint16 { - c.Lock() - defer c.Unlock() - - x := c.mirrors[mirror] - if x == nil { - return 0 - } - - return x[ip] -} - -func (c *Connections) updateMirror(ip string, port uint16, mirror uint32) error { - if mirror == 0 { - return ErrMirrorZero - } +func (c *Connections) updateMirror(ip string, mirror uint32, port uint16) error { + logger.Debugf("updateMirror ip=%s mirror=%d port=%d", ip, mirror, port) x := c.mirrors[mirror] if x == nil { x = make(map[string]uint16, 2) } + if _, ok := x[ip]; ok { return ErrConnectionIPMirrorAlreadyRegistered } + x[ip] = port + c.mirrors[mirror] = x return nil } -func (c *Connections) canUpdateMirror(ip string, port uint16, mirror uint32) error { - if mirror == 0 { - return ErrMirrorZero - } - +// canUpdateMirror returns false if a connection already exists with the same base IP and mirror value. +// This prevents duplicate connections to/from a single client. +func (c *Connections) canUpdateMirror(ip string, mirror uint32, port uint16) error { x := c.mirrors[mirror] if x == nil { return nil @@ -303,8 +306,8 @@ func (c *Connections) canUpdateMirror(ip string, port uint16, mirror uint32) err return nil } -// GetIPCount returns the number of connections for a given base IP (without port) -func (c *Connections) GetIPCount(ip string) int { +// IPCount returns the number of connections for a given base IP (without port) +func (c *Connections) IPCount(ip string) int { c.Lock() defer c.Unlock() return c.ipCounts[ip] @@ -343,15 +346,12 @@ func (c *Connections) PendingLen() int { return n } -// Remove removes connection. Returns an error if the addr is invalid. +// remove removes connection. Returns an error if the addr is invalid. // If a connection with this address does not exist, nothing happens. -func (c *Connections) Remove(addr string) error { +func (c *Connections) remove(addr string) error { c.Lock() defer c.Unlock() - return c.remove(addr) -} -func (c *Connections) remove(addr string) error { ip, port, err := iputil.SplitAddr(addr) if err != nil { return err @@ -384,37 +384,14 @@ func (c *Connections) remove(addr string) error { return nil } -// RemoveMatchedBy remove connections that match the matchFunc and return them -func (c *Connections) RemoveMatchedBy(f func(c Connection) (bool, error)) ([]string, error) { - c.Lock() - defer c.Unlock() - - var addrs []string - for addr, conn := range c.conns { - if ok, err := f(newConnection(conn)); err != nil { - return nil, err - } else if ok { - addrs = append(addrs, addr) - } - } - - for _, a := range addrs { - if err := c.remove(a); err != nil { - logger.WithError(err).Panic("Invalid address stored inside Connections") - } - } - - return addrs, nil -} - -// All returns a copy of all connections -func (c *Connections) All() []Connection { +// all returns a copy of all connections +func (c *Connections) all() []connection { c.Lock() defer c.Unlock() - conns := make([]Connection, 0, len(c.conns)) + conns := make([]connection, 0, len(c.conns)) for _, c := range c.conns { - conns = append(conns, newConnection(c)) + conns = append(conns, *c) } return conns diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go new file mode 100644 index 0000000000..3cbeee87fa --- /dev/null +++ b/src/daemon/connections_test.go @@ -0,0 +1,360 @@ +package daemon + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/skycoin/skycoin/src/testutil" +) + +func getMirrorPort(c *Connections, ip string, mirror uint32) uint16 { + c.Lock() + defer c.Unlock() + + logger.Debugf("getMirrorPort ip=%s mirror=%d", ip, mirror) + + x := c.mirrors[mirror] + if x == nil { + return 0 + } + + return x[ip] +} + +func TestConnectionsOutgoingFlow(t *testing.T) { + conns := NewConnections() + + ip := "127.0.0.1" + port := uint16(6060) + addr := fmt.Sprintf("%s:%d", ip, port) + + all := conns.all() + require.Empty(t, all) + + require.Equal(t, 0, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 0, conns.Len()) + require.Empty(t, conns.mirrors) + + // Flow: pending, connected, introduced + + c, err := conns.pending(addr) + require.NoError(t, err) + + require.True(t, c.Outgoing) + require.Equal(t, addr, c.Addr) + require.Equal(t, port, c.ListenPort) + require.Equal(t, ConnectionStatePending, c.State) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 1, conns.OutgoingLen()) + require.Equal(t, 1, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Empty(t, c.Mirror) + require.Empty(t, conns.mirrors) + require.False(t, c.HasIntroduced()) + require.Equal(t, addr, c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + _, err = conns.pending(addr) + require.Equal(t, ErrConnectionAlreadyRegistered, err) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 1, conns.OutgoingLen()) + require.Equal(t, 1, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Empty(t, conns.mirrors) + require.False(t, c.HasIntroduced()) + require.Equal(t, addr, c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + c, err = conns.connected(addr) + require.NoError(t, err) + + require.True(t, c.Outgoing) + require.Equal(t, addr, c.Addr) + require.Equal(t, port, c.ListenPort) + require.Equal(t, ConnectionStateConnected, c.State) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 1, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Empty(t, c.Mirror) + require.Empty(t, conns.mirrors) + require.False(t, c.HasIntroduced()) + require.Equal(t, addr, c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + m := &IntroductionMessage{ + // use a different port to make sure we don't overwrite the true listen port + ListenPort: port + 1, + Mirror: 1111, + ProtocolVersion: 2, + } + + c, err = conns.introduced(addr, m) + require.NoError(t, err) + + require.True(t, c.Outgoing) + require.Equal(t, addr, c.Addr) + require.Equal(t, port, c.ListenPort) + require.Equal(t, ConnectionStateIntroduced, c.State) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 1, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Equal(t, m.Mirror, c.Mirror) + require.Equal(t, m.ProtocolVersion, c.ProtocolVersion) + require.Len(t, conns.mirrors, 1) + require.Equal(t, port, getMirrorPort(conns, ip, c.Mirror)) + require.True(t, c.HasIntroduced()) + require.Equal(t, addr, c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + err = conns.remove(addr) + require.NoError(t, err) + + require.Equal(t, 0, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 0, conns.Len()) + require.Empty(t, conns.mirrors) + + all = conns.all() + require.Empty(t, all) + + c = conns.get(addr) + require.Nil(t, c) +} + +func TestConnectionsIncomingFlow(t *testing.T) { + conns := NewConnections() + + ip := "127.0.0.1" + port := uint16(6060) + addr := fmt.Sprintf("%s:%d", ip, port) + + all := conns.all() + require.Empty(t, all) + + require.Equal(t, 0, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 0, conns.Len()) + require.Empty(t, conns.mirrors) + + // Flow: connected, introduced + + c, err := conns.connected(addr) + require.NoError(t, err) + + require.False(t, c.Outgoing) + require.Equal(t, addr, c.Addr) + require.Empty(t, c.ListenPort) + require.Equal(t, ConnectionStateConnected, c.State) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Empty(t, c.Mirror) + require.Empty(t, conns.mirrors) + require.False(t, c.HasIntroduced()) + require.Empty(t, c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + m := &IntroductionMessage{ + // use a different port to make sure that we use the self-reported listen port for incoming connections + ListenPort: port + 1, + Mirror: 1111, + ProtocolVersion: 2, + } + + c, err = conns.introduced(addr, m) + require.NoError(t, err) + + require.False(t, c.Outgoing) + require.Equal(t, addr, c.Addr) + require.Equal(t, m.ListenPort, c.ListenPort) + require.Equal(t, ConnectionStateIntroduced, c.State) + require.Equal(t, 1, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 1, conns.Len()) + require.Equal(t, m.Mirror, c.Mirror) + require.Equal(t, m.ProtocolVersion, c.ProtocolVersion) + require.Len(t, conns.mirrors, 1) + require.Equal(t, m.ListenPort, getMirrorPort(conns, ip, c.Mirror)) + require.True(t, c.HasIntroduced()) + require.Equal(t, fmt.Sprintf("%s:%d", ip, m.ListenPort), c.ListenAddr()) + + all = conns.all() + require.Equal(t, []connection{*c}, all) + + err = conns.remove(addr) + require.NoError(t, err) + + require.Equal(t, 0, conns.IPCount(ip)) + require.Equal(t, 0, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 0, conns.Len()) + require.Empty(t, conns.mirrors) + + all = conns.all() + require.Empty(t, all) + + c = conns.get(addr) + require.Nil(t, c) +} + +func TestConnectionsMultiple(t *testing.T) { + conns := NewConnections() + + addr1 := "127.0.0.1:6060" + addr2 := "127.0.0.1:6061" + + _, err := conns.pending(addr1) + require.NoError(t, err) + + _, err = conns.pending(addr2) + require.NoError(t, err) + + require.Equal(t, 2, conns.OutgoingLen()) + require.Equal(t, 2, conns.PendingLen()) + require.Equal(t, 2, conns.IPCount("127.0.0.1")) + + _, err = conns.connected(addr1) + require.NoError(t, err) + require.Equal(t, 1, conns.PendingLen()) + + _, err = conns.connected(addr2) + require.NoError(t, err) + require.Equal(t, 0, conns.PendingLen()) + + _, err = conns.introduced(addr1, &IntroductionMessage{ + Mirror: 6, + ListenPort: 6060, + ProtocolVersion: 2, + }) + require.NoError(t, err) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 1, len(conns.mirrors)) + + // introduction fails if a base IP + mirror is already in use + _, err = conns.introduced(addr2, &IntroductionMessage{ + Mirror: 6, + ListenPort: 6061, + ProtocolVersion: 2, + }) + require.Equal(t, ErrConnectionIPMirrorAlreadyRegistered, err) + require.Equal(t, 0, conns.PendingLen()) + + c := conns.get(addr2) + require.Equal(t, ConnectionStateConnected, c.State) + + _, err = conns.introduced(addr2, &IntroductionMessage{ + Mirror: 7, + ListenPort: 6061, + ProtocolVersion: 2, + }) + require.NoError(t, err) + require.Equal(t, 2, len(conns.mirrors)) + require.Equal(t, 2, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 2, conns.Len()) + require.Equal(t, 2, conns.IPCount("127.0.0.1")) + + // Add another connection with a different base IP but same mirror value + addr3 := "127.1.1.1:12345" + _, err = conns.connected(addr3) + require.NoError(t, err) + + _, err = conns.introduced(addr3, &IntroductionMessage{ + Mirror: 6, + ListenPort: 6060, + ProtocolVersion: 2, + }) + require.NoError(t, err) + + require.Equal(t, 2, len(conns.mirrors)) + require.Equal(t, 2, len(conns.mirrors[6])) + require.Equal(t, uint16(6060), getMirrorPort(conns, "127.0.0.1", 6)) + require.Equal(t, uint16(6061), getMirrorPort(conns, "127.0.0.1", 7)) + require.Equal(t, uint16(6060), getMirrorPort(conns, "127.1.1.1", 6)) + + require.Equal(t, 2, conns.OutgoingLen()) + require.Equal(t, 0, conns.PendingLen()) + require.Equal(t, 3, conns.Len()) + require.Equal(t, 2, conns.IPCount("127.0.0.1")) + require.Equal(t, 1, conns.IPCount("127.1.1.1")) + + err = conns.remove(addr1) + err = conns.remove(addr2) + err = conns.remove(addr3) + require.NoError(t, err) + require.Empty(t, conns.mirrors) + require.Equal(t, 0, conns.Len()) +} + +func TestConnectionsErrors(t *testing.T) { + conns := NewConnections() + + _, err := conns.pending("foo") + testutil.RequireError(t, err, "address foo: missing port in address") + + _, err = conns.connected("foo") + testutil.RequireError(t, err, "address foo: missing port in address") + + _, err = conns.introduced("foo", nil) + testutil.RequireError(t, err, "address foo: missing port in address") + + err = conns.remove("foo") + testutil.RequireError(t, err, "address foo: missing port in address") + + _, err = conns.introduced("127.0.0.1:6060", &IntroductionMessage{}) + require.Equal(t, ErrConnectionNotExist, err) +} + +func TestConnectionsSetHeight(t *testing.T) { + conns := NewConnections() + addr := "127.0.0.1:6060" + height := uint64(1010) + + err := conns.SetHeight(addr, height) + require.Equal(t, ErrConnectionNotExist, err) + + c, err := conns.connected(addr) + require.NoError(t, err) + require.Empty(t, c.Height) + + err = conns.SetHeight(addr, height) + + c = conns.get(addr) + require.NotNil(t, c) + require.Equal(t, height, c.Height) +} + +func TestConnectionsModifyMirrorPanics(t *testing.T) { + conns := NewConnections() + addr := "127.0.0.1:6060" + + _, err := conns.connected(addr) + require.NoError(t, err) + + // modifying mirror value causes panic + require.Panics(t, func() { + conns.modify(addr, func(c *ConnectionDetails) { + c.Mirror++ + }) // nolint: errcheck + }) +} diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 189922345f..e368af7927 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -52,10 +52,6 @@ var ( // ErrDisconnectInvalidExtraData is returned when extra field can't be parsed as specific data type. // e.g. ExtraData length in IntroductionMessage is not the same as cipher.PubKey ErrDisconnectInvalidExtraData gnet.DisconnectReason = errors.New("Invalid extra data") - // ErrDisconnectMirrorInUse mirror value is already in use by another connection with a matching base IP - ErrDisconnectMirrorInUse gnet.DisconnectReason = errors.New("Mirror value already in use") - // ErrDisconnectInvalidMirror mirror value is invalid - ErrDisconnectInvalidMirror gnet.DisconnectReason = errors.New("Mirror value is invalid") // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") @@ -243,7 +239,6 @@ type Daemoner interface { DaemonConfig() DaemonConfig BlockchainPubkey() cipher.PubKey RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error - GetMirrorPort(addr string, mirror uint32) uint16 ConnectionIntroduced(addr string, m *IntroductionMessage) error RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error @@ -661,23 +656,6 @@ loop: return nil } -// GetListenPort returns the ListenPort for a given address. -// If no port is found, 0 is returned. -func (dm *Daemon) GetListenPort(addr string) uint16 { - c, ok := dm.connections.Get(addr) - if !ok { - return 0 - } - - ip, _, err := iputil.SplitAddr(addr) - if err != nil { - logger.Errorf("GetListenPort received invalid addr: %v", err) - return 0 - } - - return dm.connections.GetMirrorPort(ip, c.Mirror) -} - // Connects to a given peer. Returns an error if no connection attempt was // made. If the connection attempt itself fails, the error is sent to // the connectionErrors channel. @@ -695,28 +673,18 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { return errors.New("Not localhost") } - conned, err := dm.pool.Pool.IsConnExist(p.Addr) - if err != nil { - return err - } - - if conned { - return errors.New("Already connected") - } - - c, ok := dm.connections.Get(p.Addr) - if ok && c.State == ConnectionStatePending { - errors.New("Connection is pending") + if c := dm.connections.get(p.Addr); c != nil { + return errors.New("Already connected to this peer") } - cnt := dm.connections.GetIPCount(a) + cnt := dm.connections.IPCount(a) if !dm.Config.LocalhostOnly && cnt != 0 { return errors.New("Already connected to a peer with this base IP") } logger.WithField("addr", p.Addr).Debug("Establishing outgoing conneciton") - if _, err := dm.connections.AddPendingOutgoing(p.Addr); err != nil { + if _, err := dm.connections.pending(p.Addr); err != nil { logger.Critical().WithError(err).WithField("addr", p.Addr).Error("AddPendingOutgoing failed") return err } @@ -766,37 +734,24 @@ func (dm *Daemon) connectToRandomPeer() { } // Make a connection to a random (public) peer - peers := dm.pex.RandomPublic(dm.Config.OutgoingMax) + peers := dm.pex.RandomPublicUntrusted(dm.Config.OutgoingMax) for _, p := range peers { - // Check if the peer has public port - if p.HasIncomingPort { - // Try to connect the peer if it's ip:mirror does not exist - if port := dm.GetMirrorPort(p.Addr, dm.Messages.Mirror); port == 0 { - if err := dm.connectToPeer(p); err != nil { - logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") - } - continue - } - } else { - // Try to connect to the peer if we don't know whether the peer have public port - if err := dm.connectToPeer(p); err != nil { - logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") - } - continue + if err := dm.connectToPeer(p); err != nil { + logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") } } if len(peers) == 0 { - // Reset the retry times of all peers, dm.pex.ResetAllRetryTimes() } } -// We remove a peer from the Pex if we failed to connect +// handleConnectionError removes the pending connection from connections and +// updates the retry times in pex func (dm *Daemon) handleConnectionError(c ConnectionError) { logger.WithField("addr", c.Addr).WithError(c.Error).Debug("handleConnectionError") - if err := dm.connections.Remove(c.Addr); err != nil { - logger.WithField("addr", c.Addr).WithError(err).Error("connections.Remove") + if err := dm.connections.remove(c.Addr); err != nil { + logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } // TODO - On failure to connect, use exponential backoff, not peer list @@ -806,36 +761,22 @@ func (dm *Daemon) handleConnectionError(c ConnectionError) { // Removes connections who haven't sent a version after connecting func (dm *Daemon) cullInvalidConnections() { now := time.Now().UTC() - addrs, err := dm.connections.RemoveMatchedBy(func(c Connection) (bool, error) { + for _, c := range dm.connections.all() { if c.State != ConnectionStateConnected { - return false, nil + continue } if c.ConnectedAt.Add(dm.Config.IntroductionWait).Before(now) { - return true, nil - } - return false, nil - }) - - if err != nil { - logger.WithError(err).Error("cullInvalidConnections failed") - return - } - - for _, a := range addrs { - logger.WithField("addr", a).Infof("Disconnecting peer for not sending a version") - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIntroductionTimeout); err != nil { - logger.WithError(err).WithField("addr", a).Error("Disconnect") - } - - if !dm.isTrustedPeer(a) { - dm.pex.RemovePeer(a) + logger.WithField("addr", c.Addr).Infof("Disconnecting peer for not sending a version") + if err := dm.Disconnect(c.Addr, ErrDisconnectIntroductionTimeout); err != nil { + logger.WithError(err).WithField("addr", c.Addr).Error("Disconnect") + } } } } func (dm *Daemon) isTrustedPeer(addr string) bool { - peer, ok := dm.pex.GetPeerByAddr(addr) + peer, ok := dm.pex.GetPeer(addr) if !ok { return false } @@ -852,11 +793,11 @@ func (dm *Daemon) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) err // needsIntro check if the connection needs introduction message func (dm *Daemon) needsIntro(addr string) bool { - c, ok := dm.connections.Get(addr) - if !ok { + c := dm.connections.get(addr) + if c == nil { logger.WithField("addr", addr).Warning("needsIntro did not find a matching connection") } - return ok && !c.HasIntroduced() + return c != nil && !c.HasIntroduced() } // Processes a queued AsyncMessage. @@ -932,9 +873,12 @@ func (dm *Daemon) onConnect(e ConnectEvent) { } // Update the connections state machine - c, err := dm.connections.Connected(e.Conn) + c, err := dm.connections.connected(e.Conn.Addr()) if err != nil { logger.Critical().WithError(err).WithField("addr", a).Error("connections.Connected failed") + if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIncomprehensibleError); err != nil { + logger.WithError(err).WithField("addr", a).Error("Disconnect") + } return } @@ -961,9 +905,16 @@ func (dm *Daemon) onDisconnect(e DisconnectEvent) { "reason": e.Reason, }).Info("onDisconnect") - if err := dm.connections.Remove(e.Addr); err != nil { + if err := dm.connections.remove(e.Addr); err != nil { logger.WithError(err).WithField("addr", e.Addr).Error("connections.Remove failed") } + + // If the peer did not send an introduction in time, it is not a valid peer and remove it from the peer list + if e.Reason == ErrDisconnectIntroductionTimeout { + if !dm.isTrustedPeer(e.Addr) { + dm.pex.RemovePeer(e.Addr) + } + } } // Triggered when an gnet.Connection terminates @@ -995,17 +946,7 @@ func (dm *Daemon) ipCountMaxed(addr string) bool { return true } - return dm.connections.GetIPCount(ip) >= dm.Config.IPCountsMax -} - -// GetMirrorPort returns whether an addr+mirror's port. If port is 0 then it does not exist. -func (dm *Daemon) GetMirrorPort(addr string, mirror uint32) uint16 { - ip, _, err := iputil.SplitAddr(addr) - if err != nil { - logger.WithError(err).WithField("addr", addr).Error("getMirrorPort called with invalid addr") - return 0 - } - return dm.connections.GetMirrorPort(ip, mirror) + return dm.connections.IPCount(ip) >= dm.Config.IPCountsMax } // When an async message send finishes, its result is handled by this. @@ -1258,7 +1199,7 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { // ConnectionIntroduced removes the peer from expect introduction pool func (dm *Daemon) ConnectionIntroduced(addr string, m *IntroductionMessage) error { - _, err := dm.connections.Introduced(addr, m) + _, err := dm.connections.introduced(addr, m) return err } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 333aefabdf..815b7567a3 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -9,6 +9,8 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/daemon/strand" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/dbutil" @@ -84,6 +86,44 @@ func (gw *Gateway) strand(name string, f func()) { } } +// Connection a connection's state within the daemon +type Connection struct { + Addr string + Pex pex.Peer + ConnectionDetails + GnetConnectionDetails +} + +// GnetConnectionDetails connection data from gnet +type GnetConnectionDetails struct { + GnetID int + LastSent time.Time + LastReceived time.Time +} + +func newConnection(dc *connection, gc *gnet.Connection, pp *pex.Peer) Connection { + c := Connection{} + + if dc != nil { + c.Addr = dc.Addr + c.ConnectionDetails = dc.ConnectionDetails + } + + if gc != nil { + c.GnetConnectionDetails = GnetConnectionDetails{ + GnetID: gc.ID, + LastSent: gc.LastSent, + LastReceived: gc.LastReceived, + } + } + + if pp != nil { + c.Pex = *pp + } + + return c +} + // GetOutgoingConnections returns solicited (outgoing) connections func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { var conns []Connection @@ -99,14 +139,21 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { return nil, nil } - cs := gw.d.connections.All() + cs := gw.d.connections.all() conns := make([]Connection, 0) for _, c := range cs { - if c.Outgoing && c.State != ConnectionStatePending { - conns = append(conns, c) + if !c.Outgoing || c.State != ConnectionStateIntroduced { + continue } + + cc, err := gw.newConnection(&c) + if err != nil { + return nil, err + } + + conns = append(conns, *cc) } // Sort connnections by IP address @@ -129,17 +176,40 @@ func (gw *Gateway) GetDefaultConnections() []string { // GetConnection returns a *Connection of specific address func (gw *Gateway) GetConnection(addr string) (*Connection, error) { - var c Connection - var exists bool + var c *connection gw.strand("GetConnection", func() { - c, exists = gw.d.connections.Get(addr) + c = gw.d.connections.get(addr) }) - if !exists { + if c == nil { return nil, nil } - return &c, nil + return gw.newConnection(c) +} + +// newConnection creates a Connection from daemon.connection, gnet.Connection and pex.Peer +func (gw *Gateway) newConnection(c *connection) (*Connection, error) { + if c == nil { + return nil, nil + } + + gc, err := gw.d.pool.Pool.GetConnection(c.Addr) + if err != nil { + return nil, err + } + + var pp *pex.Peer + listenAddr := c.ListenAddr() + if listenAddr != "" { + p, ok := gw.d.pex.GetPeer(listenAddr) + if ok { + pp = &p + } + } + + cc := newConnection(c, gc, pp) + return &cc, nil } // GetTrustConnections returns all trusted connections @@ -172,9 +242,9 @@ type BlockchainProgress struct { Peers []PeerBlockchainHeight } -// NewBlockchainProgress creates BlockchainProgress from the local head blockchain sequence number +// newBlockchainProgress creates BlockchainProgress from the local head blockchain sequence number // and a list of remote peers -func NewBlockchainProgress(headSeq uint64, conns []Connection) *BlockchainProgress { +func newBlockchainProgress(headSeq uint64, conns []connection) *BlockchainProgress { peers := newPeerBlockchainHeights(conns) return &BlockchainProgress{ @@ -190,7 +260,7 @@ type PeerBlockchainHeight struct { Height uint64 } -func newPeerBlockchainHeights(conns []Connection) []PeerBlockchainHeight { +func newPeerBlockchainHeights(conns []connection) []PeerBlockchainHeight { peers := make([]PeerBlockchainHeight, 0, len(conns)) for _, c := range conns { if c.State != ConnectionStatePending { @@ -218,21 +288,21 @@ func EstimateBlockchainHeight(headSeq uint64, peers []PeerBlockchainHeight) uint func (gw *Gateway) GetBlockchainProgress() (*BlockchainProgress, error) { var headSeq uint64 var err error - var conns []Connection + var conns []connection gw.strand("GetBlockchainProgress", func() { headSeq, _, err = gw.v.HeadBkSeq() if err != nil { return } - conns = gw.d.connections.All() + conns = gw.d.connections.all() }) if err != nil { return nil, err } - return NewBlockchainProgress(headSeq, conns), nil + return newBlockchainProgress(headSeq, conns), nil } // ResendUnconfirmedTxns resents all unconfirmed transactions, returning the txids diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index c60449bd5a..458dd34b02 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -94,7 +94,7 @@ func TestNewConnectionAlreadyConnected(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { require.False(t, solicited) cc <- p.pool[1] } @@ -131,7 +131,7 @@ func TestAcceptConnections(t *testing.T) { cc := make(chan *Connection, 1) var wasSolicited *bool - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { wasSolicited = &solicited require.False(t, solicited) cc <- p.pool[1] @@ -220,7 +220,7 @@ func TestHandleConnection(t *testing.T) { // Unsolicited cc := make(chan *Connection, 1) var wasSolicited *bool - p.Config.ConnectCallback = func(address string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { wasSolicited = &solicited cc <- p.pool[1] } @@ -250,7 +250,7 @@ func TestHandleConnection(t *testing.T) { require.False(t, *wasSolicited) // Solicited - p.Config.ConnectCallback = func(address string, s bool) { + p.Config.ConnectCallback = func(c *Connection, s bool) { wasSolicited = &s cc <- p.pool[2] } @@ -351,7 +351,7 @@ func TestDisconnect(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.pool[1] } @@ -494,7 +494,7 @@ func TestConnectionReadLoopReadError(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.addresses[addr] } @@ -542,7 +542,7 @@ func TestConnectionReadLoopSetReadDeadlineFailed(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.addresses[addr] } @@ -585,7 +585,7 @@ func TestConnectionReadLoopInvalidMessageLength(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.addresses[addr] } @@ -631,7 +631,7 @@ func TestConnectionReadLoopTerminates(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.addresses[addr] } @@ -682,8 +682,8 @@ func TestProcessConnectionBuffers(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { - cc <- p.addresses[addr] + p.Config.ConnectCallback = func(c *Connection, solicited bool) { + cc <- p.addresses[c.Addr()] } p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { @@ -817,7 +817,7 @@ func TestConnectionWriteLoop(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.pool[1] } @@ -917,7 +917,7 @@ func TestPoolSendMessageOK(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.pool[1] } @@ -955,7 +955,7 @@ func TestPoolSendMessageWriteQueueFull(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { cc <- p.pool[1] } @@ -1013,7 +1013,7 @@ func TestPoolBroadcastMessage(t *testing.T) { ready := make(chan struct{}) var i int var counterLock sync.Mutex - p.Config.ConnectCallback = func(addr string, solicited bool) { + p.Config.ConnectCallback = func(c *Connection, solicited bool) { counterLock.Lock() defer counterLock.Unlock() i++ diff --git a/src/daemon/messages.go b/src/daemon/messages.go index e799db7a49..459195cb8a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -90,15 +90,9 @@ type Messages struct { // NewMessages creates Messages func NewMessages(c MessagesConfig) *Messages { - // mirror cannot be zero - var mirror uint32 - for mirror == 0 { - mirror = rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32() - } - return &Messages{ Config: c, - Mirror: mirror, + Mirror: rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32(), } } @@ -192,8 +186,7 @@ func NewGivePeersMessage(peers []pex.Peer) *GivePeersMessage { for _, ps := range peers { ipaddr, err := NewIPAddr(ps.Addr) if err != nil { - logger.Warningf("GivePeersMessage skipping address %s", ps.Addr) - logger.Warning(err.Error()) + logger.WithError(err).WithField("addr", ps.Addr).Warning("GivePeersMessage skipping invalid address") continue } ipaddrs = append(ipaddrs, ipaddr) @@ -234,11 +227,11 @@ type IntroductionMessage struct { // Mirror is a random value generated on client startup that is used // to identify self-connections Mirror uint32 - // Port is the port that this client is listening on - Port uint16 + // ListenPort is the port that this client is listening on + ListenPort uint16 // Protocol version - Version int32 - c *gnet.MessageContext `enc:"-"` + ProtocolVersion int32 + c *gnet.MessageContext `enc:"-"` // We validate the message in Handle() and cache the result for Process() valid bool `enc:"-"` // skip it during encoding // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. @@ -249,16 +242,15 @@ type IntroductionMessage struct { // NewIntroductionMessage creates introduction message func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey) *IntroductionMessage { return &IntroductionMessage{ - Mirror: mirror, - Version: version, - Port: port, - Extra: pubkey[:], + Mirror: mirror, + ProtocolVersion: version, + ListenPort: port, + Extra: pubkey[:], } } // Handle Responds to an gnet.Pool event. We implement Handle() here because we -// need to control the DisconnectReason sent back to gnet. We still implement -// Process(), where we do modifications that are not threadsafe +// need to control the DisconnectReason sent back to gnet. func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { d := daemon.(Daemoner) @@ -274,8 +266,8 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // Disconnect if peer version is not within the supported range dc := d.DaemonConfig() - if intro.Version < dc.MinProtocolVersion { - logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.Version, dc.MinProtocolVersion) + if intro.ProtocolVersion < dc.MinProtocolVersion { + logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.ProtocolVersion, dc.MinProtocolVersion) if err := d.Disconnect(mc.Addr, ErrDisconnectVersionNotSupported); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -284,7 +276,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa logger.WithFields(logrus.Fields{ "addr": mc.Addr, - "protocolVersion": intro.Version, + "protocolVersion": intro.ProtocolVersion, }).Info("Peer protocol version accepted") // v25 Checks the blockchain pubkey, would accept message with no Pubkey @@ -322,27 +314,19 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } // Checks if the introduction message is from outgoing connection. - // It's outgoing connection if port == intro.Port, as the incoming + // It's outgoing connection if port == intro.ListenPort, as the incoming // connection's port is a random port, it's different from the port // in introduction message. - if port == intro.Port { + if port == intro.ListenPort { if err := d.SetHasIncomingPort(mc.Addr); err != nil { logger.Errorf("Failed to set peer has incoming port status, %v", err) } } else { - if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.Port)); err != nil { + if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.ListenPort)); err != nil { logger.Errorf("Failed to add peer: %v", err) } } - // Disconnect if connected twice to the same peer (judging by ip:mirror) - if knownPort := d.GetMirrorPort(mc.Addr, intro.Mirror); knownPort != 0 { - logger.Infof("%s is already connected on port %d", mc.Addr, knownPort) - if err := d.Disconnect(mc.Addr, ErrDisconnectConnectedTwice); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } - return ErrDisconnectConnectedTwice - } return nil }() @@ -371,10 +355,8 @@ func (intro *IntroductionMessage) Process(d Daemoner) { logger.WithError(err).WithField("addr", a).Warning("ConnectionIntroduced failed") var reason gnet.DisconnectReason switch err { - case ErrMirrorZero: - reason = ErrDisconnectInvalidMirror case ErrConnectionIPMirrorAlreadyRegistered: - reason = ErrDisconnectMirrorInUse + reason = ErrDisconnectConnectedTwice default: reason = ErrDisconnectIncomprehensibleError } diff --git a/src/daemon/messages_benchmark_test.go b/src/daemon/messages_benchmark_test.go index 62ee758a94..58821035b7 100644 --- a/src/daemon/messages_benchmark_test.go +++ b/src/daemon/messages_benchmark_test.go @@ -64,10 +64,10 @@ func BenchmarkSerializeGivePeersMessage(b *testing.B) { var introPubKey = cipher.MustPubKeyFromHex("03cd7dfcd8c3452d1bb5d9d9e34dd95d6848cb9f66c2aad127b60578f4be7498f2") var introMessageObj = IntroductionMessage{ - Mirror: 1234, - Port: 5678, - Version: 1, - Extra: introPubKey[:], + Mirror: 1234, + ListenPort: 5678, + ProtocolVersion: 1, + Extra: introPubKey[:], } func BenchmarkDeserializeRawIntroductionMessage(b *testing.B) { diff --git a/src/daemon/messages_example_test.go b/src/daemon/messages_example_test.go index 00fae5e49f..b89420a73d 100644 --- a/src/daemon/messages_example_test.go +++ b/src/daemon/messages_example_test.go @@ -432,8 +432,8 @@ func ExampleIntroductionMessage() { // 0x0000 | 33 00 00 00 ....................................... Length // 0x0004 | 49 4e 54 52 ....................................... Prefix // 0x0008 | d2 04 00 00 ....................................... Mirror - // 0x000c | d2 1e ............................................. Port - // 0x000e | 05 00 00 00 ....................................... Version + // 0x000c | d2 1e ............................................. ListenPort + // 0x000e | 05 00 00 00 ....................................... ProtocolVersion // 0x0012 | 21 00 00 00 ....................................... Extra length // 0x0016 | 03 ................................................ Extra[0] // 0x0017 | 28 ................................................ Extra[1] diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index f285242232..f5b34bfa8e 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -21,11 +21,6 @@ func TestIntroductionMessage(t *testing.T) { pubkey, _ := cipher.GenerateKeyPair() pubkey2, _ := cipher.GenerateKeyPair() - type mirrorPortResult struct { - port uint16 - exist bool - } - type daemonMockValue struct { protocolVersion uint32 minProtocolVersion uint32 @@ -34,18 +29,21 @@ func TestIntroductionMessage(t *testing.T) { isMaxConnectionsReached bool isMaxConnectionsReachedErr error setHasIncomingPortErr error - getMirrorPortResult mirrorPortResult recordMessageEventErr error pubkey cipher.PubKey disconnectReason gnet.DisconnectReason disconnectErr error addPeerArg string addPeerErr error + connectionIntroducedErr error + requestBlocksFromAddrErr error + announceAllTxnsErr error } tt := []struct { name string addr string + doProcess bool mockValue daemonMockValue intro *IntroductionMessage err error @@ -56,15 +54,12 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, }, err: nil, }, @@ -74,17 +69,14 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, - pubkey: pubkey, + pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey[:], + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, + Extra: pubkey[:], }, err: nil, }, @@ -94,17 +86,14 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, - pubkey: pubkey, + pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey[:], + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, + Extra: pubkey[:], }, err: nil, }, @@ -114,17 +103,14 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, - pubkey: pubkey, + pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: append(pubkey[:], []byte("additional data")...), + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, + Extra: append(pubkey[:], []byte("additional data")...), }, err: nil, }, @@ -132,20 +118,17 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with different pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, + mirror: 10000, + protocolVersion: 1, pubkey: pubkey, disconnectReason: ErrDisconnectBlockchainPubkeyNotMatched, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: pubkey2[:], + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, + Extra: pubkey2[:], }, err: ErrDisconnectBlockchainPubkeyNotMatched, }, @@ -153,20 +136,17 @@ func TestIntroductionMessage(t *testing.T) { name: "INTR message with invalid pubkey", addr: "121.121.121.121:6000", mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, + mirror: 10000, + protocolVersion: 1, pubkey: pubkey, disconnectReason: ErrDisconnectInvalidExtraData, }, intro: &IntroductionMessage{ - Mirror: 10001, - Port: 6000, - Version: 1, - valid: true, - Extra: []byte("invalid extra data"), + Mirror: 10001, + ListenPort: 6000, + ProtocolVersion: 1, + valid: true, + Extra: []byte("invalid extra data"), }, err: ErrDisconnectInvalidExtraData, }, @@ -182,7 +162,7 @@ func TestIntroductionMessage(t *testing.T) { err: ErrDisconnectSelf, }, { - name: "Version below minimum supported version", + name: "ProtocolVersion below minimum supported version", mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, @@ -190,8 +170,8 @@ func TestIntroductionMessage(t *testing.T) { disconnectReason: ErrDisconnectVersionNotSupported, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 0, + Mirror: 10001, + ProtocolVersion: 0, }, err: ErrDisconnectVersionNotSupported, }, @@ -205,9 +185,9 @@ func TestIntroductionMessage(t *testing.T) { pubkey: pubkey, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 1, - Port: 6000, + Mirror: 10001, + ProtocolVersion: 1, + ListenPort: 6000, }, err: ErrDisconnectIncomprehensibleError, }, @@ -219,41 +199,36 @@ func TestIntroductionMessage(t *testing.T) { protocolVersion: 1, isDefaultConnection: true, isMaxConnectionsReached: true, - getMirrorPortResult: mirrorPortResult{ - exist: false, - }, - pubkey: pubkey, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: nil, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 1, - Port: 6000, - valid: true, + Mirror: 10001, + ProtocolVersion: 1, + ListenPort: 6000, + valid: true, }, }, { - name: "Connect twice", - addr: "121.121.121.121:6000", + name: "Connect twice", + addr: "121.121.121.121:6000", + doProcess: true, mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - isDefaultConnection: true, - getMirrorPortResult: mirrorPortResult{ - exist: true, - }, - pubkey: pubkey, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, - disconnectReason: ErrDisconnectConnectedTwice, + mirror: 10000, + protocolVersion: 1, + isDefaultConnection: true, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: nil, + disconnectReason: ErrDisconnectConnectedTwice, + connectionIntroducedErr: ErrConnectionIPMirrorAlreadyRegistered, }, intro: &IntroductionMessage{ - Mirror: 10001, - Version: 1, - Port: 6000, + Mirror: 10001, + ProtocolVersion: 1, + ListenPort: 6000, }, - err: ErrDisconnectConnectedTwice, }, } @@ -270,7 +245,6 @@ func TestIntroductionMessage(t *testing.T) { d.On("Mirror").Return(tc.mockValue.mirror) d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) - d.On("GetMirrorPort", tc.addr, tc.intro.Mirror).Return(tc.mockValue.getMirrorPortResult.port, tc.mockValue.getMirrorPortResult.exist) d.On("RecordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) d.On("ResetRetryTimes", tc.addr) d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) @@ -279,9 +253,19 @@ func TestIntroductionMessage(t *testing.T) { d.On("RemoveFromExpectingIntroductions", tc.addr) d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) + d.On("ConnectionIntroduced", tc.addr, tc.intro).Return(tc.mockValue.connectionIntroducedErr) + d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) + d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) err := tc.intro.Handle(mc, d) - require.Equal(t, tc.err, err) + + if tc.doProcess { + require.NoError(t, err) + tc.intro.Process(d) + d.AssertCalled(t, "Disconnect", tc.addr, tc.mockValue.disconnectReason) + } else { + require.Equal(t, tc.err, err) + } }) } } @@ -300,19 +284,19 @@ func TestMessageEncodeDecode(t *testing.T) { goldenFile: "intro-msg.golden", obj: &IntroductionMessage{}, msg: &IntroductionMessage{ - Mirror: 99998888, - Port: 8888, - Version: 12341234, + Mirror: 99998888, + ListenPort: 8888, + ProtocolVersion: 12341234, }, }, { goldenFile: "intro-msg-pubkey.golden", obj: &IntroductionMessage{}, msg: &IntroductionMessage{ - Mirror: 99998888, - Port: 8888, - Version: 12341234, - Extra: introPubKey[:], + Mirror: 99998888, + ListenPort: 8888, + ProtocolVersion: 12341234, + Extra: introPubKey[:], }, }, { diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index bb54805a00..7f25e5f9e8 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -86,6 +86,20 @@ func (_m *MockDaemoner) BroadcastMessage(msg gnet.Message) error { return r0 } +// ConnectionIntroduced provides a mock function with given fields: addr, m +func (_m *MockDaemoner) ConnectionIntroduced(addr string, m *IntroductionMessage) error { + ret := _m.Called(addr, m) + + var r0 error + if rf, ok := ret.Get(0).(func(string, *IntroductionMessage) error); ok { + r0 = rf(addr, m) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // DaemonConfig provides a mock function with given fields: func (_m *MockDaemoner) DaemonConfig() DaemonConfig { ret := _m.Called() @@ -128,27 +142,6 @@ func (_m *MockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { return r0 } -// GetMirrorPort provides a mock function with given fields: addr, mirror -func (_m *MockDaemoner) GetMirrorPort(addr string, mirror uint32) (uint16, bool) { - ret := _m.Called(addr, mirror) - - var r0 uint16 - if rf, ok := ret.Get(0).(func(string, uint32) uint16); ok { - r0 = rf(addr, mirror) - } else { - r0 = ret.Get(0).(uint16) - } - - var r1 bool - if rf, ok := ret.Get(1).(func(string, uint32) bool); ok { - r1 = rf(addr, mirror) - } else { - r1 = ret.Get(1).(bool) - } - - return r0, r1 -} - // GetSignedBlocksSince provides a mock function with given fields: seq, count func (_m *MockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { ret := _m.Called(seq, count) @@ -360,20 +353,6 @@ func (_m *MockDaemoner) RandomExchangeable(n int) pex.Peers { return r0 } -// RecordConnectionMirror provides a mock function with given fields: addr, mirror -func (_m *MockDaemoner) RecordConnectionMirror(addr string, mirror uint32) error { - ret := _m.Called(addr, mirror) - - var r0 error - if rf, ok := ret.Get(0).(func(string, uint32) error); ok { - r0 = rf(addr, mirror) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // RecordMessageEvent provides a mock function with given fields: m, c func (_m *MockDaemoner) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error { ret := _m.Called(m, c) @@ -393,11 +372,6 @@ func (_m *MockDaemoner) RecordPeerHeight(addr string, height uint64) { _m.Called(addr, height) } -// RemoveFromExpectingIntroductions provides a mock function with given fields: addr -func (_m *MockDaemoner) RemoveFromExpectingIntroductions(addr string) { - _m.Called(addr) -} - // RequestBlocksFromAddr provides a mock function with given fields: addr func (_m *MockDaemoner) RequestBlocksFromAddr(addr string) error { ret := _m.Called(addr) diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index 4d2cb1609a..f2a2347b94 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -220,8 +220,8 @@ func (pl *peerlist) len() int { return len(pl.peers) } -// getPeerByAddr returns peer of given address -func (pl *peerlist) getPeerByAddr(addr string) (Peer, bool) { +// getPeer returns peer for a given address +func (pl *peerlist) getPeer(addr string) (Peer, bool) { p, ok := pl.peers[addr] if ok { return *p, true diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index b950c2b4d3..655aa26136 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -536,11 +536,11 @@ func (px *Pex) RemovePeer(addr string) { px.peerlist.removePeer(addr) } -// GetPeerByAddr returns peer of given address -func (px *Pex) GetPeerByAddr(addr string) (Peer, bool) { +// GetPeer returns peer of given address +func (px *Pex) GetPeer(addr string) (Peer, bool) { px.RLock() defer px.RUnlock() - return px.peerlist.getPeerByAddr(addr) + return px.peerlist.getPeer(addr) } // Trusted returns trusted peers @@ -564,11 +564,13 @@ func (px *Pex) TrustedPublic() Peers { return px.peerlist.getCanTryPeers([]Filter{isPublic, isTrusted}) } -// RandomPublic returns N random public peers -func (px *Pex) RandomPublic(n int) Peers { +// RandomPublicUntrusted returns N random public untrusted peers +func (px *Pex) RandomPublicUntrusted(n int) Peers { px.RLock() defer px.RUnlock() - return px.peerlist.random(n, []Filter{isPublic}) + return px.peerlist.random(n, []Filter{func(p Peer) bool { + return !p.Private && !p.Trusted + }}) } // RandomExchangeable returns N random exchangeable peers diff --git a/src/daemon/pex/pex_test.go b/src/daemon/pex/pex_test.go index 79c1e2597c..cc867c3401 100644 --- a/src/daemon/pex/pex_test.go +++ b/src/daemon/pex/pex_test.go @@ -735,7 +735,7 @@ func TestPeerRandomPublic(t *testing.T) { pex.peerlist.setPeers(tc.peers) - peers := pex.RandomPublic(tc.n) + peers := pex.RandomPublicUntrusted(tc.n) require.Len(t, peers, tc.expectN) }) } @@ -848,7 +848,7 @@ func TestPexRandomPublic(t *testing.T) { pex.peerlist.setPeers(tc.peers) // get N random public - peers := pex.RandomPublic(tc.n) + peers := pex.RandomPublicUntrusted(tc.n) require.Len(t, peers, tc.expectN) @@ -1368,7 +1368,7 @@ func TestPexGetPeerByAddr(t *testing.T) { pex.peerlist.setPeers(tc.initPeers) - p, ok := pex.GetPeerByAddr(tc.addr) + p, ok := pex.GetPeer(tc.addr) require.Equal(t, tc.find, ok) if ok { require.Equal(t, tc.peer, p) diff --git a/src/daemon/storage_test.go b/src/daemon/storage_test.go deleted file mode 100644 index 157e76dac6..0000000000 --- a/src/daemon/storage_test.go +++ /dev/null @@ -1,341 +0,0 @@ -package daemon - -import ( - "net" - "sync" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/skycoin/skycoin/src/daemon/gnet" -) - -func TestGet(t *testing.T) { - conns := NewConnections() - - addr := "127.0.0.1:6060" - details := ConnectionDetails{ - Mirror: 99, - State: ConnectionStatePending, - ConnectedAt: time.Now().UTC(), - ListenPort: 10101, - Height: 1111, - } - - c, err := conns.Add(fakeGnetConn(addr), details) - require.NoError(t, err) - require.Equal(t, details, c.ConnectionDetails) - require.Equal(t, 111, c.GnetID) - require.NotEmpty(t, c.LastReceived) - require.NotEmpty(t, c.LastSent) - - c2, ok := conns.Get(addr) - require.True(t, ok) - require.Equal(t, c, c2) -} - -func TestRemoveMatchedBy(t *testing.T) { - ei := NewConnections() - - now := time.Now().UTC() - - addr1 := "127.0.0.1:6060" - addr2 := "127.0.1.1:6061" - addr3 := "127.1.1.1:6062" - - _, err := ei.Add(fakeGnetConn(addr1), ConnectionDetails{ - ConnectedAt: now, - }) - require.NoError(t, err) - - _, err = ei.Add(fakeGnetConn(addr2), ConnectionDetails{ - ConnectedAt: now.Add(1), - }) - require.NoError(t, err) - - _, err = ei.Add(fakeGnetConn(addr3), ConnectionDetails{ - ConnectedAt: now.Add(2), - }) - require.NoError(t, err) - - wg := sync.WaitGroup{} - vc := make(chan string, 3) - - wg.Add(2) - go func() { - defer wg.Done() - as, err := ei.RemoveMatchedBy(func(c Connection) (bool, error) { - if c.Addr == addr1 || c.Addr == addr2 { - return true, nil - } - return false, nil - }) - require.NoError(t, err) - - for _, s := range as { - vc <- s - } - }() - - go func() { - defer wg.Done() - as, err := ei.RemoveMatchedBy(func(c Connection) (bool, error) { - if c.Addr == addr3 { - return true, nil - } - return false, nil - }) - - require.NoError(t, err) - - for _, s := range as { - vc <- s - } - }() - - wg.Wait() - require.Equal(t, 3, len(vc)) - - _, ok := ei.Get(addr1) - require.False(t, ok) - _, ok = ei.Get(addr2) - require.False(t, ok) - _, ok = ei.Get(addr3) - require.False(t, ok) -} - -func TestMirrorConnections(t *testing.T) { - mc := NewConnections() - - localhost := "127.0.0.1" - addr1 := "127.0.0.1:6060" - addr2 := "127.0.0.1:6061" - addr3 := "127.1.1.1:6060" - - c := mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(0), c) - - _, err := mc.Add(fakeGnetConn(addr1), ConnectionDetails{ - Mirror: 99, - }) - require.NoError(t, err) - - c = mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(6060), c) - - err = mc.Remove(addr1) - require.NoError(t, err) - - c = mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(0), c) - - _, err = mc.Add(fakeGnetConn(addr2), ConnectionDetails{ - Mirror: 99, - }) - require.NoError(t, err) - - c = mc.GetMirrorPort(addr2, 99) - require.Equal(t, uint16(6061), c) - - _, err = mc.Add(fakeGnetConn(addr1), ConnectionDetails{ - Mirror: 99, - }) - require.Equal(t, ErrConnectionIPMirrorAlreadyRegistered, err) - - c = mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(6061), c) - - _, err = mc.Add(fakeGnetConn(addr1), ConnectionDetails{ - Mirror: 999, - }) - - c = mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(6061), c) - c = mc.GetMirrorPort(localhost, 999) - require.Equal(t, uint16(6060), c) - - _, err = mc.Add(fakeGnetConn(addr3), ConnectionDetails{ - Mirror: 99, - }) - require.NoError(t, err) - - c = mc.GetMirrorPort("127.1.1.1", 99) - require.Equal(t, uint16(6060), c) - - err = mc.Remove(addr2) - require.NoError(t, err) - - c = mc.GetMirrorPort(localhost, 99) - require.Equal(t, uint16(0), c) - c = mc.GetMirrorPort(localhost, 999) - require.Equal(t, uint16(6060), c) - - err = mc.Remove(addr1) - require.NoError(t, err) - - c = mc.GetMirrorPort(localhost, 999) - require.Equal(t, uint16(0), c) - - err = mc.Remove(addr3) - require.NoError(t, err) - - c = mc.GetMirrorPort("127.1.1.1", 99) - require.Equal(t, uint16(0), c) -} - -func TestIPCount(t *testing.T) { - ic := NewConnections() - - localhost := "127.0.0.1" - addr1 := "127.0.0.1:6060" - addr2 := "127.0.0.1:6061" - - require.Equal(t, 0, ic.GetIPCount(localhost)) - require.Equal(t, 0, ic.Len()) - - _, ok := ic.Get(addr1) - require.False(t, ok) - - _, err := ic.Add(fakeGnetConn(addr1), ConnectionDetails{ - Mirror: 1, - }) - require.NoError(t, err) - require.Equal(t, 1, ic.GetIPCount(localhost)) - - _, err = ic.Add(fakeGnetConn(addr2), ConnectionDetails{ - Mirror: 2, - }) - require.NoError(t, err) - require.Equal(t, 2, ic.GetIPCount(localhost)) - - err = ic.Remove(addr1) - require.NoError(t, err) - require.Equal(t, 1, ic.GetIPCount(localhost)) - - err = ic.Remove(addr1) - require.NoError(t, err) - require.Equal(t, 1, ic.GetIPCount(localhost)) - - err = ic.Remove(addr2) - require.NoError(t, err) - require.Equal(t, 0, ic.GetIPCount(localhost)) -} - -func TestConnectionHeightsAll(t *testing.T) { - p := NewConnections() - - addr1 := "127.0.0.1:1234" - addr2 := "127.0.0.1:5678" - addr3 := "127.0.0.1:9999" - - require.Empty(t, p.conns) - err := p.Remove(addr1) - require.NoError(t, err) - require.Empty(t, p.conns) - require.Empty(t, p.mirrors) - require.Empty(t, p.ipCounts) - - e := p.EstimateHeight(1) - require.Equal(t, uint64(1), e) - - e = p.EstimateHeight(13) - require.Equal(t, uint64(13), e) - - _, err = p.Add(fakeGnetConn(addr1), ConnectionDetails{ - Height: 10, - Mirror: 1, - }) - require.NoError(t, err) - require.Len(t, p.conns, 1) - - records := p.All() - require.Len(t, records, 1) - require.Equal(t, addr1, records[0].Addr) - require.Equal(t, 10, records[0].Height) - - err = p.Modify(addr1, func(c *ConnectionDetails) error { - c.Height = 11 - return nil - }) - require.NoError(t, err) - require.Len(t, p.conns, 1) - - records = p.All() - require.Len(t, records, 1) - require.Equal(t, addr1, records[0].Addr) - require.Equal(t, 11, records[0].Height) - - e = p.EstimateHeight(1) - require.Equal(t, uint64(11), e) - - e = p.EstimateHeight(13) - require.Equal(t, uint64(13), e) - - _, err = p.Add(fakeGnetConn(addr2), ConnectionDetails{ - Height: 12, - Mirror: 2, - }) - require.NoError(t, err) - _, err = p.Add(fakeGnetConn(addr3), ConnectionDetails{ - Height: 12, - Mirror: 3, - }) - require.NoError(t, err) - require.Len(t, p.conns, 3) - require.Equal(t, 3, p.Len()) - - records = p.All() - require.Len(t, records, 3) - require.Equal(t, addr1, records[0].Addr) - require.Equal(t, 11, records[0].Height) - require.Equal(t, addr2, records[1].Addr) - require.Equal(t, 12, records[1].Height) - require.Equal(t, addr3, records[2].Addr) - require.Equal(t, 12, records[2].Height) - - e = p.EstimateHeight(1) - require.Equal(t, uint64(12), e) - - e = p.EstimateHeight(13) - require.Equal(t, uint64(13), e) - - _, err = p.Add(fakeGnetConn(addr3), ConnectionDetails{ - Height: 24, - Mirror: 4, - }) - require.NoError(t, err) - e = p.EstimateHeight(13) - require.Equal(t, uint64(24), e) -} - -func fakeGnetConn(addr string) *gnet.Connection { - return &gnet.Connection{ - ID: 111, - LastReceived: time.Now().UTC(), - LastSent: time.Now().UTC(), - Conn: fakeNetConn{ - remoteAddr: fakeNetAddr{ - addr: addr, - }, - }, - } -} - -type fakeNetAddr struct { - net.Addr - addr string -} - -func (f fakeNetAddr) String() string { - return f.addr -} - -type fakeNetConn struct { - net.Conn - remoteAddr fakeNetAddr -} - -func (f fakeNetConn) RemoteAddr() net.Addr { - return f.remoteAddr -} diff --git a/src/readable/network.go b/src/readable/network.go index 734f89ec79..9409037351 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -6,16 +6,16 @@ import ( // Connection a connection's state within the daemon type Connection struct { - GnetID int `json:"id"` - Addr string `json:"address"` - LastSent int64 `json:"last_sent"` - LastReceived int64 `json:"last_received"` - ConnectedAt int64 `json:"connected_at"` - Outgoing bool `json:"outgoing"` - State string `json:"state"` - Mirror uint32 `json:"mirror"` - ListenPort uint16 `json:"listen_port"` - Height uint64 `json:"height"` + GnetID int `json:"id"` + Addr string `json:"address"` + LastSent int64 `json:"last_sent"` + LastReceived int64 `json:"last_received"` + ConnectedAt int64 `json:"connected_at"` + Outgoing bool `json:"outgoing"` + State daemon.ConnectionState `json:"state"` + Mirror uint32 `json:"mirror"` + ListenPort uint16 `json:"listen_port"` + Height uint64 `json:"height"` } // NewConnection copies daemon.Connection to a struct with json tags @@ -41,7 +41,7 @@ func NewConnection(c *daemon.Connection) Connection { LastReceived: lastReceived, ConnectedAt: connectedAt, Outgoing: c.Outgoing, - State: string(c.State), + State: c.State, Mirror: c.Mirror, ListenPort: c.ListenPort, Height: c.Height, diff --git a/src/util/iputil/iputil.go b/src/util/iputil/iputil.go index 6b492a00ef..1dccbd9cd0 100644 --- a/src/util/iputil/iputil.go +++ b/src/util/iputil/iputil.go @@ -5,11 +5,19 @@ package iputil import ( "errors" - "fmt" "net" "strconv" ) +var ( + // ErrMissingIP IP missing from ip:port string + ErrMissingIP = errors.New("IP missing from ip:port address") + // ErrInvalidPort port invalid in ip:port string + ErrInvalidPort = errors.New("Port invalid in ip:port address") + // ErrNoLocalIP no localhost IP found in system net interfaces + ErrNoLocalIP = errors.New("No local IP found") +) + // LocalhostIP returns the address for localhost on the machine func LocalhostIP() (string, error) { tt, err := net.Interfaces() @@ -27,7 +35,7 @@ func LocalhostIP() (string, error) { } } } - return "", errors.New("No local IP found") + return "", ErrNoLocalIP } // IsLocalhost returns true if addr is a localhost address @@ -46,12 +54,12 @@ func SplitAddr(addr string) (string, uint16, error) { } if ip == "" { - return "", 0, fmt.Errorf("IP missing from %s", addr) + return "", 0, ErrMissingIP } port64, err := strconv.ParseUint(port, 10, 16) if err != nil { - return "", 0, fmt.Errorf("Invalid port in %s", addr) + return "", 0, ErrInvalidPort } return ip, uint16(port64), nil diff --git a/src/util/iputil/iputil_test.go b/src/util/iputil/iputil_test.go index bc2280e49b..cc437c72d0 100644 --- a/src/util/iputil/iputil_test.go +++ b/src/util/iputil/iputil_test.go @@ -1,7 +1,6 @@ package iputil import ( - "fmt" "net" "testing" @@ -73,15 +72,15 @@ func TestSplitAddr(t *testing.T) { }, { input: "0.0.0.0:", - err: fmt.Errorf("Invalid port in %s", "0.0.0.0:"), + err: ErrInvalidPort, }, { input: "0.0.0.0:x", - err: fmt.Errorf("Invalid port in %s", "0.0.0.0:x"), + err: ErrInvalidPort, }, { input: ":9999", - err: fmt.Errorf("IP missing from %s", ":9999"), + err: ErrMissingIP, }, { input: "127.0.0.1", @@ -102,7 +101,7 @@ func TestSplitAddr(t *testing.T) { }, { input: "[::]:x", - err: fmt.Errorf("Invalid port in %s", "[::]:x"), + err: ErrInvalidPort, }, } From 0bf57b5fff124b96dd71c2aa2b4235b1abe98213 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 16:52:34 +0800 Subject: [PATCH 310/399] Fixups --- CHANGELOG.md | 2 +- src/api/integration/integration_test.go | 1 + src/api/network_test.go | 24 ++-- src/daemon/connections.go | 6 +- src/daemon/daemon.go | 93 ++++++++------- src/daemon/messages.go | 145 ++++++++++++------------ src/daemon/messages_test.go | 27 +---- src/daemon/mock_daemoner_test.go | 117 ++++++++++--------- 8 files changed, 205 insertions(+), 210 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e503929fd..77c6566a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,7 +81,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli generateAddresses` renamed to `cli walletAddAddresses` - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` -- `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"introduced"`. Added `"connected_at"` field. +- `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"`. Added `"connected_at"` field. ### Removed diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index ba8dde3dac..8f2d922140 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -1860,6 +1860,7 @@ func TestLiveNetworkConnections(t *testing.T) { require.Equal(t, cc.Outgoing, connection.Outgoing) require.True(t, cc.LastReceived <= connection.LastReceived) require.True(t, cc.LastSent <= connection.LastSent) + require.Equal(t, cc.ConnectedAt, connection.ConnectedAt) checked = true } diff --git a/src/api/network_test.go b/src/api/network_test.go index 09be74ca9c..f7c3f8bcba 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -56,11 +56,12 @@ func TestConnection(t *testing.T) { LastReceived: time.Unix(1111111, 0), }, ConnectionDetails: daemon.ConnectionDetails{ - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - Mirror: 6789, - ListenPort: 9877, - Height: 1234, + Outgoing: true, + ConnectedAt: time.Unix(222222, 0), + State: daemon.ConnectionStateIntroduced, + Mirror: 6789, + ListenPort: 9877, + Height: 1234, }, }, result: &readable.Connection{ @@ -68,6 +69,7 @@ func TestConnection(t *testing.T) { GnetID: 1, LastSent: 99999, LastReceived: 1111111, + ConnectedAt: 222222, Outgoing: true, State: daemon.ConnectionStateIntroduced, Mirror: 6789, @@ -159,11 +161,12 @@ func TestConnections(t *testing.T) { LastReceived: time.Unix(1111111, 0), }, ConnectionDetails: daemon.ConnectionDetails{ - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - Mirror: 9876, - ListenPort: 9877, - Height: 1234, + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + ConnectedAt: time.Unix(222222, 0), + Mirror: 9876, + ListenPort: 9877, + Height: 1234, }, }, }, @@ -174,6 +177,7 @@ func TestConnections(t *testing.T) { GnetID: 1, LastSent: 99999, LastReceived: 1111111, + ConnectedAt: 222222, Outgoing: true, State: daemon.ConnectionStateIntroduced, Mirror: 9876, diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 5f70b30db4..14aa518849 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -123,7 +123,7 @@ func (c *Connections) pending(addr string) (*connection, error) { }, } - logger.WithField("addr", addr).Debug("AddPendingOutgoing") + logger.WithField("addr", addr).Debug("Connections.pending") return c.conns[addr], nil } @@ -166,7 +166,7 @@ func (c *Connections) connected(addr string) (*connection, error) { logger.WithFields(logrus.Fields{ "addr": addr, "outgoing": conn.Outgoing, - }).Debug("Connected") + }).Debug("Connections.connected") return conn, nil } @@ -227,7 +227,7 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti logger.WithFields(logrus.Fields{ "addr": addr, "outgoing": conn.Outgoing, - }).Debug("Introduced") + }).Debug("Connections.introduced") return conn, nil } diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index e368af7927..cf8d6e44d0 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -212,10 +212,10 @@ func NewDaemonConfig() DaemonConfig { } //go:generate go install -//go:generate mockery -name Daemoner -case underscore -inpkg -testonly +//go:generate mockery -name daemoner -case underscore -inpkg -testonly -// Daemoner Daemon interface -type Daemoner interface { +// daemoner Daemon interface +type daemoner interface { SendMessage(addr string, msg gnet.Message) error BroadcastMessage(msg gnet.Message) error Disconnect(addr string, r gnet.DisconnectReason) error @@ -238,10 +238,11 @@ type Daemoner interface { Mirror() uint32 DaemonConfig() DaemonConfig BlockchainPubkey() cipher.PubKey - RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error - ConnectionIntroduced(addr string, m *IntroductionMessage) error RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error + + recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error + connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) } // Daemon stateful properties of the daemon @@ -267,7 +268,7 @@ type Daemon struct { // Connection failure events connectionErrors chan ConnectionError // Message handling queue - messageEvents chan MessageEvent + messageEvents chan messageEvent // quit channel quit chan struct{} // done channel @@ -302,7 +303,7 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), - messageEvents: make(chan MessageEvent, config.Pool.EventChannelSize), + messageEvents: make(chan messageEvent, config.Pool.EventChannelSize), quit: make(chan struct{}), done: make(chan struct{}), } @@ -316,7 +317,7 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { // ConnectEvent generated when a client connects type ConnectEvent struct { - Conn *gnet.Connection + Addr string Solicited bool } @@ -332,9 +333,9 @@ type ConnectionError struct { Error error } -// MessageEvent encapsulates a deserialized message from the network -type MessageEvent struct { - Message AsyncMessage +// messageEvent encapsulates a deserialized message from the network +type messageEvent struct { + Message asyncMessage Context *gnet.MessageContext } @@ -685,7 +686,7 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { logger.WithField("addr", p.Addr).Debug("Establishing outgoing conneciton") if _, err := dm.connections.pending(p.Addr); err != nil { - logger.Critical().WithError(err).WithField("addr", p.Addr).Error("AddPendingOutgoing failed") + logger.Critical().WithError(err).WithField("addr", p.Addr).Error("dm.connections.pending failed") return err } @@ -784,10 +785,10 @@ func (dm *Daemon) isTrustedPeer(addr string) bool { return peer.Trusted } -// RecordMessageEvent records an AsyncMessage to the messageEvent chan. Do not access +// recordMessageEvent records an asyncMessage to the messageEvent chan. Do not access // messageEvent directly. -func (dm *Daemon) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error { - dm.messageEvents <- MessageEvent{m, c} +func (dm *Daemon) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error { + dm.messageEvents <- messageEvent{m, c} return nil } @@ -800,14 +801,12 @@ func (dm *Daemon) needsIntro(addr string) bool { return c != nil && !c.HasIntroduced() } -// Processes a queued AsyncMessage. -func (dm *Daemon) processMessageEvent(e MessageEvent) { +// Processes a queued asyncMessage. +func (dm *Daemon) processMessageEvent(e messageEvent) { // The first message received must be an Introduction // We have to check at process time and not record time because // Introduction message does not update ExpectingIntroductions until its - // Process() is called - // _, needsIntro := self.expectingIntroductions[e.Context.Addr] - // if needsIntro { + // process() is called if dm.needsIntro(e.Context.Addr) { _, isIntro := e.Message.(*IntroductionMessage) if !isIntro { @@ -820,23 +819,21 @@ func (dm *Daemon) processMessageEvent(e MessageEvent) { } } } - e.Message.Process(dm) + e.Message.process(dm) } // Called when a ConnectEvent is processed off the onConnectEvent channel func (dm *Daemon) onConnect(e ConnectEvent) { - a := e.Conn.Addr() - direction := "incoming" if e.Solicited { direction = "outgoing" } logger.WithFields(logrus.Fields{ - "addr": a, + "addr": e.Addr, "direction": direction, }).Info("Connected to peer") - exist, err := dm.pool.Pool.IsConnExist(a) + exist, err := dm.pool.Pool.IsConnExist(e.Addr) if err != nil { logger.Critical().WithError(err).Error("IsConnExist failed") return @@ -847,10 +844,10 @@ func (dm *Daemon) onConnect(e ConnectEvent) { return } - if dm.ipCountMaxed(a) { - logger.Infof("Max connections for %s reached, disconnecting", a) - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIPLimitReached); err != nil { - logger.WithError(err).WithField("addr", a).Error("Disconnect") + if dm.ipCountMaxed(e.Addr) { + logger.WithField("addr", e.Addr).Info("Max connections for this address reached, disconnecting") + if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { + logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") } return } @@ -864,38 +861,38 @@ func (dm *Daemon) onConnect(e ConnectEvent) { } if n > dm.Config.OutgoingMax { - logger.WithField("addr", a).Warning("Max outgoing connections is reached, disconnecting") - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { - logger.WithError(err).WithField("addr", a).Error("Disconnect") + logger.WithField("addr", e.Addr).Warning("Max outgoing connections is reached, disconnecting") + if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { + logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") } return } } // Update the connections state machine - c, err := dm.connections.connected(e.Conn.Addr()) + c, err := dm.connections.connected(e.Addr) if err != nil { - logger.Critical().WithError(err).WithField("addr", a).Error("connections.Connected failed") - if err := dm.pool.Pool.Disconnect(a, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", a).Error("Disconnect") + logger.Critical().WithError(err).WithField("addr", e.Addr).Error("connections.Connected failed") + if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIncomprehensibleError); err != nil { + logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") } return } - // The connection should already be known as outgoing/solicited due to an earlier AddPendingOutgoing call. - // If they do not match, there is a flaw in the concept or implementation of the state machine. + // The connection should already be known as outgoing/solicited due to an earlier connections.pending call. + // If they do not match, there is e.Addr flaw in the concept or implementation of the state machine. if c.Outgoing != e.Solicited { logger.Critical().Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") } logger.WithFields(logrus.Fields{ - "addr": a, + "addr": e.Addr, "mirror": dm.Messages.Mirror, }).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey) - if err := dm.pool.Pool.SendMessage(a, m); err != nil { - logger.WithField("addr", a).WithError(err).Error("Send IntroductionMessage failed") + if err := dm.pool.Pool.SendMessage(e.Addr, m); err != nil { + logger.WithField("addr", e.Addr).WithError(err).Error("Send IntroductionMessage failed") } } @@ -933,12 +930,13 @@ func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { // Triggered when an gnet.Connection is connected func (dm *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) { dm.onConnectEvent <- ConnectEvent{ - Conn: c, + Addr: c.Addr(), Solicited: solicited, } } -// Returns whether the ipCount maximum has been reached +// Returns whether the ipCount maximum has been reached. +// Always false when using LocalhostOnly config. func (dm *Daemon) ipCountMaxed(addr string) bool { ip, _, err := iputil.SplitAddr(addr) if err != nil { @@ -946,7 +944,7 @@ func (dm *Daemon) ipCountMaxed(addr string) bool { return true } - return dm.connections.IPCount(ip) >= dm.Config.IPCountsMax + return !dm.Config.LocalhostOnly && dm.connections.IPCount(ip) >= dm.Config.IPCountsMax } // When an async message send finishes, its result is handled by this. @@ -1197,10 +1195,9 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { return dm.Config.BlockchainPubkey } -// ConnectionIntroduced removes the peer from expect introduction pool -func (dm *Daemon) ConnectionIntroduced(addr string, m *IntroductionMessage) error { - _, err := dm.connections.introduced(addr, m) - return err +// connectionIntroduced removes the peer from expect introduction pool +func (dm *Daemon) connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) { + return dm.connections.introduced(addr, m) } // Implements pooler interface diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 459195cb8a..12851fdd37 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -25,7 +25,7 @@ import ( // DaemonLoop(). // Message do this by caching the gnet.MessageContext received in Handle() // and placing itself on the messageEvent channel. -// When the message is retrieved from the messageEvent channel, its Process() +// When the message is retrieved from the messageEvent channel, its process() // method is called. // MessageConfig config contains a gnet.Message's 4byte prefix and a @@ -129,18 +129,16 @@ func (ipa IPAddr) String() string { return fmt.Sprintf("%s:%d", net.IP(ipb).String(), ipa.Port) } -// AsyncMessage messages that perform an action when received must implement this interface. -// Process() is called after the message is pulled off of messageEvent channel. +// asyncMessage messages that perform an action when received must implement this interface. +// process() is called after the message is pulled off of messageEvent channel. // Messages should place themselves on the messageEvent channel in their // Handle() method required by gnet. -type AsyncMessage interface { - Process(d Daemoner) +type asyncMessage interface { + process(d daemoner) } // GetPeersMessage sent to request peers type GetPeersMessage struct { - // c *gnet.MessageContext `enc:"-"` - // connID int `enc:"-"` addr string `enc:"-"` } @@ -151,13 +149,12 @@ func NewGetPeersMessage() *GetPeersMessage { // Handle handles message func (gpm *GetPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - // self.connID = mc.ConnID gpm.addr = mc.Addr - return daemon.(Daemoner).RecordMessageEvent(gpm, mc) + return daemon.(daemoner).recordMessageEvent(gpm, mc) } -// Process Notifies the Pex instance that peers were requested -func (gpm *GetPeersMessage) Process(d Daemoner) { +// process Notifies the Pex instance that peers were requested +func (gpm *GetPeersMessage) process(d daemoner) { if d.PexConfig().Disabled { return } @@ -170,7 +167,7 @@ func (gpm *GetPeersMessage) Process(d Daemoner) { m := NewGivePeersMessage(peers) if err := d.SendMessage(gpm.addr, m); err != nil { - logger.Errorf("Send GivePeersMessage to %s failed: %v", gpm.addr, err) + logger.WithField("addr", gpm.addr).WithError(err).Error("Send GivePeersMessage failed") } } @@ -208,11 +205,11 @@ func (gpm *GivePeersMessage) GetPeers() []string { // Handle handle message func (gpm *GivePeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gpm.c = mc - return daemon.(Daemoner).RecordMessageEvent(gpm, mc) + return daemon.(daemoner).recordMessageEvent(gpm, mc) } -// Process Notifies the Pex instance that peers were received -func (gpm *GivePeersMessage) Process(d Daemoner) { +// process Notifies the Pex instance that peers were received +func (gpm *GivePeersMessage) process(d daemoner) { if d.PexConfig().Disabled { return } @@ -232,7 +229,7 @@ type IntroductionMessage struct { // Protocol version ProtocolVersion int32 c *gnet.MessageContext `enc:"-"` - // We validate the message in Handle() and cache the result for Process() + // We validate the message in Handle() and cache the result for process() valid bool `enc:"-"` // skip it during encoding // Extra is extra bytes added to the struct to accommodate multiple versions of this packet. // Currently it contains the blockchain pubkey but will accept a client that does not provide it. @@ -252,12 +249,15 @@ func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey ci // Handle Responds to an gnet.Pool event. We implement Handle() here because we // need to control the DisconnectReason sent back to gnet. func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - d := daemon.(Daemoner) + d := daemon.(daemoner) err := func() error { // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { - logger.Infof("Remote mirror value %v matches ours", intro.Mirror) + logger.WithFields(logrus.Fields{ + "addr": mc.Addr, + "mirror": intro.Mirror, + }).Infof("Remote mirror value matches ours") if err := d.Disconnect(mc.Addr, ErrDisconnectSelf); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -267,7 +267,11 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // Disconnect if peer version is not within the supported range dc := d.DaemonConfig() if intro.ProtocolVersion < dc.MinProtocolVersion { - logger.Infof("%s protocol version %d below minimum supported protocol version %d. Disconnecting.", mc.Addr, intro.ProtocolVersion, dc.MinProtocolVersion) + logger.WithFields(logrus.Fields{ + "addr": mc.Addr, + "protocolVersion": intro.ProtocolVersion, + "minProtocolVersion": dc.MinProtocolVersion, + }).Infof("protocol version below minimum supported protocol version") if err := d.Disconnect(mc.Addr, ErrDisconnectVersionNotSupported); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -284,7 +288,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.Infof("Extra data length does not meet the minimum requirement") + logger.WithField("addr", mc.Addr).Info("Extra data length does not meet the minimum requirement") if err := d.Disconnect(mc.Addr, ErrDisconnectInvalidExtraData); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -293,7 +297,11 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) if d.BlockchainPubkey() != bcPubKey { - logger.Infof("Blockchain pubkey does not match, local: %s, remote: %s", d.BlockchainPubkey().Hex(), bcPubKey.Hex()) + logger.WithFields(logrus.Fields{ + "addr": mc.Addr, + "pubkey": bcPubKey.Hex(), + "daemonPubkey": d.BlockchainPubkey().Hex(), + }).Info("Blockchain pubkey does not match") if err := d.Disconnect(mc.Addr, ErrDisconnectBlockchainPubkeyNotMatched); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -301,32 +309,6 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa } } - // only solicited connection can be added to exchange peer list, because accepted - // connection may not have an incoming port - ip, port, err := iputil.SplitAddr(mc.Addr) - if err != nil { - // This should never happen, but the program should still work if it does - logger.Errorf("Invalid Addr() for connection: %s", mc.Addr) - if err := d.Disconnect(mc.Addr, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") - } - return ErrDisconnectIncomprehensibleError - } - - // Checks if the introduction message is from outgoing connection. - // It's outgoing connection if port == intro.ListenPort, as the incoming - // connection's port is a random port, it's different from the port - // in introduction message. - if port == intro.ListenPort { - if err := d.SetHasIncomingPort(mc.Addr); err != nil { - logger.Errorf("Failed to set peer has incoming port status, %v", err) - } - } else { - if err := d.AddPeer(fmt.Sprintf("%s:%d", ip, intro.ListenPort)); err != nil { - logger.Errorf("Failed to add peer: %v", err) - } - } - return nil }() @@ -338,21 +320,22 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return err } - err = d.RecordMessageEvent(intro, mc) + err = d.recordMessageEvent(intro, mc) d.ResetRetryTimes(mc.Addr) return err } -// Process an event queued by Handle() -func (intro *IntroductionMessage) Process(d Daemoner) { +// process an event queued by Handle() +func (intro *IntroductionMessage) process(d daemoner) { if !intro.valid { return } a := intro.c.Addr - if err := d.ConnectionIntroduced(a, intro); err != nil { - logger.WithError(err).WithField("addr", a).Warning("ConnectionIntroduced failed") + c, err := d.connectionIntroduced(a, intro) + if err != nil { + logger.WithError(err).WithField("addr", a).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason switch err { case ErrConnectionIPMirrorAlreadyRegistered: @@ -368,6 +351,22 @@ func (intro *IntroductionMessage) Process(d Daemoner) { return } + if c.Outgoing { + // For successful outgoing connections, mark the peer as having an incoming port in the pex peerlist + // The peer should already be in the peerlist, since we use the peerlist to choose an outgoing connection to make + if err := d.SetHasIncomingPort(c.ListenAddr()); err != nil { + logger.WithField("addr", err).WithError(err).Error("SetHasIncomingPort failed") + } + } else { + // For successful incoming connections, add the peer to the peer list, with their self-reported listen port + if err := d.AddPeer(c.ListenAddr()); err != nil { + logger.WithError(err).WithFields(logrus.Fields{ + "addr": a, + "listenAddr": c.ListenAddr(), + }).Error("AddPeer failed") + } + } + // Request blocks immediately after they're confirmed if err := d.RequestBlocksFromAddr(intro.c.Addr); err != nil { logger.WithError(err).Warning("RequestBlocksFromAddr") @@ -389,11 +388,11 @@ type PingMessage struct { // Handle implements the Messager interface func (ping *PingMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { ping.c = mc - return daemon.(Daemoner).RecordMessageEvent(ping, mc) + return daemon.(daemoner).recordMessageEvent(ping, mc) } -// Process Sends a PongMessage to the sender of PingMessage -func (ping *PingMessage) Process(d Daemoner) { +// process Sends a PongMessage to the sender of PingMessage +func (ping *PingMessage) process(d daemoner) { if d.DaemonConfig().LogPings { logger.WithField("addr", ping.c.Addr).Debug("Replying to ping") } @@ -435,11 +434,11 @@ func NewGetBlocksMessage(lastBlock uint64, requestedBlocks uint64) *GetBlocksMes func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gbm.c = mc - return daemon.(Daemoner).RecordMessageEvent(gbm, mc) + return daemon.(daemoner).recordMessageEvent(gbm, mc) } -// Process should send number to be requested, with request -func (gbm *GetBlocksMessage) Process(d Daemoner) { +// process should send number to be requested, with request +func (gbm *GetBlocksMessage) process(d daemoner) { // TODO -- we need the sig to be sent with the block, but only the master // can sign blocks. Thus the sig needs to be stored with the block. if d.DaemonConfig().DisableNetworking { @@ -482,11 +481,11 @@ func NewGiveBlocksMessage(blocks []coin.SignedBlock) *GiveBlocksMessage { // Handle handle message func (gbm *GiveBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gbm.c = mc - return daemon.(Daemoner).RecordMessageEvent(gbm, mc) + return daemon.(daemoner).recordMessageEvent(gbm, mc) } -// Process process message -func (gbm *GiveBlocksMessage) Process(d Daemoner) { +// process process message +func (gbm *GiveBlocksMessage) process(d daemoner) { if d.DaemonConfig().DisableNetworking { logger.Critical().Info("Visor disabled, ignoring GiveBlocksMessage") return @@ -578,11 +577,11 @@ func NewAnnounceBlocksMessage(seq uint64) *AnnounceBlocksMessage { // Handle handles message func (abm *AnnounceBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { abm.c = mc - return daemon.(Daemoner).RecordMessageEvent(abm, mc) + return daemon.(daemoner).recordMessageEvent(abm, mc) } -// Process process message -func (abm *AnnounceBlocksMessage) Process(d Daemoner) { +// process process message +func (abm *AnnounceBlocksMessage) process(d daemoner) { if d.DaemonConfig().DisableNetworking { return } @@ -635,11 +634,11 @@ func (atm *AnnounceTxnsMessage) GetFiltered() []cipher.SHA256 { // Handle handle message func (atm *AnnounceTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { atm.c = mc - return daemon.(Daemoner).RecordMessageEvent(atm, mc) + return daemon.(daemoner).recordMessageEvent(atm, mc) } -// Process process message -func (atm *AnnounceTxnsMessage) Process(d Daemoner) { +// process process message +func (atm *AnnounceTxnsMessage) process(d daemoner) { if d.DaemonConfig().DisableNetworking { return } @@ -676,11 +675,11 @@ func NewGetTxnsMessage(txns []cipher.SHA256) *GetTxnsMessage { // Handle handle message func (gtm *GetTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gtm.c = mc - return daemon.(Daemoner).RecordMessageEvent(gtm, mc) + return daemon.(daemoner).recordMessageEvent(gtm, mc) } -// Process process message -func (gtm *GetTxnsMessage) Process(d Daemoner) { +// process process message +func (gtm *GetTxnsMessage) process(d daemoner) { if d.DaemonConfig().DisableNetworking { return } @@ -723,11 +722,11 @@ func (gtm *GiveTxnsMessage) GetFiltered() []cipher.SHA256 { // Handle handle message func (gtm *GiveTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { gtm.c = mc - return daemon.(Daemoner).RecordMessageEvent(gtm, mc) + return daemon.(daemoner).recordMessageEvent(gtm, mc) } -// Process process message -func (gtm *GiveTxnsMessage) Process(d Daemoner) { +// process process message +func (gtm *GiveTxnsMessage) process(d daemoner) { if d.DaemonConfig().DisableNetworking { return } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index f5b34bfa8e..686ad9a76b 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -35,6 +35,7 @@ func TestIntroductionMessage(t *testing.T) { disconnectErr error addPeerArg string addPeerErr error + connectionIntroduced *connection connectionIntroducedErr error requestBlocksFromAddrErr error announceAllTxnsErr error @@ -176,23 +177,7 @@ func TestIntroductionMessage(t *testing.T) { err: ErrDisconnectVersionNotSupported, }, { - name: "Invalid address", - addr: "121.121.121.121", - mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - disconnectReason: ErrDisconnectIncomprehensibleError, - pubkey: pubkey, - }, - intro: &IntroductionMessage{ - Mirror: 10001, - ProtocolVersion: 1, - ListenPort: 6000, - }, - err: ErrDisconnectIncomprehensibleError, - }, - { - name: "incomming connection", + name: "incoming connection", addr: "121.121.121.121:12345", mockValue: daemonMockValue{ mirror: 10000, @@ -237,7 +222,7 @@ func TestIntroductionMessage(t *testing.T) { mc := &gnet.MessageContext{Addr: tc.addr} tc.intro.c = mc - d := &MockDaemoner{} + d := &mockDaemoner{} d.On("DaemonConfig").Return(DaemonConfig{ ProtocolVersion: int32(tc.mockValue.protocolVersion), MinProtocolVersion: int32(tc.mockValue.minProtocolVersion), @@ -245,7 +230,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("Mirror").Return(tc.mockValue.mirror) d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) - d.On("RecordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) + d.On("recordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) d.On("ResetRetryTimes", tc.addr) d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) @@ -253,7 +238,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("RemoveFromExpectingIntroductions", tc.addr) d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) - d.On("ConnectionIntroduced", tc.addr, tc.intro).Return(tc.mockValue.connectionIntroducedErr) + d.On("connectionIntroduced", tc.addr, tc.intro).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) @@ -261,7 +246,7 @@ func TestIntroductionMessage(t *testing.T) { if tc.doProcess { require.NoError(t, err) - tc.intro.Process(d) + tc.intro.process(d) d.AssertCalled(t, "Disconnect", tc.addr, tc.mockValue.disconnectReason) } else { require.Equal(t, tc.err, err) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index 7f25e5f9e8..ba8205f1c3 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -9,13 +9,50 @@ import mock "github.com/stretchr/testify/mock" import pex "github.com/skycoin/skycoin/src/daemon/pex" import visor "github.com/skycoin/skycoin/src/visor" -// MockDaemoner is an autogenerated mock type for the Daemoner type -type MockDaemoner struct { +// mockDaemoner is an autogenerated mock type for the daemoner type +type mockDaemoner struct { mock.Mock } +// connectionIntroduced provides a mock function with given fields: addr, m +func (_m *mockDaemoner) connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) { + ret := _m.Called(addr, m) + + var r0 *connection + if rf, ok := ret.Get(0).(func(string, *IntroductionMessage) *connection); ok { + r0 = rf(addr, m) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*connection) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(string, *IntroductionMessage) error); ok { + r1 = rf(addr, m) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// recordMessageEvent provides a mock function with given fields: m, c +func (_m *mockDaemoner) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error { + ret := _m.Called(m, c) + + var r0 error + if rf, ok := ret.Get(0).(func(asyncMessage, *gnet.MessageContext) error); ok { + r0 = rf(m, c) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // AddPeer provides a mock function with given fields: addr -func (_m *MockDaemoner) AddPeer(addr string) error { +func (_m *mockDaemoner) AddPeer(addr string) error { ret := _m.Called(addr) var r0 error @@ -29,7 +66,7 @@ func (_m *MockDaemoner) AddPeer(addr string) error { } // AddPeers provides a mock function with given fields: addrs -func (_m *MockDaemoner) AddPeers(addrs []string) int { +func (_m *mockDaemoner) AddPeers(addrs []string) int { ret := _m.Called(addrs) var r0 int @@ -43,7 +80,7 @@ func (_m *MockDaemoner) AddPeers(addrs []string) int { } // AnnounceAllTxns provides a mock function with given fields: -func (_m *MockDaemoner) AnnounceAllTxns() error { +func (_m *mockDaemoner) AnnounceAllTxns() error { ret := _m.Called() var r0 error @@ -57,7 +94,7 @@ func (_m *MockDaemoner) AnnounceAllTxns() error { } // BlockchainPubkey provides a mock function with given fields: -func (_m *MockDaemoner) BlockchainPubkey() cipher.PubKey { +func (_m *mockDaemoner) BlockchainPubkey() cipher.PubKey { ret := _m.Called() var r0 cipher.PubKey @@ -73,7 +110,7 @@ func (_m *MockDaemoner) BlockchainPubkey() cipher.PubKey { } // BroadcastMessage provides a mock function with given fields: msg -func (_m *MockDaemoner) BroadcastMessage(msg gnet.Message) error { +func (_m *mockDaemoner) BroadcastMessage(msg gnet.Message) error { ret := _m.Called(msg) var r0 error @@ -86,22 +123,8 @@ func (_m *MockDaemoner) BroadcastMessage(msg gnet.Message) error { return r0 } -// ConnectionIntroduced provides a mock function with given fields: addr, m -func (_m *MockDaemoner) ConnectionIntroduced(addr string, m *IntroductionMessage) error { - ret := _m.Called(addr, m) - - var r0 error - if rf, ok := ret.Get(0).(func(string, *IntroductionMessage) error); ok { - r0 = rf(addr, m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // DaemonConfig provides a mock function with given fields: -func (_m *MockDaemoner) DaemonConfig() DaemonConfig { +func (_m *mockDaemoner) DaemonConfig() DaemonConfig { ret := _m.Called() var r0 DaemonConfig @@ -115,7 +138,7 @@ func (_m *MockDaemoner) DaemonConfig() DaemonConfig { } // Disconnect provides a mock function with given fields: addr, r -func (_m *MockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { +func (_m *mockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { ret := _m.Called(addr, r) var r0 error @@ -129,7 +152,7 @@ func (_m *MockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { } // ExecuteSignedBlock provides a mock function with given fields: b -func (_m *MockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { +func (_m *mockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { ret := _m.Called(b) var r0 error @@ -143,7 +166,7 @@ func (_m *MockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { } // GetSignedBlocksSince provides a mock function with given fields: seq, count -func (_m *MockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { +func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { ret := _m.Called(seq, count) var r0 []coin.SignedBlock @@ -166,7 +189,7 @@ func (_m *MockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.S } // GetUnconfirmedKnown provides a mock function with given fields: txns -func (_m *MockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { +func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { ret := _m.Called(txns) var r0 coin.Transactions @@ -189,7 +212,7 @@ func (_m *MockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transact } // GetUnconfirmedUnknown provides a mock function with given fields: txns -func (_m *MockDaemoner) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +func (_m *mockDaemoner) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { ret := _m.Called(txns) var r0 []cipher.SHA256 @@ -212,7 +235,7 @@ func (_m *MockDaemoner) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SH } // HeadBkSeq provides a mock function with given fields: -func (_m *MockDaemoner) HeadBkSeq() (uint64, bool, error) { +func (_m *mockDaemoner) HeadBkSeq() (uint64, bool, error) { ret := _m.Called() var r0 uint64 @@ -240,12 +263,12 @@ func (_m *MockDaemoner) HeadBkSeq() (uint64, bool, error) { } // IncreaseRetryTimes provides a mock function with given fields: addr -func (_m *MockDaemoner) IncreaseRetryTimes(addr string) { +func (_m *mockDaemoner) IncreaseRetryTimes(addr string) { _m.Called(addr) } // InjectTransaction provides a mock function with given fields: txn -func (_m *MockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { +func (_m *mockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { ret := _m.Called(txn) var r0 bool @@ -275,7 +298,7 @@ func (_m *MockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.Er } // IsDefaultConnection provides a mock function with given fields: addr -func (_m *MockDaemoner) IsDefaultConnection(addr string) bool { +func (_m *mockDaemoner) IsDefaultConnection(addr string) bool { ret := _m.Called(addr) var r0 bool @@ -289,7 +312,7 @@ func (_m *MockDaemoner) IsDefaultConnection(addr string) bool { } // IsMaxDefaultConnectionsReached provides a mock function with given fields: -func (_m *MockDaemoner) IsMaxDefaultConnectionsReached() (bool, error) { +func (_m *mockDaemoner) IsMaxDefaultConnectionsReached() (bool, error) { ret := _m.Called() var r0 bool @@ -310,7 +333,7 @@ func (_m *MockDaemoner) IsMaxDefaultConnectionsReached() (bool, error) { } // Mirror provides a mock function with given fields: -func (_m *MockDaemoner) Mirror() uint32 { +func (_m *mockDaemoner) Mirror() uint32 { ret := _m.Called() var r0 uint32 @@ -324,7 +347,7 @@ func (_m *MockDaemoner) Mirror() uint32 { } // PexConfig provides a mock function with given fields: -func (_m *MockDaemoner) PexConfig() pex.Config { +func (_m *mockDaemoner) PexConfig() pex.Config { ret := _m.Called() var r0 pex.Config @@ -338,7 +361,7 @@ func (_m *MockDaemoner) PexConfig() pex.Config { } // RandomExchangeable provides a mock function with given fields: n -func (_m *MockDaemoner) RandomExchangeable(n int) pex.Peers { +func (_m *mockDaemoner) RandomExchangeable(n int) pex.Peers { ret := _m.Called(n) var r0 pex.Peers @@ -353,27 +376,13 @@ func (_m *MockDaemoner) RandomExchangeable(n int) pex.Peers { return r0 } -// RecordMessageEvent provides a mock function with given fields: m, c -func (_m *MockDaemoner) RecordMessageEvent(m AsyncMessage, c *gnet.MessageContext) error { - ret := _m.Called(m, c) - - var r0 error - if rf, ok := ret.Get(0).(func(AsyncMessage, *gnet.MessageContext) error); ok { - r0 = rf(m, c) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // RecordPeerHeight provides a mock function with given fields: addr, height -func (_m *MockDaemoner) RecordPeerHeight(addr string, height uint64) { +func (_m *mockDaemoner) RecordPeerHeight(addr string, height uint64) { _m.Called(addr, height) } // RequestBlocksFromAddr provides a mock function with given fields: addr -func (_m *MockDaemoner) RequestBlocksFromAddr(addr string) error { +func (_m *mockDaemoner) RequestBlocksFromAddr(addr string) error { ret := _m.Called(addr) var r0 error @@ -387,12 +396,12 @@ func (_m *MockDaemoner) RequestBlocksFromAddr(addr string) error { } // ResetRetryTimes provides a mock function with given fields: addr -func (_m *MockDaemoner) ResetRetryTimes(addr string) { +func (_m *mockDaemoner) ResetRetryTimes(addr string) { _m.Called(addr) } // SendMessage provides a mock function with given fields: addr, msg -func (_m *MockDaemoner) SendMessage(addr string, msg gnet.Message) error { +func (_m *mockDaemoner) SendMessage(addr string, msg gnet.Message) error { ret := _m.Called(addr, msg) var r0 error @@ -406,7 +415,7 @@ func (_m *MockDaemoner) SendMessage(addr string, msg gnet.Message) error { } // SetHasIncomingPort provides a mock function with given fields: addr -func (_m *MockDaemoner) SetHasIncomingPort(addr string) error { +func (_m *mockDaemoner) SetHasIncomingPort(addr string) error { ret := _m.Called(addr) var r0 error From b1167bb0e37631f5a8461f1cea033c50a831581d Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 17:24:39 +0800 Subject: [PATCH 311/399] Fix lint --- src/daemon/connections.go | 16 ++++++++-------- src/daemon/connections_test.go | 7 +++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 14aa518849..40f211724c 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -186,11 +186,6 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti return nil, ErrConnectionNotExist } - listenPort := conn.ListenPort - if !conn.Outgoing { - listenPort = m.ListenPort - } - if conn.State != ConnectionStateConnected { logger.Critical().WithFields(logrus.Fields{ "addr": conn.Addr, @@ -198,7 +193,7 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti }).Warningf("Transitioning to State %q but State is not %q", ConnectionStateIntroduced, ConnectionStateConnected) } - if err := c.canUpdateMirror(ip, m.Mirror, listenPort); err != nil { + if err := c.canUpdateMirror(ip, m.Mirror); err != nil { return nil, err } @@ -210,11 +205,16 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti if conn.Outgoing && conn.ListenPort != m.ListenPort { logger.Critical().WithFields(logrus.Fields{ "addr": conn.Addr, - "connListenPort": listenPort, + "connListenPort": conn.ListenPort, "messageListenPort": m.ListenPort, }).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") } + listenPort := conn.ListenPort + if !conn.Outgoing { + listenPort = m.ListenPort + } + if err := c.updateMirror(ip, m.Mirror, listenPort); err != nil { logger.WithError(err).Panic("updateMirror failed, but shouldn't") } @@ -293,7 +293,7 @@ func (c *Connections) updateMirror(ip string, mirror uint32, port uint16) error // canUpdateMirror returns false if a connection already exists with the same base IP and mirror value. // This prevents duplicate connections to/from a single client. -func (c *Connections) canUpdateMirror(ip string, mirror uint32, port uint16) error { +func (c *Connections) canUpdateMirror(ip string, mirror uint32) error { x := c.mirrors[mirror] if x == nil { return nil diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go index 3cbeee87fa..f8873ecd53 100644 --- a/src/daemon/connections_test.go +++ b/src/daemon/connections_test.go @@ -299,7 +299,9 @@ func TestConnectionsMultiple(t *testing.T) { require.Equal(t, 1, conns.IPCount("127.1.1.1")) err = conns.remove(addr1) + require.NoError(t, err) err = conns.remove(addr2) + require.NoError(t, err) err = conns.remove(addr3) require.NoError(t, err) require.Empty(t, conns.mirrors) @@ -338,6 +340,7 @@ func TestConnectionsSetHeight(t *testing.T) { require.Empty(t, c.Height) err = conns.SetHeight(addr, height) + require.NoError(t, err) c = conns.get(addr) require.NotNil(t, c) @@ -353,8 +356,8 @@ func TestConnectionsModifyMirrorPanics(t *testing.T) { // modifying mirror value causes panic require.Panics(t, func() { - conns.modify(addr, func(c *ConnectionDetails) { + conns.modify(addr, func(c *ConnectionDetails) { // nolint: errcheck c.Mirror++ - }) // nolint: errcheck + }) }) } From 5035614d1f55af8f8bd6a99bde600dd7add5093a Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 17:51:16 +0800 Subject: [PATCH 312/399] Manage UserAgent inside daemon.Connections --- src/api/network_test.go | 13 +++++++++---- src/daemon/connections.go | 3 +++ src/daemon/gateway.go | 8 ++++---- src/daemon/messages.go | 9 --------- src/readable/network.go | 12 ++++++------ src/util/useragent/useragent.go | 10 ++++++++++ src/util/useragent/useragent_test.go | 12 ++++++++++++ 7 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/api/network_test.go b/src/api/network_test.go index f7c3f8bcba..e0f14b5bdd 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -14,6 +14,7 @@ import ( "github.com/skycoin/skycoin/src/daemon" "github.com/skycoin/skycoin/src/readable" + "github.com/skycoin/skycoin/src/util/useragent" ) func TestConnection(t *testing.T) { @@ -50,8 +51,8 @@ func TestConnection(t *testing.T) { addr: "addr", gatewayGetConnectionResult: &daemon.Connection{ Addr: "127.0.0.1:6061", - GnetConnectionDetails: daemon.GnetConnectionDetails{ - GnetID: 1, + Gnet: daemon.GnetConnectionDetails{ + ID: 1, LastSent: time.Unix(99999, 0), LastReceived: time.Unix(1111111, 0), }, @@ -62,6 +63,7 @@ func TestConnection(t *testing.T) { Mirror: 6789, ListenPort: 9877, Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, }, result: &readable.Connection{ @@ -75,6 +77,7 @@ func TestConnection(t *testing.T) { Mirror: 6789, ListenPort: 9877, Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, }, @@ -155,8 +158,8 @@ func TestConnections(t *testing.T) { gatewayGetSolicitedConnectionsResult: []daemon.Connection{ { Addr: "127.0.0.1:6061", - GnetConnectionDetails: daemon.GnetConnectionDetails{ - GnetID: 1, + Gnet: daemon.GnetConnectionDetails{ + ID: 1, LastSent: time.Unix(99999, 0), LastReceived: time.Unix(1111111, 0), }, @@ -167,6 +170,7 @@ func TestConnections(t *testing.T) { Mirror: 9876, ListenPort: 9877, Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, }, }, @@ -183,6 +187,7 @@ func TestConnections(t *testing.T) { Mirror: 9876, ListenPort: 9877, Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, }, }, diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 40f211724c..a2a077967b 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -9,6 +9,7 @@ import ( "github.com/sirupsen/logrus" "github.com/skycoin/skycoin/src/util/iputil" + "github.com/skycoin/skycoin/src/util/useragent" ) // ConnectionState connection state in the state machine @@ -49,6 +50,7 @@ type ConnectionDetails struct { ListenPort uint16 ProtocolVersion int32 Height uint64 + UserAgent useragent.Data } // HasIntroduced returns true if the connection has introduced @@ -223,6 +225,7 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti conn.Mirror = m.Mirror conn.ProtocolVersion = m.ProtocolVersion conn.ListenPort = listenPort + conn.UserAgent = m.userAgentData logger.WithFields(logrus.Fields{ "addr": addr, diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 815b7567a3..88d684f88e 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -90,13 +90,13 @@ func (gw *Gateway) strand(name string, f func()) { type Connection struct { Addr string Pex pex.Peer + Gnet GnetConnectionDetails ConnectionDetails - GnetConnectionDetails } // GnetConnectionDetails connection data from gnet type GnetConnectionDetails struct { - GnetID int + ID int LastSent time.Time LastReceived time.Time } @@ -110,8 +110,8 @@ func newConnection(dc *connection, gc *gnet.Connection, pp *pex.Peer) Connection } if gc != nil { - c.GnetConnectionDetails = GnetConnectionDetails{ - GnetID: gc.ID, + c.Gnet = GnetConnectionDetails{ + ID: gc.ID, LastSent: gc.LastSent, LastReceived: gc.LastReceived, } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index e6d4bccdf6..a3f867a2c0 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -413,15 +413,6 @@ func (intro *IntroductionMessage) process(d daemoner) { } } - // Record the user agent of the peer - // TODO -- remove and handle inside Connections - if err := d.RecordUserAgent(a, intro.userAgentData); err != nil { - logger.WithError(err).WithFields(logrus.Fields{ - "addr": a, - "userAgentData": fmt.Sprintf("%+v", intro.userAgentData), - }).Error("RecordUserAgent failed") - } - // Request blocks immediately after they're confirmed if err := d.RequestBlocksFromAddr(intro.c.Addr); err != nil { logger.WithError(err).Warning("RequestBlocksFromAddr") diff --git a/src/readable/network.go b/src/readable/network.go index a3b5f24650..17cd04f512 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -26,18 +26,18 @@ func NewConnection(c *daemon.Connection) Connection { var lastReceived int64 var connectedAt int64 - if !c.LastSent.IsZero() { - lastSent = c.LastSent.Unix() + if !c.Gnet.LastSent.IsZero() { + lastSent = c.Gnet.LastSent.Unix() } - if !c.LastReceived.IsZero() { - lastReceived = c.LastReceived.Unix() + if !c.Gnet.LastReceived.IsZero() { + lastReceived = c.Gnet.LastReceived.Unix() } if !c.ConnectedAt.IsZero() { connectedAt = c.ConnectedAt.Unix() } return Connection{ - GnetID: c.GnetID, + GnetID: c.Gnet.ID, Addr: c.Addr, LastSent: lastSent, LastReceived: lastReceived, @@ -47,6 +47,6 @@ func NewConnection(c *daemon.Connection) Connection { Mirror: c.Mirror, ListenPort: c.ListenPort, Height: c.Height, - UserAgent: c.Pex.UserAgent, + UserAgent: c.UserAgent, } } diff --git a/src/util/useragent/useragent.go b/src/util/useragent/useragent.go index b04763f11d..834d90d8c9 100644 --- a/src/util/useragent/useragent.go +++ b/src/util/useragent/useragent.go @@ -184,6 +184,16 @@ func Parse(userAgent string) (Data, error) { }, nil } +// MustParse parses and panics on error +func MustParse(userAgent string) Data { + d, err := Parse(userAgent) + if err != nil { + panic(err) + } + + return d +} + // validate validates a user agent string. The user agent must not contain illegal characters. func validate(userAgent string) error { if len(userAgent) > MaxLen { diff --git a/src/util/useragent/useragent_test.go b/src/util/useragent/useragent_test.go index 787ddbee1e..8f229bc4c6 100644 --- a/src/util/useragent/useragent_test.go +++ b/src/util/useragent/useragent_test.go @@ -227,3 +227,15 @@ func TestEmpty(t *testing.T) { d.Version = "0.24.1" require.False(t, d.Empty()) } + +func TestMustParse(t *testing.T) { + d := MustParse("skycoin:0.25.0") + require.Equal(t, Data{ + Coin: "skycoin", + Version: "0.25.0", + }, d) + + require.Panics(t, func() { + MustParse("foo") // nolint: errcheck + }) +} From 986a28f8ae79c4a5f0ada52832773c94ae341bcc Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 17:53:20 +0800 Subject: [PATCH 313/399] Fixup warning --- src/daemon/connections.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index a2a077967b..bd67ed7a7e 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -364,8 +364,8 @@ func (c *Connections) remove(addr string) error { if conn != nil { x, ok := c.mirrors[conn.Mirror] if ok { - if x[ip] != port { - logger.Critical().WithField("addr", addr).Warning("Indexed IP+Mirror value found but the port doesn't match") + if x[ip] != conn.ListenPort { + logger.Critical().WithField("addr", addr).Warning("Indexed IP+Mirror value found but the ListenPort doesn't match") } delete(x, ip) From 3b3f7f3856038022d823772db04a75f0ec308c98 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 17:57:14 +0800 Subject: [PATCH 314/399] Fix lint --- src/daemon/connections.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index bd67ed7a7e..8bb2072155 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -355,7 +355,7 @@ func (c *Connections) remove(addr string) error { c.Lock() defer c.Unlock() - ip, port, err := iputil.SplitAddr(addr) + ip, _, err := iputil.SplitAddr(addr) if err != nil { return err } From 6a71748d598d4a0dc8d2537473261966bd6a6562 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 19:27:13 +0800 Subject: [PATCH 315/399] Merge daemon events to one channel --- src/daemon/connections.go | 35 +++--- src/daemon/connections_test.go | 4 +- src/daemon/daemon.go | 190 +++++++++++++++------------------ src/daemon/gateway.go | 6 +- src/daemon/messages.go | 14 ++- src/daemon/messages_test.go | 2 +- 6 files changed, 126 insertions(+), 125 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 8bb2072155..ee5e78fc01 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -35,10 +35,10 @@ const ( var ( // ErrConnectionNotExist connection does not exist when performing an operation that requires it to exist ErrConnectionNotExist = errors.New("Connection does not exist") - // ErrConnectionAlreadyRegistered connection already registered in Connections - ErrConnectionAlreadyRegistered = errors.New("Connection already registered") - // ErrConnectionIPMirrorAlreadyRegistered connection already registered for a given base IP and mirror - ErrConnectionIPMirrorAlreadyRegistered = errors.New("Connection already registered with this base IP and mirror") + // ErrConnectionExists connection exists in Connections + ErrConnectionExists = errors.New("Connection exists") + // ErrConnectionIPMirrorExists connection exists for a given base IP and mirror + ErrConnectionIPMirrorExists = errors.New("Connection exists with this base IP and mirror") ) // ConnectionDetails connection data managed by daemon @@ -111,7 +111,7 @@ func (c *Connections) pending(addr string) (*connection, error) { } if _, ok := c.conns[addr]; ok { - return nil, ErrConnectionAlreadyRegistered + return nil, ErrConnectionExists } c.ipCounts[ip]++ @@ -135,6 +135,12 @@ func (c *Connections) connected(addr string) (*connection, error) { c.Lock() defer c.Unlock() + // TODO -- we can have a pending outgoing connection, + // simulataneously the other client establishes an incoming connection, + // but we'll think it's an outgoing connection since it exists already + // Then one of them will fail and we'll remove it, ending up with no connection + // So we need to disambiguate the direction + ip, _, err := iputil.SplitAddr(addr) if err != nil { return nil, err @@ -158,7 +164,7 @@ func (c *Connections) connected(addr string) (*connection, error) { } if conn.State != ConnectionStatePending { - logger.Critical().WithField("state", conn.State).Warningf("Transitioning to State %q but State is not %q", ConnectionStateConnected, ConnectionStatePending) + logger.Critical().WithField("state", conn.State).Warningf("Transitioning to state %q but state is not %q", ConnectionStateConnected, ConnectionStatePending) } } @@ -190,12 +196,17 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti if conn.State != ConnectionStateConnected { logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - }).Warningf("Transitioning to State %q but State is not %q", ConnectionStateIntroduced, ConnectionStateConnected) + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + }).Warningf("Transitioning to state %q but state is not %q", ConnectionStateIntroduced, ConnectionStateConnected) } if err := c.canUpdateMirror(ip, m.Mirror); err != nil { + logger.WithFields(logrus.Fields{ + "addr": conn.Addr, + "outgoing": conn.Outgoing, + }).WithError(err).Debug("canUpdateMirror failed") return nil, err } @@ -277,15 +288,13 @@ func (c *Connections) SetHeight(addr string, height uint64) error { } func (c *Connections) updateMirror(ip string, mirror uint32, port uint16) error { - logger.Debugf("updateMirror ip=%s mirror=%d port=%d", ip, mirror, port) - x := c.mirrors[mirror] if x == nil { x = make(map[string]uint16, 2) } if _, ok := x[ip]; ok { - return ErrConnectionIPMirrorAlreadyRegistered + return ErrConnectionIPMirrorExists } x[ip] = port @@ -303,7 +312,7 @@ func (c *Connections) canUpdateMirror(ip string, mirror uint32) error { } if _, ok := x[ip]; ok { - return ErrConnectionIPMirrorAlreadyRegistered + return ErrConnectionIPMirrorExists } return nil diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go index f8873ecd53..6ccd63909a 100644 --- a/src/daemon/connections_test.go +++ b/src/daemon/connections_test.go @@ -61,7 +61,7 @@ func TestConnectionsOutgoingFlow(t *testing.T) { require.Equal(t, []connection{*c}, all) _, err = conns.pending(addr) - require.Equal(t, ErrConnectionAlreadyRegistered, err) + require.Equal(t, ErrConnectionExists, err) require.Equal(t, 1, conns.IPCount(ip)) require.Equal(t, 1, conns.OutgoingLen()) require.Equal(t, 1, conns.PendingLen()) @@ -256,7 +256,7 @@ func TestConnectionsMultiple(t *testing.T) { ListenPort: 6061, ProtocolVersion: 2, }) - require.Equal(t, ErrConnectionIPMirrorAlreadyRegistered, err) + require.Equal(t, ErrConnectionIPMirrorExists, err) require.Equal(t, 0, conns.PendingLen()) c := conns.get(addr2) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 5b0eda7289..558b4167e1 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -277,14 +277,19 @@ type Daemon struct { announcedTxns *announcedTxnsCache // Cache of connection metadata connections *Connections - // Client connection callbacks - onConnectEvent chan ConnectEvent - // Client disconnection callbacks - onDisconnectEvent chan DisconnectEvent - // Connection failure events - connectionErrors chan ConnectionError - // Message handling queue - messageEvents chan messageEvent + + // // Client connection callbacks + // onConnectEvent chan ConnectEvent + // // Client disconnection callbacks + // onDisconnectEvent chan DisconnectEvent + // // Connection failure events + // connectionErrors chan ConnectionError + // // Message handling queue + // messageEvents chan messageEvent + + // connect, disconnect, message, error events channel + events chan interface{} + // quit channel quit chan struct{} // done channel @@ -317,15 +322,13 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { announcedTxns: newAnnouncedTxnsCache(), connections: NewConnections(), - // TODO -- if there are performance problems from blocking chans, - // Its because we are connecting to more things than OutgoingMax - // if we have private peers - onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), - onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), - connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), - messageEvents: make(chan messageEvent, config.Pool.EventChannelSize), - quit: make(chan struct{}), - done: make(chan struct{}), + // onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), + // onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), + // connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), + // messageEvents: make(chan messageEvent, config.Pool.EventChannelSize), + events: make(chan interface{}, config.Pool.EventChannelSize), + quit: make(chan struct{}), + done: make(chan struct{}), } d.Gateway = NewGateway(config.Gateway, d) @@ -524,7 +527,7 @@ loop: m := NewGetPeersMessage() if err := dm.pool.Pool.BroadcastMessage(m); err != nil { - logger.Error(err) + logger.WithError(err).Error("Broadcast GetPeersMessage failed") } case <-clearStaleConnectionsTicker.C: @@ -559,33 +562,13 @@ loop: dm.makePrivateConnections() } - case r := <-dm.onConnectEvent: - // Process callbacks for when a client connects. No disconnect chan - // is needed because the callback is triggered by HandleDisconnectEvent - // which is already select{}ed here - elapser.Register("dm.onConnectEvent") - if dm.Config.DisableNetworking { - logger.Error("There should be no connect events") - return nil - } - dm.onConnect(r) - - case de := <-dm.onDisconnectEvent: - elapser.Register("dm.onDisconnectEvent") - if dm.Config.DisableNetworking { - logger.Error("There should be no disconnect events") - return nil - } - dm.onDisconnect(de) - - case r := <-dm.connectionErrors: - // Handle connection errors - elapser.Register("dm.connectionErrors") + case r := <-dm.events: + elapser.Register("dm.event") if dm.Config.DisableNetworking { - logger.Error("There should be no connection errors") + logger.Error("There should be no events") return nil } - dm.handleConnectionError(r) + dm.handleEvent(r) case <-flushAnnouncedTxnsTicker.C: elapser.Register("flushAnnouncedTxnsTicker") @@ -596,15 +579,6 @@ loop: return err } - case m := <-dm.messageEvents: - // Message handlers - elapser.Register("dm.messageEvents") - if dm.Config.DisableNetworking { - logger.Error("There should be no message events") - return nil - } - dm.processMessageEvent(m) - case req := <-dm.Gateway.requests: // Process any pending RPC requests elapser.Register("dm.Gateway.requests") @@ -705,7 +679,7 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { return errors.New("Already connected to a peer with this base IP") } - logger.WithField("addr", p.Addr).Debug("Establishing outgoing conneciton") + logger.WithField("addr", p.Addr).Debug("Establishing outgoing connection") if _, err := dm.connections.pending(p.Addr); err != nil { logger.Critical().WithError(err).WithField("addr", p.Addr).Error("dm.connections.pending failed") @@ -714,7 +688,10 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { go func() { if err := dm.pool.Pool.Connect(p.Addr); err != nil { - dm.connectionErrors <- ConnectionError{p.Addr, err} + dm.events <- ConnectionError{ + Addr: p.Addr, + Error: err, + } } }() return nil @@ -769,18 +746,6 @@ func (dm *Daemon) connectToRandomPeer() { } } -// handleConnectionError removes the pending connection from connections and -// updates the retry times in pex -func (dm *Daemon) handleConnectionError(c ConnectionError) { - logger.WithField("addr", c.Addr).WithError(c.Error).Debug("handleConnectionError") - if err := dm.connections.remove(c.Addr); err != nil { - logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") - } - - // TODO - On failure to connect, use exponential backoff, not peer list - dm.pex.IncreaseRetryTimes(c.Addr) -} - // Removes connections who haven't sent a version after connecting func (dm *Daemon) cullInvalidConnections() { now := time.Now().UTC() @@ -810,7 +775,10 @@ func (dm *Daemon) isTrustedPeer(addr string) bool { // recordMessageEvent records an asyncMessage to the messageEvent chan. Do not access // messageEvent directly. func (dm *Daemon) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error { - dm.messageEvents <- messageEvent{m, c} + dm.events <- messageEvent{ + Message: m, + Context: c, + } return nil } @@ -823,8 +791,25 @@ func (dm *Daemon) needsIntro(addr string) bool { return c != nil && !c.HasIntroduced() } -// Processes a queued asyncMessage. -func (dm *Daemon) processMessageEvent(e messageEvent) { +func (dm *Daemon) handleEvent(e interface{}) { + switch x := e.(type) { + case messageEvent: + dm.onMessageEvent(x) + case ConnectEvent: + dm.onConnectEvent(x) + case DisconnectEvent: + dm.onDisconnectEvent(x) + case ConnectionError: + dm.onConnectionError(x) + default: + logger.WithFields(logrus.Fields{ + "type": fmt.Sprintf("%T", e), + "value": fmt.Sprintf("%+v", e), + }).Panic("Invalid object in events queue") + } +} + +func (dm *Daemon) onMessageEvent(e messageEvent) { // The first message received must be an Introduction // We have to check at process time and not record time because // Introduction message does not update ExpectingIntroductions until its @@ -844,32 +829,28 @@ func (dm *Daemon) processMessageEvent(e messageEvent) { e.Message.process(dm) } -// Called when a ConnectEvent is processed off the onConnectEvent channel -func (dm *Daemon) onConnect(e ConnectEvent) { - direction := "incoming" - if e.Solicited { - direction = "outgoing" +func (dm *Daemon) onConnectEvent(e ConnectEvent) { + fields := logrus.Fields{ + "addr": e.Addr, + "outgoing": e.Solicited, } - logger.WithFields(logrus.Fields{ - "addr": e.Addr, - "direction": direction, - }).Info("Connected to peer") + logger.WithFields(fields).Info("Connected to peer") exist, err := dm.pool.Pool.IsConnExist(e.Addr) if err != nil { - logger.Critical().WithError(err).Error("IsConnExist failed") + logger.Critical().WithFields(fields).WithError(err).Error("IsConnExist failed") return } if !exist { - logger.Warning("While processing an onConnect event, no pool connection was found") + logger.WithFields(fields).Warning("While processing an onConnect event, no pool connection was found") return } if dm.ipCountMaxed(e.Addr) { - logger.WithField("addr", e.Addr).Info("Max connections for this address reached, disconnecting") + logger.WithFields(fields).Info("Max connections for this address reached, disconnecting") if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { - logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") + logger.WithError(err).WithFields(fields).Error("Disconnect") } return } @@ -878,14 +859,14 @@ func (dm *Daemon) onConnect(e ConnectEvent) { // Disconnect if the max outgoing connections is reached n, err := dm.pool.Pool.OutgoingConnectionsNum() if err != nil { - logger.Critical().WithError(err).Error("OutgoingConnectionsNum failed") + logger.Critical().WithError(err).WithFields(fields).Error("OutgoingConnectionsNum failed") return } if n > dm.Config.OutgoingMax { - logger.WithField("addr", e.Addr).Warning("Max outgoing connections is reached, disconnecting") + logger.WithFields(fields).Warning("Max outgoing connections is reached, disconnecting") if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { - logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") + logger.WithError(err).WithFields(fields).Error("Disconnect") } return } @@ -894,9 +875,9 @@ func (dm *Daemon) onConnect(e ConnectEvent) { // Update the connections state machine c, err := dm.connections.connected(e.Addr) if err != nil { - logger.Critical().WithError(err).WithField("addr", e.Addr).Error("connections.Connected failed") + logger.Critical().WithError(err).WithFields(fields).Error("connections.Connected failed") if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIncomprehensibleError); err != nil { - logger.WithError(err).WithField("addr", e.Addr).Error("Disconnect") + logger.WithError(err).WithFields(fields).Error("Disconnect") } return } @@ -904,29 +885,27 @@ func (dm *Daemon) onConnect(e ConnectEvent) { // The connection should already be known as outgoing/solicited due to an earlier connections.pending call. // If they do not match, there is e.Addr flaw in the concept or implementation of the state machine. if c.Outgoing != e.Solicited { - logger.Critical().Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") + logger.Critical().WithFields(fields).Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") } - logger.WithFields(logrus.Fields{ - "addr": e.Addr, - "mirror": dm.Messages.Mirror, - }).Debug("Sending introduction message") + logger.WithFields(fields).WithField("mirror", dm.Messages.Mirror).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) if err := dm.pool.Pool.SendMessage(e.Addr, m); err != nil { - logger.WithField("addr", e.Addr).WithError(err).Error("Send IntroductionMessage failed") + logger.WithFields(fields).WithError(err).Error("Send IntroductionMessage failed") return } } -func (dm *Daemon) onDisconnect(e DisconnectEvent) { - logger.WithFields(logrus.Fields{ +func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { + fields := logrus.Fields{ "addr": e.Addr, "reason": e.Reason, - }).Info("onDisconnect") + } + logger.WithFields(fields).Info("onDisconnect") if err := dm.connections.remove(e.Addr); err != nil { - logger.WithError(err).WithField("addr", e.Addr).Error("connections.Remove failed") + logger.WithError(err).WithFields(fields).Error("connections.Remove failed") } // If the peer did not send an introduction in time, it is not a valid peer and remove it from the peer list @@ -937,22 +916,29 @@ func (dm *Daemon) onDisconnect(e DisconnectEvent) { } } +func (dm *Daemon) onConnectionError(c ConnectionError) { + // Remove the pending connection from connections and update the retry times in pex + logger.WithField("addr", c.Addr).WithError(c.Error).Debug("onConnectionError") + if err := dm.connections.remove(c.Addr); err != nil { + logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") + } + + // TODO - On failure to connect, use exponential backoff, not peer list + dm.pex.IncreaseRetryTimes(c.Addr) +} + // Triggered when an gnet.Connection terminates func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { e := DisconnectEvent{ Addr: addr, Reason: reason, } - select { - case dm.onDisconnectEvent <- e: - default: - logger.Warning("onDisconnectEvent channel is full") - } + dm.events <- e } // Triggered when an gnet.Connection is connected func (dm *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) { - dm.onConnectEvent <- ConnectEvent{ + dm.events <- ConnectEvent{ Addr: c.Addr(), Solicited: solicited, } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 88d684f88e..0adf878cc4 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -144,9 +144,9 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { conns := make([]Connection, 0) for _, c := range cs { - if !c.Outgoing || c.State != ConnectionStateIntroduced { - continue - } + // if !c.Outgoing || c.State != ConnectionStateIntroduced { + // continue + // } cc, err := gw.newConnection(&c) if err != nil { diff --git a/src/daemon/messages.go b/src/daemon/messages.go index a3f867a2c0..85831f3939 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -275,6 +275,8 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa d := daemon.(daemoner) var userAgentData useragent.Data + logger.WithField("addr", mc.Addr).Debug("IntroductionMessage.Handle") + err := func() error { // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { @@ -305,7 +307,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa logger.WithFields(logrus.Fields{ "addr": mc.Addr, "protocolVersion": intro.ProtocolVersion, - }).Info("Peer protocol version accepted") + }).Debug("Peer protocol version accepted") // v24 does not send blockchain pubkey or user agent // v25 sends blockchain pubkey and user agent @@ -373,18 +375,22 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // process an event queued by Handle() func (intro *IntroductionMessage) process(d daemoner) { + a := intro.c.Addr + logger.WithFields(logrus.Fields{ + "addr": a, + "listenPort": intro.ListenPort, + }).Debug("IntroductionMessage.process") + if !intro.valid { return } - a := intro.c.Addr - c, err := d.connectionIntroduced(a, intro) if err != nil { logger.WithError(err).WithField("addr", a).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason switch err { - case ErrConnectionIPMirrorAlreadyRegistered: + case ErrConnectionIPMirrorExists: reason = ErrDisconnectConnectedTwice default: reason = ErrDisconnectIncomprehensibleError diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index d8d9622d6f..994bb6ffdd 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -245,7 +245,7 @@ func TestIntroductionMessage(t *testing.T) { addPeerArg: "121.121.121.121:6000", addPeerErr: nil, disconnectReason: ErrDisconnectConnectedTwice, - connectionIntroducedErr: ErrConnectionIPMirrorAlreadyRegistered, + connectionIntroducedErr: ErrConnectionIPMirrorExists, }, intro: &IntroductionMessage{ Mirror: 10001, From d15f593cd79b47a6c9afe272edbdffcbf86517b2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sat, 27 Oct 2018 20:02:30 +0800 Subject: [PATCH 316/399] Guard against expired message processing --- src/daemon/connections.go | 87 +++++++++++++++++++++++++------- src/daemon/connections_test.go | 49 ++++++++++++++---- src/daemon/daemon.go | 37 +++++--------- src/daemon/gateway.go | 6 +-- src/daemon/messages.go | 10 +++- src/daemon/mock_daemoner_test.go | 6 +-- 6 files changed, 135 insertions(+), 60 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index ee5e78fc01..e76f826152 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -39,6 +39,14 @@ var ( ErrConnectionExists = errors.New("Connection exists") // ErrConnectionIPMirrorExists connection exists for a given base IP and mirror ErrConnectionIPMirrorExists = errors.New("Connection exists with this base IP and mirror") + // ErrConnectionStateNotConnected connect state is not "connected" + ErrConnectionStateNotConnected = errors.New("Connection state is not \"connected\"") + // ErrConnectionGnetIDMismatch gnet ID in argument does not match gnet ID on record + ErrConnectionGnetIDMismatch = errors.New("Connection gnet ID does not match") + // ErrConnectionAlreadyIntroduced attempted to make invalid state transition from introduced state + ErrConnectionAlreadyIntroduced = errors.New("Connection is already in introduced state") + // ErrConnectionAlreadyConnected attempted to make invalid state transition from connected state + ErrConnectionAlreadyConnected = errors.New("Connection is already in connected state") ) // ConnectionDetails connection data managed by daemon @@ -66,6 +74,7 @@ func (c ConnectionDetails) HasIntroduced() bool { type connection struct { Addr string ConnectionDetails + gnetID int } // ListenAddr returns the addr that connection listens on, if available @@ -131,16 +140,10 @@ func (c *Connections) pending(addr string) (*connection, error) { } // connected the connection has connected -func (c *Connections) connected(addr string) (*connection, error) { +func (c *Connections) connected(addr string, gnetID int) (*connection, error) { c.Lock() defer c.Unlock() - // TODO -- we can have a pending outgoing connection, - // simulataneously the other client establishes an incoming connection, - // but we'll think it's an outgoing connection since it exists already - // Then one of them will fail and we'll remove it, ending up with no connection - // So we need to disambiguate the direction - ip, _, err := iputil.SplitAddr(addr) if err != nil { return nil, err @@ -163,17 +166,37 @@ func (c *Connections) connected(addr string) (*connection, error) { return nil, err } - if conn.State != ConnectionStatePending { - logger.Critical().WithField("state", conn.State).Warningf("Transitioning to state %q but state is not %q", ConnectionStateConnected, ConnectionStatePending) + switch conn.State { + case ConnectionStatePending: + case ConnectionStateConnected: + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "gnetID": gnetID, + }).Warningf("Connections.connected called on already connected connection") + return nil, ErrConnectionAlreadyConnected + case ConnectionStateIntroduced: + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "gnetID": gnetID, + }).Warning("Connections.connected called on already introduced connection") + return nil, ErrConnectionAlreadyIntroduced + default: + logger.Panic("Connection state invalid") } } + conn.gnetID = gnetID conn.ConnectedAt = time.Now().UTC() conn.State = ConnectionStateConnected logger.WithFields(logrus.Fields{ "addr": addr, "outgoing": conn.Outgoing, + "gnetID": gnetID, }).Debug("Connections.connected") return conn, nil @@ -194,12 +217,38 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti return nil, ErrConnectionNotExist } - if conn.State != ConnectionStateConnected { + switch conn.State { + case ConnectionStatePending: logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - }).Warningf("Transitioning to state %q but state is not %q", ConnectionStateIntroduced, ConnectionStateConnected) + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, + "gnetID": m.c.ConnID, + }).Warningf("Connections.introduced called on pending connection") + return nil, ErrConnectionStateNotConnected + case ConnectionStateConnected: + if m.c.ConnID != conn.gnetID { + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, + "gnetID": m.c.ConnID, + }).Warningf("Connections.introduced called with different gnet ID") + return nil, ErrConnectionGnetIDMismatch + } + case ConnectionStateIntroduced: + logger.Critical().WithFields(logrus.Fields{ + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, + "gnetID": m.c.ConnID, + }).Warning("Connections.introduced called on already introduced connection") + return nil, ErrConnectionAlreadyIntroduced + default: + logger.Panic("invalid connection state") } if err := c.canUpdateMirror(ip, m.Mirror); err != nil { @@ -256,12 +305,16 @@ func (c *Connections) get(addr string) *connection { // modify modifies a connection. // It is unsafe to modify the Mirror value with this method -func (c *Connections) modify(addr string, f func(c *ConnectionDetails)) error { +func (c *Connections) modify(addr string, gnetID int, f func(c *ConnectionDetails)) error { conn := c.conns[addr] if conn == nil { return ErrConnectionNotExist } + if conn.gnetID != gnetID { + return ErrConnectionGnetIDMismatch + } + // copy and modify cd := conn.ConnectionDetails @@ -278,11 +331,11 @@ func (c *Connections) modify(addr string, f func(c *ConnectionDetails)) error { } // SetHeight sets the height for a connection -func (c *Connections) SetHeight(addr string, height uint64) error { +func (c *Connections) SetHeight(addr string, gnetID int, height uint64) error { c.Lock() defer c.Unlock() - return c.modify(addr, func(c *ConnectionDetails) { + return c.modify(addr, gnetID, func(c *ConnectionDetails) { c.Height = height }) } diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go index 6ccd63909a..c8941320cb 100644 --- a/src/daemon/connections_test.go +++ b/src/daemon/connections_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/testutil" ) @@ -73,7 +74,15 @@ func TestConnectionsOutgoingFlow(t *testing.T) { all = conns.all() require.Equal(t, []connection{*c}, all) - c, err = conns.connected(addr) + _, err = conns.introduced(addr, &IntroductionMessage{ + c: &gnet.MessageContext{ + ConnID: 0, + }, + }) + require.Equal(t, ErrConnectionStateNotConnected, err) + require.Equal(t, 1, conns.PendingLen()) + + c, err = conns.connected(addr, 0) require.NoError(t, err) require.True(t, c.Outgoing) @@ -97,6 +106,9 @@ func TestConnectionsOutgoingFlow(t *testing.T) { ListenPort: port + 1, Mirror: 1111, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, } c, err = conns.introduced(addr, m) @@ -154,7 +166,7 @@ func TestConnectionsIncomingFlow(t *testing.T) { // Flow: connected, introduced - c, err := conns.connected(addr) + c, err := conns.connected(addr, 0) require.NoError(t, err) require.False(t, c.Outgoing) @@ -178,6 +190,9 @@ func TestConnectionsIncomingFlow(t *testing.T) { ListenPort: port + 1, Mirror: 1111, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, } c, err = conns.introduced(addr, m) @@ -233,11 +248,11 @@ func TestConnectionsMultiple(t *testing.T) { require.Equal(t, 2, conns.PendingLen()) require.Equal(t, 2, conns.IPCount("127.0.0.1")) - _, err = conns.connected(addr1) + _, err = conns.connected(addr1, 0) require.NoError(t, err) require.Equal(t, 1, conns.PendingLen()) - _, err = conns.connected(addr2) + _, err = conns.connected(addr2, 0) require.NoError(t, err) require.Equal(t, 0, conns.PendingLen()) @@ -245,6 +260,9 @@ func TestConnectionsMultiple(t *testing.T) { Mirror: 6, ListenPort: 6060, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, }) require.NoError(t, err) require.Equal(t, 0, conns.PendingLen()) @@ -255,6 +273,9 @@ func TestConnectionsMultiple(t *testing.T) { Mirror: 6, ListenPort: 6061, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, }) require.Equal(t, ErrConnectionIPMirrorExists, err) require.Equal(t, 0, conns.PendingLen()) @@ -266,6 +287,9 @@ func TestConnectionsMultiple(t *testing.T) { Mirror: 7, ListenPort: 6061, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, }) require.NoError(t, err) require.Equal(t, 2, len(conns.mirrors)) @@ -276,13 +300,16 @@ func TestConnectionsMultiple(t *testing.T) { // Add another connection with a different base IP but same mirror value addr3 := "127.1.1.1:12345" - _, err = conns.connected(addr3) + _, err = conns.connected(addr3, 0) require.NoError(t, err) _, err = conns.introduced(addr3, &IntroductionMessage{ Mirror: 6, ListenPort: 6060, ProtocolVersion: 2, + c: &gnet.MessageContext{ + ConnID: 0, + }, }) require.NoError(t, err) @@ -314,7 +341,7 @@ func TestConnectionsErrors(t *testing.T) { _, err := conns.pending("foo") testutil.RequireError(t, err, "address foo: missing port in address") - _, err = conns.connected("foo") + _, err = conns.connected("foo", 0) testutil.RequireError(t, err, "address foo: missing port in address") _, err = conns.introduced("foo", nil) @@ -332,14 +359,14 @@ func TestConnectionsSetHeight(t *testing.T) { addr := "127.0.0.1:6060" height := uint64(1010) - err := conns.SetHeight(addr, height) + err := conns.SetHeight(addr, 0, height) require.Equal(t, ErrConnectionNotExist, err) - c, err := conns.connected(addr) + c, err := conns.connected(addr, 0) require.NoError(t, err) require.Empty(t, c.Height) - err = conns.SetHeight(addr, height) + err = conns.SetHeight(addr, 0, height) require.NoError(t, err) c = conns.get(addr) @@ -351,12 +378,12 @@ func TestConnectionsModifyMirrorPanics(t *testing.T) { conns := NewConnections() addr := "127.0.0.1:6060" - _, err := conns.connected(addr) + _, err := conns.connected(addr, 0) require.NoError(t, err) // modifying mirror value causes panic require.Panics(t, func() { - conns.modify(addr, func(c *ConnectionDetails) { // nolint: errcheck + conns.modify(addr, 0, func(c *ConnectionDetails) { // nolint: errcheck c.Mirror++ }) }) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 558b4167e1..74df11c3f6 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -243,7 +243,7 @@ type daemoner interface { SetHasIncomingPort(addr string) error IncreaseRetryTimes(addr string) ResetRetryTimes(addr string) - RecordPeerHeight(addr string, height uint64) + RecordPeerHeight(addr string, gnetID int, height uint64) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) HeadBkSeq() (uint64, bool, error) ExecuteSignedBlock(b coin.SignedBlock) error @@ -277,19 +277,8 @@ type Daemon struct { announcedTxns *announcedTxnsCache // Cache of connection metadata connections *Connections - - // // Client connection callbacks - // onConnectEvent chan ConnectEvent - // // Client disconnection callbacks - // onDisconnectEvent chan DisconnectEvent - // // Connection failure events - // connectionErrors chan ConnectionError - // // Message handling queue - // messageEvents chan messageEvent - // connect, disconnect, message, error events channel events chan interface{} - // quit channel quit chan struct{} // done channel @@ -321,14 +310,9 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { announcedTxns: newAnnouncedTxnsCache(), connections: NewConnections(), - - // onConnectEvent: make(chan ConnectEvent, config.Pool.MaxConnections*2), - // onDisconnectEvent: make(chan DisconnectEvent, config.Pool.MaxConnections*2), - // connectionErrors: make(chan ConnectionError, config.Pool.MaxConnections*2), - // messageEvents: make(chan messageEvent, config.Pool.EventChannelSize), - events: make(chan interface{}, config.Pool.EventChannelSize), - quit: make(chan struct{}), - done: make(chan struct{}), + events: make(chan interface{}, config.Pool.EventChannelSize), + quit: make(chan struct{}), + done: make(chan struct{}), } d.Gateway = NewGateway(config.Gateway, d) @@ -340,6 +324,7 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { // ConnectEvent generated when a client connects type ConnectEvent struct { + GnetID int Addr string Solicited bool } @@ -833,8 +818,9 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { fields := logrus.Fields{ "addr": e.Addr, "outgoing": e.Solicited, + "gnetID": e.GnetID, } - logger.WithFields(fields).Info("Connected to peer") + logger.WithFields(fields).Info("onConnectEvent") exist, err := dm.pool.Pool.IsConnExist(e.Addr) if err != nil { @@ -873,7 +859,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { } // Update the connections state machine - c, err := dm.connections.connected(e.Addr) + c, err := dm.connections.connected(e.Addr, e.GnetID) if err != nil { logger.Critical().WithError(err).WithFields(fields).Error("connections.Connected failed") if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIncomprehensibleError); err != nil { @@ -902,7 +888,7 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { "addr": e.Addr, "reason": e.Reason, } - logger.WithFields(fields).Info("onDisconnect") + logger.WithFields(fields).Info("onDisconnectEvent") if err := dm.connections.remove(e.Addr); err != nil { logger.WithError(err).WithFields(fields).Error("connections.Remove failed") @@ -939,6 +925,7 @@ func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { // Triggered when an gnet.Connection is connected func (dm *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) { dm.events <- ConnectEvent{ + GnetID: c.ID, Addr: c.Addr(), Solicited: solicited, } @@ -1283,8 +1270,8 @@ func (dm *Daemon) ResetRetryTimes(addr string) { // Implements chain height store // RecordPeerHeight records the height of specific peer -func (dm *Daemon) RecordPeerHeight(addr string, height uint64) { - if err := dm.connections.SetHeight(addr, height); err != nil { +func (dm *Daemon) RecordPeerHeight(addr string, gnetID int, height uint64) { + if err := dm.connections.SetHeight(addr, gnetID, height); err != nil { logger.Critical().WithError(err).WithField("addr", addr).Error("connections.SetHeight failed") } } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 0adf878cc4..88d684f88e 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -144,9 +144,9 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { conns := make([]Connection, 0) for _, c := range cs { - // if !c.Outgoing || c.State != ConnectionStateIntroduced { - // continue - // } + if !c.Outgoing || c.State != ConnectionStateIntroduced { + continue + } cc, err := gw.newConnection(&c) if err != nil { diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 85831f3939..75672e7426 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -379,6 +379,7 @@ func (intro *IntroductionMessage) process(d daemoner) { logger.WithFields(logrus.Fields{ "addr": a, "listenPort": intro.ListenPort, + "gnetID": intro.c.ConnID, }).Debug("IntroductionMessage.process") if !intro.valid { @@ -390,6 +391,13 @@ func (intro *IntroductionMessage) process(d daemoner) { logger.WithError(err).WithField("addr", a).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason switch err { + // It is hypothetically possible that a message would get processed after + // a disconnect event for a given connection. + // In this case, drop the packet. + // Do not perform a disconnect, since this would operate on the new connection. + case ErrConnectionGnetIDMismatch, ErrConnectionStateNotConnected, ErrConnectionAlreadyIntroduced: + logger.Critical().WithError(err).Warning("IntroductionMessage.process connection state out of order") + return case ErrConnectionIPMirrorExists: reason = ErrDisconnectConnectedTwice default: @@ -497,7 +505,7 @@ func (gbm *GetBlocksMessage) process(d daemoner) { return } // Record this as this peer's highest block - d.RecordPeerHeight(gbm.c.Addr, gbm.LastBlock) + d.RecordPeerHeight(gbm.c.Addr, gbm.c.ConnID, gbm.LastBlock) // Fetch and return signed blocks since LastBlock blocks, err := d.GetSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) if err != nil { diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index 576401a555..e73fc53bfe 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -377,9 +377,9 @@ func (_m *mockDaemoner) RandomExchangeable(n int) pex.Peers { return r0 } -// RecordPeerHeight provides a mock function with given fields: addr, height -func (_m *mockDaemoner) RecordPeerHeight(addr string, height uint64) { - _m.Called(addr, height) +// RecordPeerHeight provides a mock function with given fields: addr, gnetID, height +func (_m *mockDaemoner) RecordPeerHeight(addr string, gnetID int, height uint64) { + _m.Called(addr, gnetID, height) } // RecordUserAgent provides a mock function with given fields: addr, userAgent From eb78d2857e585e5fb273dcb9acbe8ccbb3b0c763 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sun, 28 Oct 2018 04:28:54 +0000 Subject: [PATCH 317/399] [api] refs #1980 - Burn factor in /health endpoint --- src/api/README.md | 3 ++- src/api/health.go | 3 +++ src/api/health_test.go | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/README.md b/src/api/README.md index 001d0d7b3c..fb0127131b 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -232,7 +232,8 @@ Response: "wallet_api_enabled": true, "gui_enabled": true, "unversioned_api_enabled": false, - "json_rpc_enabled": false + "json_rpc_enabled": false, + "coinhours_burn_factor": 2 } ``` diff --git a/src/api/health.go b/src/api/health.go index 2ae13fccd6..34823419b7 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -6,6 +6,7 @@ import ( "time" "github.com/skycoin/skycoin/src/readable" + "github.com/skycoin/skycoin/src/util/fee" wh "github.com/skycoin/skycoin/src/util/http" ) @@ -29,6 +30,7 @@ type HealthResponse struct { GUIEnabled bool `json:"gui_enabled"` UnversionedAPIEnabled bool `json:"unversioned_api_enabled"` JSON20RPCEnabled bool `json:"json_rpc_enabled"` + BurnFactor uint64 `json:coinhours_burn_factor` } // healthHandler returns node health data @@ -75,6 +77,7 @@ func healthHandler(c muxConfig, csrfStore *CSRFStore, gateway Gatewayer) http.Ha GUIEnabled: c.enableGUI, JSON20RPCEnabled: c.enableJSON20RPC, WalletAPIEnabled: walletAPIEnabled, + BurnFactor: fee.BurnFactor, }) } } diff --git a/src/api/health_test.go b/src/api/health_test.go index f328b6a1f9..728bc0bb86 100644 --- a/src/api/health_test.go +++ b/src/api/health_test.go @@ -188,6 +188,8 @@ func TestHealthHandler(t *testing.T) { require.Equal(t, tc.cfg.enableGUI, r.GUIEnabled) require.Equal(t, tc.cfg.enableJSON20RPC, r.JSON20RPCEnabled) require.Equal(t, tc.walletAPIEnabled, r.WalletAPIEnabled) + + require.Equal(t, uint64(0x2), r.BurnFactor) }) } } From 0e016b490dc280f81388fae6fee3112ac9e4b96a Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sun, 28 Oct 2018 07:13:49 +0000 Subject: [PATCH 318/399] [api] refs #1980 - Silence make lin warnings Reported in https://travis-ci.org/simelo/skycoin/jobs/447292744#L1918-L1924 --- src/api/health.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/health.go b/src/api/health.go index 34823419b7..7080ca2ea7 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -30,7 +30,7 @@ type HealthResponse struct { GUIEnabled bool `json:"gui_enabled"` UnversionedAPIEnabled bool `json:"unversioned_api_enabled"` JSON20RPCEnabled bool `json:"json_rpc_enabled"` - BurnFactor uint64 `json:coinhours_burn_factor` + BurnFactor uint64 `json:"coinhours_burn_factor"` } // healthHandler returns node health data From 522357f19505e4f789757a2dc0caa6842ab2ee0a Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sun, 28 Oct 2018 08:06:39 +0000 Subject: [PATCH 319/399] [cli] refs #1980 - coinhours_burn_factor in CLI golden files --- .../testdata/status-csrf-enabled-no-unconfirmed.golden | 3 ++- src/cli/integration/testdata/status-csrf-enabled.golden | 3 ++- src/cli/integration/testdata/status-no-unconfirmed.golden | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden index 8a99a3e7f2..aaea8a1f5e 100644 --- a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden @@ -29,7 +29,8 @@ "wallet_api_enabled": true, "gui_enabled": false, "unversioned_api_enabled": false, - "json_rpc_enabled": false + "json_rpc_enabled": false, + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-csrf-enabled.golden b/src/cli/integration/testdata/status-csrf-enabled.golden index 17ed42d4a2..c9834fde59 100644 --- a/src/cli/integration/testdata/status-csrf-enabled.golden +++ b/src/cli/integration/testdata/status-csrf-enabled.golden @@ -29,7 +29,8 @@ "wallet_api_enabled": true, "gui_enabled": false, "unversioned_api_enabled": false, - "json_rpc_enabled": false + "json_rpc_enabled": false, + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-no-unconfirmed.golden b/src/cli/integration/testdata/status-no-unconfirmed.golden index 7e5d1c7cd6..2f013033db 100644 --- a/src/cli/integration/testdata/status-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-no-unconfirmed.golden @@ -29,7 +29,8 @@ "wallet_api_enabled": true, "gui_enabled": false, "unversioned_api_enabled": false, - "json_rpc_enabled": false + "json_rpc_enabled": false, + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" From cd48336b7985f075b3448fb57f4b1a5f178bb539 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sun, 28 Oct 2018 04:10:30 -0400 Subject: [PATCH 320/399] [api] refs #1980 - coinhours_burn_factor added in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4436af248f..da77cbc406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Add `-csv` option to `cli send` and `cli createRawTransaction`, which will send coins to multiple addresses defined in a csv file - Add `-disable-default-peers` option to disable the default hardcoded peers and mark all cached peers as untrusted - Add `-custom-peers-file` to load peers from disk. This peers file is a newline separate list of `ip:port` strings -- Add `user_agent`, `coin`, `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled` configuration settings to the `/api/v1/health` endpoint response +- Add `user_agent`, `coin`, `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled`, `coinhours_burn_factor` configuration settings to the `/api/v1/health` endpoint response - Add `verbose` flag to `/api/v1/block`, `/api/v1/blocks`, `/api/v1/last_blocks`, `/api/v1/pendingTxs`, `/api/v1/transaction`, `/api/v1/transactions`, `/api/v1/wallet/transactions` to return verbose block data, which includes the address, coins, hours and calculcated_hours of the block's transaction's inputs - Add `encoded` flag to `/api/v1/transaction` to return an encoded transaction - Add `-http-prof-host` option to choose the HTTP profiler's bind hostname (defaults to `localhost:6060`) From ee2a4aa701966e6b93896a7f8822cf788c6a9eec Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 19:04:38 +0800 Subject: [PATCH 321/399] Use gnet ID with addr --- src/daemon/connections.go | 73 +++++++++++++++++++++-------------- src/daemon/daemon.go | 33 +++++++++------- src/daemon/gateway.go | 2 +- src/daemon/gnet/dispatcher.go | 10 +++-- src/daemon/gnet/message.go | 3 +- src/daemon/gnet/pool.go | 49 +++++++++++++---------- src/daemon/strand/strand.go | 5 --- src/readable/network.go | 2 +- 8 files changed, 101 insertions(+), 76 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index e76f826152..32dec3199f 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -74,7 +74,7 @@ func (c ConnectionDetails) HasIntroduced() bool { type connection struct { Addr string ConnectionDetails - gnetID int + gnetID uint64 } // ListenAddr returns the addr that connection listens on, if available @@ -140,7 +140,7 @@ func (c *Connections) pending(addr string) (*connection, error) { } // connected the connection has connected -func (c *Connections) connected(addr string, gnetID int) (*connection, error) { +func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) { c.Lock() defer c.Unlock() @@ -170,18 +170,20 @@ func (c *Connections) connected(addr string, gnetID int) (*connection, error) { case ConnectionStatePending: case ConnectionStateConnected: logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - "gnetID": gnetID, + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, + "gnetID": gnetID, }).Warningf("Connections.connected called on already connected connection") return nil, ErrConnectionAlreadyConnected case ConnectionStateIntroduced: logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - "gnetID": gnetID, + "addr": conn.Addr, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, + "gnetID": gnetID, }).Warning("Connections.connected called on already introduced connection") return nil, ErrConnectionAlreadyIntroduced default: @@ -305,7 +307,7 @@ func (c *Connections) get(addr string) *connection { // modify modifies a connection. // It is unsafe to modify the Mirror value with this method -func (c *Connections) modify(addr string, gnetID int, f func(c *ConnectionDetails)) error { +func (c *Connections) modify(addr string, gnetID uint64, f func(c *ConnectionDetails)) error { conn := c.conns[addr] if conn == nil { return ErrConnectionNotExist @@ -331,7 +333,7 @@ func (c *Connections) modify(addr string, gnetID int, f func(c *ConnectionDetail } // SetHeight sets the height for a connection -func (c *Connections) SetHeight(addr string, gnetID int, height uint64) error { +func (c *Connections) SetHeight(addr string, gnetID uint64, height uint64) error { c.Lock() defer c.Unlock() @@ -413,7 +415,7 @@ func (c *Connections) PendingLen() int { // remove removes connection. Returns an error if the addr is invalid. // If a connection with this address does not exist, nothing happens. -func (c *Connections) remove(addr string) error { +func (c *Connections) remove(addr string, gnetID uint64) error { c.Lock() defer c.Unlock() @@ -423,25 +425,38 @@ func (c *Connections) remove(addr string) error { } conn := c.conns[addr] - if conn != nil { - x, ok := c.mirrors[conn.Mirror] - if ok { - if x[ip] != conn.ListenPort { - logger.Critical().WithField("addr", addr).Warning("Indexed IP+Mirror value found but the ListenPort doesn't match") - } - - delete(x, ip) - } + if conn == nil { + return ErrConnectionNotExist + } - if len(x) == 0 { - delete(c.mirrors, conn.Mirror) - } + fields := logrus.Fields{ + "addr": addr, + "connGnetID": conn.gnetID, + "gnetID": gnetID, + } + + if conn.gnetID != gnetID { + logger.Critical().WithFields(fields).Warning("Connections.remove gnetID does not match") + return ErrConnectionGnetIDMismatch + } - if c.ipCounts[ip] > 0 { - c.ipCounts[ip]-- - } else { - logger.Critical().WithField("addr", addr).Warning("ipCount was already 0 when removing existing address") + x, ok := c.mirrors[conn.Mirror] + if ok { + if x[ip] != conn.ListenPort { + logger.Critical().WithFields(fields).Warning("Indexed IP+Mirror value found but the ListenPort doesn't match") } + + delete(x, ip) + } + + if len(x) == 0 { + delete(c.mirrors, conn.Mirror) + } + + if c.ipCounts[ip] > 0 { + c.ipCounts[ip]-- + } else { + logger.Critical().WithFields(fields).Warning("ipCount was already 0 when removing existing address") } delete(c.conns, addr) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 74df11c3f6..5ba45423ad 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -243,7 +243,7 @@ type daemoner interface { SetHasIncomingPort(addr string) error IncreaseRetryTimes(addr string) ResetRetryTimes(addr string) - RecordPeerHeight(addr string, gnetID int, height uint64) + RecordPeerHeight(addr string, gnetID, height uint64) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) HeadBkSeq() (uint64, bool, error) ExecuteSignedBlock(b coin.SignedBlock) error @@ -324,13 +324,14 @@ func NewDaemon(config Config, db *dbutil.DB) (*Daemon, error) { // ConnectEvent generated when a client connects type ConnectEvent struct { - GnetID int + GnetID uint64 Addr string Solicited bool } // DisconnectEvent generated when a connection terminated type DisconnectEvent struct { + GnetID uint64 Addr string Reason gnet.DisconnectReason } @@ -806,7 +807,7 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { "addr": e.Context.Addr, "messageType": fmt.Sprintf("%T", e.Message), }).Info("needsIntro but message is not IntroductionMessage") - if err := dm.pool.Pool.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { + if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } } @@ -835,7 +836,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { if dm.ipCountMaxed(e.Addr) { logger.WithFields(fields).Info("Max connections for this address reached, disconnecting") - if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { + if err := dm.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { logger.WithError(err).WithFields(fields).Error("Disconnect") } return @@ -851,7 +852,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { if n > dm.Config.OutgoingMax { logger.WithFields(fields).Warning("Max outgoing connections is reached, disconnecting") - if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { + if err := dm.Disconnect(e.Addr, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { logger.WithError(err).WithFields(fields).Error("Disconnect") } return @@ -862,7 +863,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { c, err := dm.connections.connected(e.Addr, e.GnetID) if err != nil { logger.Critical().WithError(err).WithFields(fields).Error("connections.Connected failed") - if err := dm.pool.Pool.Disconnect(e.Addr, ErrDisconnectIncomprehensibleError); err != nil { + if err := dm.Disconnect(e.Addr, ErrDisconnectIncomprehensibleError); err != nil { logger.WithError(err).WithFields(fields).Error("Disconnect") } return @@ -887,11 +888,13 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { fields := logrus.Fields{ "addr": e.Addr, "reason": e.Reason, + "gnetID": e.GnetID, } logger.WithFields(fields).Info("onDisconnectEvent") - if err := dm.connections.remove(e.Addr); err != nil { + if err := dm.connections.remove(e.Addr, e.GnetID); err != nil { logger.WithError(err).WithFields(fields).Error("connections.Remove failed") + return } // If the peer did not send an introduction in time, it is not a valid peer and remove it from the peer list @@ -905,7 +908,7 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { func (dm *Daemon) onConnectionError(c ConnectionError) { // Remove the pending connection from connections and update the retry times in pex logger.WithField("addr", c.Addr).WithError(c.Error).Debug("onConnectionError") - if err := dm.connections.remove(c.Addr); err != nil { + if err := dm.connections.remove(c.Addr, 0); err != nil { logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } @@ -914,8 +917,9 @@ func (dm *Daemon) onConnectionError(c ConnectionError) { } // Triggered when an gnet.Connection terminates -func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { +func (dm *Daemon) onGnetDisconnect(addr string, gnetID uint64, reason gnet.DisconnectReason) { e := DisconnectEvent{ + GnetID: gnetID, Addr: addr, Reason: reason, } @@ -923,10 +927,10 @@ func (dm *Daemon) onGnetDisconnect(addr string, reason gnet.DisconnectReason) { } // Triggered when an gnet.Connection is connected -func (dm *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) { +func (dm *Daemon) onGnetConnect(addr string, gnetID uint64, solicited bool) { dm.events <- ConnectEvent{ - GnetID: c.ID, - Addr: c.Addr(), + GnetID: gnetID, + Addr: addr, Solicited: solicited, } } @@ -1209,8 +1213,7 @@ func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { return dm.pool.Pool.BroadcastMessage(msg) } -// Disconnect removes a connection from the pool by address, and passes a Disconnection to -// the DisconnectCallback +// Disconnect removes a connection from the pool by address, and invokes DisconnectCallback func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { return dm.pool.Pool.Disconnect(addr, r) } @@ -1270,7 +1273,7 @@ func (dm *Daemon) ResetRetryTimes(addr string) { // Implements chain height store // RecordPeerHeight records the height of specific peer -func (dm *Daemon) RecordPeerHeight(addr string, gnetID int, height uint64) { +func (dm *Daemon) RecordPeerHeight(addr string, gnetID, height uint64) { if err := dm.connections.SetHeight(addr, gnetID, height); err != nil { logger.Critical().WithError(err).WithField("addr", addr).Error("connections.SetHeight failed") } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 88d684f88e..666a10224d 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -96,7 +96,7 @@ type Connection struct { // GnetConnectionDetails connection data from gnet type GnetConnectionDetails struct { - ID int + ID uint64 LastSent time.Time LastReceived time.Time } diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index 001da78719..14bd4cdb12 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -7,6 +7,8 @@ import ( "reflect" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/cipher/encoder" ) @@ -32,7 +34,7 @@ func sendMessage(conn net.Conn, msg Message, timeout time.Duration) error { } // Event handler that is called after a Connection sends a complete message -func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { +func convertToMessage(id uint64, msg []byte, debugPrint bool) (Message, error) { msgID := [4]byte{} if len(msg) < len(msgID) { return nil, errors.New("Not enough data to read msg id") @@ -45,12 +47,14 @@ func convertToMessage(id int, msg []byte, debugPrint bool) (Message, error) { } if debugPrint { - logger.Debugf("convertToMessage for connection %d, message type %v", id, t) + logger.WithFields(logrus.Fields{ + "connID": id, + "messageType": fmt.Sprintf("%v", t), + }).Debugf("convertToMessage") } var m Message v := reflect.New(t) - //logger.Debugf("Giving %d bytes to the decoder", len(msg)) used, err := deserializeMessage(msg, v) if err != nil { return nil, err diff --git a/src/daemon/gnet/message.go b/src/daemon/gnet/message.go index fd144b127e..4d23d44907 100644 --- a/src/daemon/gnet/message.go +++ b/src/daemon/gnet/message.go @@ -81,8 +81,7 @@ type Message interface { // MessageContext message context type MessageContext struct { - // Conn *Connection // connection message was received from - ConnID int // connection message was received from + ConnID uint64 // connection message was received from Addr string } diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 8c448b3f1d..ea37700719 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -127,7 +127,7 @@ const ( // Connection is stored by the ConnectionPool type Connection struct { // Key in ConnectionPool.Pool - ID int + ID uint64 // TCP connection Conn net.Conn // Message buffer @@ -144,7 +144,7 @@ type Connection struct { } // NewConnection creates a new Connection tied to a ConnectionPool -func NewConnection(pool *ConnectionPool, id int, conn net.Conn, writeQueueSize int, solicited bool) *Connection { +func NewConnection(pool *ConnectionPool, id uint64, conn net.Conn, writeQueueSize int, solicited bool) *Connection { return &Connection{ ID: id, Conn: conn, @@ -176,10 +176,10 @@ func (conn *Connection) Close() error { } // DisconnectCallback triggered on client disconnect -type DisconnectCallback func(addr string, reason DisconnectReason) +type DisconnectCallback func(addr string, id uint64, reason DisconnectReason) // ConnectCallback triggered on client connect -type ConnectCallback func(c *Connection, solicited bool) +type ConnectCallback func(addr string, id uint64, solicited bool) // ConnectionPool connection pool type ConnectionPool struct { @@ -188,7 +188,7 @@ type ConnectionPool struct { // Channel for async message sending SendResults chan SendResult // All connections, indexed by ConnId - pool map[int]*Connection + pool map[uint64]*Connection // All connections, indexed by address addresses map[string]*Connection // connected default peer connections @@ -196,7 +196,7 @@ type ConnectionPool struct { // User-defined state to be passed into message handlers messageState interface{} // Connection ID counter - connID int + connID uint64 // Listening connection listener net.Listener listenerLock sync.Mutex @@ -219,7 +219,7 @@ func NewConnectionPool(c Config, state interface{}) *ConnectionPool { pool := &ConnectionPool{ Config: c, - pool: make(map[int]*Connection), + pool: make(map[uint64]*Connection), addresses: make(map[string]*Connection), defaultConnections: make(map[string]struct{}), SendResults: make(chan SendResult, c.SendResultsSize), @@ -382,6 +382,10 @@ func (pool *ConnectionPool) NewConnection(conn net.Conn, solicited bool) (*Conne } pool.connID++ + // ID must start at 1; in case connID overflows back to 0, force it to 1 + if pool.connID == 0 { + pool.connID = 1 + } nc = NewConnection(pool, pool.connID, conn, pool.Config.ConnectionWriteQueueSize, solicited) pool.pool[nc.ID] = nc @@ -440,7 +444,7 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro } if pool.Config.ConnectCallback != nil { - pool.Config.ConnectCallback(c, solicited) + pool.Config.ConnectCallback(c.Addr(), c.ID, solicited) } msgC := make(chan []byte, 32) @@ -787,8 +791,7 @@ func (pool *ConnectionPool) Connect(address string) error { return nil } -// Disconnect removes a connection from the pool by address, and passes a Disconnection to -// the DisconnectCallback +// Disconnect removes a connection from the pool by address and invokes DisconnectCallback func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { if err := pool.strand("Disconnect", func() error { logger.WithFields(logrus.Fields{ @@ -796,7 +799,11 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { "reason": r, }).Debug("Disconnecting") - exist := pool.disconnect(addr) + conn := pool.disconnect(addr) + + if conn == nil { + return errors.New("Disconnect: connection does not exist") + } // checks if the address is default node address if _, ok := pool.Config.defaultConnections[addr]; ok { @@ -804,8 +811,8 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { logger.Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) } - if pool.Config.DisconnectCallback != nil && exist { - pool.Config.DisconnectCallback(addr, r) + if pool.Config.DisconnectCallback != nil { + pool.Config.DisconnectCallback(addr, conn.ID, r) } return nil @@ -816,24 +823,27 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { return nil } -func (pool *ConnectionPool) disconnect(addr string) bool { +func (pool *ConnectionPool) disconnect(addr string) *Connection { conn, ok := pool.addresses[addr] if !ok { - return false + return nil } - // TODO -- send disconnect reason packet + fields := logrus.Fields{ + "addr": addr, + "id": conn.ID, + } delete(pool.pool, conn.ID) delete(pool.addresses, addr) delete(pool.defaultConnections, addr) if err := conn.Close(); err != nil { - logger.WithError(err).WithField("addr", addr).Error("conn.Close") + logger.WithError(err).WithFields(fields).Error("conn.Close") } - logger.WithField("addr", addr).Debug("Closed connection and removed from pool") + logger.WithFields(fields).Debug("Closed connection and removed from pool") - return true + return conn } // disconnectAll disconnects all connections. Only safe to call in Shutdown() @@ -944,7 +954,6 @@ func (pool *ConnectionPool) BroadcastMessage(msg Message) error { // first return value. Otherwise, error will be nil and DisconnectReason will // be the value returned from the message handler. func (pool *ConnectionPool) receiveMessage(c *Connection, msg []byte) error { - m, err := convertToMessage(c.ID, msg, pool.Config.DebugPrint) if err != nil { return err diff --git a/src/daemon/strand/strand.go b/src/daemon/strand/strand.go index c66eb42972..f219302279 100644 --- a/src/daemon/strand/strand.go +++ b/src/daemon/strand/strand.go @@ -89,11 +89,6 @@ func Strand(logger *logging.Logger, c chan Request, name string, f func() error, err = f() - // Log the error here so that the Request channel consumer doesn't need to - if err != nil { - logger.WithError(err).WithField("operation", name).Error() - } - // Notify us if the function call took too long elapsed := time.Since(t) if elapsed > logDurationThreshold { diff --git a/src/readable/network.go b/src/readable/network.go index 17cd04f512..968cd325c5 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -7,7 +7,7 @@ import ( // Connection a connection's state within the daemon type Connection struct { - GnetID int `json:"id"` + GnetID uint64 `json:"id"` Addr string `json:"address"` LastSent int64 `json:"last_sent"` LastReceived int64 `json:"last_received"` From 4157806ea83c05bf6ba83688f8b08217a8e1865c Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 19:39:22 +0800 Subject: [PATCH 322/399] Fixups; cleanup tests --- src/api/integration/integration_test.go | 11 +- src/daemon/connections.go | 65 +++++++----- src/daemon/connections_test.go | 133 +++++++++++++++--------- src/daemon/daemon.go | 6 +- src/daemon/messages.go | 2 +- src/daemon/messages_test.go | 9 +- src/daemon/mock_daemoner_test.go | 16 +-- 7 files changed, 149 insertions(+), 93 deletions(-) diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 899b9ee932..d39022bedc 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -1850,14 +1850,21 @@ func TestLiveNetworkConnections(t *testing.T) { require.Equal(t, cc.Mirror, connection.Mirror) switch cc.State { - // If the connection was introduced it should stay introduced case daemon.ConnectionStateIntroduced: + // If the connection was introduced it should stay introduced require.Equal(t, daemon.ConnectionStateIntroduced, connection.State) - // If the connection was connected it should stay connected or have become introduced case daemon.ConnectionStateConnected: + // If the connection was connected it should stay connected or have become introduced require.NotEqual(t, daemon.ConnectionStatePending, connection.State) } + // The GnetID should be 0 if pending, otherwise it should not be 0 + if cc.State == daemon.ConnectionStatePending { + require.Equal(t, uint64(0), cc.GnetID) + } else { + require.NotEmpty(t, uint64(0), cc.GnetID) + } + require.Equal(t, cc.Outgoing, connection.Outgoing) require.True(t, cc.LastReceived <= connection.LastReceived) require.True(t, cc.LastSent <= connection.LastSent) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 32dec3199f..c966269841 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -47,6 +47,8 @@ var ( ErrConnectionAlreadyIntroduced = errors.New("Connection is already in introduced state") // ErrConnectionAlreadyConnected attempted to make invalid state transition from connected state ErrConnectionAlreadyConnected = errors.New("Connection is already in connected state") + // ErrInvalidGnetID invalid gnet ID value used as argument + ErrInvalidGnetID = errors.New("Invalid gnet ID") ) // ConnectionDetails connection data managed by daemon @@ -116,6 +118,7 @@ func (c *Connections) pending(addr string) (*connection, error) { ip, port, err := iputil.SplitAddr(addr) if err != nil { + logger.Critical().WithError(err).Error("Connections.pending called with invalid addr") return nil, err } @@ -144,8 +147,19 @@ func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) c.Lock() defer c.Unlock() + fields := logrus.Fields{ + "addr": addr, + "gnetID": gnetID, + } + + if gnetID == 0 { + logger.Critical().WithError(ErrInvalidGnetID).Error("Connections.connected called with invalid gnetID") + return nil, ErrInvalidGnetID + } + ip, _, err := iputil.SplitAddr(addr) if err != nil { + logger.Critical().WithError(err).Error("Connections.connected called with invalid addr") return nil, err } @@ -160,31 +174,21 @@ func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) c.conns[addr] = conn } else { - if addr != conn.Addr { - err := errors.New("gnet.Connection.Addr does not match recorded Connection address") - logger.Critical().WithError(err).Error() - return nil, err + fields := logrus.Fields{ + "addr": addr, + "gnetID": gnetID, + "state": conn.State, + "outgoing": conn.Outgoing, + "connGnetID": conn.gnetID, } switch conn.State { case ConnectionStatePending: case ConnectionStateConnected: - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - "connGnetID": conn.gnetID, - "gnetID": gnetID, - }).Warningf("Connections.connected called on already connected connection") + logger.Critical().WithFields(fields).Warningf("Connections.connected called on already connected connection") return nil, ErrConnectionAlreadyConnected case ConnectionStateIntroduced: - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - "connGnetID": conn.gnetID, - "gnetID": gnetID, - }).Warning("Connections.connected called on already introduced connection") + logger.Critical().WithFields(fields).Warning("Connections.connected called on already introduced connection") return nil, ErrConnectionAlreadyIntroduced default: logger.Panic("Connection state invalid") @@ -195,22 +199,26 @@ func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) conn.ConnectedAt = time.Now().UTC() conn.State = ConnectionStateConnected - logger.WithFields(logrus.Fields{ - "addr": addr, - "outgoing": conn.Outgoing, - "gnetID": gnetID, - }).Debug("Connections.connected") + fields["outgoing"] = conn.Outgoing + + logger.WithFields(fields).Debug("Connections.connected") return conn, nil } // introduced the connection has introduced itself -func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connection, error) { +func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMessage) (*connection, error) { c.Lock() defer c.Unlock() + if gnetID == 0 { + logger.Critical().WithError(ErrInvalidGnetID).Error("Connections.introduced called with invalid gnetID") + return nil, ErrInvalidGnetID + } + ip, _, err := iputil.SplitAddr(addr) if err != nil { + logger.Critical().WithError(err).Error("Connections.introduced called with invalid addr") return nil, err } @@ -226,17 +234,17 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti "state": conn.State, "outgoing": conn.Outgoing, "connGnetID": conn.gnetID, - "gnetID": m.c.ConnID, + "gnetID": gnetID, }).Warningf("Connections.introduced called on pending connection") return nil, ErrConnectionStateNotConnected case ConnectionStateConnected: - if m.c.ConnID != conn.gnetID { + if gnetID != conn.gnetID { logger.Critical().WithFields(logrus.Fields{ "addr": conn.Addr, "state": conn.State, "outgoing": conn.Outgoing, "connGnetID": conn.gnetID, - "gnetID": m.c.ConnID, + "gnetID": gnetID, }).Warningf("Connections.introduced called with different gnet ID") return nil, ErrConnectionGnetIDMismatch } @@ -246,7 +254,7 @@ func (c *Connections) introduced(addr string, m *IntroductionMessage) (*connecti "state": conn.State, "outgoing": conn.Outgoing, "connGnetID": conn.gnetID, - "gnetID": m.c.ConnID, + "gnetID": gnetID, }).Warning("Connections.introduced called on already introduced connection") return nil, ErrConnectionAlreadyIntroduced default: @@ -421,6 +429,7 @@ func (c *Connections) remove(addr string, gnetID uint64) error { ip, _, err := iputil.SplitAddr(addr) if err != nil { + logger.Critical().WithError(err).Error("Connections.remove called with invalid addr") return err } diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go index c8941320cb..ff790157a7 100644 --- a/src/daemon/connections_test.go +++ b/src/daemon/connections_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/testutil" ) @@ -74,15 +73,11 @@ func TestConnectionsOutgoingFlow(t *testing.T) { all = conns.all() require.Equal(t, []connection{*c}, all) - _, err = conns.introduced(addr, &IntroductionMessage{ - c: &gnet.MessageContext{ - ConnID: 0, - }, - }) + _, err = conns.introduced(addr, 1, &IntroductionMessage{}) require.Equal(t, ErrConnectionStateNotConnected, err) require.Equal(t, 1, conns.PendingLen()) - c, err = conns.connected(addr, 0) + c, err = conns.connected(addr, 1) require.NoError(t, err) require.True(t, c.Outgoing) @@ -106,12 +101,9 @@ func TestConnectionsOutgoingFlow(t *testing.T) { ListenPort: port + 1, Mirror: 1111, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, } - c, err = conns.introduced(addr, m) + c, err = conns.introduced(addr, 1, m) require.NoError(t, err) require.True(t, c.Outgoing) @@ -132,7 +124,7 @@ func TestConnectionsOutgoingFlow(t *testing.T) { all = conns.all() require.Equal(t, []connection{*c}, all) - err = conns.remove(addr) + err = conns.remove(addr, 1) require.NoError(t, err) require.Equal(t, 0, conns.IPCount(ip)) @@ -166,7 +158,7 @@ func TestConnectionsIncomingFlow(t *testing.T) { // Flow: connected, introduced - c, err := conns.connected(addr, 0) + c, err := conns.connected(addr, 1) require.NoError(t, err) require.False(t, c.Outgoing) @@ -190,12 +182,9 @@ func TestConnectionsIncomingFlow(t *testing.T) { ListenPort: port + 1, Mirror: 1111, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, } - c, err = conns.introduced(addr, m) + c, err = conns.introduced(addr, 1, m) require.NoError(t, err) require.False(t, c.Outgoing) @@ -216,7 +205,7 @@ func TestConnectionsIncomingFlow(t *testing.T) { all = conns.all() require.Equal(t, []connection{*c}, all) - err = conns.remove(addr) + err = conns.remove(addr, 1) require.NoError(t, err) require.Equal(t, 0, conns.IPCount(ip)) @@ -248,34 +237,28 @@ func TestConnectionsMultiple(t *testing.T) { require.Equal(t, 2, conns.PendingLen()) require.Equal(t, 2, conns.IPCount("127.0.0.1")) - _, err = conns.connected(addr1, 0) + _, err = conns.connected(addr1, 1) require.NoError(t, err) require.Equal(t, 1, conns.PendingLen()) - _, err = conns.connected(addr2, 0) + _, err = conns.connected(addr2, 2) require.NoError(t, err) require.Equal(t, 0, conns.PendingLen()) - _, err = conns.introduced(addr1, &IntroductionMessage{ + _, err = conns.introduced(addr1, 1, &IntroductionMessage{ Mirror: 6, ListenPort: 6060, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, }) require.NoError(t, err) require.Equal(t, 0, conns.PendingLen()) require.Equal(t, 1, len(conns.mirrors)) // introduction fails if a base IP + mirror is already in use - _, err = conns.introduced(addr2, &IntroductionMessage{ + _, err = conns.introduced(addr2, 2, &IntroductionMessage{ Mirror: 6, ListenPort: 6061, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, }) require.Equal(t, ErrConnectionIPMirrorExists, err) require.Equal(t, 0, conns.PendingLen()) @@ -283,13 +266,10 @@ func TestConnectionsMultiple(t *testing.T) { c := conns.get(addr2) require.Equal(t, ConnectionStateConnected, c.State) - _, err = conns.introduced(addr2, &IntroductionMessage{ + _, err = conns.introduced(addr2, 2, &IntroductionMessage{ Mirror: 7, ListenPort: 6061, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, }) require.NoError(t, err) require.Equal(t, 2, len(conns.mirrors)) @@ -300,16 +280,13 @@ func TestConnectionsMultiple(t *testing.T) { // Add another connection with a different base IP but same mirror value addr3 := "127.1.1.1:12345" - _, err = conns.connected(addr3, 0) + _, err = conns.connected(addr3, 3) require.NoError(t, err) - _, err = conns.introduced(addr3, &IntroductionMessage{ + _, err = conns.introduced(addr3, 3, &IntroductionMessage{ Mirror: 6, ListenPort: 6060, ProtocolVersion: 2, - c: &gnet.MessageContext{ - ConnID: 0, - }, }) require.NoError(t, err) @@ -325,14 +302,21 @@ func TestConnectionsMultiple(t *testing.T) { require.Equal(t, 2, conns.IPCount("127.0.0.1")) require.Equal(t, 1, conns.IPCount("127.1.1.1")) - err = conns.remove(addr1) + err = conns.remove(addr1, 2) + require.Equal(t, ErrConnectionGnetIDMismatch, err) + require.Equal(t, 3, conns.Len()) + + err = conns.remove(addr1, 1) require.NoError(t, err) - err = conns.remove(addr2) + err = conns.remove(addr2, 2) require.NoError(t, err) - err = conns.remove(addr3) + err = conns.remove(addr3, 3) require.NoError(t, err) require.Empty(t, conns.mirrors) require.Equal(t, 0, conns.Len()) + + err = conns.remove(addr1, 1) + require.Equal(t, ErrConnectionNotExist, err) } func TestConnectionsErrors(t *testing.T) { @@ -341,17 +325,23 @@ func TestConnectionsErrors(t *testing.T) { _, err := conns.pending("foo") testutil.RequireError(t, err, "address foo: missing port in address") - _, err = conns.connected("foo", 0) + _, err = conns.connected("foo", 1) testutil.RequireError(t, err, "address foo: missing port in address") - _, err = conns.introduced("foo", nil) + _, err = conns.introduced("foo", 1, &IntroductionMessage{}) testutil.RequireError(t, err, "address foo: missing port in address") - err = conns.remove("foo") + err = conns.remove("foo", 0) testutil.RequireError(t, err, "address foo: missing port in address") - _, err = conns.introduced("127.0.0.1:6060", &IntroductionMessage{}) + _, err = conns.introduced("127.0.0.1:6060", 1, &IntroductionMessage{}) require.Equal(t, ErrConnectionNotExist, err) + + _, err = conns.connected("127.0.0.1:6060", 0) + require.Equal(t, ErrInvalidGnetID, err) + + _, err = conns.introduced("127.0.0.1:6060", 0, &IntroductionMessage{}) + require.Equal(t, ErrInvalidGnetID, err) } func TestConnectionsSetHeight(t *testing.T) { @@ -359,16 +349,19 @@ func TestConnectionsSetHeight(t *testing.T) { addr := "127.0.0.1:6060" height := uint64(1010) - err := conns.SetHeight(addr, 0, height) + err := conns.SetHeight(addr, 1, height) require.Equal(t, ErrConnectionNotExist, err) - c, err := conns.connected(addr, 0) + c, err := conns.connected(addr, 1) require.NoError(t, err) require.Empty(t, c.Height) - err = conns.SetHeight(addr, 0, height) + err = conns.SetHeight(addr, 1, height) require.NoError(t, err) + err = conns.SetHeight(addr, 2, height) + require.Equal(t, ErrConnectionGnetIDMismatch, err) + c = conns.get(addr) require.NotNil(t, c) require.Equal(t, height, c.Height) @@ -378,13 +371,55 @@ func TestConnectionsModifyMirrorPanics(t *testing.T) { conns := NewConnections() addr := "127.0.0.1:6060" - _, err := conns.connected(addr, 0) + _, err := conns.connected(addr, 1) require.NoError(t, err) // modifying mirror value causes panic require.Panics(t, func() { - conns.modify(addr, 0, func(c *ConnectionDetails) { // nolint: errcheck + conns.modify(addr, 1, func(c *ConnectionDetails) { // nolint: errcheck c.Mirror++ }) }) } + +func TestConnectionsStateTransitionErrors(t *testing.T) { + conns := NewConnections() + addr := "127.0.0.1:6060" + + _, err := conns.pending(addr) + require.NoError(t, err) + + // pending -> pending fails + _, err = conns.pending(addr) + require.Equal(t, ErrConnectionExists, err) + + // pending -> introduced fails + _, err = conns.introduced(addr, 1, &IntroductionMessage{}) + require.Equal(t, ErrConnectionStateNotConnected, err) + + _, err = conns.connected(addr, 1) + require.NoError(t, err) + + // connected -> connected fails + _, err = conns.connected(addr, 1) + require.Equal(t, ErrConnectionAlreadyConnected, err) + + // connected -> introduced fails if gnet ID does not match + _, err = conns.introduced(addr, 2, &IntroductionMessage{}) + require.Equal(t, ErrConnectionGnetIDMismatch, err) + + _, err = conns.introduced(addr, 1, &IntroductionMessage{}) + require.NoError(t, err) + + // introduced -> connected fails + _, err = conns.connected(addr, 1) + require.Equal(t, ErrConnectionAlreadyIntroduced, err) + + // introduced -> pending fails + _, err = conns.pending(addr) + require.Equal(t, ErrConnectionExists, err) + + // introduced -> introduced fails + _, err = conns.introduced(addr, 1, &IntroductionMessage{}) + require.Equal(t, ErrConnectionAlreadyIntroduced, err) +} diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 5ba45423ad..1e84c27fa1 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -258,7 +258,7 @@ type daemoner interface { RecordUserAgent(addr string, userAgent useragent.Data) error recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error - connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) + connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage) (*connection, error) } // Daemon stateful properties of the daemon @@ -1196,8 +1196,8 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { } // connectionIntroduced removes the peer from expect introduction pool -func (dm *Daemon) connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) { - return dm.connections.introduced(addr, m) +func (dm *Daemon) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage) (*connection, error) { + return dm.connections.introduced(addr, gnetID, m) } // Implements pooler interface diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 75672e7426..7f88504453 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -386,7 +386,7 @@ func (intro *IntroductionMessage) process(d daemoner) { return } - c, err := d.connectionIntroduced(a, intro) + c, err := d.connectionIntroduced(a, intro.c.ConnID, intro) if err != nil { logger.WithError(err).WithField("addr", a).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 994bb6ffdd..fa1fa884e4 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -45,6 +45,7 @@ func TestIntroductionMessage(t *testing.T) { tt := []struct { name string addr string + gnetID uint64 doProcess bool mockValue daemonMockValue intro *IntroductionMessage @@ -236,6 +237,7 @@ func TestIntroductionMessage(t *testing.T) { { name: "Connect twice", addr: "121.121.121.121:6000", + gnetID: 2, doProcess: true, mockValue: daemonMockValue{ mirror: 10000, @@ -257,7 +259,10 @@ func TestIntroductionMessage(t *testing.T) { for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - mc := &gnet.MessageContext{Addr: tc.addr} + mc := &gnet.MessageContext{ + Addr: tc.addr, + ConnID: tc.gnetID, + } tc.intro.c = mc d := &mockDaemoner{} @@ -280,7 +285,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("RemoveFromExpectingIntroductions", tc.addr) d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) - d.On("connectionIntroduced", tc.addr, tc.intro).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) + d.On("connectionIntroduced", tc.addr, tc.gnetID, tc.intro).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index e73fc53bfe..e24f3f4e82 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -15,13 +15,13 @@ type mockDaemoner struct { mock.Mock } -// connectionIntroduced provides a mock function with given fields: addr, m -func (_m *mockDaemoner) connectionIntroduced(addr string, m *IntroductionMessage) (*connection, error) { - ret := _m.Called(addr, m) +// connectionIntroduced provides a mock function with given fields: addr, gnetID, m +func (_m *mockDaemoner) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage) (*connection, error) { + ret := _m.Called(addr, gnetID, m) var r0 *connection - if rf, ok := ret.Get(0).(func(string, *IntroductionMessage) *connection); ok { - r0 = rf(addr, m) + if rf, ok := ret.Get(0).(func(string, uint64, *IntroductionMessage) *connection); ok { + r0 = rf(addr, gnetID, m) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*connection) @@ -29,8 +29,8 @@ func (_m *mockDaemoner) connectionIntroduced(addr string, m *IntroductionMessage } var r1 error - if rf, ok := ret.Get(1).(func(string, *IntroductionMessage) error); ok { - r1 = rf(addr, m) + if rf, ok := ret.Get(1).(func(string, uint64, *IntroductionMessage) error); ok { + r1 = rf(addr, gnetID, m) } else { r1 = ret.Error(1) } @@ -378,7 +378,7 @@ func (_m *mockDaemoner) RandomExchangeable(n int) pex.Peers { } // RecordPeerHeight provides a mock function with given fields: addr, gnetID, height -func (_m *mockDaemoner) RecordPeerHeight(addr string, gnetID int, height uint64) { +func (_m *mockDaemoner) RecordPeerHeight(addr string, gnetID uint64, height uint64) { _m.Called(addr, gnetID, height) } From b815cb765098be46b02ad2713f1a26b2af716b31 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 19:45:41 +0800 Subject: [PATCH 323/399] Fix tests --- src/daemon/gnet/pool_test.go | 82 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index 458dd34b02..8b7fd0daf9 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -43,14 +43,14 @@ func TestNewConnectionPool(t *testing.T) { cfg.DialTimeout = time.Duration(777) p := NewConnectionPool(cfg, nil) - require.Equal(t, p.Config, cfg) - require.Equal(t, p.Config.Port, cfg.Port) - require.Equal(t, p.Config.Address, cfg.Address) + require.Equal(t, cfg, p.Config) + require.Equal(t, cfg.Port, p.Config.Port) + require.Equal(t, cfg.Address, p.Config.Address) require.NotNil(t, p.pool) - require.Equal(t, len(p.pool), 0) + require.Equal(t, 0, len(p.pool)) require.NotNil(t, p.addresses) - require.Equal(t, len(p.addresses), 0) - require.Equal(t, p.connID, 0) + require.Equal(t, 0, len(p.addresses)) + require.Equal(t, uint64(0), p.connID) } func TestNewConnection(t *testing.T) { @@ -72,13 +72,13 @@ func TestNewConnection(t *testing.T) { err = p.strand("", func() error { c := p.addresses[conn.LocalAddr().String()] - require.Equal(t, p.pool[p.connID], c) - require.Equal(t, p.connID, 1) + require.Equal(t, c, p.pool[p.connID]) + require.Equal(t, uint64(1), p.connID) require.Equal(t, c.Addr(), conn.LocalAddr().String()) - require.Equal(t, cap(c.WriteQueue), cfg.ConnectionWriteQueueSize) + require.Equal(t, cfg.ConnectionWriteQueueSize, cap(c.WriteQueue)) require.NotNil(t, c.Buffer) - require.Equal(t, c.Buffer.Len(), 0) - require.Equal(t, c.ConnectionPool, p) + require.Equal(t, 0, c.Buffer.Len()) + require.Equal(t, p, c.ConnectionPool) require.False(t, c.LastSent.IsZero()) require.False(t, c.LastReceived.IsZero()) return nil @@ -94,7 +94,7 @@ func TestNewConnectionAlreadyConnected(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { require.False(t, solicited) cc <- p.pool[1] } @@ -131,7 +131,7 @@ func TestAcceptConnections(t *testing.T) { cc := make(chan *Connection, 1) var wasSolicited *bool - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { wasSolicited = &solicited require.False(t, solicited) cc <- p.pool[1] @@ -220,7 +220,7 @@ func TestHandleConnection(t *testing.T) { // Unsolicited cc := make(chan *Connection, 1) var wasSolicited *bool - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { wasSolicited = &solicited cc <- p.pool[1] } @@ -250,7 +250,7 @@ func TestHandleConnection(t *testing.T) { require.False(t, *wasSolicited) // Solicited - p.Config.ConnectCallback = func(c *Connection, s bool) { + p.Config.ConnectCallback = func(addr string, id uint64, s bool) { wasSolicited = &s cc <- p.pool[2] } @@ -351,7 +351,7 @@ func TestDisconnect(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.pool[1] } @@ -377,7 +377,7 @@ func TestDisconnect(t *testing.T) { require.NoError(t, err) err = p.strand("", func() error { - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, cAddr, addr) } return nil @@ -388,7 +388,7 @@ func TestDisconnect(t *testing.T) { require.NoError(t, err) err = p.strand("", func() error { - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { t.Fatal("disconnect unknown connection should not see this") } return nil @@ -396,7 +396,7 @@ func TestDisconnect(t *testing.T) { require.NoError(t, err) err = p.Disconnect("", nil) - require.NoError(t, err) + require.Equal(t, errors.New("Disconnect: connection does not exist"), err) p.Shutdown() <-q @@ -475,14 +475,14 @@ func TestGetConnections(t *testing.T) { require.NoError(t, err) require.Equal(t, len(conns), 3) - m := make(map[int]*Connection, 3) + m := make(map[uint64]*Connection, 3) for i, c := range conns { m[c.ID] = &conns[i] } require.Equal(t, len(m), 3) for i := 1; i <= 3; i++ { - require.Equal(t, m[i], p.pool[i]) + require.Equal(t, m[uint64(i)], p.pool[uint64(i)]) } p.Shutdown() @@ -494,7 +494,7 @@ func TestConnectionReadLoopReadError(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.addresses[addr] } @@ -510,7 +510,7 @@ func TestConnectionReadLoopReadError(t *testing.T) { readDataErr := errors.New("read data failed: failed") disconnectCalled := make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, readDataErr, reason) close(disconnectCalled) } @@ -542,7 +542,7 @@ func TestConnectionReadLoopSetReadDeadlineFailed(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.addresses[addr] } @@ -558,7 +558,7 @@ func TestConnectionReadLoopSetReadDeadlineFailed(t *testing.T) { // 2: // Use a mock net.Conn that fails on SetReadDeadline disconnectCalled := make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, ErrDisconnectSetReadDeadlineFailed, reason) close(disconnectCalled) } @@ -585,7 +585,7 @@ func TestConnectionReadLoopInvalidMessageLength(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.addresses[addr] } @@ -602,7 +602,7 @@ func TestConnectionReadLoopInvalidMessageLength(t *testing.T) { // Use a mock net.Conn that returns some bytes on Read // Look for these bytes copied into the eventChannel disconnectCalled := make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, ErrDisconnectInvalidMessageLength, reason) close(disconnectCalled) } @@ -631,7 +631,7 @@ func TestConnectionReadLoopTerminates(t *testing.T) { p := NewConnectionPool(cfg, nil) cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.addresses[addr] } @@ -649,7 +649,7 @@ func TestConnectionReadLoopTerminates(t *testing.T) { // 4: Use a mock net.Conn that successfully returns 0 bytes when read rnconn := newReadNothingConn() disconnectCalled := make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, readDataErr, reason) close(disconnectCalled) } @@ -682,11 +682,11 @@ func TestProcessConnectionBuffers(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { - cc <- p.addresses[c.Addr()] + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { + cc <- p.addresses[addr] } - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { t.Fatalf("Unexpected disconnect address=%s reason=%v", addr, reason) } @@ -723,7 +723,7 @@ func TestProcessConnectionBuffers(t *testing.T) { t.Logf("Pushing multiple messages, first one causing an error") disconnectCalled := make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, reason, ErrErrorMessageHandler) close(disconnectCalled) } @@ -737,7 +737,7 @@ func TestProcessConnectionBuffers(t *testing.T) { t.Fatal("disconnect did not happen, would block") } - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { fmt.Println(reason) t.Fatal("should not see this") } @@ -754,7 +754,7 @@ func TestProcessConnectionBuffers(t *testing.T) { require.NotNil(t, c) disconnectCalled = make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { require.Equal(t, c.Addr(), addr) require.Equal(t, reason, ErrDisconnectInvalidMessageLength) require.Nil(t, p.pool[1]) @@ -784,7 +784,7 @@ func TestProcessConnectionBuffers(t *testing.T) { t.Logf("Pushing message with too large length") p.Config.MaxMessageLength = 4 disconnectCalled = make(chan struct{}) - p.Config.DisconnectCallback = func(addr string, r DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, r DisconnectReason) { require.Equal(t, ErrDisconnectInvalidMessageLength, r) close(disconnectCalled) } @@ -817,12 +817,12 @@ func TestConnectionWriteLoop(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.pool[1] } disconnectErr := make(chan DisconnectReason, 1) - p.Config.DisconnectCallback = func(addr string, reason DisconnectReason) { + p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { fmt.Printf("DisconnectCallback called, address=%s reason=%v\n", addr, reason) disconnectErr <- reason } @@ -917,7 +917,7 @@ func TestPoolSendMessageOK(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.pool[1] } @@ -955,7 +955,7 @@ func TestPoolSendMessageWriteQueueFull(t *testing.T) { // Setup a callback to capture the connection pointer so we can get the address cc := make(chan *Connection, 1) - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { cc <- p.pool[1] } @@ -1013,7 +1013,7 @@ func TestPoolBroadcastMessage(t *testing.T) { ready := make(chan struct{}) var i int var counterLock sync.Mutex - p.Config.ConnectCallback = func(c *Connection, solicited bool) { + p.Config.ConnectCallback = func(addr string, id uint64, solicited bool) { counterLock.Lock() defer counterLock.Unlock() i++ From d17470ac6e5bfb40a6e38c77b7beed19863e202a Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 20:20:48 +0800 Subject: [PATCH 324/399] Ensure connect callback and connect error callback order --- src/daemon/daemon.go | 45 ++++++++++----- src/daemon/gnet/pool.go | 122 +++++++++++++++++++++++----------------- src/daemon/pool.go | 1 + 3 files changed, 102 insertions(+), 66 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 1e84c27fa1..3374cafa4a 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -336,10 +336,11 @@ type DisconnectEvent struct { Reason gnet.DisconnectReason } -// ConnectionError represent a failure to connect/dial a connection, with context -type ConnectionError struct { - Addr string - Error error +// ConnectFailureEvent represent a failure to connect/dial a connection, with context +type ConnectFailureEvent struct { + Addr string + Solicited bool + Error error } // messageEvent encapsulates a deserialized message from the network @@ -674,9 +675,10 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { go func() { if err := dm.pool.Pool.Connect(p.Addr); err != nil { - dm.events <- ConnectionError{ - Addr: p.Addr, - Error: err, + dm.events <- ConnectFailureEvent{ + Addr: p.Addr, + Solicited: true, + Error: err, } } }() @@ -785,8 +787,8 @@ func (dm *Daemon) handleEvent(e interface{}) { dm.onConnectEvent(x) case DisconnectEvent: dm.onDisconnectEvent(x) - case ConnectionError: - dm.onConnectionError(x) + case ConnectFailureEvent: + dm.onConnectFailure(x) default: logger.WithFields(logrus.Fields{ "type": fmt.Sprintf("%T", e), @@ -905,9 +907,14 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { } } -func (dm *Daemon) onConnectionError(c ConnectionError) { +func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { // Remove the pending connection from connections and update the retry times in pex - logger.WithField("addr", c.Addr).WithError(c.Error).Debug("onConnectionError") + logger.WithField("addr", c.Addr).WithError(c.Error).Debug("onConnectFailure") + // onConnectFailure should only trigger for "pending" connections which have gnet ID 0; + // connections in any other state will have a nonzero gnet ID. + // if the connection is in a different state, the gnet ID will not match, the connection + // won't be removed and we'll receive an error. + // If this happens, it is a bug, and the connections state may be corrupted. if err := dm.connections.remove(c.Addr, 0); err != nil { logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } @@ -916,17 +923,16 @@ func (dm *Daemon) onConnectionError(c ConnectionError) { dm.pex.IncreaseRetryTimes(c.Addr) } -// Triggered when an gnet.Connection terminates +// onGnetDisconnect triggered when a gnet.Connection terminates func (dm *Daemon) onGnetDisconnect(addr string, gnetID uint64, reason gnet.DisconnectReason) { - e := DisconnectEvent{ + dm.events <- DisconnectEvent{ GnetID: gnetID, Addr: addr, Reason: reason, } - dm.events <- e } -// Triggered when an gnet.Connection is connected +// onGnetConnect Triggered when a gnet.Connection connects func (dm *Daemon) onGnetConnect(addr string, gnetID uint64, solicited bool) { dm.events <- ConnectEvent{ GnetID: gnetID, @@ -935,6 +941,15 @@ func (dm *Daemon) onGnetConnect(addr string, gnetID uint64, solicited bool) { } } +// onGnetConnectFailure triggered when a gnet.Connection fails to connect +func (dm *Daemon) onGnetConnectFailure(addr string, solicited bool, err error) { + dm.events <- ConnectFailureEvent{ + Addr: addr, + Solicited: solicited, + Error: err, + } +} + // Returns whether the ipCount maximum has been reached. // Always false when using LocalhostOnly config. func (dm *Daemon) ipCountMaxed(addr string) bool { diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index ea37700719..c9e8da25e1 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -57,6 +57,11 @@ var ( ErrNoReachableConnections = errors.New("All pool connections are unreachable at this time") // ErrPoolEmpty when broadcasting a message, the connection pool was empty ErrPoolEmpty = errors.New("Connection pool is empty") + // ErrConnectionExists connection exists + ErrConnectionExists = errors.New("Connection exists") + // ErrMaxOutgoingConnectionsReached outgoing connections max reached + ErrMaxOutgoingConnectionsReached = errors.New("Outgoing connections max reached") + // Logger logger = logging.MustGetLogger("gnet") ) @@ -91,6 +96,8 @@ type Config struct { DisconnectCallback DisconnectCallback // Triggered on client connect ConnectCallback ConnectCallback + // Triggered on client connect failure + ConnectFailureCallback ConnectFailureCallback // Print debug logs DebugPrint bool // Default "trusted" peers @@ -181,6 +188,9 @@ type DisconnectCallback func(addr string, id uint64, reason DisconnectReason) // ConnectCallback triggered on client connect type ConnectCallback func(addr string, id uint64, solicited bool) +// ConnectFailureCallback trigger on client connect failure +type ConnectFailureCallback func(addr string, solicited bool, err error) + // ConnectionPool connection pool type ConnectionPool struct { // Configuration parameters @@ -360,41 +370,36 @@ func (pool *ConnectionPool) strand(name string, f func() error) error { return strand.Strand(logger, pool.reqC, name, f, pool.quit, ErrConnectionPoolClosed) } -// NewConnection creates a new Connection around a net.Conn. Trying to make a connection +// newConnection creates a new Connection around a net.Conn. Trying to make a connection // to an address that is already connected will failed. // Returns nil, nil when max default connection limit hit -func (pool *ConnectionPool) NewConnection(conn net.Conn, solicited bool) (*Connection, error) { +func (pool *ConnectionPool) newConnection(conn net.Conn, solicited bool) (*Connection, error) { a := conn.RemoteAddr().String() - var nc *Connection - if err := pool.strand("NewConnection", func() error { - if _, ok := pool.addresses[a]; ok { - return fmt.Errorf("Already connected to %s", a) - } - - if _, ok := pool.Config.defaultConnections[a]; ok { - if pool.isMaxDefaultConnectionsReached() && solicited { - return nil - } + if _, ok := pool.addresses[a]; ok { + return nil, fmt.Errorf("Already connected to %s", a) + } - pool.defaultConnections[a] = struct{}{} - l := len(pool.defaultConnections) - logger.Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) + if _, ok := pool.Config.defaultConnections[a]; ok { + if pool.isMaxDefaultConnectionsReached() && solicited { + return nil, nil } - pool.connID++ - // ID must start at 1; in case connID overflows back to 0, force it to 1 - if pool.connID == 0 { - pool.connID = 1 - } - nc = NewConnection(pool, pool.connID, conn, pool.Config.ConnectionWriteQueueSize, solicited) + pool.defaultConnections[a] = struct{}{} + l := len(pool.defaultConnections) + logger.Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) + } - pool.pool[nc.ID] = nc - pool.addresses[a] = nc - return nil - }); err != nil { - return nil, err + pool.connID++ + // ID must start at 1; in case connID overflows back to 0, force it to 1 + if pool.connID == 0 { + pool.connID = 1 } + nc := NewConnection(pool, pool.connID, conn, pool.Config.ConnectionWriteQueueSize, solicited) + + pool.pool[nc.ID] = nc + pool.addresses[a] = nc + return nc, nil } @@ -417,36 +422,50 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro defer func() { if err != nil { if closeErr := conn.Close(); closeErr != nil { - logger.WithError(closeErr).WithField("addr", addr).Error("conn.Close") + logger.WithError(closeErr).WithField("addr", addr).Error("handleConnection conn.Close") } } }() - exist, err := pool.IsConnExist(addr) - if err != nil { - return - } - if exist { - err = fmt.Errorf("Connection %s already exists", addr) - return - } + err = pool.strand("handleConnection", func() error { + if pool.isConnExist(addr) { + return fmt.Errorf("Connection %s already exists", addr) + } - return pool.NewConnection(conn, solicited) + var err error + c, err = pool.newConnection(conn, solicited) + if err != nil { + return err + } + + if c == nil { + return nil + } + + if pool.Config.ConnectCallback != nil { + pool.Config.ConnectCallback(c.Addr(), c.ID, solicited) + } + + return nil + }) + + return }() + // TODO -- this error is not fully propagated back to a caller of Connect() so the daemon state + // can get stuck in pending if err != nil { + if pool.Config.ConnectFailureCallback != nil { + pool.Config.ConnectFailureCallback(addr, solicited, err) + } return err } - // c is nil if max default connection limit is reached + // c may be nil if already connected to that connection or max outgoing connections reached if c == nil { return nil } - if pool.Config.ConnectCallback != nil { - pool.Config.ConnectCallback(c.Addr(), c.ID, solicited) - } - msgC := make(chan []byte, 32) errC := make(chan error, 3) @@ -664,9 +683,7 @@ func decodeData(buf *bytes.Buffer, maxMsgLength int) ([][]byte, error) { func (pool *ConnectionPool) IsConnExist(addr string) (bool, error) { var exist bool if err := pool.strand("IsConnExist", func() error { - if _, ok := pool.addresses[addr]; ok { - exist = true - } + exist = pool.isConnExist(addr) return nil }); err != nil { return false, fmt.Errorf("Check connection existence failed: %v ", err) @@ -675,6 +692,12 @@ func (pool *ConnectionPool) IsConnExist(addr string) (bool, error) { return exist, nil } +// isConnExist check if the connection of address does exist +func (pool *ConnectionPool) isConnExist(addr string) bool { + _, ok := pool.addresses[addr] + return ok +} + // IsDefaultConnection returns if the addr is a default connection func (pool *ConnectionPool) IsDefaultConnection(addr string) bool { _, ok := pool.Config.defaultConnections[addr] @@ -748,13 +771,10 @@ func (pool *ConnectionPool) GetConnection(addr string) (*Connection, error) { // Connect to an address func (pool *ConnectionPool) Connect(address string) error { - exist, err := pool.IsConnExist(address) - if err != nil { + if exist, err := pool.IsConnExist(address); err != nil { return err - } - - if exist { - return nil + } else if exist { + return ErrConnectionExists } var hitMaxDefaultConnNum bool @@ -769,7 +789,7 @@ func (pool *ConnectionPool) Connect(address string) error { } if hitMaxDefaultConnNum { - return nil + return ErrMaxOutgoingConnectionsReached } logger.WithField("addr", address).Debugf("Making TCP connection") diff --git a/src/daemon/pool.go b/src/daemon/pool.go index 93b330f3e9..0d9f6a9895 100644 --- a/src/daemon/pool.go +++ b/src/daemon/pool.go @@ -64,6 +64,7 @@ func NewPool(cfg PoolConfig, d *Daemon) *Pool { gnetCfg.Address = cfg.address gnetCfg.ConnectCallback = d.onGnetConnect gnetCfg.DisconnectCallback = d.onGnetDisconnect + gnetCfg.ConnectFailureCallback = d.onGnetConnectFailure gnetCfg.MaxConnections = cfg.MaxConnections gnetCfg.MaxDefaultPeerOutgoingConnections = cfg.MaxDefaultPeerOutgoingConnections gnetCfg.DefaultConnections = cfg.DefaultConnections From 08c9575d8f8fa0bf6fbe5069535132e47bc42c64 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 20:32:56 +0800 Subject: [PATCH 325/399] Fix test --- src/daemon/gnet/pool.go | 2 +- src/daemon/gnet/pool_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index c9e8da25e1..cdcf749a2d 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -509,7 +509,7 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro logger.WithError(err).WithField("addr", addr).Error("conn.Close") } case err = <-errC: - logger.WithError(err).WithField("addr", addr).Error("handleConnection failure") + logger.WithError(err).WithField("addr", addr).Error("handleConnection readLoop/sendLoop/receiveMessage failure") if err := pool.Disconnect(c.Addr(), err); err != nil { logger.WithError(err).WithField("addr", addr).Error("Disconnect") } diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index 8b7fd0daf9..374e08b20c 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -117,7 +117,7 @@ func TestNewConnectionAlreadyConnected(t *testing.T) { require.NotNil(t, ac) require.Equal(t, c.ID, ac.ID) - _, err = p.NewConnection(c.Conn, true) + _, err = p.newConnection(c.Conn, true) require.Error(t, err) require.True(t, strings.HasPrefix(err.Error(), "Already connected to")) @@ -300,7 +300,7 @@ func TestConnect(t *testing.T) { // If already connected, should return same connection err = p.Connect(addr) - require.NoError(t, err) + require.Equal(t, ErrConnectionExists, err) wait() delete(p.addresses, addr) From 580dc8b8069c08ae55a172051dc851d3fea75ab2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 21:03:43 +0800 Subject: [PATCH 326/399] Fixups --- src/api/README.md | 14 +++--- src/daemon/connections.go | 102 ++++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 59 deletions(-) diff --git a/src/api/README.md b/src/api/README.md index 817d7fb17c..df9cbf0a29 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3572,9 +3572,10 @@ Args: ``` Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. -The `"pending"` state is prior to connection establishment. -The `"connected"` state is after connection establishment, but before the introduction handshake has completed. -The `"introduced"` state is after the introduction handshake has completed. + +* The `"pending"` state is prior to connection establishment. +* The `"connected"` state is after connection establishment, but before the introduction handshake has completed. +* The `"introduced"` state is after the introduction handshake has completed. Example: @@ -3610,9 +3611,10 @@ Method: GET ``` Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. -The `"pending"` state is prior to connection establishment. -The `"connected"` state is after connection establishment, but before the introduction handshake has completed. -The `"introduced"` state is after the introduction handshake has completed. + +* The `"pending"` state is prior to connection establishment. +* The `"connected"` state is after connection establishment, but before the introduction handshake has completed. +* The `"introduced"` state is after the introduction handshake has completed. Example: diff --git a/src/daemon/connections.go b/src/daemon/connections.go index c966269841..4f06346509 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -118,7 +118,7 @@ func (c *Connections) pending(addr string) (*connection, error) { ip, port, err := iputil.SplitAddr(addr) if err != nil { - logger.Critical().WithError(err).Error("Connections.pending called with invalid addr") + logger.Critical().WithField("addr", addr).WithError(err).Error("Connections.pending called with invalid addr") return nil, err } @@ -153,13 +153,13 @@ func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) } if gnetID == 0 { - logger.Critical().WithError(ErrInvalidGnetID).Error("Connections.connected called with invalid gnetID") + logger.Critical().WithFields(fields).WithError(ErrInvalidGnetID).Error("Connections.connected called with invalid gnetID") return nil, ErrInvalidGnetID } ip, _, err := iputil.SplitAddr(addr) if err != nil { - logger.Critical().WithError(err).Error("Connections.connected called with invalid addr") + logger.Critical().WithFields(fields).WithError(err).Error("Connections.connected called with invalid addr") return nil, err } @@ -185,13 +185,13 @@ func (c *Connections) connected(addr string, gnetID uint64) (*connection, error) switch conn.State { case ConnectionStatePending: case ConnectionStateConnected: - logger.Critical().WithFields(fields).Warningf("Connections.connected called on already connected connection") + logger.Critical().WithFields(fields).Error("Connections.connected called on already connected connection") return nil, ErrConnectionAlreadyConnected case ConnectionStateIntroduced: - logger.Critical().WithFields(fields).Warning("Connections.connected called on already introduced connection") + logger.Critical().WithFields(fields).Error("Connections.connected called on already introduced connection") return nil, ErrConnectionAlreadyIntroduced default: - logger.Panic("Connection state invalid") + logger.WithFields(fields).Panic("Connection state invalid") } } @@ -211,14 +211,19 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess c.Lock() defer c.Unlock() + fields := logrus.Fields{ + "addr": addr, + "gnetID": gnetID, + } + if gnetID == 0 { - logger.Critical().WithError(ErrInvalidGnetID).Error("Connections.introduced called with invalid gnetID") + logger.Critical().WithFields(fields).WithError(ErrInvalidGnetID).Error("Connections.introduced called with invalid gnetID") return nil, ErrInvalidGnetID } ip, _, err := iputil.SplitAddr(addr) if err != nil { - logger.Critical().WithError(err).Error("Connections.introduced called with invalid addr") + logger.Critical().WithFields(fields).WithError(err).Error("Connections.introduced called with invalid addr") return nil, err } @@ -227,45 +232,40 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess return nil, ErrConnectionNotExist } - switch conn.State { - case ConnectionStatePending: - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, + fields["outgoing"] = conn.Outgoing + + if err := func() error { + fields := logrus.Fields{ + "addr": addr, "outgoing": conn.Outgoing, - "connGnetID": conn.gnetID, - "gnetID": gnetID, - }).Warningf("Connections.introduced called on pending connection") - return nil, ErrConnectionStateNotConnected - case ConnectionStateConnected: - if gnetID != conn.gnetID { - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "state": conn.State, - "outgoing": conn.Outgoing, - "connGnetID": conn.gnetID, - "gnetID": gnetID, - }).Warningf("Connections.introduced called with different gnet ID") - return nil, ErrConnectionGnetIDMismatch - } - case ConnectionStateIntroduced: - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, "state": conn.State, - "outgoing": conn.Outgoing, - "connGnetID": conn.gnetID, "gnetID": gnetID, - }).Warning("Connections.introduced called on already introduced connection") - return nil, ErrConnectionAlreadyIntroduced - default: - logger.Panic("invalid connection state") - } + "connGnetID": conn.gnetID, + } - if err := c.canUpdateMirror(ip, m.Mirror); err != nil { - logger.WithFields(logrus.Fields{ - "addr": conn.Addr, - "outgoing": conn.Outgoing, - }).WithError(err).Debug("canUpdateMirror failed") + switch conn.State { + case ConnectionStatePending: + logger.Critical().WithFields(fields).Error("Connections.introduced called on pending connection") + return ErrConnectionStateNotConnected + case ConnectionStateConnected: + if gnetID != conn.gnetID { + logger.Critical().WithFields(fields).Error("Connections.introduced called with different gnet ID") + return ErrConnectionGnetIDMismatch + } + case ConnectionStateIntroduced: + logger.Critical().WithFields(fields).Error("Connections.introduced called on already introduced connection") + return ErrConnectionAlreadyIntroduced + default: + logger.WithFields(fields).Panic("invalid connection state") + } + + if err := c.canUpdateMirror(ip, m.Mirror); err != nil { + logger.WithFields(fields).WithError(err).Debug("canUpdateMirror failed") + return err + } + + return nil + }(); err != nil { return nil, err } @@ -275,11 +275,9 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess // A misbehaving peer could report a different ListenPort in their IntroductionMessage, // but it shouldn't affect our records. if conn.Outgoing && conn.ListenPort != m.ListenPort { - logger.Critical().WithFields(logrus.Fields{ - "addr": conn.Addr, - "connListenPort": conn.ListenPort, - "messageListenPort": m.ListenPort, - }).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") + fields["connListenPort"] = conn.ListenPort + fields["introListenPort"] = m.ListenPort + logger.Critical().WithFields(fields).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") } listenPort := conn.ListenPort @@ -288,7 +286,8 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess } if err := c.updateMirror(ip, m.Mirror, listenPort); err != nil { - logger.WithError(err).Panic("updateMirror failed, but shouldn't") + fields["mirror"] = m.Mirror + logger.WithFields(fields).WithError(err).Panic("updateMirror failed, but shouldn't") } conn.State = ConnectionStateIntroduced @@ -297,10 +296,7 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess conn.ListenPort = listenPort conn.UserAgent = m.userAgentData - logger.WithFields(logrus.Fields{ - "addr": addr, - "outgoing": conn.Outgoing, - }).Debug("Connections.introduced") + logger.WithFields(fields).Debug("Connections.introduced") return conn, nil } From df36515f241a6409a230d8bacd7da2f32e7dd42f Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 21:41:07 +0800 Subject: [PATCH 327/399] Cleanup logs in daemon packages --- src/daemon/connections.go | 64 +++++++++++++++------------------ src/daemon/connections_test.go | 2 -- src/daemon/daemon.go | 65 ++++++++++++++++++---------------- src/daemon/gnet/dispatcher.go | 3 +- src/daemon/gnet/pool.go | 39 +++++++++----------- src/daemon/messages.go | 29 ++++++++------- src/daemon/pex/peerlist.go | 14 ++++++-- src/daemon/pex/pex.go | 26 +++++++------- src/daemon/strand/strand.go | 2 +- 9 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/daemon/connections.go b/src/daemon/connections.go index 4f06346509..349e9052ec 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -234,38 +234,29 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess fields["outgoing"] = conn.Outgoing - if err := func() error { - fields := logrus.Fields{ - "addr": addr, - "outgoing": conn.Outgoing, - "state": conn.State, - "gnetID": gnetID, - "connGnetID": conn.gnetID, - } - - switch conn.State { - case ConnectionStatePending: - logger.Critical().WithFields(fields).Error("Connections.introduced called on pending connection") - return ErrConnectionStateNotConnected - case ConnectionStateConnected: - if gnetID != conn.gnetID { - logger.Critical().WithFields(fields).Error("Connections.introduced called with different gnet ID") - return ErrConnectionGnetIDMismatch - } - case ConnectionStateIntroduced: - logger.Critical().WithFields(fields).Error("Connections.introduced called on already introduced connection") - return ErrConnectionAlreadyIntroduced - default: - logger.WithFields(fields).Panic("invalid connection state") - } + errorFields := logrus.Fields{ + "state": conn.State, + "connGnetID": conn.gnetID, + } - if err := c.canUpdateMirror(ip, m.Mirror); err != nil { - logger.WithFields(fields).WithError(err).Debug("canUpdateMirror failed") - return err + switch conn.State { + case ConnectionStatePending: + logger.Critical().WithFields(fields).WithFields(errorFields).Error("Connections.introduced called on pending connection") + return nil, ErrConnectionStateNotConnected + case ConnectionStateConnected: + if gnetID != conn.gnetID { + logger.Critical().WithFields(fields).WithFields(errorFields).Error("Connections.introduced called with different gnet ID") + return nil, ErrConnectionGnetIDMismatch } + case ConnectionStateIntroduced: + logger.Critical().WithFields(fields).WithFields(errorFields).Error("Connections.introduced called on already introduced connection") + return nil, ErrConnectionAlreadyIntroduced + default: + logger.WithFields(fields).WithFields(errorFields).Panic("invalid connection state") + } - return nil - }(); err != nil { + if err := c.canUpdateMirror(ip, m.Mirror); err != nil { + logger.WithFields(fields).WithFields(errorFields).WithField("mirror", m.Mirror).WithError(err).Debug("canUpdateMirror failed") return nil, err } @@ -275,9 +266,10 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess // A misbehaving peer could report a different ListenPort in their IntroductionMessage, // but it shouldn't affect our records. if conn.Outgoing && conn.ListenPort != m.ListenPort { - fields["connListenPort"] = conn.ListenPort - fields["introListenPort"] = m.ListenPort - logger.Critical().WithFields(fields).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") + logger.Critical().WithFields(fields).WithFields(logrus.Fields{ + "connListenPort": conn.ListenPort, + "introListenPort": m.ListenPort, + }).Warning("Outgoing connection's ListenPort does not match reported IntroductionMessage ListenPort") } listenPort := conn.ListenPort @@ -286,8 +278,7 @@ func (c *Connections) introduced(addr string, gnetID uint64, m *IntroductionMess } if err := c.updateMirror(ip, m.Mirror, listenPort); err != nil { - fields["mirror"] = m.Mirror - logger.WithFields(fields).WithError(err).Panic("updateMirror failed, but shouldn't") + logger.WithFields(fields).WithField("mirror", m.Mirror).WithError(err).Panic("updateMirror failed, but shouldn't") } conn.State = ConnectionStateIntroduced @@ -328,7 +319,10 @@ func (c *Connections) modify(addr string, gnetID uint64, f func(c *ConnectionDet // compare to original if cd.Mirror != conn.ConnectionDetails.Mirror { - logger.Panic("Connections.modify connection mirror value was changed") + logger.WithFields(logrus.Fields{ + "addr": addr, + "gnetID": gnetID, + }).Panic("Connections.modify connection mirror value was changed") } conn.ConnectionDetails = cd diff --git a/src/daemon/connections_test.go b/src/daemon/connections_test.go index ff790157a7..43aae240ba 100644 --- a/src/daemon/connections_test.go +++ b/src/daemon/connections_test.go @@ -13,8 +13,6 @@ func getMirrorPort(c *Connections, ip string, mirror uint32) uint16 { c.Lock() defer c.Unlock() - logger.Debugf("getMirrorPort ip=%s mirror=%d", ip, mirror) - x := c.mirrors[mirror] if x == nil { return 0 diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 3374cafa4a..5a93a0eddb 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -95,12 +95,12 @@ func (cfg *Config) preprocess() (Config, error) { if config.Daemon.Address == "" { local, err := iputil.LocalhostIP() if err != nil { - logger.Panicf("Failed to obtain localhost IP: %v", err) + logger.WithError(err).Panic("Failed to obtain localhost IP") } config.Daemon.Address = local } else { if !iputil.IsLocalhost(config.Daemon.Address) { - logger.Panicf("Invalid address for localhost-only: %s", config.Daemon.Address) + logger.WithField("addr", config.Daemon.Address).Panic("Invalid address for localhost-only") } } config.Pex.AllowLocalhost = true @@ -579,13 +579,17 @@ loop: if dm.visor.Config.IsMaster { sb, err := dm.CreateAndPublishBlock() if err != nil { - logger.Errorf("Failed to create and publish block: %v", err) + logger.WithError(err).Error("Failed to create and publish block") continue } // Not a critical error, but we want it visible in logs head := sb.Block.Head - logger.Critical().Infof("Created and published a new block, version=%d seq=%d time=%d", head.Version, head.BkSeq, head.Time) + logger.Critical().WithFields(logrus.Fields{ + "version": head.Version, + "seq": head.BkSeq, + "time": head.Time, + }).Info("Created and published a new block") } case <-unconfirmedRefreshTicker.C: @@ -593,7 +597,7 @@ loop: // Get the transactions that turn to valid validTxns, err := dm.visor.RefreshUnconfirmed() if err != nil { - logger.Errorf("dm.Visor.RefreshUnconfirmed failed: %v", err) + logger.WithError(err).Error("dm.Visor.RefreshUnconfirmed failed") continue } // Announce these transactions @@ -606,7 +610,7 @@ loop: // Remove transactions that become invalid (violating hard constraints) removedTxns, err := dm.visor.RemoveInvalidUnconfirmed() if err != nil { - logger.Errorf("dm.Visor.RemoveInvalidUnconfirmed failed: %v", err) + logger.WithError(err).Error("dm.Visor.RemoveInvalidUnconfirmed failed") continue } if len(removedTxns) > 0 { @@ -650,7 +654,7 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { a, _, err := iputil.SplitAddr(p.Addr) if err != nil { - logger.Warningf("PEX gave us an invalid peer: %v", err) + logger.WithField("addr", p.Addr).WithError(err).Warning("PEX gave us an invalid peer") return errors.New("Invalid peer") } if dm.Config.LocalhostOnly && !iputil.IsLocalhost(a) { @@ -693,9 +697,9 @@ func (dm *Daemon) makePrivateConnections() { peers := dm.pex.Private() for _, p := range peers { - logger.Infof("Private peer attempt: %s", p.Addr) + logger.WithField("addr", p.Addr).Info("Private peer attempt") if err := dm.connectToPeer(p); err != nil { - logger.Debugf("Did not connect to private peer: %v", err) + logger.WithField("addr", p.Addr).WithError(err).Debug("Did not connect to private peer") } } } @@ -743,7 +747,7 @@ func (dm *Daemon) cullInvalidConnections() { } if c.ConnectedAt.Add(dm.Config.IntroductionWait).Before(now) { - logger.WithField("addr", c.Addr).Infof("Disconnecting peer for not sending a version") + logger.WithField("addr", c.Addr).Info("Disconnecting peer for not sending a version") if err := dm.Disconnect(c.Addr, ErrDisconnectIntroductionTimeout); err != nil { logger.WithError(err).WithField("addr", c.Addr).Error("Disconnect") } @@ -770,15 +774,6 @@ func (dm *Daemon) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) err return nil } -// needsIntro check if the connection needs introduction message -func (dm *Daemon) needsIntro(addr string) bool { - c := dm.connections.get(addr) - if c == nil { - logger.WithField("addr", addr).Warning("needsIntro did not find a matching connection") - } - return c != nil && !c.HasIntroduced() -} - func (dm *Daemon) handleEvent(e interface{}) { switch x := e.(type) { case messageEvent: @@ -798,11 +793,15 @@ func (dm *Daemon) handleEvent(e interface{}) { } func (dm *Daemon) onMessageEvent(e messageEvent) { - // The first message received must be an Introduction - // We have to check at process time and not record time because - // Introduction message does not update ExpectingIntroductions until its - // process() is called - if dm.needsIntro(e.Context.Addr) { + // If the connection does not exist, abort message processing + c := dm.connections.get(e.Context.Addr) + if c == nil { + logger.WithField("addr", e.Context.Addr).Info("onMessageEvent no connection found") + return + } + + // The first message received must be an IntroductionMessage + if !c.HasIntroduced() { _, isIntro := e.Message.(*IntroductionMessage) if !isIntro { logger.WithFields(logrus.Fields{ @@ -877,7 +876,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { logger.Critical().WithFields(fields).Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") } - logger.WithFields(fields).WithField("mirror", dm.Messages.Mirror).Debug("Sending introduction message") + logger.WithFields(fields).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) if err := dm.pool.Pool.SendMessage(e.Addr, m); err != nil { @@ -967,9 +966,13 @@ func (dm *Daemon) ipCountMaxed(addr string) bool { // outside of the daemon run loop func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { if r.Error != nil { - logger.Warningf("Failed to send %s to %s: %v", reflect.TypeOf(r.Message), r.Addr, r.Error) + logger.WithError(r.Error).WithFields(logrus.Fields{ + "addr": r.Addr, + "msgType": reflect.TypeOf(r.Message), + }).Warning("Failed to send message") return } + switch r.Message.(type) { case SendingTxnsMessage: dm.announcedTxns.add(r.Message.(SendingTxnsMessage).GetFiltered()) @@ -995,7 +998,7 @@ func (dm *Daemon) RequestBlocks() error { err = dm.pool.Pool.BroadcastMessage(m) if err != nil { - logger.Debugf("Broadcast GetBlocksMessage failed: %v", err) + logger.WithError(err).Debug("Broadcast GetBlocksMessage failed") } return err @@ -1019,7 +1022,7 @@ func (dm *Daemon) AnnounceBlocks() error { err = dm.pool.Pool.BroadcastMessage(m) if err != nil { - logger.Debugf("Broadcast AnnounceBlocksMessage failed: %v", err) + logger.WithError(err).Debug("Broadcast AnnounceBlocksMessage failed") } return err @@ -1048,7 +1051,7 @@ func (dm *Daemon) AnnounceAllTxns() error { } if err != nil { - logger.Debugf("Broadcast AnnounceTxnsMessage failed, err: %v", err) + logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") } return err @@ -1093,7 +1096,7 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { err := dm.pool.Pool.BroadcastMessage(m) if err != nil { - logger.Debugf("Broadcast AnnounceTxnsMessage failed: %v", err) + logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") } return err @@ -1132,7 +1135,7 @@ func (dm *Daemon) ResendUnconfirmedTxns() ([]cipher.SHA256, error) { var txids []cipher.SHA256 for i := range txns { - logger.Debugf("Rebroadcast txn %s", txns[i].Hash().Hex()) + logger.WithField("txid", txns[i].Hash().Hex()).Debug("Rebroadcast transaction") if err := dm.BroadcastTransaction(txns[i].Transaction); err == nil { txids = append(txids, txns[i].Transaction.Hash()) } diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index 14bd4cdb12..ce6ff8d24a 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -99,8 +99,7 @@ func EncodeMessage(msg Message) []byte { t := reflect.ValueOf(msg).Elem().Type() msgID, succ := MessageIDMap[t] if !succ { - txt := "Attempted to serialize message struct not in MessageIdMap: %v" - logger.Panicf(txt, msg) + logger.Panicf("Attempted to serialize message struct not in MessageIdMap: %v", msg) } bMsg := encoder.Serialize(msg) diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index cdcf749a2d..c272d15353 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -316,7 +316,7 @@ func (pool *ConnectionPool) processStrand() { return case req := <-pool.reqC: if err := req.Func(); err != nil { - logger.WithField("operation", req.Name).WithError(err).Errorf("strand req.Func failed") + logger.WithField("operation", req.Name).WithError(err).Error("strand req.Func failed") } } } @@ -601,7 +601,7 @@ func (pool *ConnectionPool) sendLoop(conn *Connection, timeout time.Duration, qc // since no further action in this block will happen after the write. if err == nil { if err := pool.updateLastSent(conn.Addr(), Now()); err != nil { - logger.Warningf("updateLastSent(%s) failed", conn.Addr()) + logger.WithField("addr", conn.Addr()).WithError(err).Warning("updateLastSent failed") } } @@ -611,7 +611,7 @@ func (pool *ConnectionPool) sendLoop(conn *Connection, timeout time.Duration, qc return nil case pool.SendResults <- sr: default: - logger.Warningf("SendResults queue full address=%s", conn.Addr()) + logger.WithField("addr", conn.Addr()).Warning("SendResults queue full") } if err != nil { @@ -642,7 +642,6 @@ func readData(reader io.Reader, buf []byte) ([]byte, error) { func decodeData(buf *bytes.Buffer, maxMsgLength int) ([][]byte, error) { dataArray := [][]byte{} for buf.Len() > messageLengthSize { - //logger.Debug("There is data in the buffer, extracting") prefix := buf.Bytes()[:messageLengthSize] // decode message length tmpLength := uint32(0) @@ -656,14 +655,13 @@ func decodeData(buf *bytes.Buffer, maxMsgLength int) ([][]byte, error) { } length := int(tmpLength) - // logger.Debugf("Length is %d", length) + // Disconnect if we received an invalid length. if length < messagePrefixLength || length > maxMsgLength { return [][]byte{}, ErrDisconnectInvalidMessageLength } if buf.Len()-messageLengthSize < length { - // logger.Debug("Skipping, not enough data to read this") return [][]byte{}, nil } @@ -771,27 +769,22 @@ func (pool *ConnectionPool) GetConnection(addr string) (*Connection, error) { // Connect to an address func (pool *ConnectionPool) Connect(address string) error { - if exist, err := pool.IsConnExist(address); err != nil { - return err - } else if exist { - return ErrConnectionExists - } + if err := pool.strand("Connect", func() error { + if pool.isConnExist(address) { + return ErrConnectionExists + } - var hitMaxDefaultConnNum bool - // Checks if it's one of the default connection - if err := pool.strand("Check default connection", func() error { if _, ok := pool.Config.defaultConnections[address]; ok { - hitMaxDefaultConnNum = pool.isMaxDefaultConnectionsReached() + if pool.isMaxDefaultConnectionsReached() { + return ErrMaxOutgoingConnectionsReached + } } + return nil }); err != nil { return err } - if hitMaxDefaultConnNum { - return ErrMaxOutgoingConnectionsReached - } - logger.WithField("addr", address).Debugf("Making TCP connection") conn, err := net.DialTimeout("tcp", address, pool.Config.DialTimeout) if err != nil { @@ -918,7 +911,7 @@ func (pool *ConnectionPool) OutgoingConnectionsNum() (int, error) { // SendResults channel. func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { if pool.Config.DebugPrint { - logger.Debugf("Send, Msg Type: %s", reflect.TypeOf(msg)) + logger.WithField("msgType", reflect.TypeOf(msg)).Debug("SendMessage") } return pool.strand("SendMessage", func() error { @@ -926,7 +919,7 @@ func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { select { case conn.WriteQueue <- msg: default: - logger.Critical().Infof("Write queue full for address %s", addr) + logger.Critical().WithField("addr", addr).Info("Write queue full") return ErrWriteQueueFull } } else { @@ -939,7 +932,7 @@ func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { // BroadcastMessage sends a Message to all connections in the Pool. func (pool *ConnectionPool) BroadcastMessage(msg Message) error { if pool.Config.DebugPrint { - logger.Debugf("Broadcast, Msg Type: %s", reflect.TypeOf(msg)) + logger.WithField("msgType", reflect.TypeOf(msg)).Debug("BroadcastMessage") } fullWriteQueue := []string{} @@ -952,7 +945,7 @@ func (pool *ConnectionPool) BroadcastMessage(msg Message) error { select { case conn.WriteQueue <- msg: default: - logger.Critical().Infof("Write queue full for address %s", conn.Addr()) + logger.Critical().WithField("addr", conn.Addr()).Info("Write queue full") fullWriteQueue = append(fullWriteQueue, conn.Addr()) } } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 7f88504453..f6d5963c6a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -216,7 +216,7 @@ func (gpm *GivePeersMessage) process(d daemoner) { return } peers := gpm.GetPeers() - logger.Debugf("Got these peers via PEX: %s", strings.Join(peers, ", ")) + logger.Debugf("Got %d peers via PEX: %s", len(peers), strings.Join(peers, ", ")) d.AddPeers(peers) } @@ -248,7 +248,10 @@ type IntroductionMessage struct { // NewIntroductionMessage creates introduction message func NewIntroductionMessage(mirror uint32, version int32, port uint16, pubkey cipher.PubKey, userAgent string) *IntroductionMessage { if len(userAgent) > useragent.MaxLen { - logger.Panicf("user agent %q exceeds max len %d", userAgent, useragent.MaxLen) + logger.WithFields(logrus.Fields{ + "userAgent": userAgent, + "maxLen": useragent.MaxLen, + }).Panic("user agent exceeds max len") } if userAgent == "" { logger.Panic("user agent is required") @@ -283,7 +286,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa logger.WithFields(logrus.Fields{ "addr": mc.Addr, "mirror": intro.Mirror, - }).Infof("Remote mirror value matches ours") + }).Info("Remote mirror value matches ours") if err := d.Disconnect(mc.Addr, ErrDisconnectSelf); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -297,7 +300,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa "addr": mc.Addr, "protocolVersion": intro.ProtocolVersion, "minProtocolVersion": dc.MinProtocolVersion, - }).Infof("protocol version below minimum supported protocol version") + }).Info("protocol version below minimum supported protocol version") if err := d.Disconnect(mc.Addr, ErrDisconnectVersionNotSupported); err != nil { logger.WithError(err).WithField("addr", mc.Addr).Warning("Disconnect") } @@ -398,6 +401,8 @@ func (intro *IntroductionMessage) process(d daemoner) { case ErrConnectionGnetIDMismatch, ErrConnectionStateNotConnected, ErrConnectionAlreadyIntroduced: logger.Critical().WithError(err).Warning("IntroductionMessage.process connection state out of order") return + case ErrConnectionNotExist: + return case ErrConnectionIPMirrorExists: reason = ErrDisconnectConnectedTwice default: @@ -578,10 +583,10 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { err := d.ExecuteSignedBlock(b) if err == nil { - logger.Critical().Infof("Added new block %d", b.Block.Head.BkSeq) + logger.Critical().WithField("seq", b.Block.Head.BkSeq).Info("Added new block") processed++ } else { - logger.Critical().Errorf("Failed to execute received block %d: %v", b.Block.Head.BkSeq, err) + logger.Critical().WithError(err).WithField("seq", b.Block.Head.BkSeq).Error("Failed to execute received block") // Blocks must be received in order, so if one fails its assumed // the rest are failing break @@ -664,7 +669,7 @@ func (abm *AnnounceBlocksMessage) process(d daemoner) { // If client is not caught up, won't attempt to get block m := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) if err := d.SendMessage(abm.c.Addr, m); err != nil { - logger.Errorf("Send GetBlocksMessage to %s failed: %v", abm.c.Addr, err) + logger.WithError(err).WithField("addr", abm.c.Addr).Error("Send GetBlocksMessage") } } @@ -715,7 +720,7 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { m := NewGetTxnsMessage(unknown) if err := d.SendMessage(atm.c.Addr, m); err != nil { - logger.WithField("addr", atm.c.Addr).WithError(err).Errorf("Send GetTxnsMessage failed") + logger.WithField("addr", atm.c.Addr).WithError(err).Error("Send GetTxnsMessage failed") } } @@ -757,7 +762,7 @@ func (gtm *GetTxnsMessage) process(d daemoner) { // Reply to sender with GiveTxnsMessage m := NewGiveTxnsMessage(known) if err := d.SendMessage(gtm.c.Addr, m); err != nil { - logger.Errorf("Send GiveTxnsMessage to %s failed: %v", gtm.c.Addr, err) + logger.WithError(err).WithField("addr", gtm.c.Addr).Error("Send GiveTxnsMessage") } } @@ -799,13 +804,13 @@ func (gtm *GiveTxnsMessage) process(d daemoner) { // since each is independent known, softErr, err := d.InjectTransaction(txn) if err != nil { - logger.Warningf("Failed to record transaction %s: %v", txn.Hash().Hex(), err) + logger.WithError(err).WithField("txid", txn.Hash().Hex()).Warning("Failed to record transaction") continue } else if softErr != nil { - logger.Warningf("Transaction soft violation: %v", err) + logger.WithError(err).WithField("txid", txn.Hash().Hex()).Warning("Transaction soft violation") continue } else if known { - logger.Warningf("Duplicate Transaction: %s", txn.Hash().Hex()) + logger.WithField("txid", txn.Hash().Hex()).Warning("Duplicate transaction") continue } diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index 821d1b851d..ea21120ad1 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -8,6 +8,8 @@ import ( "os" "time" + "github.com/sirupsen/logrus" + "github.com/skycoin/skycoin/src/util/file" "github.com/skycoin/skycoin/src/util/useragent" ) @@ -58,21 +60,27 @@ func loadCachedPeersFile(path string) (map[string]*Peer, error) { peers := make(map[string]*Peer, len(peersJSON)) for addr, peerJSON := range peersJSON { + fields := logrus.Fields{ + "addr": addr, + "path": path, + } + a, err := validateAddress(addr, true) if err != nil { - logger.Errorf("Invalid address in peers JSON file %s: %v", addr, err) + logger.WithError(err).WithFields(fields).Error("Invalid address in peers JSON file") continue } peer, err := newPeerFromJSON(peerJSON) if err != nil { - logger.Errorf("newPeerFromJSON failed: %v", err) + logger.WithError(err).WithFields(fields).Error("newPeerFromJSON failed") continue } if a != peer.Addr { - logger.Errorf("Address key %s does not match Peer.Addr %s", a, peer.Addr) + fields["peerAddr"] = peer.Addr + logger.WithFields(fields).Error("Address key does not match Peer.Addr") continue } diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index c9a0f7fc5e..8d040c7d26 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -260,7 +260,7 @@ func New(cfg Config) (*Pex, error) { // Add custom peers if cfg.CustomPeersFile != "" { if err := pex.loadCustom(cfg.CustomPeersFile); err != nil { - logger.Critical().WithError(err).Errorf("Failed to load custom peers from %s", cfg.CustomPeersFile) + logger.Critical().WithError(err).WithField("file", cfg.CustomPeersFile).Error("Failed to load custom peers file") return nil, err } } @@ -274,7 +274,7 @@ func New(cfg Config) (*Pex, error) { if pex.Config.DownloadPeerList { go func() { if err := pex.downloadPeers(); err != nil { - logger.Errorf("Failed to download peers list: %v", err) + logger.WithError(err).Error("Failed to download peers list") } }() } @@ -292,7 +292,7 @@ func (px *Pex) Run() error { // Save the peerlist logger.Info("Save peerlist") if err := px.save(); err != nil { - logger.Errorf("Save peers failed: %v", err) + logger.WithError(err).Error("Save peerlist failed") } }() @@ -324,15 +324,15 @@ func (px *Pex) Shutdown() { func (px *Pex) downloadPeers() error { body, err := backoffDownloadText(px.Config.PeerListURL) if err != nil { - logger.Errorf("Failed to download peers from %s. err: %s", px.Config.PeerListURL, err.Error()) + logger.WithError(err).WithField("url", px.Config.PeerListURL).Error("Failed to download peers") return err } peers := parseRemotePeerList(body) - logger.Infof("Downloaded peers list from %s, got %d peers", px.Config.PeerListURL, len(peers)) + logger.WithField("url", px.Config.PeerListURL).Infof("Downloaded peers list, got %d peers", len(peers)) n := px.AddPeers(peers) - logger.Infof("Added %d/%d peers from downloaded peers list", n, len(peers)) + logger.WithField("url", px.Config.PeerListURL).Infof("Added %d/%d peers from downloaded peers list", n, len(peers)) return nil } @@ -368,7 +368,7 @@ func (px *Pex) loadCache() error { var validPeers []Peer for addr, p := range peers { if _, err := validateAddress(addr, px.Config.AllowLocalhost); err != nil { - logger.Errorf("Invalid peer address: %v", err) + logger.WithError(err).Error("Invalid peer address") continue } @@ -426,7 +426,7 @@ func (px *Pex) AddPeer(addr string) error { cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Errorf("Invalid address %s: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("Invalid address") return ErrInvalidAddress } @@ -458,7 +458,7 @@ func (px *Pex) AddPeers(addrs []string) int { for _, addr := range addrs { a, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Infof("Add peers sees an invalid address %s: %v", addr, err) + logger.WithField("addr", addr).WithError(err).Info("Add peers sees an invalid address") continue } validAddrs = append(validAddrs, a) @@ -488,7 +488,7 @@ func (px *Pex) SetPrivate(addr string, private bool) error { cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Errorf("Invalid address %s: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("Invalid address") return ErrInvalidAddress } @@ -502,7 +502,7 @@ func (px *Pex) SetTrusted(addr string) error { cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Errorf("Invalid address %s: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("Invalid address") return ErrInvalidAddress } @@ -524,7 +524,7 @@ func (px *Pex) SetHasIncomingPort(addr string, hasPublicPort bool) error { cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Errorf("Invalid address %s: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("Invalid address") return ErrInvalidAddress } @@ -538,7 +538,7 @@ func (px *Pex) SetUserAgent(addr string, userAgent useragent.Data) error { cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { - logger.Errorf("Invalid address %s: %v", addr, err) + logger.WithError(err).WithField("addr", addr).Error("Invalid address") return ErrInvalidAddress } diff --git a/src/daemon/strand/strand.go b/src/daemon/strand/strand.go index f219302279..629960f2b4 100644 --- a/src/daemon/strand/strand.go +++ b/src/daemon/strand/strand.go @@ -40,7 +40,7 @@ type Request struct { // channel closes. func Strand(logger *logging.Logger, c chan Request, name string, f func() error, quit chan struct{}, quitErr error) error { if Debug { - logger.WithField("operation", name).Debugf("Strand precall") + logger.WithField("operation", name).Debug("Strand precall") } done := make(chan struct{}) From 7c1a8445ce884ac01a16ec8f1bd8ff11844be591 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 22:05:38 +0800 Subject: [PATCH 328/399] Return all connections in /api/v1/network/connections --- CHANGELOG.md | 1 + src/api/gateway.go | 2 +- src/api/mock_gatewayer_test.go | 4 ++-- src/api/network.go | 2 +- src/api/network_test.go | 8 ++++---- src/daemon/gateway.go | 16 ++++++---------- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 628f87df55..b5d4629fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` - `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"`. Added `"connected_at"` field. +- `/api/v1/network/connections` now includes incoming connections ### Removed diff --git a/src/api/gateway.go b/src/api/gateway.go index 5bb56dd8c9..18a7d6a7cb 100644 --- a/src/api/gateway.go +++ b/src/api/gateway.go @@ -44,7 +44,7 @@ type Gatewayer interface { GetBlockchainMetadata() (*visor.BlockchainMetadata, error) GetBlockchainProgress() (*daemon.BlockchainProgress, error) GetConnection(addr string) (*daemon.Connection, error) - GetOutgoingConnections() ([]daemon.Connection, error) + GetConnections() ([]daemon.Connection, error) GetDefaultConnections() []string GetTrustConnections() []string GetExchgConnection() []string diff --git a/src/api/mock_gatewayer_test.go b/src/api/mock_gatewayer_test.go index 7dcdd90eb1..5c20980d7c 100644 --- a/src/api/mock_gatewayer_test.go +++ b/src/api/mock_gatewayer_test.go @@ -504,8 +504,8 @@ func (_m *MockGatewayer) GetLastBlocksVerbose(num uint64) ([]coin.SignedBlock, [ return r0, r1, r2 } -// GetOutgoingConnections provides a mock function with given fields: -func (_m *MockGatewayer) GetOutgoingConnections() ([]daemon.Connection, error) { +// GetConnections provides a mock function with given fields: +func (_m *MockGatewayer) GetConnections() ([]daemon.Connection, error) { ret := _m.Called() var r0 []daemon.Connection diff --git a/src/api/network.go b/src/api/network.go index 768e329daa..fb4aa5c69e 100644 --- a/src/api/network.go +++ b/src/api/network.go @@ -71,7 +71,7 @@ func connectionsHandler(gateway Gatewayer) http.HandlerFunc { return } - dcnxs, err := gateway.GetOutgoingConnections() + dcnxs, err := gateway.GetConnections() if err != nil { wh.Error500(w, err.Error()) return diff --git a/src/api/network_test.go b/src/api/network_test.go index e0f14b5bdd..39d21c9628 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -194,18 +194,18 @@ func TestConnections(t *testing.T) { }, { - name: "500 - GetOutgoingConnections failed", + name: "500 - GetConnections failed", method: http.MethodGet, status: http.StatusInternalServerError, - err: "500 Internal Server Error - GetOutgoingConnections failed", - gatewayGetSolicitedConnectionsError: errors.New("GetOutgoingConnections failed"), + err: "500 Internal Server Error - GetConnections failed", + gatewayGetSolicitedConnectionsError: errors.New("GetConnections failed"), }, } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { endpoint := "/api/v1/network/connections" gateway := &MockGatewayer{} - gateway.On("GetOutgoingConnections").Return(tc.gatewayGetSolicitedConnectionsResult, tc.gatewayGetSolicitedConnectionsError) + gateway.On("GetConnections").Return(tc.gatewayGetSolicitedConnectionsResult, tc.gatewayGetSolicitedConnectionsError) req, err := http.NewRequest(tc.method, endpoint, nil) require.NoError(t, err) diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 666a10224d..2301c5700c 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -124,17 +124,17 @@ func newConnection(dc *connection, gc *gnet.Connection, pp *pex.Peer) Connection return c } -// GetOutgoingConnections returns solicited (outgoing) connections -func (gw *Gateway) GetOutgoingConnections() ([]Connection, error) { +// GetConnections returns solicited (outgoing) connections +func (gw *Gateway) GetConnections() ([]Connection, error) { var conns []Connection var err error - gw.strand("GetOutgoingConnections", func() { - conns, err = gw.getOutgoingConnections() + gw.strand("GetConnections", func() { + conns, err = gw.getConnections() }) return conns, err } -func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { +func (gw *Gateway) getConnections() ([]Connection, error) { if gw.d.pool.Pool == nil { return nil, nil } @@ -144,10 +144,6 @@ func (gw *Gateway) getOutgoingConnections() ([]Connection, error) { conns := make([]Connection, 0) for _, c := range cs { - if !c.Outgoing || c.State != ConnectionStateIntroduced { - continue - } - cc, err := gw.newConnection(&c) if err != nil { return nil, err @@ -916,7 +912,7 @@ func (gw *Gateway) GetHealth() (*Health, error) { return } - conns, err := gw.getOutgoingConnections() + conns, err := gw.getConnections() if err != nil { return } From 9f9edbc65406f98ca4cdd46464aa1e75f32fe35a Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 22:07:47 +0800 Subject: [PATCH 329/399] Omit pending connections from API --- CHANGELOG.md | 2 +- src/daemon/gateway.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d4629fa9..56854b0551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,7 +80,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `cli addressGen` arguments have changed - `cli generateWallet` renamed to `cli walletCreate` - `cli generateAddresses` renamed to `cli walletAddAddresses` -- `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode. +- `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode - `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` - `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"`. Added `"connected_at"` field. diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 2301c5700c..deaa37488b 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -144,6 +144,11 @@ func (gw *Gateway) getConnections() ([]Connection, error) { conns := make([]Connection, 0) for _, c := range cs { + // Skip pending connections since they're not really connected + if c.State == ConnectionStatePending { + continue + } + cc, err := gw.newConnection(&c) if err != nil { return nil, err From 6ec53c9e8eef72edbc76434743fedcffdc790250 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 22:10:19 +0800 Subject: [PATCH 330/399] Add new node to peers.txt --- peers.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/peers.txt b/peers.txt index 9aab20f655..b8d1a70025 100644 --- a/peers.txt +++ b/peers.txt @@ -45,4 +45,5 @@ 49.135.7.8:6000 207.237.45.196:6000 45.63.21.232:6000 -101.167.169.158:6000 \ No newline at end of file +101.167.169.158:6000 +172.105.210.184:6000 From d05f66f1aaecfa9c58f0440227768571b76158aa Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 22:38:25 +0800 Subject: [PATCH 331/399] Prevent BroadcastMessage from sending before introduced --- src/daemon/daemon.go | 44 +++++++++++------------- src/daemon/gnet/pool.go | 59 ++++++++++++++++---------------- src/daemon/gnet/pool_test.go | 14 ++++++-- src/daemon/messages_test.go | 46 ++++++++++--------------- src/daemon/mock_daemoner_test.go | 35 ------------------- 5 files changed, 80 insertions(+), 118 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 5a93a0eddb..337f39dd62 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -234,8 +234,6 @@ type daemoner interface { SendMessage(addr string, msg gnet.Message) error BroadcastMessage(msg gnet.Message) error Disconnect(addr string, r gnet.DisconnectReason) error - IsDefaultConnection(addr string) bool - IsMaxDefaultConnectionsReached() (bool, error) PexConfig() pex.Config RandomExchangeable(n int) pex.Peers AddPeer(addr string) error @@ -513,7 +511,7 @@ loop: } m := NewGetPeersMessage() - if err := dm.pool.Pool.BroadcastMessage(m); err != nil { + if err := dm.BroadcastMessage(m); err != nil { logger.WithError(err).Error("Broadcast GetPeersMessage failed") } @@ -879,7 +877,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { logger.WithFields(fields).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) - if err := dm.pool.Pool.SendMessage(e.Addr, m); err != nil { + if err := dm.SendMessage(e.Addr, m); err != nil { logger.WithFields(fields).WithError(err).Error("Send IntroductionMessage failed") return } @@ -996,7 +994,7 @@ func (dm *Daemon) RequestBlocks() error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - err = dm.pool.Pool.BroadcastMessage(m) + err = dm.BroadcastMessage(m) if err != nil { logger.WithError(err).Debug("Broadcast GetBlocksMessage failed") } @@ -1020,7 +1018,7 @@ func (dm *Daemon) AnnounceBlocks() error { m := NewAnnounceBlocksMessage(headSeq) - err = dm.pool.Pool.BroadcastMessage(m) + err = dm.BroadcastMessage(m) if err != nil { logger.WithError(err).Debug("Broadcast AnnounceBlocksMessage failed") } @@ -1045,7 +1043,7 @@ func (dm *Daemon) AnnounceAllTxns() error { for _, hs := range hashesSet { m := NewAnnounceTxnsMessage(hs) - if err = dm.pool.Pool.BroadcastMessage(m); err != nil { + if err = dm.BroadcastMessage(m); err != nil { break } } @@ -1094,7 +1092,7 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { m := NewAnnounceTxnsMessage(txns) - err := dm.pool.Pool.BroadcastMessage(m) + err := dm.BroadcastMessage(m) if err != nil { logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") } @@ -1118,7 +1116,7 @@ func (dm *Daemon) RequestBlocksFromAddr(addr string) error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - return dm.pool.Pool.SendMessage(addr, m) + return dm.SendMessage(addr, m) } // ResendUnconfirmedTxns resends all unconfirmed transactions and returns the hashes that were successfully rebroadcast. @@ -1158,8 +1156,8 @@ func (dm *Daemon) BroadcastTransaction(t coin.Transaction) error { logger.Debugf("BroadcastTransaction to %d conns", l) m := NewGiveTxnsMessage(coin.Transactions{t}) - if err := dm.pool.Pool.BroadcastMessage(m); err != nil { - logger.WithError(err).Error("BroadcastTransaction Pool.BroadcastMessage failed") + if err := dm.BroadcastMessage(m); err != nil { + logger.WithError(err).Error("Broadcast GiveTxnsMessage failed") return err } @@ -1195,7 +1193,7 @@ func (dm *Daemon) broadcastBlock(sb coin.SignedBlock) error { } m := NewGiveBlocksMessage([]coin.SignedBlock{sb}) - return dm.pool.Pool.BroadcastMessage(m) + return dm.BroadcastMessage(m) } // Mirror returns the message mirror @@ -1226,9 +1224,17 @@ func (dm *Daemon) SendMessage(addr string, msg gnet.Message) error { return dm.pool.Pool.SendMessage(addr, msg) } -// BroadcastMessage sends a Message to all connections in the Pool. +// BroadcastMessage sends a Message to all introduced connections in the Pool func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { - return dm.pool.Pool.BroadcastMessage(msg) + conns := dm.connections.all() + var addrs []string + for _, c := range conns { + if c.HasIntroduced() { + addrs = append(addrs, c.Addr) + } + } + + return dm.pool.Pool.BroadcastMessage(msg, addrs) } // Disconnect removes a connection from the pool by address, and invokes DisconnectCallback @@ -1236,16 +1242,6 @@ func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { return dm.pool.Pool.Disconnect(addr, r) } -// IsDefaultConnection returns if the addr is a default connection -func (dm *Daemon) IsDefaultConnection(addr string) bool { - return dm.pool.Pool.IsDefaultConnection(addr) -} - -// IsMaxDefaultConnectionsReached returns whether the max default connection number was reached. -func (dm *Daemon) IsMaxDefaultConnectionsReached() (bool, error) { - return dm.pool.Pool.IsMaxDefaultConnectionsReached() -} - // Implements pexer interface // RandomExchangeable returns N random exchangeable peers diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index c272d15353..9ea72e366c 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -55,12 +55,16 @@ var ( ErrWriteQueueFull = errors.New("Write queue full") // ErrNoReachableConnections when broadcasting a message, no connections were available to send a message to ErrNoReachableConnections = errors.New("All pool connections are unreachable at this time") + // ErrNoMatchingConnections when broadcasting a message, no connections were found for the provided addresses + ErrNoMatchingConnections = errors.New("No connections found for broadcast addresses") // ErrPoolEmpty when broadcasting a message, the connection pool was empty ErrPoolEmpty = errors.New("Connection pool is empty") // ErrConnectionExists connection exists ErrConnectionExists = errors.New("Connection exists") // ErrMaxOutgoingConnectionsReached outgoing connections max reached ErrMaxOutgoingConnectionsReached = errors.New("Outgoing connections max reached") + // ErrNoAddresses no addresses were provided to BroadcastMessage + ErrNoAddresses = errors.New("No addresses provided") // Logger logger = logging.MustGetLogger("gnet") @@ -696,25 +700,6 @@ func (pool *ConnectionPool) isConnExist(addr string) bool { return ok } -// IsDefaultConnection returns if the addr is a default connection -func (pool *ConnectionPool) IsDefaultConnection(addr string) bool { - _, ok := pool.Config.defaultConnections[addr] - return ok -} - -// IsMaxDefaultConnectionsReached returns whether the max default connection number was reached. -func (pool *ConnectionPool) IsMaxDefaultConnectionsReached() (bool, error) { - var reached bool - if err := pool.strand("IsMaxDefaultConnectionsReached", func() error { - reached = pool.isMaxDefaultConnectionsReached() - return nil - }); err != nil { - return false, err - } - - return reached, nil -} - func (pool *ConnectionPool) isMaxDefaultConnectionsReached() bool { return len(pool.defaultConnections) >= pool.Config.MaxDefaultPeerOutgoingConnections } @@ -907,8 +892,7 @@ func (pool *ConnectionPool) OutgoingConnectionsNum() (int, error) { return n, nil } -// SendMessage sends a Message to a Connection and pushes the result onto the -// SendResults channel. +// SendMessage sends a Message to a Connection func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { if pool.Config.DebugPrint { logger.WithField("msgType", reflect.TypeOf(msg)).Debug("SendMessage") @@ -929,28 +913,43 @@ func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { }) } -// BroadcastMessage sends a Message to all connections in the Pool. -func (pool *ConnectionPool) BroadcastMessage(msg Message) error { +// BroadcastMessage sends a Message to all connections specified in addrs. +// If a connection does not exist for a given address, it is skipped. +// If no messages were written to any connection, an error is returned. +func (pool *ConnectionPool) BroadcastMessage(msg Message, addrs []string) error { if pool.Config.DebugPrint { logger.WithField("msgType", reflect.TypeOf(msg)).Debug("BroadcastMessage") } + if len(addrs) == 0 { + return ErrNoAddresses + } + fullWriteQueue := []string{} if err := pool.strand("BroadcastMessage", func() error { if len(pool.pool) == 0 { return ErrPoolEmpty } - for _, conn := range pool.pool { - select { - case conn.WriteQueue <- msg: - default: - logger.Critical().WithField("addr", conn.Addr()).Info("Write queue full") - fullWriteQueue = append(fullWriteQueue, conn.Addr()) + foundConns := 0 + + for _, addr := range addrs { + if conn, ok := pool.addresses[addr]; ok { + foundConns++ + select { + case conn.WriteQueue <- msg: + default: + logger.Critical().WithField("addr", conn.Addr()).Info("Write queue full") + fullWriteQueue = append(fullWriteQueue, conn.Addr()) + } } } - if len(fullWriteQueue) == len(pool.pool) { + if foundConns == 0 { + return ErrNoMatchingConnections + } + + if len(fullWriteQueue) == foundConns { return ErrNoReachableConnections } diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index 374e08b20c..15e3736c70 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -1048,8 +1048,18 @@ func TestPoolBroadcastMessage(t *testing.T) { <-ready + var addrs []string + err = p.strand("addresses", func() error { + for a := range p.addresses { + addrs = append(addrs, a) + } + return nil + }) + require.NoError(t, err) + require.NotEmpty(t, addrs) + m := NewByteMessage(88) - err = p.BroadcastMessage(m) + err = p.BroadcastMessage(m, addrs) require.NoError(t, err) // Spam the connections with so much data that their write queue overflows, @@ -1062,7 +1072,7 @@ func TestPoolBroadcastMessage(t *testing.T) { for i := 0; i < attempts; i++ { go func() { defer wg.Done() - err := p.BroadcastMessage(m) + err := p.BroadcastMessage(m, addrs) if err == ErrNoReachableConnections { once.Do(func() { gotErr = true diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index fa1fa884e4..8d4b1da665 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -23,23 +23,20 @@ func TestIntroductionMessage(t *testing.T) { pubkey2, _ := cipher.GenerateKeyPair() type daemonMockValue struct { - protocolVersion uint32 - minProtocolVersion uint32 - mirror uint32 - isDefaultConnection bool - isMaxConnectionsReached bool - isMaxConnectionsReachedErr error - setHasIncomingPortErr error - recordMessageEventErr error - pubkey cipher.PubKey - disconnectReason gnet.DisconnectReason - disconnectErr error - addPeerArg string - addPeerErr error - connectionIntroduced *connection - connectionIntroducedErr error - requestBlocksFromAddrErr error - announceAllTxnsErr error + protocolVersion uint32 + minProtocolVersion uint32 + mirror uint32 + setHasIncomingPortErr error + recordMessageEventErr error + pubkey cipher.PubKey + disconnectReason gnet.DisconnectReason + disconnectErr error + addPeerArg string + addPeerErr error + connectionIntroduced *connection + connectionIntroducedErr error + requestBlocksFromAddrErr error + announceAllTxnsErr error } tt := []struct { @@ -219,13 +216,11 @@ func TestIntroductionMessage(t *testing.T) { name: "incoming connection", addr: "121.121.121.121:12345", mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - isDefaultConnection: true, - isMaxConnectionsReached: true, - pubkey: pubkey, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, + mirror: 10000, + protocolVersion: 1, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: nil, }, intro: &IntroductionMessage{ Mirror: 10001, @@ -242,7 +237,6 @@ func TestIntroductionMessage(t *testing.T) { mockValue: daemonMockValue{ mirror: 10000, protocolVersion: 1, - isDefaultConnection: true, pubkey: pubkey, addPeerArg: "121.121.121.121:6000", addPeerErr: nil, @@ -275,7 +269,6 @@ func TestIntroductionMessage(t *testing.T) { }, }) d.On("Mirror").Return(tc.mockValue.mirror) - d.On("IsDefaultConnection", tc.addr).Return(tc.mockValue.isDefaultConnection) d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) d.On("recordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) d.On("ResetRetryTimes", tc.addr) @@ -283,7 +276,6 @@ func TestIntroductionMessage(t *testing.T) { d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) d.On("IncreaseRetryTimes", tc.addr) d.On("RemoveFromExpectingIntroductions", tc.addr) - d.On("IsMaxDefaultConnectionsReached").Return(tc.mockValue.isMaxConnectionsReached, tc.mockValue.isMaxConnectionsReachedErr) d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) d.On("connectionIntroduced", tc.addr, tc.gnetID, tc.intro).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index e24f3f4e82..de6614bbdf 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -298,41 +298,6 @@ func (_m *mockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.Er return r0, r1, r2 } -// IsDefaultConnection provides a mock function with given fields: addr -func (_m *mockDaemoner) IsDefaultConnection(addr string) bool { - ret := _m.Called(addr) - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(addr) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// IsMaxDefaultConnectionsReached provides a mock function with given fields: -func (_m *mockDaemoner) IsMaxDefaultConnectionsReached() (bool, error) { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // Mirror provides a mock function with given fields: func (_m *mockDaemoner) Mirror() uint32 { ret := _m.Called() From b6d4d7c08cbe153e83f3c861baf78e72966cdf30 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 23:40:51 +0800 Subject: [PATCH 332/399] Add more reasons to remove peer from pex --- src/daemon/daemon.go | 7 +++++-- src/daemon/messages.go | 2 +- src/visor/blockchain.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 337f39dd62..e7d6521f46 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -896,8 +896,11 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { return } - // If the peer did not send an introduction in time, it is not a valid peer and remove it from the peer list - if e.Reason == ErrDisconnectIntroductionTimeout { + switch e.Reason { + case ErrDisconnectIntroductionTimeout, + ErrDisconnectBlockchainPubkeyNotMatched, + ErrDisconnectInvalidExtraData, + ErrDisconnectInvalidUserAgent: if !dm.isTrustedPeer(e.Addr) { dm.pex.RemovePeer(e.Addr) } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index f6d5963c6a..ade54fb08a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -810,7 +810,7 @@ func (gtm *GiveTxnsMessage) process(d daemoner) { logger.WithError(err).WithField("txid", txn.Hash().Hex()).Warning("Transaction soft violation") continue } else if known { - logger.WithField("txid", txn.Hash().Hex()).Warning("Duplicate transaction") + logger.WithField("txid", txn.Hash().Hex()).Debug("Duplicate transaction") continue } diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index a6577a08c9..4ee502b112 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -633,7 +633,7 @@ func (bc Blockchain) processTransactions(tx *dbutil.Tx, txs coin.Transactions) ( // amongst different txns. Duplicate transactions are // caught earlier, when duplicate expected outputs are // checked for, and will not trigger this. - return nil, errors.New("Duplicate transaction") + return nil, errors.New("Unexpected duplicate transaction") } } for a := range s.In { From 60b6c2231936c39ab868e2c5a4f8341e76b09b54 Mon Sep 17 00:00:00 2001 From: gz-c Date: Sun, 28 Oct 2018 23:53:42 +0800 Subject: [PATCH 333/399] Fix MaxConnections enforcement --- src/daemon/daemon.go | 10 ++++------ src/daemon/gnet/pool.go | 25 +++++++++++++++---------- src/skycoin/config.go | 15 ++++++++++++--- src/skycoin/skycoin.go | 1 + 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index e7d6521f46..124eb45573 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -532,9 +532,8 @@ loop: case <-outgoingConnectionsTicker.C: // Fill up our outgoing connections elapser.Register("outgoingConnectionsTicker") - trustPeerNum := len(dm.pex.Trusted()) if !dm.Config.DisableOutgoingConnections && - dm.connections.OutgoingLen() < (dm.Config.OutgoingMax+trustPeerNum) && + dm.connections.OutgoingLen() < dm.Config.OutgoingMax && dm.connections.PendingLen() < dm.Config.PendingMax { dm.connectToRandomPeer() } @@ -550,10 +549,10 @@ loop: case r := <-dm.events: elapser.Register("dm.event") if dm.Config.DisableNetworking { - logger.Error("There should be no events") - return nil + logger.Critical().Error("Networking is disabled, there should be no events") + } else { + dm.handleEvent(r) } - dm.handleEvent(r) case <-flushAnnouncedTxnsTicker.C: elapser.Register("flushAnnouncedTxnsTicker") @@ -561,7 +560,6 @@ loop: if err := dm.visor.SetTransactionsAnnounced(txns); err != nil { logger.WithError(err).Error("Failed to set unconfirmed txn announce time") - return err } case req := <-dm.Gateway.requests: diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 9ea72e366c..a4ac7f9b09 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -379,18 +379,23 @@ func (pool *ConnectionPool) strand(name string, f func() error) error { // Returns nil, nil when max default connection limit hit func (pool *ConnectionPool) newConnection(conn net.Conn, solicited bool) (*Connection, error) { a := conn.RemoteAddr().String() - if _, ok := pool.addresses[a]; ok { + + if pool.isConnExist(a) { return nil, fmt.Errorf("Already connected to %s", a) } + if pool.isMaxConnectionsReached() { + return nil, errors.New("Max connections reached") + } + if _, ok := pool.Config.defaultConnections[a]; ok { - if pool.isMaxDefaultConnectionsReached() && solicited { - return nil, nil + if pool.isMaxDefaultOutgoingConnectionsReached() && solicited { + return nil, errors.New("Max default outgoing connections reached") } pool.defaultConnections[a] = struct{}{} l := len(pool.defaultConnections) - logger.Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) + logger.WithField("addr", a).Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) } pool.connID++ @@ -432,10 +437,6 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro }() err = pool.strand("handleConnection", func() error { - if pool.isConnExist(addr) { - return fmt.Errorf("Connection %s already exists", addr) - } - var err error c, err = pool.newConnection(conn, solicited) if err != nil { @@ -700,10 +701,14 @@ func (pool *ConnectionPool) isConnExist(addr string) bool { return ok } -func (pool *ConnectionPool) isMaxDefaultConnectionsReached() bool { +func (pool *ConnectionPool) isMaxDefaultOutgoingConnectionsReached() bool { return len(pool.defaultConnections) >= pool.Config.MaxDefaultPeerOutgoingConnections } +func (pool *ConnectionPool) isMaxConnectionsReached() bool { + return len(pool.pool) >= pool.Config.MaxConnections +} + // DefaultConnectionsInUse returns the default connection in use func (pool *ConnectionPool) DefaultConnectionsInUse() (int, error) { var use int @@ -760,7 +765,7 @@ func (pool *ConnectionPool) Connect(address string) error { } if _, ok := pool.Config.defaultConnections[address]; ok { - if pool.isMaxDefaultConnectionsReached() { + if pool.isMaxDefaultOutgoingConnectionsReached() { return ErrMaxOutgoingConnectionsReached } } diff --git a/src/skycoin/config.go b/src/skycoin/config.go index f50483eed7..265e0fad4e 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -74,6 +74,8 @@ type NodeConfig struct { Address string // gnet uses this for TCP incoming and outgoing Port int + // MaxConnections is the maximum number of total connections allowed + MaxConnections int // Maximum outgoing connections to maintain MaxOutgoingConnections int // Maximum default outgoing connections @@ -216,9 +218,11 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { Address: "", //gnet uses this for TCP incoming and outgoing Port: node.Port, - // MaxOutgoingConnections is the maximum outgoing connections allowed. + // MaxConnections is the maximum number of total connections allowed + MaxConnections: 128, + // MaxOutgoingConnections is the maximum outgoing connections allowed MaxOutgoingConnections: 8, - // MaxDefaultOutgoingConnections is the maximum default outgoing connections allowed. + // MaxDefaultOutgoingConnections is the maximum default outgoing connections allowed MaxDefaultPeerOutgoingConnections: 1, DownloadPeerList: true, PeerListURL: node.PeerListURL, @@ -387,6 +391,10 @@ func (c *Config) postProcess() error { return errors.New("Web interface auth enabled but HTTPS is not enabled. Use -web-interface-plaintext-auth=true if this is desired") } + if c.Node.MaxOutgoingConnections > c.Node.MaxConnections { + return errors.New("-max-outgoing-connections cannot be higher than -max-connections") + } + return nil } @@ -520,7 +528,8 @@ func (c *NodeConfig) RegisterFlags() { flag.Uint64Var(&c.GenesisTimestamp, "genesis-timestamp", c.GenesisTimestamp, "genesis block timestamp") flag.StringVar(&c.WalletDirectory, "wallet-dir", c.WalletDirectory, "location of the wallet files. Defaults to ~/.skycoin/wallet/") - flag.IntVar(&c.MaxOutgoingConnections, "max-outgoing-connections", c.MaxOutgoingConnections, "The maximum outgoing connections allowed") + flat.IntVar(&c.MaxConnections, "max-connections", c.MaxConnections, "Maximum number of total connections allowed") + flag.IntVar(&c.MaxOutgoingConnections, "max-outgoing-connections", c.MaxOutgoingConnections, "Maximum number of outgoing connections allowed") flag.IntVar(&c.MaxDefaultPeerOutgoingConnections, "max-default-peer-outgoing-connections", c.MaxDefaultPeerOutgoingConnections, "The maximum default peer outgoing connections allowed") flag.IntVar(&c.PeerlistSize, "peerlist-size", c.PeerlistSize, "The peer list size") flag.DurationVar(&c.OutgoingConnectionsRate, "connection-rate", c.OutgoingConnectionsRate, "How often to make an outgoing connection") diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 871b0a7c5c..2b6d4004cf 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -347,6 +347,7 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Pool.DefaultConnections = c.config.Node.DefaultConnections dc.Pool.MaxDefaultPeerOutgoingConnections = c.config.Node.MaxDefaultPeerOutgoingConnections + dc.Pool.ConnectionsMax = c.config.Node.MaxConnections dc.Pex.DataDirectory = c.config.Node.DataDirectory dc.Pex.Disabled = c.config.Node.DisablePEX From afe439b811dce5714922e719be4a8d19af0566bf Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 00:35:04 +0800 Subject: [PATCH 334/399] Fix connection limit enforcement --- src/daemon/daemon.go | 49 ++++++------ src/daemon/gnet/pool.go | 163 +++++++++++++++++++++------------------- src/daemon/pool.go | 8 +- src/skycoin/config.go | 2 +- src/skycoin/skycoin.go | 4 +- 5 files changed, 117 insertions(+), 109 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 124eb45573..4bb7de9852 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -122,6 +122,17 @@ func (cfg *Config) preprocess() (Config, error) { } } + if config.Daemon.MaxConnections < config.Daemon.MaxOutgoingConnections { + return Config{}, errors.New("MaxOutgoingConnections cannot be more than MaxConnections") + } + + if config.Daemon.MaxPendingConnections > config.Daemon.MaxOutgoingConnections { + config.Daemon.MaxPendingConnections = config.Daemon.MaxOutgoingConnections + } + + config.Pool.MaxConnections = config.Daemon.MaxConnections + config.Pool.MaxOutgoingConnections = config.Daemon.MaxOutgoingConnections + userAgent, err := config.Daemon.UserAgent.Build() if err != nil { return Config{}, err @@ -150,13 +161,14 @@ type DaemonConfig struct { // nolint: golint DataDirectory string // How often to check and initiate an outgoing connection if needed OutgoingRate time.Duration - // How often to re-attempt to fill any missing private (aka required) - // connections + // How often to re-attempt to fill any missing private (aka required) connections PrivateRate time.Duration + // Maximum number of connections + MaxConnections int // Number of outgoing connections to maintain - OutgoingMax int + MaxOutgoingConnections int // Maximum number of connections to try at once - PendingMax int + MaxPendingConnections int // How long to wait for a version packet IntroductionWait time.Duration // How often to check for peers that have decided to stop communicating @@ -205,8 +217,9 @@ func NewDaemonConfig() DaemonConfig { Port: 6677, OutgoingRate: time.Second * 5, PrivateRate: time.Second * 5, - OutgoingMax: 8, - PendingMax: 8, + MaxConnections: 128, + MaxOutgoingConnections: 8, + MaxPendingConnections: 8, IntroductionWait: time.Second * 30, CullInvalidRate: time.Second * 3, FlushAnnouncedTxnsRate: time.Second * 3, @@ -533,8 +546,9 @@ loop: // Fill up our outgoing connections elapser.Register("outgoingConnectionsTicker") if !dm.Config.DisableOutgoingConnections && - dm.connections.OutgoingLen() < dm.Config.OutgoingMax && - dm.connections.PendingLen() < dm.Config.PendingMax { + dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections && + dm.connections.PendingLen() < dm.Config.MaxPendingConnections && + dm.connections.Len() < dm.Config.MaxConnections { dm.connectToRandomPeer() } @@ -722,7 +736,7 @@ func (dm *Daemon) connectToRandomPeer() { } // Make a connection to a random (public) peer - peers := dm.pex.RandomPublicUntrusted(dm.Config.OutgoingMax) + peers := dm.pex.RandomPublicUntrusted(dm.Config.MaxOutgoingConnections) for _, p := range peers { if err := dm.connectToPeer(p); err != nil { logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") @@ -839,23 +853,6 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { return } - if e.Solicited { - // Disconnect if the max outgoing connections is reached - n, err := dm.pool.Pool.OutgoingConnectionsNum() - if err != nil { - logger.Critical().WithError(err).WithFields(fields).Error("OutgoingConnectionsNum failed") - return - } - - if n > dm.Config.OutgoingMax { - logger.WithFields(fields).Warning("Max outgoing connections is reached, disconnecting") - if err := dm.Disconnect(e.Addr, ErrDisconnectMaxOutgoingConnectionsReached); err != nil { - logger.WithError(err).WithFields(fields).Error("Disconnect") - } - return - } - } - // Update the connections state machine c, err := dm.connections.connected(e.Addr, e.GnetID) if err != nil { diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index a4ac7f9b09..4db5eb9d87 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -31,7 +31,6 @@ const ( readLoopDurationThreshold = 10 * time.Second sendInMsgChanDurationThreshold = 5 * time.Second sendLoopDurationThreshold = 500 * time.Millisecond - defaultMaxDefaultConnNum = 1 ) var ( @@ -61,8 +60,12 @@ var ( ErrPoolEmpty = errors.New("Connection pool is empty") // ErrConnectionExists connection exists ErrConnectionExists = errors.New("Connection exists") - // ErrMaxOutgoingConnectionsReached outgoing connections max reached - ErrMaxOutgoingConnectionsReached = errors.New("Outgoing connections max reached") + // ErrMaxConnectionsReached max connection reached + ErrMaxConnectionsReached = errors.New("Max connections reached") + // ErrMaxOutgoingConnectionsReached max outgoing connections reached + ErrMaxOutgoingConnectionsReached = errors.New("Max outgoing connections reached") + // ErrMaxOutgoingDefaultConnectionsReached max outgoing default connections reached + ErrMaxOutgoingDefaultConnectionsReached = errors.New("Max outgoing default connections reached") // ErrNoAddresses no addresses were provided to BroadcastMessage ErrNoAddresses = errors.New("No addresses provided") @@ -76,12 +79,14 @@ type Config struct { Address string // Port to listen on. Set to 0 for arbitrary assignment Port uint16 - // Connection limits + // Maximum total connections MaxConnections int - // Messages greater than length are rejected and the sender disconnected - MaxMessageLength int + // Maximum outgoing connections + MaxOutgoingConnections int // Maximum allowed default outgoing connection number MaxDefaultPeerOutgoingConnections int + // Messages greater than length are rejected and the sender disconnected + MaxMessageLength int // Timeout is the timeout for dialing new connections. Use a // timeout of 0 to ignore timeout. DialTimeout time.Duration @@ -117,7 +122,7 @@ func NewConfig() Config { Port: 0, MaxConnections: 128, MaxMessageLength: 256 * 1024, - MaxDefaultPeerOutgoingConnections: defaultMaxDefaultConnNum, + MaxDefaultPeerOutgoingConnections: 1, DialTimeout: time.Second * 30, ReadTimeout: time.Second * 30, WriteTimeout: time.Second * 30, @@ -206,7 +211,9 @@ type ConnectionPool struct { // All connections, indexed by address addresses map[string]*Connection // connected default peer connections - defaultConnections map[string]struct{} + defaultOutgoingConnections map[string]struct{} + // connected outgoing connections + outgoingConnections map[string]struct{} // User-defined state to be passed into message handlers messageState interface{} // Connection ID counter @@ -232,16 +239,17 @@ func NewConnectionPool(c Config, state interface{}) *ConnectionPool { } pool := &ConnectionPool{ - Config: c, - pool: make(map[uint64]*Connection), - addresses: make(map[string]*Connection), - defaultConnections: make(map[string]struct{}), - SendResults: make(chan SendResult, c.SendResultsSize), - messageState: state, - quit: make(chan struct{}), - done: make(chan struct{}), - strandDone: make(chan struct{}), - reqC: make(chan strand.Request), + Config: c, + pool: make(map[uint64]*Connection), + addresses: make(map[string]*Connection), + defaultOutgoingConnections: make(map[string]struct{}), + outgoingConnections: make(map[string]struct{}), + SendResults: make(chan SendResult, c.SendResultsSize), + messageState: state, + quit: make(chan struct{}), + done: make(chan struct{}), + strandDone: make(chan struct{}), + reqC: make(chan strand.Request), } return pool @@ -374,32 +382,52 @@ func (pool *ConnectionPool) strand(name string, f func() error) error { return strand.Strand(logger, pool.reqC, name, f, pool.quit, ErrConnectionPoolClosed) } +func (pool *ConnectionPool) canConnect(a string, solicited bool) error { + if pool.isConnExist(a) { + return ErrConnectionExists + } + + if pool.isMaxConnectionsReached() { + return ErrMaxConnectionsReached + } + + if solicited { + if pool.isMaxOutgoingConnectionsReached() { + return ErrMaxOutgoingConnectionsReached + } + + if _, ok := pool.Config.defaultConnections[a]; ok { + if pool.isMaxOutgoingDefaultConnectionsReached() { + return ErrMaxOutgoingDefaultConnectionsReached + } + } + } + + return nil +} + // newConnection creates a new Connection around a net.Conn. Trying to make a connection // to an address that is already connected will failed. // Returns nil, nil when max default connection limit hit func (pool *ConnectionPool) newConnection(conn net.Conn, solicited bool) (*Connection, error) { a := conn.RemoteAddr().String() - if pool.isConnExist(a) { - return nil, fmt.Errorf("Already connected to %s", a) + if err := pool.canConnect(a, solicited); err != nil { + return nil, err } - if pool.isMaxConnectionsReached() { - return nil, errors.New("Max connections reached") - } + if solicited { + pool.outgoingConnections[a] = struct{}{} - if _, ok := pool.Config.defaultConnections[a]; ok { - if pool.isMaxDefaultOutgoingConnectionsReached() && solicited { - return nil, errors.New("Max default outgoing connections reached") + if _, ok := pool.Config.defaultConnections[a]; ok { + pool.defaultOutgoingConnections[a] = struct{}{} + l := len(pool.defaultOutgoingConnections) + logger.WithField("addr", a).Debugf("%d/%d outgoing default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) } - - pool.defaultConnections[a] = struct{}{} - l := len(pool.defaultConnections) - logger.WithField("addr", a).Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) } - pool.connID++ // ID must start at 1; in case connID overflows back to 0, force it to 1 + pool.connID++ if pool.connID == 0 { pool.connID = 1 } @@ -428,6 +456,13 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro addr := conn.RemoteAddr().String() c, err := func() (c *Connection, err error) { + // TODO -- when limits in newConnection() are reached, should we allow the peer + // to be added anyway, so that we can disconnect it normally and send a disconnect packet? + // It would have to allowed to complete the handshake, otherwise the DISC packet will be ignored + // Or we would have to permit a DISC packet before an INTR + // But the read/write loop would still need to be started + // A ConnectEvent would need to be triggered, or else the DisconnectEvent gnet ID will not match the + // pending connection's zero gnet ID. defer func() { if err != nil { if closeErr := conn.Close(); closeErr != nil { @@ -701,25 +736,16 @@ func (pool *ConnectionPool) isConnExist(addr string) bool { return ok } -func (pool *ConnectionPool) isMaxDefaultOutgoingConnectionsReached() bool { - return len(pool.defaultConnections) >= pool.Config.MaxDefaultPeerOutgoingConnections -} - func (pool *ConnectionPool) isMaxConnectionsReached() bool { return len(pool.pool) >= pool.Config.MaxConnections } -// DefaultConnectionsInUse returns the default connection in use -func (pool *ConnectionPool) DefaultConnectionsInUse() (int, error) { - var use int - if err := pool.strand("GetDefaultConnectionsInUse", func() error { - use = len(pool.defaultConnections) - return nil - }); err != nil { - return 0, err - } +func (pool *ConnectionPool) isMaxOutgoingConnectionsReached() bool { + return len(pool.outgoingConnections) >= pool.Config.MaxOutgoingConnections +} - return use, nil +func (pool *ConnectionPool) isMaxOutgoingDefaultConnectionsReached() bool { + return len(pool.defaultOutgoingConnections) >= pool.Config.MaxDefaultPeerOutgoingConnections } func (pool *ConnectionPool) updateLastSent(addr string, t time.Time) error { @@ -759,18 +785,8 @@ func (pool *ConnectionPool) GetConnection(addr string) (*Connection, error) { // Connect to an address func (pool *ConnectionPool) Connect(address string) error { - if err := pool.strand("Connect", func() error { - if pool.isConnExist(address) { - return ErrConnectionExists - } - - if _, ok := pool.Config.defaultConnections[address]; ok { - if pool.isMaxDefaultOutgoingConnectionsReached() { - return ErrMaxOutgoingConnectionsReached - } - } - - return nil + if err := pool.strand("canConnect", func() error { + return pool.canConnect(address, true) }); err != nil { return err } @@ -802,15 +818,22 @@ func (pool *ConnectionPool) Disconnect(addr string, r DisconnectReason) error { "reason": r, }).Debug("Disconnecting") + // checks if the address is default node address + isDefaultOutgoingConn := false + if _, ok := pool.Config.defaultConnections[addr]; ok { + if _, ok := pool.outgoingConnections[addr]; ok { + isDefaultOutgoingConn = true + } + } + conn := pool.disconnect(addr) if conn == nil { return errors.New("Disconnect: connection does not exist") } - // checks if the address is default node address - if _, ok := pool.Config.defaultConnections[addr]; ok { - l := len(pool.defaultConnections) + if isDefaultOutgoingConn { + l := len(pool.defaultOutgoingConnections) logger.Debugf("%d/%d default connections in use", l, pool.Config.MaxDefaultPeerOutgoingConnections) } @@ -839,7 +862,8 @@ func (pool *ConnectionPool) disconnect(addr string) *Connection { delete(pool.pool, conn.ID) delete(pool.addresses, addr) - delete(pool.defaultConnections, addr) + delete(pool.defaultOutgoingConnections, addr) + delete(pool.outgoingConnections, addr) if err := conn.Close(); err != nil { logger.WithError(err).WithFields(fields).Error("conn.Close") } @@ -880,23 +904,6 @@ func (pool *ConnectionPool) Size() (l int, err error) { return } -// OutgoingConnectionsNum returns the number of outgoing connections -func (pool *ConnectionPool) OutgoingConnectionsNum() (int, error) { - var n int - if err := pool.strand("OutgoingSize", func() error { - for _, p := range pool.pool { - if p.Solicited { - n++ - } - } - return nil - }); err != nil { - return 0, err - } - - return n, nil -} - // SendMessage sends a Message to a Connection func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { if pool.Config.DebugPrint { diff --git a/src/daemon/pool.go b/src/daemon/pool.go index 0d9f6a9895..ff46dfc2df 100644 --- a/src/daemon/pool.go +++ b/src/daemon/pool.go @@ -22,9 +22,11 @@ type PoolConfig struct { ClearStaleRate time.Duration // Buffer size for gnet.ConnectionPool's network Read events EventChannelSize int - // Maximum number of connections to maintain + // Maximum number of connections MaxConnections int - // Maximum number of connections to peers in the DefaultConnections list to maintain + // Maximum number of outgoing connections + MaxOutgoingConnections int + // Maximum number of outgoing connections to peers in the DefaultConnections list to maintain MaxDefaultPeerOutgoingConnections int // Default "trusted" peers DefaultConnections []string @@ -46,6 +48,7 @@ func NewPoolConfig() PoolConfig { ClearStaleRate: 1 * time.Second, EventChannelSize: 4096, MaxConnections: 128, + MaxOutgoingConnections: 8, MaxDefaultPeerOutgoingConnections: 1, } } @@ -66,6 +69,7 @@ func NewPool(cfg PoolConfig, d *Daemon) *Pool { gnetCfg.DisconnectCallback = d.onGnetDisconnect gnetCfg.ConnectFailureCallback = d.onGnetConnectFailure gnetCfg.MaxConnections = cfg.MaxConnections + gnetCfg.MaxOutgoingConnections = cfg.MaxOutgoingConnections gnetCfg.MaxDefaultPeerOutgoingConnections = cfg.MaxDefaultPeerOutgoingConnections gnetCfg.DefaultConnections = cfg.DefaultConnections diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 265e0fad4e..0a57a73902 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -528,7 +528,7 @@ func (c *NodeConfig) RegisterFlags() { flag.Uint64Var(&c.GenesisTimestamp, "genesis-timestamp", c.GenesisTimestamp, "genesis block timestamp") flag.StringVar(&c.WalletDirectory, "wallet-dir", c.WalletDirectory, "location of the wallet files. Defaults to ~/.skycoin/wallet/") - flat.IntVar(&c.MaxConnections, "max-connections", c.MaxConnections, "Maximum number of total connections allowed") + flag.IntVar(&c.MaxConnections, "max-connections", c.MaxConnections, "Maximum number of total connections allowed") flag.IntVar(&c.MaxOutgoingConnections, "max-outgoing-connections", c.MaxOutgoingConnections, "Maximum number of outgoing connections allowed") flag.IntVar(&c.MaxDefaultPeerOutgoingConnections, "max-default-peer-outgoing-connections", c.MaxDefaultPeerOutgoingConnections, "The maximum default peer outgoing connections allowed") flag.IntVar(&c.PeerlistSize, "peerlist-size", c.PeerlistSize, "The peer list size") diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 2b6d4004cf..66a08f8d65 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -347,7 +347,6 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Pool.DefaultConnections = c.config.Node.DefaultConnections dc.Pool.MaxDefaultPeerOutgoingConnections = c.config.Node.MaxDefaultPeerOutgoingConnections - dc.Pool.ConnectionsMax = c.config.Node.MaxConnections dc.Pex.DataDirectory = c.config.Node.DataDirectory dc.Pex.Disabled = c.config.Node.DisablePEX @@ -365,7 +364,8 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Daemon.Port = c.config.Node.Port dc.Daemon.Address = c.config.Node.Address dc.Daemon.LocalhostOnly = c.config.Node.LocalhostOnly - dc.Daemon.OutgoingMax = c.config.Node.MaxOutgoingConnections + dc.Daemon.MaxConnections = c.config.Node.MaxConnections + dc.Daemon.MaxOutgoingConnections = c.config.Node.MaxOutgoingConnections dc.Daemon.DataDirectory = c.config.Node.DataDirectory dc.Daemon.LogPings = !c.config.Node.DisablePingPong dc.Daemon.BlockchainPubkey = c.config.Node.blockchainPubkey From a09ec907086b2fd3f2997638eee91c7cd3cb6f55 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 00:35:51 +0800 Subject: [PATCH 335/399] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56854b0551..ac2b72318a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Daemon configured builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. The builds available for previous versions are configured for desktop client use. - `skycoin-cli` builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. - A user agent string is sent in the wire protocol's introduction packet +- `-max-connections` option to control total max connections ### Fixed From c8efca044502eef80faf5a8c2ab3b4315e295169 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Sun, 28 Oct 2018 18:17:45 +0000 Subject: [PATCH 336/399] [cli] refs #1980 - Replace whitespace with tabs four coin hours rate in status golden files --- .../testdata/status-csrf-enabled-no-unconfirmed.golden | 2 +- src/cli/integration/testdata/status-csrf-enabled.golden | 2 +- src/cli/integration/testdata/status-no-unconfirmed.golden | 2 +- src/cli/integration/testdata/status.golden | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden index aaea8a1f5e..4bdcf069bf 100644 --- a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-csrf-enabled.golden b/src/cli/integration/testdata/status-csrf-enabled.golden index c9834fde59..519a5e0e1f 100644 --- a/src/cli/integration/testdata/status-csrf-enabled.golden +++ b/src/cli/integration/testdata/status-csrf-enabled.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-no-unconfirmed.golden b/src/cli/integration/testdata/status-no-unconfirmed.golden index 2f013033db..595d7471ec 100644 --- a/src/cli/integration/testdata/status-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-no-unconfirmed.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status.golden b/src/cli/integration/testdata/status.golden index aa2bb08f22..59db6ebc51 100644 --- a/src/cli/integration/testdata/status.golden +++ b/src/cli/integration/testdata/status.golden @@ -30,6 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false + "coinhours_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" From 6dc6855047faa5106273921a312c51db067e8cfb Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Sun, 28 Oct 2018 20:30:46 -0400 Subject: [PATCH 337/399] Use POST for long queries --- .../static/src/app/services/api.service.ts | 32 +++++++++++++++---- .../static/src/app/services/wallet.service.ts | 14 ++------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gui/static/src/app/services/api.service.ts b/src/gui/static/src/app/services/api.service.ts index 813d0507ab..e6b1e2d97e 100644 --- a/src/gui/static/src/app/services/api.service.ts +++ b/src/gui/static/src/app/services/api.service.ts @@ -7,6 +7,7 @@ import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; import { TranslateService } from '@ngx-translate/core'; import { BigNumber } from 'bignumber.js'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { Address, GetWalletsResponseEntry, GetWalletsResponseWallet, NormalTransaction, @@ -16,23 +17,26 @@ import { @Injectable() export class ApiService { private url = environment.nodeUrl; + private gettingCsrf: BehaviorSubject = new BehaviorSubject(false); constructor( private http: Http, private translate: TranslateService, ) { } - getExplorerAddress(address: Address): Observable { - return this.get('explorer/address', {address: address.address}) + getTransactions(addresses: Address[]): Observable { + const formattedAddresses = addresses.map(a => a.address).join(','); + + return this.post('transactions', {addrs: formattedAddresses, verbose: true}) .map(transactions => transactions.map(transaction => ({ addresses: [], balance: new BigNumber(0), block: transaction.status.block_seq, confirmed: transaction.status.confirmed, - timestamp: transaction.timestamp, - txid: transaction.txid, - inputs: transaction.inputs, - outputs: transaction.outputs, + timestamp: transaction.txn.timestamp, + txid: transaction.txn.txid, + inputs: transaction.txn.inputs, + outputs: transaction.txn.outputs, }))); } @@ -123,7 +127,21 @@ export class ApiService { } getCsrf() { - return this.get('csrf').map(response => response.csrf_token); + return this.gettingCsrf.filter(response => !response).first().flatMap(() => { + this.gettingCsrf.next(true); + + return this.get('csrf') + .map(response => { + setTimeout(() => this.gettingCsrf.next(false)); + + return response.csrf_token; + }) + .catch((error: any) => { + setTimeout(() => this.gettingCsrf.next(false)); + + return error; + }); + }); } post(url, params = {}, options: any = {}, useV2 = false) { diff --git a/src/gui/static/src/app/services/wallet.service.ts b/src/gui/static/src/app/services/wallet.service.ts index 3fec83a874..94901ab3f8 100644 --- a/src/gui/static/src/app/services/wallet.service.ts +++ b/src/gui/static/src/app/services/wallet.service.ts @@ -75,7 +75,7 @@ export class WalletService { return this.addressesAsString() .first() .filter(addresses => !!addresses) - .flatMap(addresses => this.apiService.get('outputs', {addrs: addresses})); + .flatMap(addresses => this.apiService.post('outputs', {addrs: addresses})); } outputsWithWallets(): Observable { @@ -198,17 +198,9 @@ export class WalletService { return this.allAddresses().first().flatMap(addresses => { this.addresses = addresses; - return Observable.forkJoin(addresses.map(address => this.apiService.getExplorerAddress(address))); + return this.apiService.getTransactions(addresses); }).map(transactions => { - return [] - .concat.apply([], transactions) - .reduce((array, item) => { - if (!array.find(trans => trans.txid === item.txid)) { - array.push(item); - } - - return array; - }, []) + return transactions .sort((a, b) => b.timestamp - a.timestamp) .map(transaction => { const outgoing = this.addresses.some(address => { From cb205638f323cfc292f1ef862d7a571c27372f14 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 12:03:09 +0800 Subject: [PATCH 338/399] Logging tweak --- src/daemon/daemon.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 4bb7de9852..2fbeccd754 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -806,7 +806,10 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { // If the connection does not exist, abort message processing c := dm.connections.get(e.Context.Addr) if c == nil { - logger.WithField("addr", e.Context.Addr).Info("onMessageEvent no connection found") + logger.WithFields(logrus.Fields{ + "addr": e.Context.Addr, + "messageType": fmt.Sprintf("%T", e.Message), + }).Info("onMessageEvent no connection found") return } From b5974e69a179f989174cf225a97e13c5be881c20 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 13:13:02 +0800 Subject: [PATCH 339/399] Fix onConnect transition and pool tests --- src/daemon/daemon.go | 29 ++++++------------ src/daemon/gnet/pool.go | 13 -------- src/daemon/gnet/pool_test.go | 59 ++++++++++++++++++++++++------------ 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 2fbeccd754..2298795b97 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -837,26 +837,7 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { } logger.WithFields(fields).Info("onConnectEvent") - exist, err := dm.pool.Pool.IsConnExist(e.Addr) - if err != nil { - logger.Critical().WithFields(fields).WithError(err).Error("IsConnExist failed") - return - } - - if !exist { - logger.WithFields(fields).Warning("While processing an onConnect event, no pool connection was found") - return - } - - if dm.ipCountMaxed(e.Addr) { - logger.WithFields(fields).Info("Max connections for this address reached, disconnecting") - if err := dm.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { - logger.WithError(err).WithFields(fields).Error("Disconnect") - } - return - } - - // Update the connections state machine + // Update the connections state machine first c, err := dm.connections.connected(e.Addr, e.GnetID) if err != nil { logger.Critical().WithError(err).WithFields(fields).Error("connections.Connected failed") @@ -872,6 +853,14 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { logger.Critical().WithFields(fields).Warning("Connection.Outgoing does not match ConnectEvent.Solicited state") } + if dm.ipCountMaxed(e.Addr) { + logger.WithFields(fields).Info("Max connections for this IP address reached, disconnecting") + if err := dm.Disconnect(e.Addr, ErrDisconnectIPLimitReached); err != nil { + logger.WithError(err).WithFields(fields).Error("Disconnect") + } + return + } + logger.WithFields(fields).Debug("Sending introduction message") m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 4db5eb9d87..f9dd7a5b11 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -717,19 +717,6 @@ func decodeData(buf *bytes.Buffer, maxMsgLength int) ([][]byte, error) { return dataArray, nil } -// IsConnExist check if the connection of address does exist -func (pool *ConnectionPool) IsConnExist(addr string) (bool, error) { - var exist bool - if err := pool.strand("IsConnExist", func() error { - exist = pool.isConnExist(addr) - return nil - }); err != nil { - return false, fmt.Errorf("Check connection existence failed: %v ", err) - } - - return exist, nil -} - // isConnExist check if the connection of address does exist func (pool *ConnectionPool) isConnExist(addr string) bool { _, ok := pool.addresses[addr] diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index 15e3736c70..289350c8b5 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -34,6 +34,9 @@ func newTestConfig() Config { cfg := NewConfig() cfg.Port = uint16(port) cfg.Address = address + cfg.MaxOutgoingConnections = 8 + cfg.MaxConnections = 8 + cfg.MaxDefaultPeerOutgoingConnections = 8 return cfg } @@ -119,7 +122,7 @@ func TestNewConnectionAlreadyConnected(t *testing.T) { _, err = p.newConnection(c.Conn, true) require.Error(t, err) - require.True(t, strings.HasPrefix(err.Error(), "Already connected to")) + require.Equal(t, ErrConnectionExists, err) p.Shutdown() <-q @@ -236,20 +239,31 @@ func TestHandleConnection(t *testing.T) { conn, err := net.Dial("tcp", addr) require.NoError(t, err) - c := <-cc + var c *Connection + waitTimeout := time.Second * 3 + select { + case c = <-cc: + case <-time.After(waitTimeout): + t.Fatal("Timed out waiting for connection") + } require.NotNil(t, c) - exist, err := p.IsConnExist(conn.LocalAddr().String()) + var exist bool + err = p.strand("isConnExist", func() error { + exist = p.isConnExist(conn.LocalAddr().String()) + return nil + }) require.NoError(t, err) require.True(t, exist) - delete(p.addresses, conn.LocalAddr().String()) - delete(p.pool, 1) + dc := p.disconnect(conn.LocalAddr().String()) + require.NotNil(t, dc) require.NotNil(t, wasSolicited) require.False(t, *wasSolicited) // Solicited + wasSolicited = nil p.Config.ConnectCallback = func(addr string, id uint64, s bool) { wasSolicited = &s cc <- p.pool[2] @@ -258,28 +272,35 @@ func TestHandleConnection(t *testing.T) { done := make(chan struct{}) go func() { defer close(done) - p.handleConnection(conn, true) // nolint: errcheck + err = p.handleConnection(conn, true) + require.NotEqual(t, ErrConnectionExists, err) + require.NotEqual(t, ErrMaxConnectionsReached, err) + require.NotEqual(t, ErrMaxOutgoingConnectionsReached, err) + require.NotEqual(t, ErrMaxOutgoingDefaultConnectionsReached, err) }() - c = <-cc + c = nil + select { + case c = <-cc: + case <-time.After(waitTimeout): + t.Fatal("Timed out waiting for connection") + } require.NotNil(t, c) require.Equal(t, addr, c.Addr()) - require.NotNil(t, wasSolicited) - require.True(t, *wasSolicited) - - exist, err = p.IsConnExist(conn.RemoteAddr().String()) - require.NoError(t, err) - require.True(t, exist) - - require.Equal(t, len(p.addresses), 1) - require.Equal(t, len(p.pool), 1) - p.Shutdown() - <-done + select { + case <-done: + case <-time.After(waitTimeout): + t.Fatal("Timed out waiting for done") + } - <-q + select { + case <-q: + case <-time.After(waitTimeout): + t.Fatal("Timed out waiting for quit") + } } func TestConnect(t *testing.T) { From 20a89263592421a89bc87e0ab1266f9297b49495 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 13:17:29 +0800 Subject: [PATCH 340/399] Prevent message processing for mismatched gnet ID --- src/daemon/daemon.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 2298795b97..4bce977d1e 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -803,7 +803,7 @@ func (dm *Daemon) handleEvent(e interface{}) { } func (dm *Daemon) onMessageEvent(e messageEvent) { - // If the connection does not exist, abort message processing + // If the connection does not exist or the gnet ID is different, abort message processing c := dm.connections.get(e.Context.Addr) if c == nil { logger.WithFields(logrus.Fields{ @@ -813,6 +813,16 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { return } + if c.gnetID != e.Context.ConnID { + logger.WithFields(logrus.Fields{ + "addr": e.Context.Addr, + "connGnetID": c.gnetID, + "contextGnetID": e.Context.ConnID, + "messageType": fmt.Sprintf("%T", e.Message), + }).Info("onMessageEvent connection gnetID does not match") + return + } + // The first message received must be an IntroductionMessage if !c.HasIntroduced() { _, isIntro := e.Message.(*IntroductionMessage) @@ -824,6 +834,7 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } + return } } e.Message.process(dm) @@ -897,6 +908,7 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { // Remove the pending connection from connections and update the retry times in pex logger.WithField("addr", c.Addr).WithError(c.Error).Debug("onConnectFailure") + // onConnectFailure should only trigger for "pending" connections which have gnet ID 0; // connections in any other state will have a nonzero gnet ID. // if the connection is in a different state, the gnet ID will not match, the connection From d8b5ba31aee6ef1707ccd4afb31216d56bcdd683 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 13:18:14 +0800 Subject: [PATCH 341/399] add note --- src/daemon/daemon.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 4bce977d1e..f364ca03d7 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -804,6 +804,8 @@ func (dm *Daemon) handleEvent(e interface{}) { func (dm *Daemon) onMessageEvent(e messageEvent) { // If the connection does not exist or the gnet ID is different, abort message processing + // This can occur because messageEvents for a given connection may occur + // after that connection has disconnected. c := dm.connections.get(e.Context.Addr) if c == nil { logger.WithFields(logrus.Fields{ From 01c8a4666b30546ad5f0d6d1c8ec4d6433817d4b Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 14:01:14 +0800 Subject: [PATCH 342/399] Add options to filter /api/v1/network/connections --- CHANGELOG.md | 2 +- src/api/README.md | 5 + src/api/client.go | 30 +++- src/api/gateway.go | 2 +- src/api/integration/integration_test.go | 22 ++- src/api/mock_gatewayer_test.go | 46 +++--- src/api/network.go | 56 ++++++- src/api/network_test.go | 202 +++++++++++++++++++----- src/daemon/daemon.go | 12 +- src/daemon/gateway.go | 26 +-- 10 files changed, 318 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac2b72318a..799ebbfb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,7 +85,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` - `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"`. Added `"connected_at"` field. -- `/api/v1/network/connections` now includes incoming connections +- `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction. ### Removed diff --git a/src/api/README.md b/src/api/README.md index df9cbf0a29..e23e54ddf6 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3608,6 +3608,9 @@ API sets: `STATUS`, `READ` ``` URI: /api/v1/network/connections Method: GET +Args: + states: [optional] comma-separated list of connection states ("pending", "connected" or "introduced"). Defaults to "connected,introduced" + direction: [optional] "outgoing" or "incoming". If not provided, both are included. ``` Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. @@ -3616,6 +3619,8 @@ Connection `"state"` value can be `"pending"`, `"connected"` or `"introduced"`. * The `"connected"` state is after connection establishment, but before the introduction handshake has completed. * The `"introduced"` state is after the introduction handshake has completed. +By default, both incoming and outgoing connections in the `"connected"` or `"introduced"` state are returned. + Example: ```sh diff --git a/src/api/client.go b/src/api/client.go index b35478fa2f..7f1f75bef0 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -15,6 +15,7 @@ import ( "time" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/daemon" "github.com/skycoin/skycoin/src/readable" ) @@ -825,10 +826,33 @@ func (c *Client) NetworkConnection(addr string) (*readable.Connection, error) { return &dc, nil } -// NetworkConnections makes a request to GET /api/v1/network/connections -func (c *Client) NetworkConnections() (*Connections, error) { +// NetworkConnectionsFilter filters for network connections +type NetworkConnectionsFilter struct { + States []daemon.ConnectionState // "pending", "connected" and "introduced" + Direction string // "incoming" or "outgoing" +} + +// NetworkConnections makes a request to GET /api/v1/network/connections. +// Connections can be filtered by state and direction. By default, "connected" and "introduced" connections +// of both directions are returned. +func (c *Client) NetworkConnections(filters *NetworkConnectionsFilter) (*Connections, error) { + v := url.Values{} + if filters != nil { + if len(filters.States) != 0 { + states := make([]string, len(filters.States)) + for i, s := range filters.States { + states[i] = string(s) + } + v.Add("states", strings.Join(states, ",")) + } + if filters.Direction != "" { + v.Add("direction", filters.Direction) + } + } + endpoint := "/api/v1/network/connections?" + v.Encode() + var dc Connections - if err := c.Get("/api/v1/network/connections", &dc); err != nil { + if err := c.Get(endpoint, &dc); err != nil { return nil, err } return &dc, nil diff --git a/src/api/gateway.go b/src/api/gateway.go index 18a7d6a7cb..88991c27dd 100644 --- a/src/api/gateway.go +++ b/src/api/gateway.go @@ -44,7 +44,7 @@ type Gatewayer interface { GetBlockchainMetadata() (*visor.BlockchainMetadata, error) GetBlockchainProgress() (*daemon.BlockchainProgress, error) GetConnection(addr string) (*daemon.Connection, error) - GetConnections() ([]daemon.Connection, error) + GetConnections(f func(c daemon.Connection) bool) ([]daemon.Connection, error) GetDefaultConnections() []string GetTrustConnections() []string GetExchgConnection() []string diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index d39022bedc..0037cffd1a 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -1806,7 +1806,7 @@ func TestStableNetworkConnections(t *testing.T) { } c := newClient() - connections, err := c.NetworkConnections() + connections, err := c.NetworkConnections(nil) require.NoError(t, err) require.Empty(t, connections.Connections) @@ -1821,7 +1821,7 @@ func TestLiveNetworkConnections(t *testing.T) { } c := newClient() - connections, err := c.NetworkConnections() + connections, err := c.NetworkConnections(nil) require.NoError(t, err) if liveDisableNetworking(t) { @@ -1876,6 +1876,24 @@ func TestLiveNetworkConnections(t *testing.T) { // This could unfortunately occur if a connection disappeared in between the two calls, // which will require a test re-run. require.True(t, checked, "Was not able to find any connection by address, despite finding connections when querying all") + + connections, err = c.NetworkConnections(&api.NetworkConnectionsFilter{ + States: []daemon.ConnectionState{daemon.ConnectionStatePending}, + }) + require.NoError(t, err) + + for _, cc := range connections.Connections { + require.Equal(t, daemon.ConnectionStatePending, cc.State) + } + + connections, err = c.NetworkConnections(&api.NetworkConnectionsFilter{ + Direction: "incoming", + }) + require.NoError(t, err) + + for _, cc := range connections.Connections { + require.False(t, cc.Outgoing) + } } func TestNetworkDefaultConnections(t *testing.T) { diff --git a/src/api/mock_gatewayer_test.go b/src/api/mock_gatewayer_test.go index 5c20980d7c..f2fef9671f 100644 --- a/src/api/mock_gatewayer_test.go +++ b/src/api/mock_gatewayer_test.go @@ -394,6 +394,29 @@ func (_m *MockGatewayer) GetConnection(addr string) (*daemon.Connection, error) return r0, r1 } +// GetConnections provides a mock function with given fields: f +func (_m *MockGatewayer) GetConnections(f func(daemon.Connection) bool) ([]daemon.Connection, error) { + ret := _m.Called(f) + + var r0 []daemon.Connection + if rf, ok := ret.Get(0).(func(func(daemon.Connection) bool) []daemon.Connection); ok { + r0 = rf(f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]daemon.Connection) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(func(daemon.Connection) bool) error); ok { + r1 = rf(f) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetDefaultConnections provides a mock function with given fields: func (_m *MockGatewayer) GetDefaultConnections() []string { ret := _m.Called() @@ -504,29 +527,6 @@ func (_m *MockGatewayer) GetLastBlocksVerbose(num uint64) ([]coin.SignedBlock, [ return r0, r1, r2 } -// GetConnections provides a mock function with given fields: -func (_m *MockGatewayer) GetConnections() ([]daemon.Connection, error) { - ret := _m.Called() - - var r0 []daemon.Connection - if rf, ok := ret.Get(0).(func() []daemon.Connection); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]daemon.Connection) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetRichlist provides a mock function with given fields: includeDistribution func (_m *MockGatewayer) GetRichlist(includeDistribution bool) (visor.Richlist, error) { ret := _m.Called(includeDistribution) diff --git a/src/api/network.go b/src/api/network.go index fb4aa5c69e..6ae48574ea 100644 --- a/src/api/network.go +++ b/src/api/network.go @@ -3,8 +3,10 @@ package api // APIs for network-related information import ( + "fmt" "net/http" "sort" + "strings" "github.com/skycoin/skycoin/src/daemon" "github.com/skycoin/skycoin/src/readable" @@ -64,6 +66,9 @@ func NewConnections(dconns []daemon.Connection) Connections { // connectionsHandler returns all outgoing connections // URI: /api/v1/network/connections // Method: GET +// Args: +// states: [optional] comma-separated list of connection states ("pending", "connected" or "introduced"). Defaults to "connected,introduced" +// direction: [optional] "outgoing" or "incoming". If not provided, both are included. func connectionsHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { @@ -71,7 +76,56 @@ func connectionsHandler(gateway Gatewayer) http.HandlerFunc { return } - dcnxs, err := gateway.GetConnections() + formStates := r.FormValue("states") + statesMap := make(map[daemon.ConnectionState]struct{}, 3) + if formStates != "" { + states := strings.Split(formStates, ",") + for _, s := range states { + switch daemon.ConnectionState(s) { + case daemon.ConnectionStatePending, + daemon.ConnectionStateConnected, + daemon.ConnectionStateIntroduced: + statesMap[daemon.ConnectionState(s)] = struct{}{} + default: + wh.Error400(w, fmt.Sprintf("Invalid state in states. Valid states are %q, %q or %q", daemon.ConnectionStatePending, daemon.ConnectionStateConnected, daemon.ConnectionStateIntroduced)) + return + } + } + } + + // "connected" and "introduced" are the defaults, if not specified + if len(statesMap) == 0 { + statesMap[daemon.ConnectionStateConnected] = struct{}{} + statesMap[daemon.ConnectionStateIntroduced] = struct{}{} + } + + direction := r.FormValue("direction") + switch direction { + case "incoming", "outgoing", "": + default: + wh.Error400(w, "Invalid direction. Valid directions are \"outgoing\" or \"incoming\"") + return + } + + dcnxs, err := gateway.GetConnections(func(c daemon.Connection) bool { + switch direction { + case "outgoing": + if !c.Outgoing { + return false + } + case "incoming": + if c.Outgoing { + return false + } + } + + if _, ok := statesMap[c.State]; !ok { + return false + } + + return true + }) + if err != nil { wh.Error500(w, err.Error()) return diff --git a/src/api/network_test.go b/src/api/network_test.go index 39d21c9628..20d3ebf684 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/skycoin/skycoin/src/daemon" @@ -135,10 +136,79 @@ func TestConnection(t *testing.T) { } func TestConnections(t *testing.T) { + intrOut := daemon.Connection{ + Addr: "127.0.0.1:6061", + Gnet: daemon.GnetConnectionDetails{ + ID: 1, + LastSent: time.Unix(99999, 0), + LastReceived: time.Unix(1111111, 0), + }, + ConnectionDetails: daemon.ConnectionDetails{ + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + ConnectedAt: time.Unix(222222, 0), + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + }, + } + + intrIn := daemon.Connection{ + Addr: "127.0.0.2:6062", + Gnet: daemon.GnetConnectionDetails{ + ID: 2, + LastSent: time.Unix(99999, 0), + LastReceived: time.Unix(1111111, 0), + }, + ConnectionDetails: daemon.ConnectionDetails{ + Outgoing: false, + State: daemon.ConnectionStateIntroduced, + ConnectedAt: time.Unix(222222, 0), + Mirror: 9877, + ListenPort: 9879, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + }, + } + + readIntrOut := readable.Connection{ + Addr: "127.0.0.1:6061", + GnetID: 1, + LastSent: 99999, + LastReceived: 1111111, + ConnectedAt: 222222, + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + } + + readIntrIn := readable.Connection{ + Addr: "127.0.0.2:6062", + GnetID: 2, + LastSent: 99999, + LastReceived: 1111111, + ConnectedAt: 222222, + Outgoing: false, + State: daemon.ConnectionStateIntroduced, + Mirror: 9877, + ListenPort: 9879, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + } + + conns := []daemon.Connection{intrOut, intrIn} + readConns := []readable.Connection{readIntrOut, readIntrIn} + tt := []struct { name string method string status int + states string + direction string err string gatewayGetSolicitedConnectionsResult []daemon.Connection gatewayGetSolicitedConnectionsError error @@ -150,49 +220,95 @@ func TestConnections(t *testing.T) { status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, + { - name: "200", - method: http.MethodGet, - status: http.StatusOK, - err: "", - gatewayGetSolicitedConnectionsResult: []daemon.Connection{ - { - Addr: "127.0.0.1:6061", - Gnet: daemon.GnetConnectionDetails{ - ID: 1, - LastSent: time.Unix(99999, 0), - LastReceived: time.Unix(1111111, 0), - }, - ConnectionDetails: daemon.ConnectionDetails{ - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - ConnectedAt: time.Unix(222222, 0), - Mirror: 9876, - ListenPort: 9877, - Height: 1234, - UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), - }, - }, + name: "200 defaults", + method: http.MethodGet, + status: http.StatusOK, + err: "", + gatewayGetSolicitedConnectionsResult: conns, + result: Connections{ + Connections: readConns, }, + }, + + { + name: "200 incoming", + method: http.MethodGet, + status: http.StatusOK, + direction: "incoming", + err: "", + gatewayGetSolicitedConnectionsResult: conns, result: Connections{ - Connections: []readable.Connection{ - { - Addr: "127.0.0.1:6061", - GnetID: 1, - LastSent: 99999, - LastReceived: 1111111, - ConnectedAt: 222222, - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - Mirror: 9876, - ListenPort: 9877, - Height: 1234, - UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), - }, - }, + Connections: readConns, + }, + }, + + { + name: "200 outgoing", + method: http.MethodGet, + status: http.StatusOK, + direction: "outgoing", + err: "", + gatewayGetSolicitedConnectionsResult: conns, + result: Connections{ + Connections: readConns, + }, + }, + + { + name: "200 pending,connected", + method: http.MethodGet, + status: http.StatusOK, + states: "pending,connected", + err: "", + gatewayGetSolicitedConnectionsResult: conns, + result: Connections{ + Connections: readConns, + }, + }, + + { + name: "200 pending,connected outgoing", + method: http.MethodGet, + status: http.StatusOK, + states: "pending,connected", + direction: "outgoing", + err: "", + gatewayGetSolicitedConnectionsResult: conns, + result: Connections{ + Connections: readConns, + }, + }, + + { + name: "200 pending,introduced,connected", + method: http.MethodGet, + status: http.StatusOK, + states: "pending,introduced,connected", + err: "", + gatewayGetSolicitedConnectionsResult: conns, + result: Connections{ + Connections: readConns, }, }, + { + name: "400 - bad state", + method: http.MethodGet, + status: http.StatusBadRequest, + states: "pending,foo", + err: "400 Bad Request - Invalid state in states. Valid states are \"pending\", \"connected\" or \"introduced\"", + }, + + { + name: "400 - bad direction", + method: http.MethodGet, + status: http.StatusBadRequest, + direction: "foo", + err: "400 Bad Request - Invalid direction. Valid directions are \"outgoing\" or \"incoming\"", + }, + { name: "500 - GetConnections failed", method: http.MethodGet, @@ -205,7 +321,17 @@ func TestConnections(t *testing.T) { t.Run(tc.name, func(t *testing.T) { endpoint := "/api/v1/network/connections" gateway := &MockGatewayer{} - gateway.On("GetConnections").Return(tc.gatewayGetSolicitedConnectionsResult, tc.gatewayGetSolicitedConnectionsError) + gateway.On("GetConnections", mock.Anything).Return(tc.gatewayGetSolicitedConnectionsResult, tc.gatewayGetSolicitedConnectionsError) + + v := url.Values{} + if tc.states != "" { + v.Add("states", tc.states) + } + if tc.direction != "" { + v.Add("direction", tc.direction) + } + + endpoint += "?" + v.Encode() req, err := http.NewRequest(tc.method, endpoint, nil) require.NoError(t, err) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index f364ca03d7..a1bec0ac96 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -545,12 +545,12 @@ loop: case <-outgoingConnectionsTicker.C: // Fill up our outgoing connections elapser.Register("outgoingConnectionsTicker") - if !dm.Config.DisableOutgoingConnections && - dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections && - dm.connections.PendingLen() < dm.Config.MaxPendingConnections && - dm.connections.Len() < dm.Config.MaxConnections { - dm.connectToRandomPeer() - } + // if !dm.Config.DisableOutgoingConnections && + // dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections && + // dm.connections.PendingLen() < dm.Config.MaxPendingConnections && + // dm.connections.Len() < dm.Config.MaxConnections { + dm.connectToRandomPeer() + // } case <-privateConnectionsTicker.C: // Always try to stay connected to our private peers diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index deaa37488b..0236c16e7c 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -125,16 +125,16 @@ func newConnection(dc *connection, gc *gnet.Connection, pp *pex.Peer) Connection } // GetConnections returns solicited (outgoing) connections -func (gw *Gateway) GetConnections() ([]Connection, error) { +func (gw *Gateway) GetConnections(f func(c Connection) bool) ([]Connection, error) { var conns []Connection var err error gw.strand("GetConnections", func() { - conns, err = gw.getConnections() + conns, err = gw.getConnections(f) }) return conns, err } -func (gw *Gateway) getConnections() ([]Connection, error) { +func (gw *Gateway) getConnections(f func(c Connection) bool) ([]Connection, error) { if gw.d.pool.Pool == nil { return nil, nil } @@ -144,17 +144,18 @@ func (gw *Gateway) getConnections() ([]Connection, error) { conns := make([]Connection, 0) for _, c := range cs { - // Skip pending connections since they're not really connected - if c.State == ConnectionStatePending { - continue - } - cc, err := gw.newConnection(&c) if err != nil { return nil, err } - conns = append(conns, *cc) + ccc := *cc + + if !f(ccc) { + continue + } + + conns = append(conns, ccc) } // Sort connnections by IP address @@ -917,7 +918,12 @@ func (gw *Gateway) GetHealth() (*Health, error) { return } - conns, err := gw.getConnections() + conns, err := gw.getConnections(func(c Connection) bool { + if c.State == ConnectionStatePending { + return false + } + return true + }) if err != nil { return } From ccbf38251ac9e1495b070b89f732e8c9ed84debe Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 29 Oct 2018 14:02:27 +0800 Subject: [PATCH 343/399] Fix lint --- src/daemon/gateway.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 0236c16e7c..5c8cb1a536 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -919,10 +919,7 @@ func (gw *Gateway) GetHealth() (*Health, error) { } conns, err := gw.getConnections(func(c Connection) bool { - if c.State == ConnectionStatePending { - return false - } - return true + return c.State != ConnectionStatePending }) if err != nil { return From 7f6d39e2865d0481ebdace037782e3f2418599e5 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Mon, 29 Oct 2018 18:16:10 +0000 Subject: [PATCH 344/399] [cli] refs #1980 - Missing comma in status golden file --- src/cli/integration/testdata/status.golden | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/integration/testdata/status.golden b/src/cli/integration/testdata/status.golden index 59db6ebc51..32344536f8 100644 --- a/src/cli/integration/testdata/status.golden +++ b/src/cli/integration/testdata/status.golden @@ -29,7 +29,7 @@ "wallet_api_enabled": true, "gui_enabled": false, "unversioned_api_enabled": false, - "json_rpc_enabled": false + "json_rpc_enabled": false, "coinhours_burn_factor": 2 }, "cli_config": { From 2ef7432dea2b641761b43ec1e43b65acbf6ff7cc Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Mon, 29 Oct 2018 18:29:21 +0000 Subject: [PATCH 345/399] [ci] refs #1980 - Prevent timeout of gcc6 installation in Travis Mac OS builds ... for instance https://travis-ci.org/simelo/skycoin/jobs/447476030#L2047-L2050 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7ea8650932..bd8e7a5cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ install: # Install pinned golangci-lint, overriding the latest version install by make install-linters - VERSION=1.10.2 ./ci-scripts/install-golangci-lint.sh - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -qq g++-6 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; echo 'Available versions (gcc)' && brew list --versions gcc ; brew list gcc@6 &>/dev/null || brew install gcc@6 ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; echo 'Available versions (gcc)' && brew list --versions gcc ; brew list gcc@6 &>/dev/null || travis_wait brew install gcc@6 ; fi - make install-deps-libc - nvm install 8.11.0 - nvm use 8.11.0 From b7c79fbd90b77a23ef7461ccf14abbb12a86ec89 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 09:15:17 +0800 Subject: [PATCH 346/399] Reset retry times after intr message fully processed --- src/daemon/daemon.go | 1 + src/daemon/gnet/pool.go | 31 +++++++++++-------------------- src/daemon/messages.go | 6 +++--- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index a1bec0ac96..6b47e91061 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -896,6 +896,7 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { return } + // TODO -- blacklist peer for certain reasons, not just remove switch e.Reason { case ErrDisconnectIntroductionTimeout, ErrDisconnectBlockchainPubkeyNotMatched, diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index f9dd7a5b11..70f99ce212 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -382,6 +382,16 @@ func (pool *ConnectionPool) strand(name string, f func() error) error { return strand.Strand(logger, pool.reqC, name, f, pool.quit, ErrConnectionPoolClosed) } +// ListeningAddress returns address, on which the ConnectionPool +// listening on. It returns nil, and error if the ConnectionPool +// is not listening +func (pool *ConnectionPool) ListeningAddress() (net.Addr, error) { + if pool.listener == nil { + return nil, errors.New("Not listening, call StartListen first") + } + return pool.listener.Addr(), nil +} + func (pool *ConnectionPool) canConnect(a string, solicited bool) error { if pool.isConnExist(a) { return ErrConnectionExists @@ -408,7 +418,6 @@ func (pool *ConnectionPool) canConnect(a string, solicited bool) error { // newConnection creates a new Connection around a net.Conn. Trying to make a connection // to an address that is already connected will failed. -// Returns nil, nil when max default connection limit hit func (pool *ConnectionPool) newConnection(conn net.Conn, solicited bool) (*Connection, error) { a := conn.RemoteAddr().String() @@ -440,16 +449,6 @@ func (pool *ConnectionPool) newConnection(conn net.Conn, solicited bool) (*Conne return nc, nil } -// ListeningAddress returns address, on which the ConnectionPool -// listening on. It returns nil, and error if the ConnectionPool -// is not listening -func (pool *ConnectionPool) ListeningAddress() (net.Addr, error) { - if pool.listener == nil { - return nil, errors.New("Not listening, call StartListen first") - } - return pool.listener.Addr(), nil -} - // Creates a Connection and begins its read and write loop func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) error { defer logger.WithField("addr", conn.RemoteAddr()).Debug("Connection closed") @@ -478,10 +477,6 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro return err } - if c == nil { - return nil - } - if pool.Config.ConnectCallback != nil { pool.Config.ConnectCallback(c.Addr(), c.ID, solicited) } @@ -495,17 +490,13 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro // TODO -- this error is not fully propagated back to a caller of Connect() so the daemon state // can get stuck in pending if err != nil { + logger.WithError(err).WithField("addr", conn.RemoteAddr()).Debug("handleConnection: newConnection failed") if pool.Config.ConnectFailureCallback != nil { pool.Config.ConnectFailureCallback(addr, solicited, err) } return err } - // c may be nil if already connected to that connection or max outgoing connections reached - if c == nil { - return nil - } - msgC := make(chan []byte, 32) errC := make(chan error, 3) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index ade54fb08a..5c35e7940e 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -371,9 +371,7 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa return err } - err = d.recordMessageEvent(intro, mc) - d.ResetRetryTimes(mc.Addr) - return err + return d.recordMessageEvent(intro, mc) } // process an event queued by Handle() @@ -416,6 +414,8 @@ func (intro *IntroductionMessage) process(d daemoner) { return } + d.ResetRetryTimes(a) + if c.Outgoing { // For successful outgoing connections, mark the peer as having an incoming port in the pex peerlist // The peer should already be in the peerlist, since we use the peerlist to choose an outgoing connection to make From c654fb70d3912d57019721b185b59b79df2c830a Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 12:27:19 +0800 Subject: [PATCH 347/399] Improve errors in message parsing --- include/skyerrors.h | 2 +- lib/cgo/libsky_error.go | 20 ++++----- src/daemon/daemon.go | 9 +++- src/daemon/gnet/dispatcher.go | 38 +++++++++++----- src/daemon/gnet/dispatcher_test.go | 64 +++++++++++++-------------- src/daemon/gnet/pool.go | 71 ++++++++++++++++++++++-------- src/daemon/gnet/pool_test.go | 32 ++++++++------ 7 files changed, 146 insertions(+), 90 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 24764198a2..99e67d1277 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -92,7 +92,7 @@ #define SKY_ErrNotExternalIP 0x06000003 #define SKY_ErrPortTooLow 0x06000004 #define SKY_ErrBlacklistedAddress 0x06000005 -#define SKY_ErrDisconnectReadFailed 0x06000006 +// #define SKY_ErrDisconnectReadFailed 0x06000006 #define SKY_ErrDisconnectWriteFailed 0x06000007 #define SKY_ErrDisconnectSetReadDeadlineFailed 0x06000008 #define SKY_ErrDisconnectInvalidMessageLength 0x06000009 diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 8dcc288bad..10fb35e573 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -202,8 +202,8 @@ const ( SKY_ErrPortTooLow // SKY_ErrBlacklistedAddress returned when attempting to add a blacklisted peer SKY_ErrBlacklistedAddress - // SKY_ErrDisconnectReadFailed also includes a remote closed socket - SKY_ErrDisconnectReadFailed + // // SKY_ErrDisconnectReadFailed also includes a remote closed socket + // SKY_ErrDisconnectReadFailed // SKY_ErrDisconnectWriteFailed write faile SKY_ErrDisconnectWriteFailed // SKY_ErrDisconnectSetReadDeadlineFailed set read deadline failed @@ -456,14 +456,14 @@ var ( // daemon // Removed in 34ad39ddb350 // gnet.ErrMaxDefaultConnectionsReached: SKY_ErrMaxDefaultConnectionsReached, - pex.ErrPeerlistFull: SKY_ErrPeerlistFull, - pex.ErrInvalidAddress: SKY_ErrInvalidAddress, - pex.ErrNoLocalhost: SKY_ErrNoLocalhost, - pex.ErrNotExternalIP: SKY_ErrNotExternalIP, - pex.ErrPortTooLow: SKY_ErrPortTooLow, - pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, - gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, - gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, + pex.ErrPeerlistFull: SKY_ErrPeerlistFull, + pex.ErrInvalidAddress: SKY_ErrInvalidAddress, + pex.ErrNoLocalhost: SKY_ErrNoLocalhost, + pex.ErrNotExternalIP: SKY_ErrNotExternalIP, + pex.ErrPortTooLow: SKY_ErrPortTooLow, + pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, + // gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, + // gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 6b47e91061..ded655b844 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -906,6 +906,11 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { dm.pex.RemovePeer(e.Addr) } } + + switch e.Reason.Error() { + case "read failed: EOF": + dm.IncreaseRetryTimes(e.Addr) + } } func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { @@ -921,8 +926,8 @@ func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } - // TODO - On failure to connect, use exponential backoff, not peer list - dm.pex.IncreaseRetryTimes(c.Addr) + // TODO - On failure to connect, use exponential backoff, need to use pex.canTry peers + dm.IncreaseRetryTimes(c.Addr) } // onGnetDisconnect triggered when a gnet.Connection terminates diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index ce6ff8d24a..34cff25921 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -37,13 +37,19 @@ func sendMessage(conn net.Conn, msg Message, timeout time.Duration) error { func convertToMessage(id uint64, msg []byte, debugPrint bool) (Message, error) { msgID := [4]byte{} if len(msg) < len(msgID) { - return nil, errors.New("Not enough data to read msg id") + logger.WithError(ErrDisconnectTruncatedMessageID).WithField("connID", id).Warning() + return nil, ErrDisconnectTruncatedMessageID } + copy(msgID[:], msg[:len(msgID)]) msg = msg[len(msgID):] - t, succ := MessageIDReverseMap[msgID] - if !succ { - return nil, fmt.Errorf("Unknown message %s received", string(msgID[:])) + t, ok := MessageIDReverseMap[msgID] + if !ok { + logger.WithError(ErrDisconnectUnknownMessage).WithFields(logrus.Fields{ + "msgID": fmt.Sprintf("%q", msgID), + "connID": id, + }).Warning() + return nil, ErrDisconnectUnknownMessage } if debugPrint { @@ -53,19 +59,26 @@ func convertToMessage(id uint64, msg []byte, debugPrint bool) (Message, error) { }).Debugf("convertToMessage") } - var m Message v := reflect.New(t) used, err := deserializeMessage(msg, v) if err != nil { - return nil, err + logger.Critical().WithError(err).WithFields(logrus.Fields{ + "connID": id, + "messageType": fmt.Sprintf("%v", t), + }).Warning("deserializeMessage failed") + return nil, ErrDisconnectMalformedMessage } if used != len(msg) { - return nil, errors.New("Data buffer was not completely decoded") + logger.WithError(ErrDisconnectMessageDecodeUnderflow).WithFields(logrus.Fields{ + "connID": id, + "messageType": fmt.Sprintf("%v", t), + }).Warning() + return nil, ErrDisconnectMessageDecodeUnderflow } - m, succ = (v.Interface()).(Message) - if !succ { + m, ok := (v.Interface()).(Message) + if !ok { // This occurs only when the user registers an interface that does not // match the Message interface. They should have known about this // earlier via a call to VerifyMessages @@ -113,8 +126,7 @@ func EncodeMessage(msg Message) []byte { } // Sends []byte over a net.Conn -var sendByteMessage = func(conn net.Conn, msg []byte, - timeout time.Duration) error { +var sendByteMessage = func(conn net.Conn, msg []byte, timeout time.Duration) error { deadline := time.Time{} if timeout != 0 { deadline = time.Now().Add(timeout) @@ -123,7 +135,9 @@ var sendByteMessage = func(conn net.Conn, msg []byte, return err } if _, err := conn.Write(msg); err != nil { - return err + return &WriteError{ + Err: err, + } } return nil } diff --git a/src/daemon/gnet/dispatcher_test.go b/src/daemon/gnet/dispatcher_test.go index 1ca0a69c3f..f3306d445c 100644 --- a/src/daemon/gnet/dispatcher_test.go +++ b/src/daemon/gnet/dispatcher_test.go @@ -8,9 +8,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - - "github.com/skycoin/skycoin/src/cipher/encoder" + "github.com/stretchr/testify/require" ) var ( @@ -31,24 +29,24 @@ func TestConvertToMessage(t *testing.T) { b = append(b, BytePrefix[:]...) b = append(b, byte(7)) m, err := convertToMessage(c.ID, b, testing.Verbose()) - assert.Nil(t, err) - assert.NotNil(t, m) + require.NoError(t, err) + require.NotNil(t, m) if m == nil { t.Fatalf("ConvertToMessage failed") } bm := m.(*ByteMessage) - assert.Equal(t, bm.X, byte(7)) + require.Equal(t, bm.X, byte(7)) } -func TestConvertToMessageNoMessageId(t *testing.T) { +func TestConvertToMessageNoMessageID(t *testing.T) { EraseMessages() resetHandler() c := &Connection{} b := []byte{} m, err := convertToMessage(c.ID, b, testing.Verbose()) - assert.Nil(t, m) - assert.NotNil(t, err) - assert.Equal(t, err.Error(), "Not enough data to read msg id") + require.Nil(t, m) + require.Error(t, err) + require.Equal(t, ErrDisconnectTruncatedMessageID, err) } func TestConvertToMessageUnknownMessage(t *testing.T) { @@ -57,9 +55,9 @@ func TestConvertToMessageUnknownMessage(t *testing.T) { c := &Connection{} b := MessagePrefix{'C', 'C', 'C', 'C'} m, err := convertToMessage(c.ID, b[:], testing.Verbose()) - assert.NotNil(t, err) - assert.Equal(t, err.Error(), "Unknown message CCCC received") - assert.Nil(t, m) + require.Error(t, err) + require.Equal(t, ErrDisconnectUnknownMessage, err) + require.Nil(t, m) } func TestConvertToMessageBadDeserialize(t *testing.T) { @@ -72,15 +70,15 @@ func TestConvertToMessageBadDeserialize(t *testing.T) { // Test with too many bytes b := append(DummyPrefix[:], []byte{0, 1, 1, 1}...) m, err := convertToMessage(c.ID, b, testing.Verbose()) - assert.NotNil(t, err) - assert.Nil(t, m) + require.Error(t, err) + require.Nil(t, m) // Test with not enough bytes b = append([]byte{}, BytePrefix[:]...) m, err = convertToMessage(c.ID, b, testing.Verbose()) - assert.NotNil(t, err) - assert.Equal(t, encoder.ErrBufferUnderflow, err) - assert.Nil(t, m) + require.Error(t, err) + require.Equal(t, ErrDisconnectMalformedMessage, err) + require.Nil(t, m) } func TestConvertToMessageNotMessage(t *testing.T) { @@ -89,7 +87,7 @@ func TestConvertToMessageNotMessage(t *testing.T) { RegisterMessage(NothingPrefix, Nothing{}) // don't verify messages c := &Connection{} - assert.Panics(t, func() { + require.Panics(t, func() { _, _ = convertToMessage(c.ID, NothingPrefix[:], testing.Verbose()) // nolint: errcheck }) } @@ -101,8 +99,8 @@ func TestDeserializeMessageTrapsPanic(t *testing.T) { m := PointerMessage{Ptr: &p} b := []byte{4, 4, 4, 4, 4, 4, 4, 4} _, err := deserializeMessage(b, reflect.ValueOf(m)) - assert.NotNil(t, err) - assert.Equal(t, err.Error(), "DeserializeRawToValue value must be a ptr, is struct") + require.Error(t, err) + require.Equal(t, err.Error(), "DeserializeRawToValue value must be a ptr, is struct") } func TestEncodeMessage(t *testing.T) { @@ -112,13 +110,13 @@ func TestEncodeMessage(t *testing.T) { VerifyMessages() m := NewByteMessage(7) b := EncodeMessage(m) - assert.True(t, bytes.Equal(b, []byte{5, 0, 0, 0, 'B', 'Y', 'T', 'E', 7})) + require.True(t, bytes.Equal(b, []byte{5, 0, 0, 0, 'B', 'Y', 'T', 'E', 7})) } func TestEncodeMessageUnknownMessage(t *testing.T) { resetHandler() EraseMessages() - assert.Panics(t, func() { EncodeMessage(&DummyMessage{}) }) + require.Panics(t, func() { EncodeMessage(&DummyMessage{}) }) } func TestSendByteMessage(t *testing.T) { @@ -126,9 +124,9 @@ func TestSendByteMessage(t *testing.T) { b := []byte{1} c := NewCaptureConn() err := sendByteMessage(c, b, 0) - assert.Nil(t, err) - assert.True(t, bytes.Equal(c.(*CaptureConn).Wrote, b)) - assert.True(t, c.(*CaptureConn).WriteDeadlineSet) + require.NoError(t, err) + require.True(t, bytes.Equal(c.(*CaptureConn).Wrote, b)) + require.True(t, c.(*CaptureConn).WriteDeadlineSet) } func TestSendByteMessageWithTimeout(t *testing.T) { @@ -136,23 +134,23 @@ func TestSendByteMessageWithTimeout(t *testing.T) { b := []byte{1} c := NewCaptureConn() err := sendByteMessage(c, b, time.Minute) - assert.Nil(t, err) - assert.True(t, bytes.Equal(c.(*CaptureConn).Wrote, b)) - assert.True(t, c.(*CaptureConn).WriteDeadlineSet) + require.NoError(t, err) + require.True(t, bytes.Equal(c.(*CaptureConn).Wrote, b)) + require.True(t, c.(*CaptureConn).WriteDeadlineSet) } func TestSendByteMessageWriteFailed(t *testing.T) { resetHandler() c := &FailingWriteConn{} err := sendByteMessage(c, nil, 0) - assert.NotNil(t, err) + require.Error(t, err) } func TestSendByteMessageWriteDeadlineFailed(t *testing.T) { resetHandler() c := &FailingWriteDeadlineConn{} err := sendByteMessage(c, nil, 0) - assert.NotNil(t, err) + require.Error(t, err) } func TestSendMessage(t *testing.T) { @@ -163,11 +161,11 @@ func TestSendMessage(t *testing.T) { m := NewByteMessage(7) sendByteMessage = func(conn net.Conn, msg []byte, tm time.Duration) error { expect := []byte{5, 0, 0, 0, 'B', 'Y', 'T', 'E', 7} - assert.True(t, bytes.Equal(msg, expect)) + require.True(t, bytes.Equal(msg, expect)) return nil } err := sendMessage(nil, m, 0) - assert.Nil(t, err) + require.NoError(t, err) } /* Helpers */ diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 70f99ce212..fa8fbfc388 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -34,10 +34,6 @@ const ( ) var ( - // ErrDisconnectReadFailed also includes a remote closed socket - ErrDisconnectReadFailed DisconnectReason = errors.New("Read failed") - // ErrDisconnectWriteFailed write faile - ErrDisconnectWriteFailed DisconnectReason = errors.New("Write failed") // ErrDisconnectSetReadDeadlineFailed set read deadline failed ErrDisconnectSetReadDeadlineFailed = errors.New("SetReadDeadline failed") // ErrDisconnectInvalidMessageLength invalid message length @@ -46,8 +42,13 @@ var ( ErrDisconnectMalformedMessage DisconnectReason = errors.New("Malformed message body") // ErrDisconnectUnknownMessage unknow message ErrDisconnectUnknownMessage DisconnectReason = errors.New("Unknown message ID") - // ErrDisconnectUnexpectedError unexpected error + // ErrDisconnectUnexpectedError unexpected error ErrDisconnectUnexpectedError DisconnectReason = errors.New("Unexpected error encountered") + // ErrDisconnectMessageDecodeUnderflow message data did not fully decode to a message object + ErrDisconnectMessageDecodeUnderflow DisconnectReason = errors.New("Message data did not fully decode to a message object") + // ErrDisconnectTruncatedMessageID message data was too short to contain a message ID + ErrDisconnectTruncatedMessageID DisconnectReason = errors.New("Message data was too short to contain a message ID") + // ErrConnectionPoolClosed error message indicates the connection pool is closed ErrConnectionPoolClosed = errors.New("Connection pool is closed") // ErrWriteQueueFull write queue is full @@ -73,6 +74,24 @@ var ( logger = logging.MustGetLogger("gnet") ) +// ReadError connection read error +type ReadError struct { + Err error +} + +func (e ReadError) Error() string { + return fmt.Sprintf("read failed: %v", e.Err) +} + +// WriteError connection read error +type WriteError struct { + Err error +} + +func (e WriteError) Error() string { + return fmt.Sprintf("write failed: %v", e.Err) +} + // Config gnet config type Config struct { // Address to listen on. Leave empty for arbitrary assignment @@ -498,7 +517,12 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro } msgC := make(chan []byte, 32) - errC := make(chan error, 3) + + type methodErr struct { + method string + err error + } + errC := make(chan methodErr, 3) var wg sync.WaitGroup wg.Add(1) @@ -506,7 +530,10 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro go func() { defer wg.Done() if err := pool.readLoop(c, msgC, qc); err != nil { - errC <- err + errC <- methodErr{ + method: "readLoop", + err: err, + } } }() @@ -514,7 +541,10 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro go func() { defer wg.Done() if err := pool.sendLoop(c, pool.Config.WriteTimeout, qc); err != nil { - errC <- err + errC <- methodErr{ + method: "sendLoop", + err: err, + } } }() @@ -527,7 +557,10 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro for msg := range msgC { elapser.Register(fmt.Sprintf("pool.receiveMessage address=%s", addr)) if err := pool.receiveMessage(c, msg); err != nil { - errC <- err + errC <- methodErr{ + method: "receiveMessage", + err: err, + } return } elapser.CheckForDone() @@ -539,9 +572,13 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro if err := conn.Close(); err != nil { logger.WithError(err).WithField("addr", addr).Error("conn.Close") } - case err = <-errC: - logger.WithError(err).WithField("addr", addr).Error("handleConnection readLoop/sendLoop/receiveMessage failure") - if err := pool.Disconnect(c.Addr(), err); err != nil { + case mErr := <-errC: + err = mErr.err + logger.WithError(mErr.err).WithFields(logrus.Fields{ + "addr": addr, + "method": mErr.method, + }).Error("handleConnection failure") + if err := pool.Disconnect(c.Addr(), mErr.err); err != nil { logger.WithError(err).WithField("addr", addr).Error("Disconnect") } } @@ -655,17 +692,15 @@ func (pool *ConnectionPool) sendLoop(conn *Connection, timeout time.Duration, qc func readData(reader io.Reader, buf []byte) ([]byte, error) { c, err := reader.Read(buf) if err != nil { - return nil, fmt.Errorf("read data failed: %v", err) + return nil, &ReadError{ + Err: err, + } } if c == 0 { return nil, nil } data := make([]byte, c) - n := copy(data, buf) - if n != c { - // I don't believe this can ever occur - return nil, errors.New("Failed to copy all the bytes") - } + copy(data, buf) return data, nil } diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index 289350c8b5..054ec257d2 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -528,12 +528,12 @@ func TestConnectionReadLoopReadError(t *testing.T) { wait() - readDataErr := errors.New("read data failed: failed") + readDataErr := "read failed: failed" disconnectCalled := make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { - require.Equal(t, readDataErr, reason) - close(disconnectCalled) + defer close(disconnectCalled) + require.Equal(t, readDataErr, reason.Error()) } // 1: @@ -542,7 +542,7 @@ func TestConnectionReadLoopReadError(t *testing.T) { reconn := NewReadErrorConn() go func() { err := p.handleConnection(reconn, false) - require.Equal(t, readDataErr, err) + require.Equal(t, readDataErr, err.Error()) }() <-cc @@ -552,7 +552,11 @@ func TestConnectionReadLoopReadError(t *testing.T) { require.True(t, reconn.(*ReadErrorConn).GetReadDeadlineSet() != time.Time{}) reconn.Close() - <-disconnectCalled + select { + case <-disconnectCalled: + case <-time.After(time.Second * 10): + t.Fatal("wait for disconnectCalled timed out") + } p.Shutdown() <-q @@ -580,8 +584,8 @@ func TestConnectionReadLoopSetReadDeadlineFailed(t *testing.T) { // Use a mock net.Conn that fails on SetReadDeadline disconnectCalled := make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { + defer close(disconnectCalled) require.Equal(t, ErrDisconnectSetReadDeadlineFailed, reason) - close(disconnectCalled) } rdfconn := &ReadDeadlineFailedConn{} @@ -624,8 +628,8 @@ func TestConnectionReadLoopInvalidMessageLength(t *testing.T) { // Look for these bytes copied into the eventChannel disconnectCalled := make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { + defer close(disconnectCalled) require.Equal(t, ErrDisconnectInvalidMessageLength, reason) - close(disconnectCalled) } raconn := newReadAlwaysConn() @@ -665,18 +669,18 @@ func TestConnectionReadLoopTerminates(t *testing.T) { wait() - readDataErr := errors.New("read data failed: done") + readDataErr := "read failed: done" // 4: Use a mock net.Conn that successfully returns 0 bytes when read rnconn := newReadNothingConn() disconnectCalled := make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { - require.Equal(t, readDataErr, reason) - close(disconnectCalled) + defer close(disconnectCalled) + require.Equal(t, readDataErr, reason.Error()) } go func() { err := p.handleConnection(rnconn, false) - require.Equal(t, readDataErr, err) + require.Equal(t, readDataErr, err.Error()) }() <-cc @@ -745,8 +749,8 @@ func TestProcessConnectionBuffers(t *testing.T) { disconnectCalled := make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { + defer close(disconnectCalled) require.Equal(t, reason, ErrErrorMessageHandler) - close(disconnectCalled) } _, err = conn.Write([]byte{4, 0, 0, 0, 'E', 'R', 'R', 0x00}) @@ -776,11 +780,11 @@ func TestProcessConnectionBuffers(t *testing.T) { disconnectCalled = make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, reason DisconnectReason) { + defer close(disconnectCalled) require.Equal(t, c.Addr(), addr) require.Equal(t, reason, ErrDisconnectInvalidMessageLength) require.Nil(t, p.pool[1]) require.Nil(t, p.pool[2]) - close(disconnectCalled) } // Sending a length of < messagePrefixLength should cause a disconnect @@ -806,8 +810,8 @@ func TestProcessConnectionBuffers(t *testing.T) { p.Config.MaxMessageLength = 4 disconnectCalled = make(chan struct{}) p.Config.DisconnectCallback = func(addr string, id uint64, r DisconnectReason) { + defer close(disconnectCalled) require.Equal(t, ErrDisconnectInvalidMessageLength, r) - close(disconnectCalled) } _, err = conn.Write([]byte{5, 0, 0, 0, 'B', 'Y', 'T', 'E'}) From 9e5d8c20f7da789feb7110a8b13e47ad5635f8bb Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 13:07:53 +0800 Subject: [PATCH 348/399] Fix lint --- lib/cgo/libsky_error.go | 2 +- src/daemon/daemon.go | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 10fb35e573..8a648cc38e 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -205,7 +205,7 @@ const ( // // SKY_ErrDisconnectReadFailed also includes a remote closed socket // SKY_ErrDisconnectReadFailed // SKY_ErrDisconnectWriteFailed write faile - SKY_ErrDisconnectWriteFailed + // SKY_ErrDisconnectWriteFailed // SKY_ErrDisconnectSetReadDeadlineFailed set read deadline failed SKY_ErrDisconnectSetReadDeadlineFailed // SKY_ErrDisconnectInvalidMessageLength invalid message length diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index ded655b844..25121a72da 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -545,12 +545,7 @@ loop: case <-outgoingConnectionsTicker.C: // Fill up our outgoing connections elapser.Register("outgoingConnectionsTicker") - // if !dm.Config.DisableOutgoingConnections && - // dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections && - // dm.connections.PendingLen() < dm.Config.MaxPendingConnections && - // dm.connections.Len() < dm.Config.MaxConnections { dm.connectToRandomPeer() - // } case <-privateConnectionsTicker.C: // Always try to stay connected to our private peers @@ -664,9 +659,10 @@ func (dm *Daemon) connectToPeer(p pex.Peer) error { a, _, err := iputil.SplitAddr(p.Addr) if err != nil { - logger.WithField("addr", p.Addr).WithError(err).Warning("PEX gave us an invalid peer") + logger.Critical().WithField("addr", p.Addr).WithError(err).Warning("PEX gave us an invalid peer") return errors.New("Invalid peer") } + if dm.Config.LocalhostOnly && !iputil.IsLocalhost(a) { return errors.New("Not localhost") } @@ -734,6 +730,15 @@ func (dm *Daemon) connectToRandomPeer() { if dm.Config.DisableOutgoingConnections { return } + if dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections { + return + } + if dm.connections.PendingLen() < dm.Config.MaxPendingConnections { + return + } + if dm.connections.Len() < dm.Config.MaxConnections { + return + } // Make a connection to a random (public) peer peers := dm.pex.RandomPublicUntrusted(dm.Config.MaxOutgoingConnections) @@ -743,6 +748,7 @@ func (dm *Daemon) connectToRandomPeer() { } } + // TODO -- don't reset if not needed? if len(peers) == 0 { dm.pex.ResetAllRetryTimes() } @@ -925,9 +931,6 @@ func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { if err := dm.connections.remove(c.Addr, 0); err != nil { logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } - - // TODO - On failure to connect, use exponential backoff, need to use pex.canTry peers - dm.IncreaseRetryTimes(c.Addr) } // onGnetDisconnect triggered when a gnet.Connection terminates From d9722e6a10cd80f1f3f4faa1d32e0098b8df1cfd Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 19:04:01 +0800 Subject: [PATCH 349/399] Add is_default_peer to connection objects --- CHANGELOG.md | 7 ++-- src/api/README.md | 19 ++++++++--- src/api/client.go | 12 +++---- src/api/network_test.go | 76 +++++++++++++++++++++++------------------ src/readable/network.go | 46 +++++++++++++------------ 5 files changed, 93 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 799ebbfb16..c9408baef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,8 +84,11 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `run.sh` is now `run-client.sh` and a new `run-daemon.sh` script is added for running in server daemon mode - `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` -- `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"`. Added `"connected_at"` field. -- `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction. +- `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"` +- `/api/v1/network/connection*` field `"is_default_peer"` added to connection object to indicate if the peer is in the hardcoded list of default peers +- `/api/v1/network/connection*` field `"connected_at"` added to connection object +- `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction + ### Removed diff --git a/src/api/README.md b/src/api/README.md index e23e54ddf6..21f38c2f72 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3597,7 +3597,8 @@ Result: "mirror": 719118746, "height": 181, "listen_port": 6000, - "user_agent": "skycoin:0.25.0" + "user_agent": "skycoin:0.25.0", + "is_default_peer": true } ``` @@ -3643,7 +3644,8 @@ Result: "mirror": 1338939619, "listen_port": 20002, "height": 180, - "user_agent": "skycoin:0.25.0" + "user_agent": "skycoin:0.25.0", + "is_default_peer": true }, { "id": 109548, @@ -3656,7 +3658,8 @@ Result: "mirror": 0, "listen_port": 6000, "height": 0, - "user_agent": "" + "user_agent": "", + "is_default_peer": false }, { "id": 99115, @@ -3669,7 +3672,8 @@ Result: "mirror": 1931713869, "listen_port": 6000, "height": 180, - "user_agent": "" + "user_agent": "", + "is_default_peer": false } ] } @@ -3685,6 +3689,8 @@ URI: /api/v1/network/defaultConnections Method: GET ``` +Returns addresses in the default hardcoded list of peers. + Example: ```sh @@ -3714,6 +3720,9 @@ URI: /api/v1/network/connections/trust Method: GET ``` +Returns addresses marked as trusted in the peerlist. +This is typically equal to the list of addresses in the default hardcoded list of peers. + Example: ```sh @@ -3743,6 +3752,8 @@ URI: /api/v1/network/connections/exchange Method: GET ``` +Returns addresses from the peerlist that are known to have an open port. + Example: ```sh diff --git a/src/api/client.go b/src/api/client.go index 7f1f75bef0..abb44d840f 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -858,8 +858,8 @@ func (c *Client) NetworkConnections(filters *NetworkConnectionsFilter) (*Connect return &dc, nil } -// NetworkDefaultConnections makes a request to GET /api/v1/network/defaultConnections -func (c *Client) NetworkDefaultConnections() ([]string, error) { +// NetworkDefaultPeers makes a request to GET /api/v1/network/defaultConnections +func (c *Client) NetworkDefaultPeers() ([]string, error) { var dc []string if err := c.Get("/api/v1/network/defaultConnections", &dc); err != nil { return nil, err @@ -867,8 +867,8 @@ func (c *Client) NetworkDefaultConnections() ([]string, error) { return dc, nil } -// NetworkTrustedConnections makes a request to GET /api/v1/network/connections/trust -func (c *Client) NetworkTrustedConnections() ([]string, error) { +// NetworkTrustedPeers makes a request to GET /api/v1/network/connections/trust +func (c *Client) NetworkTrustedPeers() ([]string, error) { var dc []string if err := c.Get("/api/v1/network/connections/trust", &dc); err != nil { return nil, err @@ -876,8 +876,8 @@ func (c *Client) NetworkTrustedConnections() ([]string, error) { return dc, nil } -// NetworkExchangeableConnections makes a request to GET /api/v1/network/connections/exchange -func (c *Client) NetworkExchangeableConnections() ([]string, error) { +// NetworkExchangedPeers makes a request to GET /api/v1/network/connections/exchange +func (c *Client) NetworkExchangedPeers() ([]string, error) { var dc []string if err := c.Get("/api/v1/network/connections/exchange", &dc); err != nil { return nil, err diff --git a/src/api/network_test.go b/src/api/network_test.go index 20d3ebf684..d1a0c5b816 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/useragent" ) @@ -66,19 +67,23 @@ func TestConnection(t *testing.T) { Height: 1234, UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, + Pex: pex.Peer{ + Trusted: false, + }, }, result: &readable.Connection{ - Addr: "127.0.0.1:6061", - GnetID: 1, - LastSent: 99999, - LastReceived: 1111111, - ConnectedAt: 222222, - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - Mirror: 6789, - ListenPort: 9877, - Height: 1234, - UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + Addr: "127.0.0.1:6061", + GnetID: 1, + LastSent: 99999, + LastReceived: 1111111, + ConnectedAt: 222222, + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + Mirror: 6789, + ListenPort: 9877, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + IsDefaultPeer: false, }, }, @@ -152,6 +157,9 @@ func TestConnections(t *testing.T) { Height: 1234, UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), }, + Pex: pex.Peer{ + Trusted: true, + }, } intrIn := daemon.Connection{ @@ -173,31 +181,33 @@ func TestConnections(t *testing.T) { } readIntrOut := readable.Connection{ - Addr: "127.0.0.1:6061", - GnetID: 1, - LastSent: 99999, - LastReceived: 1111111, - ConnectedAt: 222222, - Outgoing: true, - State: daemon.ConnectionStateIntroduced, - Mirror: 9876, - ListenPort: 9877, - Height: 1234, - UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + Addr: "127.0.0.1:6061", + GnetID: 1, + LastSent: 99999, + LastReceived: 1111111, + ConnectedAt: 222222, + Outgoing: true, + State: daemon.ConnectionStateIntroduced, + Mirror: 9876, + ListenPort: 9877, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + IsDefaultPeer: true, } readIntrIn := readable.Connection{ - Addr: "127.0.0.2:6062", - GnetID: 2, - LastSent: 99999, - LastReceived: 1111111, - ConnectedAt: 222222, - Outgoing: false, - State: daemon.ConnectionStateIntroduced, - Mirror: 9877, - ListenPort: 9879, - Height: 1234, - UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + Addr: "127.0.0.2:6062", + GnetID: 2, + LastSent: 99999, + LastReceived: 1111111, + ConnectedAt: 222222, + Outgoing: false, + State: daemon.ConnectionStateIntroduced, + Mirror: 9877, + ListenPort: 9879, + Height: 1234, + UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), + IsDefaultPeer: false, } conns := []daemon.Connection{intrOut, intrIn} diff --git a/src/readable/network.go b/src/readable/network.go index 968cd325c5..2c4efd8abf 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -7,17 +7,18 @@ import ( // Connection a connection's state within the daemon type Connection struct { - GnetID uint64 `json:"id"` - Addr string `json:"address"` - LastSent int64 `json:"last_sent"` - LastReceived int64 `json:"last_received"` - ConnectedAt int64 `json:"connected_at"` - Outgoing bool `json:"outgoing"` - State daemon.ConnectionState `json:"state"` - Mirror uint32 `json:"mirror"` - ListenPort uint16 `json:"listen_port"` - Height uint64 `json:"height"` - UserAgent useragent.Data `json:"user_agent"` + GnetID uint64 `json:"id"` + Addr string `json:"address"` + LastSent int64 `json:"last_sent"` + LastReceived int64 `json:"last_received"` + ConnectedAt int64 `json:"connected_at"` + Outgoing bool `json:"outgoing"` + State daemon.ConnectionState `json:"state"` + Mirror uint32 `json:"mirror"` + ListenPort uint16 `json:"listen_port"` + Height uint64 `json:"height"` + UserAgent useragent.Data `json:"user_agent"` + IsDefaultPeer bool `json:"is_default_peer"` } // NewConnection copies daemon.Connection to a struct with json tags @@ -37,16 +38,17 @@ func NewConnection(c *daemon.Connection) Connection { } return Connection{ - GnetID: c.Gnet.ID, - Addr: c.Addr, - LastSent: lastSent, - LastReceived: lastReceived, - ConnectedAt: connectedAt, - Outgoing: c.Outgoing, - State: c.State, - Mirror: c.Mirror, - ListenPort: c.ListenPort, - Height: c.Height, - UserAgent: c.UserAgent, + GnetID: c.Gnet.ID, + Addr: c.Addr, + LastSent: lastSent, + LastReceived: lastReceived, + ConnectedAt: connectedAt, + Outgoing: c.Outgoing, + State: c.State, + Mirror: c.Mirror, + ListenPort: c.ListenPort, + Height: c.Height, + UserAgent: c.UserAgent, + IsDefaultPeer: c.Pex.Trusted, } } From 99bd6fd8ed63db92a7b4ce465af3d728b48dc687 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 19:05:30 +0800 Subject: [PATCH 350/399] Rename to is_trusted_peer --- CHANGELOG.md | 2 +- src/api/README.md | 8 ++++---- src/api/network_test.go | 6 +++--- src/readable/network.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9408baef1..392435de00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,7 +85,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/balance`, `/api/v1/transactions`, `/api/v1/outputs` and `/api/v1/blocks` accept the `POST` method so that large request bodies can be sent to the server, which would not fit in a `GET` query string - `/api/v1/explorer/address` is deprecated in favor of `/api/v1/transactions?verbose=1` - `/api/v1/network/connection*` connection object's field `"introduced"` replaced with field `"state"` which may have the values `"pending"`, `"connected"` or `"introduced"` -- `/api/v1/network/connection*` field `"is_default_peer"` added to connection object to indicate if the peer is in the hardcoded list of default peers +- `/api/v1/network/connection*` field `"is_trusted_peer"` added to connection object to indicate if the peer is in the hardcoded list of default peers - `/api/v1/network/connection*` field `"connected_at"` added to connection object - `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction diff --git a/src/api/README.md b/src/api/README.md index 21f38c2f72..a7473eb18d 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -3598,7 +3598,7 @@ Result: "height": 181, "listen_port": 6000, "user_agent": "skycoin:0.25.0", - "is_default_peer": true + "is_trusted_peer": true } ``` @@ -3645,7 +3645,7 @@ Result: "listen_port": 20002, "height": 180, "user_agent": "skycoin:0.25.0", - "is_default_peer": true + "is_trusted_peer": true }, { "id": 109548, @@ -3659,7 +3659,7 @@ Result: "listen_port": 6000, "height": 0, "user_agent": "", - "is_default_peer": false + "is_trusted_peer": false }, { "id": 99115, @@ -3673,7 +3673,7 @@ Result: "listen_port": 6000, "height": 180, "user_agent": "", - "is_default_peer": false + "is_trusted_peer": false } ] } diff --git a/src/api/network_test.go b/src/api/network_test.go index d1a0c5b816..c422f2be86 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -83,7 +83,7 @@ func TestConnection(t *testing.T) { ListenPort: 9877, Height: 1234, UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), - IsDefaultPeer: false, + IsTrustedPeer: false, }, }, @@ -192,7 +192,7 @@ func TestConnections(t *testing.T) { ListenPort: 9877, Height: 1234, UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), - IsDefaultPeer: true, + IsTrustedPeer: true, } readIntrIn := readable.Connection{ @@ -207,7 +207,7 @@ func TestConnections(t *testing.T) { ListenPort: 9879, Height: 1234, UserAgent: useragent.MustParse("skycoin:0.25.1(foo)"), - IsDefaultPeer: false, + IsTrustedPeer: false, } conns := []daemon.Connection{intrOut, intrIn} diff --git a/src/readable/network.go b/src/readable/network.go index 2c4efd8abf..9101dd8614 100644 --- a/src/readable/network.go +++ b/src/readable/network.go @@ -18,7 +18,7 @@ type Connection struct { ListenPort uint16 `json:"listen_port"` Height uint64 `json:"height"` UserAgent useragent.Data `json:"user_agent"` - IsDefaultPeer bool `json:"is_default_peer"` + IsTrustedPeer bool `json:"is_trusted_peer"` } // NewConnection copies daemon.Connection to a struct with json tags @@ -49,6 +49,6 @@ func NewConnection(c *daemon.Connection) Connection { ListenPort: c.ListenPort, Height: c.Height, UserAgent: c.UserAgent, - IsDefaultPeer: c.Pex.Trusted, + IsTrustedPeer: c.Pex.Trusted, } } From a4018db298e19459b9703aac7e96fd7a4c6b4d54 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 19:53:50 +0800 Subject: [PATCH 351/399] Fix integration tests --- src/api/integration/integration_test.go | 14 +++++++------- ...ections.golden => network-default-peers.golden} | 0 ...tions.golden => network-exchanged-peers.golden} | 0 ...ections.golden => network-trusted-peers.golden} | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename src/api/integration/testdata/{network-default-connections.golden => network-default-peers.golden} (100%) rename src/api/integration/testdata/{network-exchangeable-connections.golden => network-exchanged-peers.golden} (100%) rename src/api/integration/testdata/{network-trusted-connections.golden => network-trusted-peers.golden} (100%) diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 0037cffd1a..1e48461cbb 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -1902,13 +1902,13 @@ func TestNetworkDefaultConnections(t *testing.T) { } c := newClient() - connections, err := c.NetworkDefaultConnections() + connections, err := c.NetworkDefaultPeers() require.NoError(t, err) require.NotEmpty(t, connections) sort.Strings(connections) var expected []string - checkGoldenFile(t, "network-default-connections.golden", TestData{connections, &expected}) + checkGoldenFile(t, "network-default-peers.golden", TestData{connections, &expected}) } func TestNetworkTrustedConnections(t *testing.T) { @@ -1917,13 +1917,13 @@ func TestNetworkTrustedConnections(t *testing.T) { } c := newClient() - connections, err := c.NetworkTrustedConnections() + connections, err := c.NetworkTrustedPeers() require.NoError(t, err) require.NotEmpty(t, connections) sort.Strings(connections) var expected []string - checkGoldenFile(t, "network-trusted-connections.golden", TestData{connections, &expected}) + checkGoldenFile(t, "network-trusted-peers.golden", TestData{connections, &expected}) } func TestStableNetworkExchangeableConnections(t *testing.T) { @@ -1932,11 +1932,11 @@ func TestStableNetworkExchangeableConnections(t *testing.T) { } c := newClient() - connections, err := c.NetworkExchangeableConnections() + connections, err := c.NetworkExchangedPeers() require.NoError(t, err) var expected []string - checkGoldenFile(t, "network-exchangeable-connections.golden", TestData{connections, &expected}) + checkGoldenFile(t, "network-exchanged-peers.golden", TestData{connections, &expected}) } func TestLiveNetworkExchangeableConnections(t *testing.T) { @@ -1945,7 +1945,7 @@ func TestLiveNetworkExchangeableConnections(t *testing.T) { } c := newClient() - _, err := c.NetworkExchangeableConnections() + _, err := c.NetworkExchangedPeers() require.NoError(t, err) } diff --git a/src/api/integration/testdata/network-default-connections.golden b/src/api/integration/testdata/network-default-peers.golden similarity index 100% rename from src/api/integration/testdata/network-default-connections.golden rename to src/api/integration/testdata/network-default-peers.golden diff --git a/src/api/integration/testdata/network-exchangeable-connections.golden b/src/api/integration/testdata/network-exchanged-peers.golden similarity index 100% rename from src/api/integration/testdata/network-exchangeable-connections.golden rename to src/api/integration/testdata/network-exchanged-peers.golden diff --git a/src/api/integration/testdata/network-trusted-connections.golden b/src/api/integration/testdata/network-trusted-peers.golden similarity index 100% rename from src/api/integration/testdata/network-trusted-connections.golden rename to src/api/integration/testdata/network-trusted-peers.golden From be0f7b8db57be8e8973df9ddc02fa4af6da7ac13 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 23:32:26 +0800 Subject: [PATCH 352/399] Fix max connections check --- src/daemon/daemon.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 9b2730e12e..9f2a6fcbc9 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -712,13 +712,13 @@ func (dm *Daemon) connectToRandomPeer() { if dm.Config.DisableOutgoingConnections { return } - if dm.connections.OutgoingLen() < dm.Config.MaxOutgoingConnections { + if dm.connections.OutgoingLen() > dm.Config.MaxOutgoingConnections { return } - if dm.connections.PendingLen() < dm.Config.MaxPendingConnections { + if dm.connections.PendingLen() > dm.Config.MaxPendingConnections { return } - if dm.connections.Len() < dm.Config.MaxConnections { + if dm.connections.Len() > dm.Config.MaxConnections { return } From d6d1b2df1a897095e83fcd5e4265c11a56095f0d Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 23:33:10 +0800 Subject: [PATCH 353/399] remove invalid TODO note --- src/daemon/messages.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 4c5e8ee875..295aefe42c 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -534,11 +534,10 @@ func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process should send number to be requested, with request func (gbm *GetBlocksMessage) process(d daemoner) { - // TODO -- we need the sig to be sent with the block, but only the master - // can sign blocks. Thus the sig needs to be stored with the block. if d.DaemonConfig().DisableNetworking { return } + // Record this as this peer's highest block d.RecordPeerHeight(gbm.c.Addr, gbm.c.ConnID, gbm.LastBlock) // Fetch and return signed blocks since LastBlock From 2fa5635a3f49929a716e11a66b5b810147d69230 Mon Sep 17 00:00:00 2001 From: gz-c Date: Tue, 30 Oct 2018 23:54:19 +0800 Subject: [PATCH 354/399] Record user agent in pex --- include/skyerrors.h | 2 -- lib/cgo/libsky_error.go | 3 --- src/daemon/daemon.go | 6 ++++-- src/daemon/errors.go | 12 +++++++----- src/daemon/gnet/pool.go | 2 -- src/daemon/messages.go | 40 +++++++++++++++++++++++----------------- src/daemon/pex/pex.go | 6 ++++++ 7 files changed, 40 insertions(+), 31 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 24d97683e1..bead645c84 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -98,7 +98,6 @@ #define SKY_ErrDisconnectInvalidMessageLength 0x06000009 #define SKY_ErrDisconnectMalformedMessage 0x0600000A #define SKY_ErrDisconnectUnknownMessage 0x0600000B -#define SKY_ErrDisconnectUnexpectedError 0x0600000C #define SKY_ErrConnectionPoolClosed 0x0600000D #define SKY_ErrWriteQueueFull 0x0600000E #define SKY_ErrNoReachableConnections 0x0600000F @@ -111,7 +110,6 @@ #define SKY_ErrDisconnectIdle 0x06000017 #define SKY_ErrDisconnectNoIntroduction 0x06000018 #define SKY_ErrDisconnectIPLimitReached 0x06000019 -#define SKY_ErrDisconnectUnexpectedError 0x0600001A #define SKY_ErrDisconnectMaxDefaultConnectionReached 0x0600001B #define SKY_ErrDisconnectMaxOutgoingConnectionsReached 0x0600001C #define SKY_ConnectionError 0x0600001D diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 77ef46d8b5..6c5baed785 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -238,8 +238,6 @@ const ( SKY_ErrDisconnectNoIntroduction // SKY_ErrDisconnectIPLimitReached ip limit reached SKY_ErrDisconnectIPLimitReached - // SKY_ErrDisconnectUnexpectedError this is returned when a seemingly impossible error is encountered - SKY_ErrDisconnectUnexpectedError // SKY_ErrDisconnectMaxDefaultConnectionReached Maximum number of default connections was reached SKY_ErrDisconnectMaxDefaultConnectionReached // nolint megacheck // SKY_ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed @@ -464,7 +462,6 @@ var ( gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, - gnet.ErrDisconnectUnexpectedError: SKY_ErrDisconnectUnexpectedError, gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 9f2a6fcbc9..7fccb7a439 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -816,17 +816,19 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { // The first message received must be an IntroductionMessage if !c.HasIntroduced() { _, isIntro := e.Message.(*IntroductionMessage) - if !isIntro { + _, isDisc := e.Message.(*DisconnectMessage) + if !isIntro && !isDisc { logger.WithFields(logrus.Fields{ "addr": e.Context.Addr, "messageType": fmt.Sprintf("%T", e.Message), - }).Info("needsIntro but message is not IntroductionMessage") + }).Info("needsIntro but first message is not INTR or DISC") if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } return } } + e.Message.process(dm) } diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 6aecb9390b..6e5d5b84fa 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -57,11 +57,13 @@ var ( ErrDisconnectReceivedDisconnect: 14, ErrDisconnectInvalidUserAgent: 15, - gnet.ErrDisconnectSetReadDeadlineFailed: 1003, - gnet.ErrDisconnectInvalidMessageLength: 1004, - gnet.ErrDisconnectMalformedMessage: 1005, - gnet.ErrDisconnectUnknownMessage: 1006, - gnet.ErrDisconnectShutdown: 1007, + gnet.ErrDisconnectSetReadDeadlineFailed: 1001, + gnet.ErrDisconnectInvalidMessageLength: 1002, + gnet.ErrDisconnectMalformedMessage: 1003, + gnet.ErrDisconnectUnknownMessage: 1004, + gnet.ErrDisconnectShutdown: 1005, + gnet.ErrDisconnectMessageDecodeUnderflow: 1006, + gnet.ErrDisconnectTruncatedMessageID: 1007, } disconnectCodeReasons map[uint16]gnet.DisconnectReason diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index 2fe19e0b72..ea97f46d8d 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -44,8 +44,6 @@ var ( ErrDisconnectUnknownMessage DisconnectReason = errors.New("Unknown message ID") // ErrDisconnectShutdown shutting down the client ErrDisconnectShutdown DisconnectReason = errors.New("Shutdown") - // ErrDisconnectUnexpectedError unexpected error - ErrDisconnectUnexpectedError DisconnectReason = errors.New("Unexpected error encountered") // ErrDisconnectMessageDecodeUnderflow message data did not fully decode to a message object ErrDisconnectMessageDecodeUnderflow DisconnectReason = errors.New("Message data did not fully decode to a message object") // ErrDisconnectTruncatedMessageID message data was too short to contain a message ID diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 295aefe42c..284953a3b4 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -279,23 +279,26 @@ func (intro *IntroductionMessage) Handle(mc *gnet.MessageContext, daemon interfa // process an event queued by Handle() func (intro *IntroductionMessage) process(d daemoner) { addr := intro.c.Addr - logger.WithFields(logrus.Fields{ + + fields := logrus.Fields{ "addr": addr, - "listenPort": intro.ListenPort, "gnetID": intro.c.ConnID, - }).Debug("IntroductionMessage.process") + "listenPort": intro.ListenPort, + } + + logger.WithFields(fields).Debug("IntroductionMessage.process") userAgent, err := intro.verify(d) if err != nil { if err := d.Disconnect(addr, err); err != nil { - logger.WithField("addr", addr).WithError(err).Warning("Disconnect") + logger.WithError(err).WithFields(fields).Warning("Disconnect") } return } c, err := d.connectionIntroduced(addr, intro.c.ConnID, intro, userAgent) if err != nil { - logger.WithError(err).WithField("addr", addr).Warning("connectionIntroduced failed") + logger.WithError(err).WithFields(fields).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason switch err { // It is hypothetically possible that a message would get processed after @@ -304,7 +307,7 @@ func (intro *IntroductionMessage) process(d daemoner) { // Do not perform a disconnect, since this would operate on the new connection. // This should be prevented by an earlier check in daemon.onMessageEvent() case ErrConnectionGnetIDMismatch, ErrConnectionStateNotConnected, ErrConnectionAlreadyIntroduced: - logger.Critical().WithError(err).Warning("IntroductionMessage.process connection state out of order") + logger.Critical().WithError(err).WithFields(fields).Warning("IntroductionMessage.process connection state out of order") return case ErrConnectionNotExist: return @@ -315,7 +318,7 @@ func (intro *IntroductionMessage) process(d daemoner) { } if err := d.Disconnect(addr, reason); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") + logger.WithError(err).WithFields(fields).Warning("Disconnect") } return @@ -323,27 +326,30 @@ func (intro *IntroductionMessage) process(d daemoner) { d.ResetRetryTimes(addr) + listenAddr := c.ListenAddr() + if c.Outgoing { // For successful outgoing connections, mark the peer as having an incoming port in the pex peerlist // The peer should already be in the peerlist, since we use the peerlist to choose an outgoing connection to make - if err := d.SetHasIncomingPort(c.ListenAddr()); err != nil { - logger.WithField("addr", addr).WithError(err).Error("SetHasIncomingPort failed") + if err := d.SetHasIncomingPort(listenAddr); err != nil { + logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("SetHasIncomingPort failed") } } else { // For successful incoming connections, add the peer to the peer list, with their self-reported listen port - if err := d.AddPeer(c.ListenAddr()); err != nil { - logger.WithError(err).WithFields(logrus.Fields{ - "addr": addr, - "listenAddr": c.ListenAddr(), - }).Error("AddPeer failed") + if err := d.AddPeer(listenAddr); err != nil { + logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("AddPeer failed") } } + if err := d.RecordUserAgent(listenAddr, c.UserAgent); err != nil { + logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("RecordUserAgent failed") + } + // Request blocks immediately after they're confirmed if err := d.RequestBlocksFromAddr(addr); err != nil { - logger.WithField("addr", addr).WithError(err).Warning("RequestBlocksFromAddr") + logger.WithError(err).WithFields(fields).Warning("RequestBlocksFromAddr") } else { - logger.WithField("addr", addr).Debug("Requested blocks") + logger.WithFields(fields).Debug("Requested blocks") } // Announce unconfirmed txns @@ -501,7 +507,7 @@ func (dm *DisconnectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process disconnect message by reflexively disconnecting func (dm *DisconnectMessage) process(d daemoner) { - logger.Critical().WithFields(logrus.Fields{ + logger.WithFields(logrus.Fields{ "addr": dm.c.Addr, "code": dm.ReasonCode, "reason": DisconnectCodeToReason(dm.ReasonCode), diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index 8d040c7d26..4ce2ee0d16 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -536,6 +536,12 @@ func (px *Pex) SetUserAgent(addr string, userAgent useragent.Data) error { px.Lock() defer px.Unlock() + if !userAgent.Empty() { + if _, err := userAgent.Build(); err != nil { + return err + } + } + cleanAddr, err := validateAddress(addr, px.Config.AllowLocalhost) if err != nil { logger.WithError(err).WithField("addr", addr).Error("Invalid address") From 26a32721e724978848799fdbb083fa6584382b01 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 00:09:42 +0800 Subject: [PATCH 355/399] Fix readme run.sh comment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f502043c74..ec93f0a426 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ For example, a burn factor of 2 means 1/2 of hours must be burned. A burn factor The coin hour burn factor can be configured with a `COINHOUR_BURN_FACTOR` envvar. It cannot be configured through the command line. ```sh -COINHOUR_BURN_FACTOR=999 ./run.sh +COINHOUR_BURN_FACTOR=999 ./run-client.sh ``` ## URI Specification From ddc01ef7264d33d3678b538e45a3df1bc563cb81 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 11:25:49 +0800 Subject: [PATCH 356/399] Add disconnect API --- CHANGELOG.md | 1 + src/api/README.md | 28 +++ src/api/address_test.go | 4 +- src/api/client.go | 9 + src/api/csrf_test.go | 3 +- src/api/gateway.go | 1 + src/api/http.go | 5 + src/api/http_test.go | 3 + src/api/mock_gatewayer_test.go | 37 ++- src/api/network.go | 39 ++++ src/api/network_test.go | 105 +++++++++ src/api/transaction_test.go | 6 +- src/api/wallet_test.go | 17 +- src/daemon/connections.go | 17 ++ src/daemon/errors.go | 13 +- src/daemon/gateway.go | 16 ++ src/skycoin/config.go | 4 +- src/visor/blockdb/mock_unspent_pooler_test.go | 219 ------------------ 18 files changed, 263 insertions(+), 264 deletions(-) delete mode 100644 src/visor/blockdb/mock_unspent_pooler_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ee15ac8e..5fe56dbe13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `skycoin-cli` builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. - A user agent string is sent in the wire protocol's introduction packet - `-max-connections` option to control total max connections +- `/api/v1/network/disconnect` to disconnect a peer ### Fixed diff --git a/src/api/README.md b/src/api/README.md index c81cd193b3..1352f8cc03 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -73,6 +73,7 @@ and the `/api/v1` prefix will be required for previously unversioned endpoints. - [Get a list of all default connections](#get-a-list-of-all-default-connections) - [Get a list of all trusted connections](#get-a-list-of-all-trusted-connections) - [Get a list of all connections discovered through peer exchange](#get-a-list-of-all-connections-discovered-through-peer-exchange) + - [Disconnect a peer](#disconnect-a-peer) - [Migrating from the unversioned API](#migrating-from-the-unversioned-api) - [Migrating from the JSONRPC API](#migrating-from-the-jsonrpc-api) - [Migrating from /api/v1/spend](#migrating-from-apiv1spend) @@ -3792,6 +3793,33 @@ Result: ] ``` +### Disconnect a peer + +API sets: `NET_CTRL` + +``` +URI: /api/v1/network/connection/disconnect +Method: POST +Args: + id: ID of the connection + +Returns 404 if the connection is not found. +``` + +Disconnects a peer by ID. + +Example: + +```sh +curl -X POST 'http://127.0.0.1:6420/api/v1/network/connection/disconnect?id=999' +``` + +Result: + +```json +{} +``` + ## Migrating from the unversioned API The unversioned API are the API endpoints without an `/api` prefix. diff --git a/src/api/address_test.go b/src/api/address_test.go index 2e2284e4e8..7950088399 100644 --- a/src/api/address_test.go +++ b/src/api/address_test.go @@ -1,10 +1,10 @@ package api import ( - "bytes" "encoding/json" "net/http" "net/http/httptest" + "strings" "testing" "github.com/stretchr/testify/require" @@ -101,7 +101,7 @@ func TestVerifyAddress(t *testing.T) { endpoint := "/api/v2/address/verify" gateway := &MockGatewayer{} - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(tc.httpBody)) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(tc.httpBody)) require.NoError(t, err) contentType := tc.contentType diff --git a/src/api/client.go b/src/api/client.go index abb44d840f..c972c0776c 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -1216,3 +1216,12 @@ func (c *Client) RecoverWallet(id, seed, password string) (*WalletResponse, erro return nil, err } + +// Disconnect disconnect a connections by ID +func (c *Client) Disconnect(id uint64) error { + v := url.Values{} + v.Add("id", fmt.Sprint(id)) + + var obj struct{} + return c.PostForm("/api/v1/network/connection/disconnect", strings.NewReader(v.Encode()), &obj) +} diff --git a/src/api/csrf_test.go b/src/api/csrf_test.go index 6789190430..d02cd744af 100644 --- a/src/api/csrf_test.go +++ b/src/api/csrf_test.go @@ -1,7 +1,6 @@ package api import ( - "bytes" "encoding/json" "fmt" "net/http" @@ -109,7 +108,7 @@ func TestCSRF(t *testing.T) { v.Add("id", "fooid") v.Add("label", "foolabel") - req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(http.MethodPost, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) diff --git a/src/api/gateway.go b/src/api/gateway.go index 88991c27dd..8c5f0f72f8 100644 --- a/src/api/gateway.go +++ b/src/api/gateway.go @@ -45,6 +45,7 @@ type Gatewayer interface { GetBlockchainProgress() (*daemon.BlockchainProgress, error) GetConnection(addr string) (*daemon.Connection, error) GetConnections(f func(c daemon.Connection) bool) ([]daemon.Connection, error) + Disconnect(id uint64) error GetDefaultConnections() []string GetTrustConnections() []string GetExchgConnection() []string diff --git a/src/api/http.go b/src/api/http.go index 1575d03f09..6ef5ea21b5 100644 --- a/src/api/http.go +++ b/src/api/http.go @@ -58,6 +58,8 @@ const ( EndpointsDeprecatedWalletSpend = "DEPRECATED_WALLET_SPEND" // EndpointsPrometheus endpoints for Go application metrics EndpointsPrometheus = "PROMETHEUS" + // EndpointsNetCtrl endpoints for managing network connections + EndpointsNetCtrl = "NET_CTRL" ) // Server exposes an HTTP API @@ -472,6 +474,9 @@ func newServerMux(c muxConfig, gateway Gatewayer, csrfStore *CSRFStore, rpc *web webHandlerV1("/network/connections/trust", forAPISet(trustConnectionsHandler(gateway), []string{EndpointsRead, EndpointsStatus})) webHandlerV1("/network/connections/exchange", forAPISet(exchgConnectionsHandler(gateway), []string{EndpointsRead, EndpointsStatus})) + // Network admin endpoints + webHandlerV1("/network/connection/disconnect", forAPISet(disconnectHandler(gateway), []string{EndpointsNetCtrl})) + // Transaction related endpoints webHandlerV1("/pendingTxs", forAPISet(pendingTxnsHandler(gateway), []string{EndpointsRead})) webHandlerV1("/transaction", forAPISet(transactionHandler(gateway), []string{EndpointsRead})) diff --git a/src/api/http_test.go b/src/api/http_test.go index 357b4cc41b..2179913a56 100644 --- a/src/api/http_test.go +++ b/src/api/http_test.go @@ -21,6 +21,8 @@ var allAPISetsEnabled = map[string]struct{}{ EndpointsWallet: struct{}{}, EndpointsInsecureWalletSeed: struct{}{}, EndpointsDeprecatedWalletSpend: struct{}{}, + EndpointsPrometheus: struct{}{}, + EndpointsNetCtrl: struct{}{}, } func defaultMuxConfig() muxConfig { @@ -47,6 +49,7 @@ var endpoints = []string{ "/last_blocks", "/version", "/network/connection", + "/network/connection/disconnect", "/network/connections", "/network/connections/exchange", "/network/connections/trust", diff --git a/src/api/mock_gatewayer_test.go b/src/api/mock_gatewayer_test.go index 43581998e6..6208d587cf 100644 --- a/src/api/mock_gatewayer_test.go +++ b/src/api/mock_gatewayer_test.go @@ -93,6 +93,20 @@ func (_m *MockGatewayer) DecryptWallet(wltID string, password []byte) (*wallet.W return r0, r1 } +// Disconnect provides a mock function with given fields: id +func (_m *MockGatewayer) Disconnect(id uint64) error { + ret := _m.Called(id) + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // EncryptWallet provides a mock function with given fields: wltID, password func (_m *MockGatewayer) EncryptWallet(wltID string, password []byte) (*wallet.Wallet, error) { ret := _m.Called(wltID, password) @@ -472,29 +486,6 @@ func (_m *MockGatewayer) GetHealth() (*daemon.Health, error) { return r0, r1 } -// GetIncomingConnections provides a mock function with given fields: -func (_m *MockGatewayer) GetIncomingConnections() ([]daemon.Connection, error) { - ret := _m.Called() - - var r0 []daemon.Connection - if rf, ok := ret.Get(0).(func() []daemon.Connection); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]daemon.Connection) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetLastBlocks provides a mock function with given fields: num func (_m *MockGatewayer) GetLastBlocks(num uint64) ([]coin.SignedBlock, error) { ret := _m.Called(num) diff --git a/src/api/network.go b/src/api/network.go index 1d35c0d60b..3912c3c7f1 100644 --- a/src/api/network.go +++ b/src/api/network.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "sort" + "strconv" "strings" "github.com/skycoin/skycoin/src/daemon" @@ -187,3 +188,41 @@ func exchgConnectionsHandler(gateway Gatewayer) http.HandlerFunc { wh.SendJSONOr500(logger, w, conns) } } + +// disconnectHandler disconnects a connection by ID or address +// URI: /api/v1/network/connection/disconnect +// Method: POST +// Args: +// id: ID of the connection +func disconnectHandler(gateway Gatewayer) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + wh.Error405(w) + return + } + + formID := r.FormValue("id") + if formID == "" { + wh.Error400(w, "id is required") + return + } + + id, err := strconv.ParseUint(formID, 10, 64) + if err != nil || id == 0 { // gnet IDs are non-zero + wh.Error400(w, "invalid id") + return + } + + if err := gateway.Disconnect(uint64(id)); err != nil { + switch err { + case daemon.ErrConnectionNotExist: + wh.Error404(w, "") + default: + wh.Error500(w, err.Error()) + } + return + } + + wh.SendJSONOr500(logger, w, struct{}{}) + } +} diff --git a/src/api/network_test.go b/src/api/network_test.go index 4e71817363..ac2b95dfac 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -525,3 +525,108 @@ func TestGetExchgConnection(t *testing.T) { }) } } + +func TestDisconnect(t *testing.T) { + tt := []struct { + name string + method string + status int + err string + disconnectErr error + result []string + id string + gnetID uint64 + }{ + { + name: "405", + method: http.MethodGet, + status: http.StatusMethodNotAllowed, + err: "405 Method Not Allowed", + }, + + { + name: "400 missing ID", + method: http.MethodPost, + status: http.StatusBadRequest, + err: "400 Bad Request - id is required", + }, + + { + name: "400 invalid ID 0", + method: http.MethodPost, + status: http.StatusBadRequest, + err: "400 Bad Request - invalid id", + id: "0", + }, + + { + name: "400 invalid ID negative", + method: http.MethodPost, + status: http.StatusBadRequest, + err: "400 Bad Request - invalid id", + id: "-100", + }, + + { + name: "404 Disconnect connection not found", + method: http.MethodPost, + status: http.StatusNotFound, + err: "404 Not Found", + disconnectErr: daemon.ErrConnectionNotExist, + id: "100", + gnetID: 100, + }, + + { + name: "500 Disconnect error", + method: http.MethodPost, + status: http.StatusInternalServerError, + err: "500 Internal Server Error - foo", + disconnectErr: errors.New("foo"), + id: "100", + gnetID: 100, + }, + + { + name: "200", + method: http.MethodPost, + status: http.StatusOK, + id: "100", + gnetID: 100, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + gateway := &MockGatewayer{} + gateway.On("Disconnect", tc.gnetID).Return(tc.disconnectErr) + + endpoint := "/api/v1/network/connection/disconnect" + v := url.Values{} + if tc.id != "" { + v.Add("id", tc.id) + } + + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) + require.NoError(t, err) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + + rr := httptest.NewRecorder() + handler := newServerMux(defaultMuxConfig(), gateway, &CSRFStore{}, nil) + handler.ServeHTTP(rr, req) + + status := rr.Code + require.Equal(t, tc.status, status, "got `%v` want `%v`", status, tc.status) + + if status != http.StatusOK { + require.Equal(t, tc.err, strings.TrimSpace(rr.Body.String()), "got `%v`| %d, want `%v`", + strings.TrimSpace(rr.Body.String()), status, tc.err) + } else { + var obj struct{} + err = json.Unmarshal(rr.Body.Bytes(), &obj) + require.NoError(t, err) + } + }) + } + +} diff --git a/src/api/transaction_test.go b/src/api/transaction_test.go index d5f4c8237e..dc137d510c 100644 --- a/src/api/transaction_test.go +++ b/src/api/transaction_test.go @@ -740,7 +740,7 @@ func TestInjectTransaction(t *testing.T) { gateway := &MockGatewayer{} gateway.On("InjectBroadcastTransaction", tc.injectTransactionArg).Return(tc.injectTransactionError) - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(tc.httpBody)) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(tc.httpBody)) require.NoError(t, err) csrfStore := &CSRFStore{ @@ -824,7 +824,7 @@ func TestResendUnconfirmedTxns(t *testing.T) { gateway := &MockGatewayer{} gateway.On("ResendUnconfirmedTxns").Return(tc.resendUnconfirmedTxnsResponse, tc.resendUnconfirmedTxnsErr) - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(tc.httpBody)) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(tc.httpBody)) require.NoError(t, err) csrfStore := &CSRFStore{ @@ -1478,7 +1478,7 @@ func TestVerifyTransaction(t *testing.T) { gateway.On("VerifyTxnVerbose", &tc.gatewayVerifyTxnVerboseArg).Return(tc.gatewayVerifyTxnVerboseResult.Uxouts, tc.gatewayVerifyTxnVerboseResult.IsTxnConfirmed, tc.gatewayVerifyTxnVerboseResult.Err) - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(tc.httpBody)) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(tc.httpBody)) require.NoError(t, err) req.Header.Set("Content-Type", tc.contentType) diff --git a/src/api/wallet_test.go b/src/api/wallet_test.go index 5fd2773b30..284c36afda 100644 --- a/src/api/wallet_test.go +++ b/src/api/wallet_test.go @@ -1,7 +1,6 @@ package api import ( - "bytes" "errors" "io" "math" @@ -630,7 +629,7 @@ func TestWalletSpendHandler(t *testing.T) { } } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -898,7 +897,7 @@ func TestWalletBalanceHandler(t *testing.T) { if len(v) > 0 { endpoint += "?" + v.Encode() } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -1043,7 +1042,7 @@ func TestUpdateWalletLabelHandler(t *testing.T) { } } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -1564,7 +1563,7 @@ func TestWalletCreateHandler(t *testing.T) { } } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) req.Header.Add("Content-Type", ContentTypeForm) require.NoError(t, err) @@ -1686,7 +1685,7 @@ func TestWalletNewSeed(t *testing.T) { endpoint += "?" + v.Encode() } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -1840,7 +1839,7 @@ func TestGetWalletSeed(t *testing.T) { v.Add("password", tc.password) } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -2054,7 +2053,7 @@ func TestWalletNewAddressesHandler(t *testing.T) { } } - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(v.Encode())) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(v.Encode())) require.NoError(t, err) req.Header.Add("Content-Type", ContentTypeForm) @@ -3035,7 +3034,7 @@ func TestWalletRecover(t *testing.T) { } endpoint := "/api/v2/wallet/recover" - req, err := http.NewRequest(tc.method, endpoint, bytes.NewBufferString(tc.httpBody)) + req, err := http.NewRequest(tc.method, endpoint, strings.NewReader(tc.httpBody)) require.NoError(t, err) contentType := tc.contentType diff --git a/src/daemon/connections.go b/src/daemon/connections.go index fb929f0a82..7b4be43991 100644 --- a/src/daemon/connections.go +++ b/src/daemon/connections.go @@ -302,6 +302,23 @@ func (c *Connections) get(addr string) *connection { return c.conns[addr] } +func (c *Connections) getByGnetID(gnetID uint64) *connection { + c.Lock() + defer c.Unlock() + + if gnetID == 0 { + return nil + } + + for _, c := range c.conns { + if c.gnetID == gnetID { + return c + } + } + + return nil +} + // modify modifies a connection. // It is unsafe to modify the Mirror value with this method func (c *Connections) modify(addr string, gnetID uint64, f func(c *ConnectionDetails)) error { diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 6e5d5b84fa..651931d7c4 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -35,6 +35,8 @@ var ( ErrDisconnectReceivedDisconnect gnet.DisconnectReason = errors.New("Received DisconnectMessage") // ErrDisconnectInvalidUserAgent is returned if the peer provides an invalid user agent ErrDisconnectInvalidUserAgent gnet.DisconnectReason = errors.New("Invalid user agent") + // ErrDisconnectRequestedByOperator the operator of the node requested a disconnect + ErrDisconnectRequestedByOperator gnet.DisconnectReason = errors.New("Disconnect requested by the node operator") // ErrDisconnectUnknownReason used when mapping an unknown reason code to an error. Is not sent over the network. ErrDisconnectUnknownReason gnet.DisconnectReason = errors.New("Unknown DisconnectReason") @@ -51,11 +53,12 @@ var ( ErrDisconnectNoIntroduction: 7, ErrDisconnectIPLimitReached: 8, ErrDisconnectUnexpectedError: 9, - ErrDisconnectMaxOutgoingConnectionsReached: 11, - ErrDisconnectBlockchainPubkeyNotMatched: 12, - ErrDisconnectInvalidExtraData: 13, - ErrDisconnectReceivedDisconnect: 14, - ErrDisconnectInvalidUserAgent: 15, + ErrDisconnectMaxOutgoingConnectionsReached: 10, + ErrDisconnectBlockchainPubkeyNotMatched: 11, + ErrDisconnectInvalidExtraData: 12, + ErrDisconnectReceivedDisconnect: 13, + ErrDisconnectInvalidUserAgent: 14, + ErrDisconnectRequestedByOperator: 15, gnet.ErrDisconnectSetReadDeadlineFailed: 1001, gnet.ErrDisconnectInvalidMessageLength: 1002, diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 194e797168..2ba640bd12 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -214,6 +214,22 @@ func (gw *Gateway) newConnection(c *connection) (*Connection, error) { return &cc, nil } +// Disconnect disconnects a connection by gnet ID +func (gw *Gateway) Disconnect(gnetID uint64) error { + var err error + gw.strand("Disconnect", func() { + var c *connection + c = gw.d.connections.getByGnetID(gnetID) + if c == nil { + err = ErrConnectionNotExist + return + } + + err = gw.d.Disconnect(c.Addr, ErrDisconnectRequestedByOperator) + }) + return err +} + // GetTrustConnections returns all trusted connections func (gw *Gateway) GetTrustConnections() []string { var conn []string diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 0a57a73902..0e3d3514b4 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -238,7 +238,7 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { WebInterfaceCert: "", WebInterfaceKey: "", WebInterfaceHTTPS: false, - EnabledAPISets: api.EndpointsRead + "," + api.EndpointsTransaction, + EnabledAPISets: strings.Join([]string{api.EndpointsRead, api.EndpointsTransaction}, ","), DisabledAPISets: "", EnableAllAPISets: false, @@ -420,6 +420,8 @@ func buildAPISets(c NodeConfig) (map[string]struct{}, error) { api.EndpointsStatus, api.EndpointsWallet, api.EndpointsTransaction, + api.EndpointsPrometheus, + api.EndpointsNetCtrl, // Do not include insecure or deprecated API sets, they must always // be explicitly enabled through -enable-api-sets } diff --git a/src/visor/blockdb/mock_unspent_pooler_test.go b/src/visor/blockdb/mock_unspent_pooler_test.go deleted file mode 100644 index 4eb70286eb..0000000000 --- a/src/visor/blockdb/mock_unspent_pooler_test.go +++ /dev/null @@ -1,219 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package blockdb - -import cipher "github.com/skycoin/skycoin/src/cipher" -import coin "github.com/skycoin/skycoin/src/coin" -import dbutil "github.com/skycoin/skycoin/src/visor/dbutil" -import mock "github.com/stretchr/testify/mock" - -// MockUnspentPooler is an autogenerated mock type for the UnspentPooler type -type MockUnspentPooler struct { - mock.Mock -} - -// AddressCount provides a mock function with given fields: _a0 -func (_m *MockUnspentPooler) AddressCount(_a0 *dbutil.Tx) (uint64, error) { - ret := _m.Called(_a0) - - var r0 uint64 - if rf, ok := ret.Get(0).(func(*dbutil.Tx) uint64); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(uint64) - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Contains provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) Contains(_a0 *dbutil.Tx, _a1 cipher.SHA256) (bool, error) { - ret := _m.Called(_a0, _a1) - - var r0 bool - if rf, ok := ret.Get(0).(func(*dbutil.Tx, cipher.SHA256) bool); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, cipher.SHA256) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Get provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) Get(_a0 *dbutil.Tx, _a1 cipher.SHA256) (*coin.UxOut, error) { - ret := _m.Called(_a0, _a1) - - var r0 *coin.UxOut - if rf, ok := ret.Get(0).(func(*dbutil.Tx, cipher.SHA256) *coin.UxOut); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*coin.UxOut) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, cipher.SHA256) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAll provides a mock function with given fields: _a0 -func (_m *MockUnspentPooler) GetAll(_a0 *dbutil.Tx) (coin.UxArray, error) { - ret := _m.Called(_a0) - - var r0 coin.UxArray - if rf, ok := ret.Get(0).(func(*dbutil.Tx) coin.UxArray); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(coin.UxArray) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetArray provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) GetArray(_a0 *dbutil.Tx, _a1 []cipher.SHA256) (coin.UxArray, error) { - ret := _m.Called(_a0, _a1) - - var r0 coin.UxArray - if rf, ok := ret.Get(0).(func(*dbutil.Tx, []cipher.SHA256) coin.UxArray); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(coin.UxArray) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, []cipher.SHA256) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetUnspentsOfAddrs provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) GetUnspentsOfAddrs(_a0 *dbutil.Tx, _a1 []cipher.Address) (coin.AddressUxOuts, error) { - ret := _m.Called(_a0, _a1) - - var r0 coin.AddressUxOuts - if rf, ok := ret.Get(0).(func(*dbutil.Tx, []cipher.Address) coin.AddressUxOuts); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(coin.AddressUxOuts) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, []cipher.Address) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetUxHash provides a mock function with given fields: _a0 -func (_m *MockUnspentPooler) GetUxHash(_a0 *dbutil.Tx) (cipher.SHA256, error) { - ret := _m.Called(_a0) - - var r0 cipher.SHA256 - if rf, ok := ret.Get(0).(func(*dbutil.Tx) cipher.SHA256); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cipher.SHA256) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Len provides a mock function with given fields: _a0 -func (_m *MockUnspentPooler) Len(_a0 *dbutil.Tx) (uint64, error) { - ret := _m.Called(_a0) - - var r0 uint64 - if rf, ok := ret.Get(0).(func(*dbutil.Tx) uint64); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(uint64) - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MaybeBuildIndexes provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) MaybeBuildIndexes(_a0 *dbutil.Tx, _a1 uint64) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*dbutil.Tx, uint64) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// ProcessBlock provides a mock function with given fields: _a0, _a1 -func (_m *MockUnspentPooler) ProcessBlock(_a0 *dbutil.Tx, _a1 *coin.SignedBlock) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*dbutil.Tx, *coin.SignedBlock) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} From db26b925c62ab885eb9e0ebae8085dea297ec52b Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Tue, 30 Oct 2018 23:41:31 -0400 Subject: [PATCH 357/399] [api] refs #1980 - Rename JSON key counhours_burn_factor => coinhour_burn_factor --- src/api/README.md | 2 +- src/api/health.go | 2 +- .../integration/testdata/generate-addresses-encrypted.golden | 2 +- src/cli/integration/testdata/integration-test-encrypted.wlt | 2 +- .../testdata/status-csrf-enabled-no-unconfirmed.golden | 2 +- src/cli/integration/testdata/status-csrf-enabled.golden | 2 +- src/cli/integration/testdata/status-no-unconfirmed.golden | 2 +- src/cli/integration/testdata/status.golden | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/README.md b/src/api/README.md index fb0127131b..60c8078c7a 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -233,7 +233,7 @@ Response: "gui_enabled": true, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhour_burn_factor": 2 } ``` diff --git a/src/api/health.go b/src/api/health.go index 7080ca2ea7..24a739d8de 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -30,7 +30,7 @@ type HealthResponse struct { GUIEnabled bool `json:"gui_enabled"` UnversionedAPIEnabled bool `json:"unversioned_api_enabled"` JSON20RPCEnabled bool `json:"json_rpc_enabled"` - BurnFactor uint64 `json:"coinhours_burn_factor"` + BurnFactor uint64 `json:"coinhour_burn_factor"` } // healthHandler returns node health data diff --git a/src/cli/integration/testdata/generate-addresses-encrypted.golden b/src/cli/integration/testdata/generate-addresses-encrypted.golden index 4383c8b10f..1d1474805d 100644 --- a/src/cli/integration/testdata/generate-addresses-encrypted.golden +++ b/src/cli/integration/testdata/generate-addresses-encrypted.golden @@ -24,4 +24,4 @@ "secret_key": "" } ] -} \ No newline at end of file +} diff --git a/src/cli/integration/testdata/integration-test-encrypted.wlt b/src/cli/integration/testdata/integration-test-encrypted.wlt index fc39e6dd22..e1738d49f3 100644 --- a/src/cli/integration/testdata/integration-test-encrypted.wlt +++ b/src/cli/integration/testdata/integration-test-encrypted.wlt @@ -19,4 +19,4 @@ "secret_key": "" } ] -} \ No newline at end of file +} diff --git a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden index 4bdcf069bf..0d5e4eb330 100644 --- a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhour_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-csrf-enabled.golden b/src/cli/integration/testdata/status-csrf-enabled.golden index 519a5e0e1f..4124dca4d9 100644 --- a/src/cli/integration/testdata/status-csrf-enabled.golden +++ b/src/cli/integration/testdata/status-csrf-enabled.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhour_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status-no-unconfirmed.golden b/src/cli/integration/testdata/status-no-unconfirmed.golden index 595d7471ec..2b1b0bfe29 100644 --- a/src/cli/integration/testdata/status-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-no-unconfirmed.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhour_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" diff --git a/src/cli/integration/testdata/status.golden b/src/cli/integration/testdata/status.golden index 32344536f8..92ad4b7b3a 100644 --- a/src/cli/integration/testdata/status.golden +++ b/src/cli/integration/testdata/status.golden @@ -30,7 +30,7 @@ "gui_enabled": false, "unversioned_api_enabled": false, "json_rpc_enabled": false, - "coinhours_burn_factor": 2 + "coinhour_burn_factor": 2 }, "cli_config": { "webrpc_address": "http://127.0.0.1:1024" From 22b06bbb3dd46fa4b3c0adf061342b1984307fee Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Ramirez Date: Wed, 31 Oct 2018 03:51:09 +0000 Subject: [PATCH 358/399] [api] refs #1980 - counhours_burn_factor => coinhour_burn_factor in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7d1a2909..b7cbff6c72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Add `-csv` option to `cli send` and `cli createRawTransaction`, which will send coins to multiple addresses defined in a csv file - Add `-disable-default-peers` option to disable the default hardcoded peers and mark all cached peers as untrusted - Add `-custom-peers-file` to load peers from disk. This peers file is a newline separate list of `ip:port` strings -- Add `user_agent`, `coin`, `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled`, `coinhours_burn_factor` configuration settings to the `/api/v1/health` endpoint response +- Add `user_agent`, `coin`, `csrf_enabled`, `csp_enabled`, `wallet_api_enabled`, `unversioned_api_enabled`, `gui_enabled` and `json_rpc_enabled`, `coinhour_burn_factor` configuration settings to the `/api/v1/health` endpoint response - Add `verbose` flag to `/api/v1/block`, `/api/v1/blocks`, `/api/v1/last_blocks`, `/api/v1/pendingTxs`, `/api/v1/transaction`, `/api/v1/transactions`, `/api/v1/wallet/transactions` to return verbose block data, which includes the address, coins, hours and calculcated_hours of the block's transaction's inputs - Add `encoded` flag to `/api/v1/transaction` to return an encoded transaction - Add `-http-prof-host` option to choose the HTTP profiler's bind hostname (defaults to `localhost:6060`) From 987c1349bb6826430e52a0c5dc19707f7c4cbbf2 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 12:35:09 +0800 Subject: [PATCH 359/399] Restore trusted peers to the random connections list --- src/daemon/daemon.go | 12 ++++++++---- src/daemon/pex/pex.go | 6 +++--- src/daemon/pex/pex_test.go | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 7fccb7a439..797442d271 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -431,12 +431,16 @@ func (dm *Daemon) Run() error { flushAnnouncedTxnsTicker := time.NewTicker(dm.Config.FlushAnnouncedTxnsRate) defer flushAnnouncedTxnsTicker.Stop() - // Connect to trusted peers + // Connect to all trusted peers on startup to try to ensure a connection + // establishes quickly. + // The number of connections to default peers is restricted; + // if multiple connections succeed, extra connections beyond the limit will + // be disconnected. if !dm.Config.DisableOutgoingConnections { wg.Add(1) go func() { defer wg.Done() - dm.connectToTrustPeer() + dm.connectToTrustedPeers() }() } @@ -692,7 +696,7 @@ func (dm *Daemon) makePrivateConnections() { } } -func (dm *Daemon) connectToTrustPeer() { +func (dm *Daemon) connectToTrustedPeers() { if dm.Config.DisableOutgoingConnections { return } @@ -723,7 +727,7 @@ func (dm *Daemon) connectToRandomPeer() { } // Make a connection to a random (public) peer - peers := dm.pex.RandomPublicUntrusted(dm.Config.MaxOutgoingConnections) + peers := dm.pex.RandomPublic(dm.Config.MaxOutgoingConnections) for _, p := range peers { if err := dm.connectToPeer(p); err != nil { logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index 4ce2ee0d16..228b342556 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -586,12 +586,12 @@ func (px *Pex) TrustedPublic() Peers { return px.peerlist.getCanTryPeers([]Filter{isPublic, isTrusted}) } -// RandomPublicUntrusted returns N random public untrusted peers -func (px *Pex) RandomPublicUntrusted(n int) Peers { +// RandomPublic returns N random public untrusted peers +func (px *Pex) RandomPublic(n int) Peers { px.RLock() defer px.RUnlock() return px.peerlist.random(n, []Filter{func(p Peer) bool { - return !p.Private && !p.Trusted + return !p.Private }}) } diff --git a/src/daemon/pex/pex_test.go b/src/daemon/pex/pex_test.go index cc867c3401..1d1b36b173 100644 --- a/src/daemon/pex/pex_test.go +++ b/src/daemon/pex/pex_test.go @@ -735,7 +735,7 @@ func TestPeerRandomPublic(t *testing.T) { pex.peerlist.setPeers(tc.peers) - peers := pex.RandomPublicUntrusted(tc.n) + peers := pex.RandomPublic(tc.n) require.Len(t, peers, tc.expectN) }) } @@ -848,7 +848,7 @@ func TestPexRandomPublic(t *testing.T) { pex.peerlist.setPeers(tc.peers) // get N random public - peers := pex.RandomPublicUntrusted(tc.n) + peers := pex.RandomPublic(tc.n) require.Len(t, peers, tc.expectN) From 350a433cee612163ded50a2a6d2c28b0d95b394c Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 12:49:04 +0800 Subject: [PATCH 360/399] Update docs for NET_CTRL api set --- src/api/README.md | 5 +++-- src/skycoin/config.go | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/api/README.md b/src/api/README.md index 1352f8cc03..cc2fbf0dba 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -139,9 +139,10 @@ These API sets are: * `STATUS` - A subset of `READ`, these endpoints report the application, network or blockchain status * `TXN` - Enables `/api/v1/injectTransaction` without enabling wallet endpoints * `WALLET` - These endpoints operate on local wallet files -* `INSECURE_WALLET_SEED` - This is the `/api/v1/wallet/seed` endpoint, used to decrypt and return the seed from an encrypted wallet. It is only intended for use by the desktop client. -* `DEPRECATED_WALLET_SPEND` - This is the `/api/v1/wallet/spend` method which is deprecated and will be removed * `PROMETHEUS` - This is the `/api/v2/metrics` method exposing in Prometheus text format the default metrics for Skycoin node application +* `NET_CTRL` - The `/api/v1/network/connection/disconnect` method, intended for network administration endpoints +* `INSECURE_WALLET_SEED` - This is the `/api/v1/wallet/seed` endpoint, used to decrypt and return the seed from an encrypted wallet. It is only intended for use by the desktop client. +* `DEPRECATED_WALLET_SPEND` - This is the `/api/v1/wallet/spend` method which is deprecated and will be removed in v0.26.0 ## Authentication diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 0e3d3514b4..06c356d00e 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -487,9 +487,21 @@ func (c *NodeConfig) RegisterFlags() { flag.StringVar(&c.WebInterfaceKey, "web-interface-key", c.WebInterfaceKey, "skycoind.key file for web interface HTTPS. If not provided, will autogenerate or use skycoind.key in -data-directory") flag.BoolVar(&c.WebInterfaceHTTPS, "web-interface-https", c.WebInterfaceHTTPS, "enable HTTPS for web interface") flag.StringVar(&c.HostWhitelist, "host-whitelist", c.HostWhitelist, "Hostnames to whitelist in the Host header check. Only applies when the web interface is bound to localhost.") - flag.StringVar(&c.EnabledAPISets, "enable-api-sets", c.EnabledAPISets, "enable API set. Options are READ, STATUS, WALLET, INSECURE_WALLET_SEED, DEPRECATED_WALLET_SPEND. Multiple values should be separated by comma") - flag.StringVar(&c.DisabledAPISets, "disable-api-sets", c.DisabledAPISets, "disable API set. Options are READ, STATUS, WALLET, INSECURE_WALLET_SEED, DEPRECATED_WALLET_SPEND. Multiple values should be separated by comma") + + allAPISets := []string{ + api.EndpointsRead, + api.EndpointsStatus, + api.EndpointsWallet, + api.EndpointsTransaction, + api.EndpointsPrometheus, + api.EndpointsNetCtrl, + api.EndpointsInsecureWalletSeed, + api.EndpointsDeprecatedWalletSpend, + } + flag.StringVar(&c.EnabledAPISets, "enable-api-sets", c.EnabledAPISets, fmt.Sprintf("enable API set. Options are %s. Multiple values should be separated by comma", strings.Join(allAPISets, ", "))) + flag.StringVar(&c.DisabledAPISets, "disable-api-sets", c.DisabledAPISets, fmt.Sprintf("disable API set. Options are %s. Multiple values should be separated by comma", strings.Join(allAPISets, ", "))) flag.BoolVar(&c.EnableAllAPISets, "enable-all-api-sets", c.EnableAllAPISets, "enable all API sets, except for deprecated or insecure sets. This option is applied before -disable-api-sets.") + flag.StringVar(&c.WebInterfaceUsername, "web-interface-username", c.WebInterfaceUsername, "username for the web interface") flag.StringVar(&c.WebInterfacePassword, "web-interface-password", c.WebInterfacePassword, "password for the web interface") flag.BoolVar(&c.WebInterfacePlaintextAuth, "web-interface-plaintext-auth", c.WebInterfacePlaintextAuth, "allow web interface auth without https") @@ -549,7 +561,7 @@ func (c *NodeConfig) applyConfigMode(configMode string) { case "": case "STANDALONE_CLIENT": c.EnableAllAPISets = true - c.EnabledAPISets = "INSECURE_WALLET_SEED" + c.EnabledAPISets = api.EndpointsInsecureWalletSeed c.EnableGUI = true c.LaunchBrowser = true c.DisableCSRF = false From da554e36acd9676db396d170f85ab774dad92922 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 13:00:31 +0800 Subject: [PATCH 361/399] Fix conn max check; reduce overly aggressive connection attempts --- src/daemon/daemon.go | 8 ++++---- src/daemon/pex/peerlist.go | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 797442d271..3379927e2a 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -716,18 +716,18 @@ func (dm *Daemon) connectToRandomPeer() { if dm.Config.DisableOutgoingConnections { return } - if dm.connections.OutgoingLen() > dm.Config.MaxOutgoingConnections { + if dm.connections.OutgoingLen() >= dm.Config.MaxOutgoingConnections { return } - if dm.connections.PendingLen() > dm.Config.MaxPendingConnections { + if dm.connections.PendingLen() >= dm.Config.MaxPendingConnections { return } - if dm.connections.Len() > dm.Config.MaxConnections { + if dm.connections.Len() >= dm.Config.MaxConnections { return } // Make a connection to a random (public) peer - peers := dm.pex.RandomPublic(dm.Config.MaxOutgoingConnections) + peers := dm.pex.RandomPublic(dm.Config.MaxOutgoingConnections - dm.connections.OutgoingLen()) for _, p := range peers { if err := dm.connectToPeer(p); err != nil { logger.WithError(err).WithField("addr", p.Addr).Warning("connectToPeer failed") diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index ea21120ad1..2caa5625aa 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -268,15 +268,16 @@ func (pl *peerlist) random(count int, flts []Filter) Peers { if len(keys) == 0 { return Peers{} } + max := count - if count == 0 || count > len(keys) { + if max == 0 || max > len(keys) { max = len(keys) } - ps := make(Peers, 0) + ps := make(Peers, max) perm := rand.Perm(len(keys)) - for _, i := range perm[:max] { - ps = append(ps, *pl.peers[keys[i]]) + for i, j := range perm[:max] { + ps[i] = *pl.peers[keys[j]] } return ps } From 7156881fa9030ad938e79ba1d8eeef63dde03084 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 13:21:31 +0800 Subject: [PATCH 362/399] Fix lint --- src/api/network_test.go | 1 - src/daemon/gateway.go | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/api/network_test.go b/src/api/network_test.go index ac2b95dfac..5d14778e3c 100644 --- a/src/api/network_test.go +++ b/src/api/network_test.go @@ -533,7 +533,6 @@ func TestDisconnect(t *testing.T) { status int err string disconnectErr error - result []string id string gnetID uint64 }{ diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 2ba640bd12..bd9f8ed5a1 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -218,8 +218,7 @@ func (gw *Gateway) newConnection(c *connection) (*Connection, error) { func (gw *Gateway) Disconnect(gnetID uint64) error { var err error gw.strand("Disconnect", func() { - var c *connection - c = gw.d.connections.getByGnetID(gnetID) + c := gw.d.connections.getByGnetID(gnetID) if c == nil { err = ErrConnectionNotExist return From 06645b5ce5ba5b02f08ed46e5f347dd7e4f3c349 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 14:16:08 +0800 Subject: [PATCH 363/399] Fixups --- src/daemon/daemon.go | 16 ++++++++-------- src/daemon/errors.go | 3 +++ src/daemon/errors_test.go | 29 +++++++++++++++++++++++++++++ src/daemon/gnet/dispatcher.go | 14 +++++--------- src/daemon/gnet/dispatcher_test.go | 17 +++++++++++++++++ src/daemon/gnet/pool.go | 6 ++++++ src/daemon/messages.go | 18 ------------------ src/daemon/messages_test.go | 28 ++++++++++++++++++++-------- 8 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 src/daemon/errors_test.go diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 3379927e2a..efe9f0a050 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -610,9 +610,9 @@ loop: case <-blocksRequestTicker.C: elapser.Register("blocksRequestTicker") - // if err := dm.RequestBlocks(); err != nil { - // logger.WithError(err).Warning("RequestBlocks failed") - // } + if err := dm.RequestBlocks(); err != nil { + logger.WithError(err).Warning("RequestBlocks failed") + } case <-blocksAnnounceTicker.C: elapser.Register("blocksAnnounceTicker") @@ -819,9 +819,9 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { // The first message received must be an IntroductionMessage if !c.HasIntroduced() { - _, isIntro := e.Message.(*IntroductionMessage) - _, isDisc := e.Message.(*DisconnectMessage) - if !isIntro && !isDisc { + switch e.Message.(type) { + case *IntroductionMessage, *DisconnectMessage: + default: logger.WithFields(logrus.Fields{ "addr": e.Context.Addr, "messageType": fmt.Sprintf("%T", e.Message), @@ -981,7 +981,7 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { } if m, ok := r.Message.(*DisconnectMessage); ok { - if err := dm.DisconnectNow(r.Addr, gnet.DisconnectReason(m.reason)); err != nil { + if err := dm.DisconnectNow(r.Addr, m.reason); err != nil { logger.WithError(err).WithField("addr", r.Addr).Warning("DisconnectNow") } } @@ -1246,7 +1246,7 @@ func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { // Disconnect sends a DisconnectMessage to a peer. After the DisconnectMessage is sent, the peer is disconnected. // This allows all pending messages to be sent. Any message queued after a DisconnectMessage is unlikely to be sent -// the peer (but possible). +// to the peer (but possible). func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { logger.WithFields(logrus.Fields{ "addr": addr, diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 651931d7c4..691801ef46 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -60,6 +60,9 @@ var ( ErrDisconnectInvalidUserAgent: 14, ErrDisconnectRequestedByOperator: 15, + // gnet codes are registered here, but they are not sent in a DISC + // message by gnet. Only daemon sends a DISC packet. + // If gnet chooses to disconnect it will not send a DISC packet. gnet.ErrDisconnectSetReadDeadlineFailed: 1001, gnet.ErrDisconnectInvalidMessageLength: 1002, gnet.ErrDisconnectMalformedMessage: 1003, diff --git a/src/daemon/errors_test.go b/src/daemon/errors_test.go new file mode 100644 index 0000000000..19e1a12796 --- /dev/null +++ b/src/daemon/errors_test.go @@ -0,0 +1,29 @@ +package daemon + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/skycoin/skycoin/src/daemon/gnet" +) + +func TestDisconnectReasonCode(t *testing.T) { + c := DisconnectReasonToCode(ErrDisconnectIdle) + require.NotEqual(t, uint16(0), c) + + r := DisconnectCodeToReason(c) + require.Equal(t, ErrDisconnectIdle, r) + + // unknown reason is fine + c = DisconnectReasonToCode(gnet.DisconnectReason(errors.New("foo"))) + require.Equal(t, uint16(0), c) + + r = DisconnectCodeToReason(c) + require.Equal(t, ErrDisconnectUnknownReason, r) + + // unknown code is fine + r = DisconnectCodeToReason(999) + require.Equal(t, ErrDisconnectUnknownReason, r) +} diff --git a/src/daemon/gnet/dispatcher.go b/src/daemon/gnet/dispatcher.go index d497fa61e7..30e69a03fe 100644 --- a/src/daemon/gnet/dispatcher.go +++ b/src/daemon/gnet/dispatcher.go @@ -33,14 +33,10 @@ func sendMessage(conn net.Conn, msg Message, timeout time.Duration) error { return sendByteMessage(conn, m, timeout) } +// msgIDStringSafe formats msgID bytes to a string that is safe for logging (e.g. not impacted by ascii control chars) func msgIDStringSafe(msgID [4]byte) string { - for _, c := range msgID { - if c < ' ' || c > '~' { - return "" - } - } - - return string(msgID[:]) + x := fmt.Sprintf("%q", msgID) + return x[1 : len(x)-1] // trim quotes that are added by %q formatting } // Event handler that is called after a Connection sends a complete message @@ -54,14 +50,14 @@ func convertToMessage(id uint64, msg []byte, debugPrint bool) (Message, error) { copy(msgID[:], msg[:len(msgID)]) if debugPrint { - logger.Debugf("Received %s message", msgIDStringSafe(msgID)) + logger.WithField("msgID", msgIDStringSafe(msgID)).Debug("Received message") } msg = msg[len(msgID):] t, ok := MessageIDReverseMap[msgID] if !ok { logger.WithError(ErrDisconnectUnknownMessage).WithFields(logrus.Fields{ - "msgID": fmt.Sprintf("%q", msgID), + "msgID": msgIDStringSafe(msgID), "connID": id, }).Warning() return nil, ErrDisconnectUnknownMessage diff --git a/src/daemon/gnet/dispatcher_test.go b/src/daemon/gnet/dispatcher_test.go index f3306d445c..425cecc72c 100644 --- a/src/daemon/gnet/dispatcher_test.go +++ b/src/daemon/gnet/dispatcher_test.go @@ -19,6 +19,23 @@ func resetHandler() { sendByteMessage = _sendByteMessage } +func TestMsgIDStringSafe(t *testing.T) { + var id [4]byte + require.Equal(t, "\\x00\\x00\\x00\\x00", msgIDStringSafe(id)) + + id = [4]byte{'F', 'O', 'O', 'B'} + + require.Equal(t, "FOOB", msgIDStringSafe(id)) + + id = [4]byte{200, 2, '\n', '\t'} + + require.Equal(t, "\\xc8\\x02\\n\\t", msgIDStringSafe(id)) + + id = [4]byte{'\'', '\\', ' ', '"'} + + require.Equal(t, "'\\\\ \\\"", msgIDStringSafe(id)) +} + func TestConvertToMessage(t *testing.T) { EraseMessages() resetHandler() diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index ea97f46d8d..fa31b41bf2 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -578,6 +578,12 @@ func (pool *ConnectionPool) handleConnection(conn net.Conn, solicited bool) erro "addr": addr, "method": mErr.method, }).Error("handleConnection failure") + + // This Disconnect does not send a DISC packet because it is inside gnet. + // A DISC packet is not useful at this point, because the error is most likely + // that the connection is unreachable. + // However, it may also be that the connection sent data that could not be deserialized + // to a message. if err := pool.Disconnect(c.Addr(), mErr.err); err != nil { logger.WithError(err).WithField("addr", addr).Error("Disconnect") } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 284953a3b4..cf65fd934a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -367,9 +367,6 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { "addr": addr, "mirror": intro.Mirror, }).Info("Remote mirror value matches ours") - if err := d.Disconnect(addr, ErrDisconnectSelf); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectSelf } @@ -381,9 +378,6 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { "protocolVersion": intro.ProtocolVersion, "minProtocolVersion": dc.MinProtocolVersion, }).Info("protocol version below minimum supported protocol version") - if err := d.Disconnect(addr, ErrDisconnectVersionNotSupported); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectVersionNotSupported } @@ -401,9 +395,6 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { logger.WithField("addr", addr).Info("Extra data length does not meet the minimum requirement") - if err := d.Disconnect(addr, ErrDisconnectInvalidExtraData); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectInvalidExtraData } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) @@ -414,9 +405,6 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { "pubkey": bcPubKey.Hex(), "daemonPubkey": d.BlockchainPubkey().Hex(), }).Info("Blockchain pubkey does not match") - if err := d.Disconnect(addr, ErrDisconnectBlockchainPubkeyNotMatched); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectBlockchainPubkeyNotMatched } @@ -424,18 +412,12 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { userAgent, _, err := encoder.DeserializeString(userAgentSerialized, useragent.MaxLen) if err != nil { logger.WithError(err).Info("Extra data user agent string could not be deserialized") - if err := d.Disconnect(addr, ErrDisconnectInvalidExtraData); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectInvalidExtraData } userAgentData, err = useragent.Parse(useragent.Sanitize(userAgent)) if err != nil { logger.WithError(err).WithField("userAgent", userAgent).Info("User agent is invalid") - if err := d.Disconnect(addr, ErrDisconnectInvalidUserAgent); err != nil { - logger.WithError(err).WithField("addr", addr).Warning("Disconnect") - } return nil, ErrDisconnectInvalidUserAgent } } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 4593bd5c24..a59c71b3dc 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -1,7 +1,6 @@ package daemon import ( - "fmt" "io/ioutil" "os" "path/filepath" @@ -39,6 +38,7 @@ func TestIntroductionMessage(t *testing.T) { connectionIntroducedErr error requestBlocksFromAddrErr error announceAllTxnsErr error + recordUserAgentErr error } tt := []struct { @@ -98,6 +98,10 @@ func TestIntroductionMessage(t *testing.T) { Addr: "121.121.121.121:6000", ConnectionDetails: ConnectionDetails{ ListenPort: 6000, + UserAgent: useragent.Data{ + Coin: "skycoin", + Version: "0.24.1", + }, }, }, addPeerArg: "121.121.121.121:6000", @@ -121,6 +125,10 @@ func TestIntroductionMessage(t *testing.T) { Addr: "121.121.121.121:6000", ConnectionDetails: ConnectionDetails{ ListenPort: 6000, + UserAgent: useragent.Data{ + Coin: "skycoin", + Version: "0.24.1", + }, }, }, addPeerArg: "121.121.121.121:6000", @@ -234,6 +242,11 @@ func TestIntroductionMessage(t *testing.T) { Addr: "121.121.121.121:12345", ConnectionDetails: ConnectionDetails{ ListenPort: 6000, + UserAgent: useragent.Data{ + Coin: "skycoin", + Version: "0.24.1", + Remark: "foo", + }, }, }, }, @@ -265,7 +278,6 @@ func TestIntroductionMessage(t *testing.T) { } for _, tc := range tt { - fmt.Println("TEST NAME", tc.name) t.Run(tc.name, func(t *testing.T) { mc := &gnet.MessageContext{ Addr: tc.addr, @@ -295,15 +307,15 @@ func TestIntroductionMessage(t *testing.T) { d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) + var userAgent useragent.Data + if tc.mockValue.connectionIntroduced != nil { + userAgent = tc.mockValue.connectionIntroduced.UserAgent + } + d.On("RecordUserAgent", tc.mockValue.addPeerArg, userAgent).Return(tc.mockValue.recordUserAgentErr) + err := tc.intro.Handle(mc, d) require.NoError(t, err) - // ip, port, err := tc.intro.verify(d) - // require.Equal(t, tc.err, err) - // if err == nil { - // require.Equal(t, tc.addr, fmt.Sprintf("%s:%d", ip, port)) - // } - tc.intro.process(d) if tc.mockValue.disconnectReason != nil { From de5d6063f44e2ae7d0862992f13bdd44172e92aa Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 31 Oct 2018 16:21:01 +0800 Subject: [PATCH 364/399] Fix broadcast failure check for inject and resend txns --- CHANGELOG.md | 2 ++ src/api/README.md | 8 +++--- src/api/client.go | 5 ++-- src/api/http.go | 2 +- src/api/integration/integration_test.go | 8 +++--- src/api/transaction.go | 21 ++++++++++----- src/api/transaction_test.go | 27 +++++++++++++------ .../status-csrf-enabled-no-unconfirmed.golden | 2 ++ .../testdata/status-csrf-enabled.golden | 2 ++ .../testdata/status-no-unconfirmed.golden | 2 ++ src/cli/integration/testdata/status.golden | 2 ++ src/daemon/daemon.go | 20 ++++++++++++-- src/skycoin/skycoin_test.go | 2 +- 13 files changed, 75 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe56dbe13..770dbad9f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `POST /api/v1/wallet/newAddress` and `POST /api/v1/wallet/spend` will correctly fail if the wallet is not encrypted but a password is provided - Return `503` error for `/api/v1/injectTransaction` for all message broadcast failures (note that it is still possible for broadcast to fail but no error to be returned, in certain conditions) - Fixed autogenerated HTTPS certs. Certs are now self-signed ECDSA certs, valid for 10 years, valid for localhost and all public interfaces found on the machine. The default cert and key are renamed from cert.pem, key.pem to skycoind.cert, skycoind.key +- `/api/v1/resendUnconfirmedTxns` will return `503 Service Unavailable` is no connections are available for broadcast ### Changed @@ -91,6 +92,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/network/connection*` field `"is_trusted_peer"` added to connection object to indicate if the peer is in the hardcoded list of default peers - `/api/v1/network/connection*` field `"connected_at"` added to connection object - `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction +- `/api/v1/resendUnconfirmedTxns` is now a `POST` method, previously was a `GET` method ### Removed diff --git a/src/api/README.md b/src/api/README.md index cc2fbf0dba..f846aad905 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -137,7 +137,7 @@ These API sets are: * `READ` - All query-related endpoints, they do not modify the state of the program * `STATUS` - A subset of `READ`, these endpoints report the application, network or blockchain status -* `TXN` - Enables `/api/v1/injectTransaction` without enabling wallet endpoints +* `TXN` - Enables `/api/v1/injectTransaction` and `/api/v1/resendUnconfirmedTxns` without enabling wallet endpoints * `WALLET` - These endpoints operate on local wallet files * `PROMETHEUS` - This is the `/api/v2/metrics` method exposing in Prometheus text format the default metrics for Skycoin node application * `NET_CTRL` - The `/api/v1/network/connection/disconnect` method, intended for network administration endpoints @@ -2243,17 +2243,17 @@ Result: ### Resend unconfirmed transactions -API sets: `READ` +API sets: `TXN` ``` URI: /api/v1/resendUnconfirmedTxns -Method: GET +Method: POST ``` Example: ```sh -curl http://127.0.0.1:6420/api/v1/resendUnconfirmedTxns +curl -X POST 'http://127.0.0.1:6420/api/v1/resendUnconfirmedTxns' ``` Result: diff --git a/src/api/client.go b/src/api/client.go index c972c0776c..1d668f8875 100644 --- a/src/api/client.go +++ b/src/api/client.go @@ -1052,10 +1052,11 @@ func (c *Client) InjectEncodedTransaction(rawTxn string) (string, error) { return txid, nil } -// ResendUnconfirmedTransactions makes a request to GET /api/v1/resendUnconfirmedTxns +// ResendUnconfirmedTransactions makes a request to POST /api/v1/resendUnconfirmedTxns func (c *Client) ResendUnconfirmedTransactions() (*ResendResult, error) { + endpoint := "/api/v1/resendUnconfirmedTxns" var r ResendResult - if err := c.Get("/api/v1/resendUnconfirmedTxns", &r); err != nil { + if err := c.PostForm(endpoint, strings.NewReader(""), &r); err != nil { return nil, err } return &r, nil diff --git a/src/api/http.go b/src/api/http.go index 6ef5ea21b5..2f4090ffb1 100644 --- a/src/api/http.go +++ b/src/api/http.go @@ -483,7 +483,7 @@ func newServerMux(c muxConfig, gateway Gatewayer, csrfStore *CSRFStore, rpc *web webHandlerV2("/transaction/verify", forAPISet(verifyTxnHandler(gateway), []string{EndpointsRead})) webHandlerV1("/transactions", forAPISet(transactionsHandler(gateway), []string{EndpointsRead})) webHandlerV1("/injectTransaction", forAPISet(injectTransactionHandler(gateway), []string{EndpointsTransaction, EndpointsWallet})) - webHandlerV1("/resendUnconfirmedTxns", forAPISet(resendUnconfirmedTxnsHandler(gateway), []string{EndpointsRead})) + webHandlerV1("/resendUnconfirmedTxns", forAPISet(resendUnconfirmedTxnsHandler(gateway), []string{EndpointsTransaction})) webHandlerV1("/rawtx", forAPISet(rawTxnHandler(gateway), []string{EndpointsRead})) // Unspent output related endpoints diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 500f12298b..257be27e4c 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -2954,9 +2954,11 @@ func TestStableResendUnconfirmedTransactions(t *testing.T) { return } c := newClient() - res, err := c.ResendUnconfirmedTransactions() - require.NoError(t, err) - require.True(t, len(res.Txids) == 0) + _, err := c.ResendUnconfirmedTransactions() + respErr, ok := err.(api.ClientError) + require.True(t, ok) + require.Equal(t, fmt.Sprintf("503 Service Unavailable - %s", daemon.ErrNetworkingDisabled), respErr.Message) + require.Equal(t, http.StatusServiceUnavailable, respErr.StatusCode) } func TestLiveResendUnconfirmedTransactions(t *testing.T) { diff --git a/src/api/transaction.go b/src/api/transaction.go index e44e33bfd0..63cb48f5f6 100644 --- a/src/api/transaction.go +++ b/src/api/transaction.go @@ -13,7 +13,6 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" - "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/readable" wh "github.com/skycoin/skycoin/src/util/http" "github.com/skycoin/skycoin/src/visor" @@ -379,10 +378,9 @@ func injectTransactionHandler(gateway Gatewayer) http.HandlerFunc { } if err := gateway.InjectBroadcastTransaction(txn); err != nil { - switch err { - case daemon.ErrOutgoingConnectionsDisabled, gnet.ErrPoolEmpty, gnet.ErrNoReachableConnections: + if daemon.IsBroadcastFailure(err) { wh.Error503(w, err.Error()) - default: + } else { wh.Error500(w, err.Error()) } return @@ -409,18 +407,27 @@ func NewResendResult(hashes []cipher.SHA256) ResendResult { } // URI: /api/v1/resendUnconfirmedTxns -// Method: GET +// Method: POST // Broadcasts all unconfirmed transactions from the unconfirmed transaction pool +// Response: +// 200 - ok, returns the transaction hashes that were resent +// 405 - method not POST +// 500 - other error +// 503 - network unavailable for broadcasting transaction func resendUnconfirmedTxnsHandler(gateway Gatewayer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { + if r.Method != http.MethodPost { wh.Error405(w) return } hashes, err := gateway.ResendUnconfirmedTxns() if err != nil { - wh.Error500(w, err.Error()) + if daemon.IsBroadcastFailure(err) { + wh.Error503(w, err.Error()) + } else { + wh.Error500(w, err.Error()) + } return } diff --git a/src/api/transaction_test.go b/src/api/transaction_test.go index dc137d510c..671081151c 100644 --- a/src/api/transaction_test.go +++ b/src/api/transaction_test.go @@ -680,13 +680,13 @@ func TestInjectTransaction(t *testing.T) { httpBody: string(invalidTxnBodyJSON), }, { - name: "503 - daemon.ErrOutgoingConnectionsDisabled", + name: "503 - daemon.ErrNetworkingDisabled", method: http.MethodPost, status: http.StatusServiceUnavailable, - err: "503 Service Unavailable - Outgoing connections are disabled", + err: "503 Service Unavailable - Networking is disabled", httpBody: string(validTxnBodyJSON), injectTransactionArg: validTransaction, - injectTransactionError: daemon.ErrOutgoingConnectionsDisabled, + injectTransactionError: daemon.ErrNetworkingDisabled, }, { name: "503 - gnet.ErrNoReachableConnections", @@ -787,29 +787,40 @@ func TestResendUnconfirmedTxns(t *testing.T) { }{ { name: "405", - method: http.MethodPost, + method: http.MethodGet, status: http.StatusMethodNotAllowed, err: "405 Method Not Allowed", }, + { - name: "500 resend failed", - method: http.MethodGet, + name: "500 resend failed network error", + method: http.MethodPost, + status: http.StatusServiceUnavailable, + err: "503 Service Unavailable - All pool connections are unreachable at this time", + resendUnconfirmedTxnsErr: gnet.ErrNoReachableConnections, + }, + + { + name: "500 resend failed unknown error", + method: http.MethodPost, status: http.StatusInternalServerError, err: "500 Internal Server Error - ResendUnconfirmedTxns failed", resendUnconfirmedTxnsErr: errors.New("ResendUnconfirmedTxns failed"), }, + { name: "200", - method: http.MethodGet, + method: http.MethodPost, status: http.StatusOK, resendUnconfirmedTxnsResponse: nil, httpResponse: ResendResult{ Txids: []string{}, }, }, + { name: "200 with hashes", - method: http.MethodGet, + method: http.MethodPost, status: http.StatusOK, resendUnconfirmedTxnsResponse: []cipher.SHA256{validHash1, validHash2}, httpResponse: ResendResult{ diff --git a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden index 8a99a3e7f2..7371e35d2b 100644 --- a/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-csrf-enabled-no-unconfirmed.golden @@ -23,6 +23,8 @@ "coin": "skycoin", "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, + "outgoing_connections": 0, + "incoming_connections": 0, "uptime": "0s", "csrf_enabled": true, "csp_enabled": true, diff --git a/src/cli/integration/testdata/status-csrf-enabled.golden b/src/cli/integration/testdata/status-csrf-enabled.golden index 17ed42d4a2..e4b68768e3 100644 --- a/src/cli/integration/testdata/status-csrf-enabled.golden +++ b/src/cli/integration/testdata/status-csrf-enabled.golden @@ -23,6 +23,8 @@ "coin": "skycoin", "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, + "outgoing_connections": 0, + "incoming_connections": 0, "uptime": "0s", "csrf_enabled": true, "csp_enabled": true, diff --git a/src/cli/integration/testdata/status-no-unconfirmed.golden b/src/cli/integration/testdata/status-no-unconfirmed.golden index 7e5d1c7cd6..be93298337 100644 --- a/src/cli/integration/testdata/status-no-unconfirmed.golden +++ b/src/cli/integration/testdata/status-no-unconfirmed.golden @@ -23,6 +23,8 @@ "coin": "skycoin", "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, + "outgoing_connections": 0, + "incoming_connections": 0, "uptime": "0s", "csrf_enabled": false, "csp_enabled": true, diff --git a/src/cli/integration/testdata/status.golden b/src/cli/integration/testdata/status.golden index aa2bb08f22..84073a8bb2 100644 --- a/src/cli/integration/testdata/status.golden +++ b/src/cli/integration/testdata/status.golden @@ -23,6 +23,8 @@ "coin": "skycoin", "user_agent": "skycoin:0.25.0-rc1", "open_connections": 0, + "outgoing_connections": 0, + "incoming_connections": 0, "uptime": "0s", "csrf_enabled": false, "csp_enabled": true, diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index efe9f0a050..098fa447d0 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -25,14 +25,26 @@ import ( ) var ( - // ErrOutgoingConnectionsDisabled is returned if outgoing connections are disabled - ErrOutgoingConnectionsDisabled = errors.New("Outgoing connections are disabled") // ErrNetworkingDisabled is returned if networking is disabled ErrNetworkingDisabled = errors.New("Networking is disabled") logger = logging.MustGetLogger("daemon") ) +// IsBroadcastFailure returns true if an error indicates that a broadcast operation failed +func IsBroadcastFailure(err error) bool { + switch err { + case ErrNetworkingDisabled, + gnet.ErrPoolEmpty, + gnet.ErrNoMatchingConnections, + gnet.ErrNoReachableConnections, + gnet.ErrNoAddresses: + return true + default: + return false + } +} + const ( daemonRunDurationThreshold = time.Millisecond * 200 ) @@ -1233,6 +1245,10 @@ func (dm *Daemon) SendMessage(addr string, msg gnet.Message) error { // BroadcastMessage sends a Message to all introduced connections in the Pool func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled + } + conns := dm.connections.all() var addrs []string for _, c := range conns { diff --git a/src/skycoin/skycoin_test.go b/src/skycoin/skycoin_test.go index 835e92aaf0..0fc6042f9d 100644 --- a/src/skycoin/skycoin_test.go +++ b/src/skycoin/skycoin_test.go @@ -68,7 +68,7 @@ func getCoinName() string { func versionUpgradeWaitTimeout(t *testing.T) time.Duration { x := os.Getenv("VERSION_UPGRADE_TEST_WAIT_TIMEOUT") if x == "" { - return time.Second * 3 + return time.Second * 5 } d, err := time.ParseDuration(x) From efdae31443a9b351b6dcc1d349fd7dccec2bdaea Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Wed, 31 Oct 2018 14:56:56 -0400 Subject: [PATCH 365/399] [ci] refs #1996 - Install gcc@6 deps' binary bottles and gcc@6 itself from sources --- .travis.yml | 3 +-- ci-scripts/install-travis-gcc.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 ci-scripts/install-travis-gcc.sh diff --git a/.travis.yml b/.travis.yml index 7ea8650932..d0069cf5d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,8 +50,7 @@ install: - make install-linters # Install pinned golangci-lint, overriding the latest version install by make install-linters - VERSION=1.10.2 ./ci-scripts/install-golangci-lint.sh - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -qq g++-6 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; echo 'Available versions (gcc)' && brew list --versions gcc ; brew list gcc@6 &>/dev/null || brew install gcc@6 ; fi + - ./ci-scripts/install-travis-gcc.sh - make install-deps-libc - nvm install 8.11.0 - nvm use 8.11.0 diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh new file mode 100755 index 0000000000..b5a3ead170 --- /dev/null +++ b/ci-scripts/install-travis-gcc.sh @@ -0,0 +1,15 @@ + +# Install gcc6 (6.4.0-2 on Mac OS) for Travis builds + +if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + sudo apt-get install -qq g++-6 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90; +fi + +if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update + echo 'Available versions (gcc)' && brew list --versions gcc + brew list gcc@6 &>/dev/null || (echo "Install gcc6 deps" && (brew deps -n gcc@6 | xargs -I NAME bash -c 'brew install NAME') && echo "Install gcc@6 from sources" && HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc@6 ) +fi + +cd $TRAVIS_BUILD_DIR + From c2328b4231e4a0c3ae5a6be60a2d07169110ec6c Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Wed, 31 Oct 2018 17:41:18 -0400 Subject: [PATCH 366/399] [ci] refs #1996 - Check that dependencies are installed --- ci-scripts/install-travis-gcc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index b5a3ead170..f8de296a93 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -8,7 +8,7 @@ fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update echo 'Available versions (gcc)' && brew list --versions gcc - brew list gcc@6 &>/dev/null || (echo "Install gcc6 deps" && (brew deps -n gcc@6 | xargs -I NAME bash -c 'brew install NAME') && echo "Install gcc@6 from sources" && HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc@6 ) + brew list gcc@6 &>/dev/null || (echo "Install gcc6 deps" && (brew deps -n gcc@6 | xargs -I NAME bash -c 'brew list NAME &> /dev/null || brew install NAME') && echo "Install gcc@6 from sources" && HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc@6 ) fi cd $TRAVIS_BUILD_DIR From 898ce9abf9291e37aa4612b3cbfe4fc891bed4b7 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Wed, 31 Oct 2018 18:21:19 -0400 Subject: [PATCH 367/399] [ci] refs #1996 - Do not build for el Capitan . Try osx_image=xc ode8.3 --- .travis.yml | 2 +- ci-scripts/install-travis-gcc.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0069cf5d4..88f16553c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: - os: osx # Do not start osx build for PR if: type != pull_request - osx_image: xcode8 + osx_image: xcode8.3 env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=30s before_install: diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index f8de296a93..8e872ee1eb 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -8,7 +8,7 @@ fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update echo 'Available versions (gcc)' && brew list --versions gcc - brew list gcc@6 &>/dev/null || (echo "Install gcc6 deps" && (brew deps -n gcc@6 | xargs -I NAME bash -c 'brew list NAME &> /dev/null || brew install NAME') && echo "Install gcc@6 from sources" && HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc@6 ) + brew list gcc@6 &>/dev/null || brew install gcc@6 fi cd $TRAVIS_BUILD_DIR From 6a17cfd83f042303cb56dc6927ae298cf30420ec Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Wed, 31 Oct 2018 18:43:23 -0400 Subject: [PATCH 368/399] [ci] refs #1996 - Ensure gcc@6 formula is symlinked into /usr/local ... which failed at https://travis-ci.org/simelo/skycoin/jobs/449096254#L1659-L1679 --- ci-scripts/install-travis-gcc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index 8e872ee1eb..c894c2d01e 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -8,7 +8,7 @@ fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update echo 'Available versions (gcc)' && brew list --versions gcc - brew list gcc@6 &>/dev/null || brew install gcc@6 + brew list gcc@6 &>/dev/null || brew install gcc@6 || brew link --overwrite gcc@6 fi cd $TRAVIS_BUILD_DIR From d78f37add99d51b9939098764de5dfe7b907a159 Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 12:11:39 +0800 Subject: [PATCH 369/399] Send GIVP if peer list full --- CHANGELOG.md | 1 + src/daemon/daemon.go | 84 +++++++++++------- src/daemon/errors.go | 3 + src/daemon/messages.go | 41 ++------- src/daemon/messages_test.go | 33 ++++++- src/daemon/mock_daemoner_test.go | 53 +----------- src/daemon/pex/peerlist.go | 54 +++++++++++- src/daemon/pex/peerlist_test.go | 64 ++++++++++++++ src/daemon/pex/pex.go | 38 ++++++-- src/daemon/pex/pex_test.go | 144 +++++++++++++++++++++++++------ src/skycoin/config.go | 2 +- 11 files changed, 367 insertions(+), 150 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8de8b60e0..74c6c01b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/network/connection*` field `"connected_at"` added to connection object - `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction - `/api/v1/resendUnconfirmedTxns` is now a `POST` method, previously was a `GET` method +- Node will send more peers before disconnecting due to a full peer list ### Removed diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 098fa447d0..e777572330 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -232,12 +232,8 @@ type daemoner interface { Disconnect(addr string, r gnet.DisconnectReason) error DisconnectNow(addr string, r gnet.DisconnectReason) error PexConfig() pex.Config - RandomExchangeable(n int) pex.Peers - AddPeer(addr string) error AddPeers(addrs []string) int - SetHasIncomingPort(addr string) error IncreaseRetryTimes(addr string) - ResetRetryTimes(addr string) RecordPeerHeight(addr string, gnetID, height uint64) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) HeadBkSeq() (uint64, bool, error) @@ -250,10 +246,10 @@ type daemoner interface { BlockchainPubkey() cipher.PubKey RequestBlocksFromAddr(addr string) error AnnounceAllTxns() error - RecordUserAgent(addr string, userAgent useragent.Data) error recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) + sendRandomPeers(addr string) error } // Daemon stateful properties of the daemon @@ -829,15 +825,15 @@ func (dm *Daemon) onMessageEvent(e messageEvent) { return } - // The first message received must be an IntroductionMessage + // The first message received must be INTR, DISC or GIVP if !c.HasIntroduced() { switch e.Message.(type) { - case *IntroductionMessage, *DisconnectMessage: + case *IntroductionMessage, *DisconnectMessage, *GivePeersMessage: default: logger.WithFields(logrus.Fields{ "addr": e.Context.Addr, "messageType": fmt.Sprintf("%T", e.Message), - }).Info("needsIntro but first message is not INTR or DISC") + }).Info("needsIntro but first message is not INTR, DISC or GIVP") if err := dm.Disconnect(e.Context.Addr, ErrDisconnectNoIntroduction); err != nil { logger.WithError(err).WithField("addr", e.Context.Addr).Error("Disconnect") } @@ -1232,8 +1228,58 @@ func (dm *Daemon) BlockchainPubkey() cipher.PubKey { } // connectionIntroduced transfers a connection to the "introduced" state in the connections state machine +// and updates other state func (dm *Daemon) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) { - return dm.connections.introduced(addr, gnetID, m, userAgent) + c, err := dm.connections.introduced(addr, gnetID, m, userAgent) + if err != nil { + return nil, err + } + + listenAddr := c.ListenAddr() + + fields := logrus.Fields{ + "addr": addr, + "gnetID": m.c.ConnID, + "connGnetID": c.gnetID, + "listenPort": m.ListenPort, + "listenAddr": listenAddr, + } + + if c.Outgoing { + // For successful outgoing connections, mark the peer as having an incoming port in the pex peerlist + // The peer should already be in the peerlist, since we use the peerlist to choose an outgoing connection to make + if err := dm.pex.SetHasIncomingPort(listenAddr, true); err != nil { + logger.Critical().WithError(err).WithFields(fields).Error("pex.SetHasIncomingPort failed") + return nil, err + } + } else { + // For successful incoming connections, add the peer to the peer list, with their self-reported listen port + if err := dm.pex.AddPeer(listenAddr); err != nil { + logger.Critical().WithError(err).WithFields(fields).Error("pex.AddPeer failed") + return nil, err + } + } + + dm.pex.ResetRetryTimes(listenAddr) + + if err := dm.pex.SetUserAgent(listenAddr, c.UserAgent); err != nil { + logger.Critical().WithError(err).WithFields(fields).Error("pex.SetUserAgent failed") + return nil, err + } + + return c, nil +} + +// sendRandomPeers sends a random sample of peers to another peer +func (dm *Daemon) sendRandomPeers(addr string) error { + peers := dm.pex.RandomExchangeable(dm.pex.Config.ReplyCount) + if len(peers) == 0 { + logger.Debug("sendRandomPeers: no peers to send in reply") + return errors.New("No peers available") + } + + m := NewGivePeersMessage(peers) + return dm.SendMessage(addr, m) } // Implements pooler interface @@ -1279,36 +1325,16 @@ func (dm *Daemon) DisconnectNow(addr string, r gnet.DisconnectReason) error { // Implements pexer interface -// RandomExchangeable returns N random exchangeable peers -func (dm *Daemon) RandomExchangeable(n int) pex.Peers { - return dm.pex.RandomExchangeable(n) -} - // PexConfig returns the pex config func (dm *Daemon) PexConfig() pex.Config { return dm.pex.Config } -// AddPeer adds peer to the pex -func (dm *Daemon) AddPeer(addr string) error { - return dm.pex.AddPeer(addr) -} - // AddPeers adds peers to the pex func (dm *Daemon) AddPeers(addrs []string) int { return dm.pex.AddPeers(addrs) } -// SetHasIncomingPort sets the peer public peer -func (dm *Daemon) SetHasIncomingPort(addr string) error { - return dm.pex.SetHasIncomingPort(addr, true) -} - -// RecordUserAgent sets the peer's user agent -func (dm *Daemon) RecordUserAgent(addr string, userAgent useragent.Data) error { - return dm.pex.SetUserAgent(addr, userAgent) -} - // IncreaseRetryTimes increases the retry times of given peer func (dm *Daemon) IncreaseRetryTimes(addr string) { dm.pex.IncreaseRetryTimes(addr) diff --git a/src/daemon/errors.go b/src/daemon/errors.go index 691801ef46..b48080964f 100644 --- a/src/daemon/errors.go +++ b/src/daemon/errors.go @@ -37,6 +37,8 @@ var ( ErrDisconnectInvalidUserAgent gnet.DisconnectReason = errors.New("Invalid user agent") // ErrDisconnectRequestedByOperator the operator of the node requested a disconnect ErrDisconnectRequestedByOperator gnet.DisconnectReason = errors.New("Disconnect requested by the node operator") + // ErrDisconnectPeerlistFull the peerlist is full + ErrDisconnectPeerlistFull gnet.DisconnectReason = errors.New("Peerlist is full") // ErrDisconnectUnknownReason used when mapping an unknown reason code to an error. Is not sent over the network. ErrDisconnectUnknownReason gnet.DisconnectReason = errors.New("Unknown DisconnectReason") @@ -59,6 +61,7 @@ var ( ErrDisconnectReceivedDisconnect: 13, ErrDisconnectInvalidUserAgent: 14, ErrDisconnectRequestedByOperator: 15, + ErrDisconnectPeerlistFull: 16, // gnet codes are registered here, but they are not sent in a DISC // message by gnet. Only daemon sends a DISC packet. diff --git a/src/daemon/messages.go b/src/daemon/messages.go index cf65fd934a..7ce793b416 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -162,15 +162,8 @@ func (gpm *GetPeersMessage) process(d daemoner) { return } - peers := d.RandomExchangeable(d.PexConfig().ReplyCount) - if len(peers) == 0 { - logger.Debug("We have no peers to send in reply") - return - } - - m := NewGivePeersMessage(peers) - if err := d.SendMessage(gpm.addr, m); err != nil { - logger.WithField("addr", gpm.addr).WithError(err).Error("Send GivePeersMessage failed") + if err := d.sendRandomPeers(gpm.addr); err != nil { + logger.WithField("addr", gpm.addr).WithError(err).Error("SendRandomPeers failed") } } @@ -296,8 +289,7 @@ func (intro *IntroductionMessage) process(d daemoner) { return } - c, err := d.connectionIntroduced(addr, intro.c.ConnID, intro, userAgent) - if err != nil { + if _, err := d.connectionIntroduced(addr, intro.c.ConnID, intro, userAgent); err != nil { logger.WithError(err).WithFields(fields).Warning("connectionIntroduced failed") var reason gnet.DisconnectReason switch err { @@ -313,6 +305,12 @@ func (intro *IntroductionMessage) process(d daemoner) { return case ErrConnectionIPMirrorExists: reason = ErrDisconnectConnectedTwice + case pex.ErrPeerlistFull: + reason = ErrDisconnectPeerlistFull + // Send more peers before disconnecting + if err := d.sendRandomPeers(addr); err != nil { + logger.WithError(err).WithFields(fields).Warning("sendRandomPeers failed") + } default: reason = ErrDisconnectUnexpectedError } @@ -324,27 +322,6 @@ func (intro *IntroductionMessage) process(d daemoner) { return } - d.ResetRetryTimes(addr) - - listenAddr := c.ListenAddr() - - if c.Outgoing { - // For successful outgoing connections, mark the peer as having an incoming port in the pex peerlist - // The peer should already be in the peerlist, since we use the peerlist to choose an outgoing connection to make - if err := d.SetHasIncomingPort(listenAddr); err != nil { - logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("SetHasIncomingPort failed") - } - } else { - // For successful incoming connections, add the peer to the peer list, with their self-reported listen port - if err := d.AddPeer(listenAddr); err != nil { - logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("AddPeer failed") - } - } - - if err := d.RecordUserAgent(listenAddr, c.UserAgent); err != nil { - logger.WithError(err).WithFields(fields).WithField("listenAddr", listenAddr).Error("RecordUserAgent failed") - } - // Request blocks immediately after they're confirmed if err := d.RequestBlocksFromAddr(addr); err != nil { logger.WithError(err).WithFields(fields).Warning("RequestBlocksFromAddr") diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index a59c71b3dc..3d53c923d5 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -13,6 +13,7 @@ import ( "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/util/useragent" ) @@ -39,6 +40,7 @@ func TestIntroductionMessage(t *testing.T) { requestBlocksFromAddrErr error announceAllTxnsErr error recordUserAgentErr error + sendRandomPeersErr error } tt := []struct { @@ -256,6 +258,34 @@ func TestIntroductionMessage(t *testing.T) { ListenPort: 6000, }, }, + { + name: "incoming connection peer list full", + addr: "121.121.121.121:12345", + mockValue: daemonMockValue{ + mirror: 10000, + protocolVersion: 1, + pubkey: pubkey, + addPeerArg: "121.121.121.121:6000", + addPeerErr: pex.ErrPeerlistFull, + disconnectReason: ErrDisconnectPeerlistFull, + connectionIntroduced: &connection{ + Addr: "121.121.121.121:12345", + ConnectionDetails: ConnectionDetails{ + ListenPort: 6000, + UserAgent: useragent.Data{ + Coin: "skycoin", + Version: "0.24.1", + Remark: "foo", + }, + }, + }, + }, + intro: &IntroductionMessage{ + Mirror: 10001, + ProtocolVersion: 1, + ListenPort: 6000, + }, + }, { name: "Connect twice", addr: "121.121.121.121:6000", @@ -297,7 +327,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("Mirror").Return(tc.mockValue.mirror) d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) d.On("recordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) - d.On("ResetRetryTimes", tc.addr) + d.On("ResetRetryTimes", tc.mockValue.addPeerArg) d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) d.On("IncreaseRetryTimes", tc.addr) @@ -306,6 +336,7 @@ func TestIntroductionMessage(t *testing.T) { d.On("connectionIntroduced", tc.addr, tc.gnetID, tc.intro, mock.Anything).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) + d.On("SendRandomPeers", tc.addr).Return(tc.mockValue.sendRandomPeersErr) var userAgent useragent.Data if tc.mockValue.connectionIntroduced != nil { diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index e7b3c14947..9d16afb5c4 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -52,8 +52,8 @@ func (_m *mockDaemoner) recordMessageEvent(m asyncMessage, c *gnet.MessageContex return r0 } -// AddPeer provides a mock function with given fields: addr -func (_m *mockDaemoner) AddPeer(addr string) error { +// sendRandomPeers provides a mock function with given fields: addr +func (_m *mockDaemoner) sendRandomPeers(addr string) error { ret := _m.Called(addr) var r0 error @@ -340,41 +340,11 @@ func (_m *mockDaemoner) PexConfig() pex.Config { return r0 } -// RandomExchangeable provides a mock function with given fields: n -func (_m *mockDaemoner) RandomExchangeable(n int) pex.Peers { - ret := _m.Called(n) - - var r0 pex.Peers - if rf, ok := ret.Get(0).(func(int) pex.Peers); ok { - r0 = rf(n) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(pex.Peers) - } - } - - return r0 -} - // RecordPeerHeight provides a mock function with given fields: addr, gnetID, height func (_m *mockDaemoner) RecordPeerHeight(addr string, gnetID uint64, height uint64) { _m.Called(addr, gnetID, height) } -// RecordUserAgent provides a mock function with given fields: addr, userAgent -func (_m *mockDaemoner) RecordUserAgent(addr string, userAgent useragent.Data) error { - ret := _m.Called(addr, userAgent) - - var r0 error - if rf, ok := ret.Get(0).(func(string, useragent.Data) error); ok { - r0 = rf(addr, userAgent) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // RequestBlocksFromAddr provides a mock function with given fields: addr func (_m *mockDaemoner) RequestBlocksFromAddr(addr string) error { ret := _m.Called(addr) @@ -389,11 +359,6 @@ func (_m *mockDaemoner) RequestBlocksFromAddr(addr string) error { return r0 } -// ResetRetryTimes provides a mock function with given fields: addr -func (_m *mockDaemoner) ResetRetryTimes(addr string) { - _m.Called(addr) -} - // SendMessage provides a mock function with given fields: addr, msg func (_m *mockDaemoner) SendMessage(addr string, msg gnet.Message) error { ret := _m.Called(addr, msg) @@ -407,17 +372,3 @@ func (_m *mockDaemoner) SendMessage(addr string, msg gnet.Message) error { return r0 } - -// SetHasIncomingPort provides a mock function with given fields: addr -func (_m *mockDaemoner) SetHasIncomingPort(addr string) error { - ret := _m.Called(addr) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(addr) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index 2caa5625aa..639134feaa 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -118,6 +118,13 @@ func (pl *peerlist) addPeers(addrs []string) { } } +func (pl *peerlist) seen(addr string) { + if p, ok := pl.peers[addr]; ok && p != nil { + p.Seen() + p.ResetRetryTimes() + } +} + // getCanTryPeers returns all peers that are triable(retried times blew exponential backoff times) // and are able to pass the filters. func (pl *peerlist) getCanTryPeers(flts []Filter) Peers { @@ -250,12 +257,12 @@ func (pl *peerlist) getPeer(addr string) (Peer, bool) { return Peer{}, false } -// ClearOld removes public peers that haven't been seen in timeAgo seconds +// clearOld removes public, untrusted peers that haven't been seen in timeAgo seconds func (pl *peerlist) clearOld(timeAgo time.Duration) { t := time.Now().UTC() for addr, peer := range pl.peers { lastSeen := time.Unix(peer.LastSeen, 0) - if !peer.Private && t.Sub(lastSeen) > timeAgo { + if !peer.Private && !peer.Trusted && t.Sub(lastSeen) > timeAgo { delete(pl.peers, addr) } } @@ -323,6 +330,49 @@ func (pl *peerlist) resetAllRetryTimes() { } } +// findWorstPeer returns the a peer not seen in the longest time, if that time is over 1 day, +// else it returns a peer with the highest retry times, if the retry times are more than 0, +// else it returns nil +func (pl *peerlist) findWorstPeer() *Peer { + now := time.Now().UTC().Unix() + lastSeen := now + retries := 0 + var oldest *Peer + var mostRetries *Peer + + for _, p := range pl.peers { + if p.Trusted || p.Private { + continue + } + + if p.LastSeen < lastSeen { + lastSeen = p.LastSeen + oldest = p + } + + if p.RetryTimes > retries { + retries = p.RetryTimes + mostRetries = p + } + } + + if oldest == nil && mostRetries == nil { + return nil + } + + if oldest != nil && now-oldest.LastSeen > 60*60*24 { + p := *oldest + return &p + } + + if mostRetries != nil && mostRetries.RetryTimes > 0 { + p := *mostRetries + return &p + } + + return nil +} + // PeerJSON is for saving and loading peers to disk. Some fields are strange, // to be backwards compatible due to variable name changes type PeerJSON struct { diff --git a/src/daemon/pex/peerlist_test.go b/src/daemon/pex/peerlist_test.go index 58d8c7d336..21418062a8 100644 --- a/src/daemon/pex/peerlist_test.go +++ b/src/daemon/pex/peerlist_test.go @@ -330,6 +330,70 @@ func TestPeerListSetTrusted(t *testing.T) { } } +func TestPeerlistFindWorstPeer(t *testing.T) { + notOldPeer := Peer{ + Addr: "3.3.3.3:6060", + LastSeen: time.Now().UTC().Unix() - 60, + RetryTimes: 0, + } + oldPeer := Peer{ + Addr: "1.1.1.1:6060", + LastSeen: time.Now().UTC().Unix() - 60*60*24*2, + RetryTimes: 0, + } + retriedPeer := Peer{ + Addr: "2.2.2.2:6060", + LastSeen: time.Now().UTC().Unix() - 60, + RetryTimes: 1, + } + + cases := []struct { + name string + initPeers []Peer + expect *Peer + }{ + { + name: "empty peerlist", + initPeers: []Peer{}, + expect: nil, + }, + + { + name: "no worst peer", + initPeers: []Peer{ + notOldPeer, + }, + expect: nil, + }, + + { + name: "old peer", + initPeers: []Peer{ + oldPeer, + retriedPeer, + }, + expect: &oldPeer, + }, + + { + name: "retried peer", + initPeers: []Peer{ + notOldPeer, + retriedPeer, + }, + expect: &retriedPeer, + }, + } + + for _, tc := range cases { + pl := newPeerlist() + pl.setPeers(tc.initPeers) + + p := pl.findWorstPeer() + require.Equal(t, tc.expect, p) + } +} + func TestPeerlistClearOld(t *testing.T) { tt := []struct { name string diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index 228b342556..25f5e35ba3 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -135,7 +135,6 @@ func (peer *Peer) IncreaseRetryTimes() { // ResetRetryTimes resets the retry time func (peer *Peer) ResetRetryTimes() { peer.RetryTimes = 0 - logger.WithField("addr", peer.Addr).Debug("Reset retry times") } // CanTry returns whether this peer is tryable base on the exponential backoff algorithm @@ -197,7 +196,7 @@ type Config struct { func NewConfig() Config { return Config{ DataDirectory: "./", - Max: 1000, + Max: 65535, Expiration: time.Hour * 24 * 7, CullRate: time.Minute * 10, ClearOldRate: time.Minute * 10, @@ -303,9 +302,7 @@ func (px *Pex) Run() error { case <-clearOldTicker.C: // Remove peers we haven't seen in a while if !px.Config.Disabled && !px.Config.NetworkDisabled { - px.Lock() px.peerlist.clearOld(px.Config.Expiration) - px.Unlock() } case <-px.quit: return nil @@ -313,6 +310,12 @@ func (px *Pex) Run() error { } } +func (px *Pex) clearOld(since time.Duration) { + px.Lock() + defer px.Unlock() + px.peerlist.clearOld(since) +} + // Shutdown notifies the pex service to exist func (px *Pex) Shutdown() { logger.Info("Shutting down pex") @@ -419,7 +422,8 @@ func (px *Pex) save() error { } // AddPeer adds a peer to the peer list, given an address. If the peer list is -// full, PeerlistFullError is returned +// full, it will try to remove an old or unreachable peer to make room. +// If no room can be made, ErrPeerlistFull is returned func (px *Pex) AddPeer(addr string) error { px.Lock() defer px.Unlock() @@ -430,14 +434,28 @@ func (px *Pex) AddPeer(addr string) error { return ErrInvalidAddress } - if !px.peerlist.hasPeer(cleanAddr) { - if px.Config.Max > 0 && px.peerlist.len() >= px.Config.Max { + if px.peerlist.hasPeer(cleanAddr) { + px.peerlist.seen(cleanAddr) + return nil + } + + if px.isFull() { + worstPeer := px.peerlist.findWorstPeer() + if worstPeer == nil { return ErrPeerlistFull } - px.peerlist.addPeer(cleanAddr) + px.peerlist.removePeer(worstPeer.Addr) + + if px.isFull() { + // This should never happen, but if it does, don't return an error + // The max is a soft limit; exceeding the max will not crash the program. + // If this did occur, it is a bug that should be fixed + logger.Critical().Error("AddPeer: after removing the worst peer, the peerlist was still full") + } } + px.peerlist.addPeer(cleanAddr) return nil } @@ -627,6 +645,10 @@ func (px *Pex) ResetAllRetryTimes() { func (px *Pex) IsFull() bool { px.RLock() defer px.RUnlock() + return px.isFull() +} + +func (px *Pex) isFull() bool { return px.Config.Max > 0 && px.peerlist.len() >= px.Config.Max } diff --git a/src/daemon/pex/pex_test.go b/src/daemon/pex/pex_test.go index 1d1b36b173..6c00aeb817 100644 --- a/src/daemon/pex/pex_test.go +++ b/src/daemon/pex/pex_test.go @@ -377,40 +377,119 @@ func TestPexLoadPeers(t *testing.T) { } func TestPexAddPeer(t *testing.T) { + now := time.Now().UTC().Unix() + tt := []struct { - name string - peers []string - max int - peer string - err error + name string + peers []Peer + max int + finalLen int + peer string + err error + removedPeer string + check func(px *Pex) }{ { - "ok", - testPeers[:1], - 2, - testPeers[1], - nil, + name: "ok", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + }, + max: 2, + peer: testPeers[1], + err: nil, + finalLen: 2, }, { - "invalid peer", - testPeers[:1], - 2, - wrongPortPeer, - ErrInvalidAddress, + name: "invalid peer", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + }, + max: 2, + peer: wrongPortPeer, + err: ErrInvalidAddress, + finalLen: 1, }, { - "reach max", - testPeers[:2], - 2, - testPeers[3], - ErrPeerlistFull, + name: "peer known", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + { + Addr: testPeers[1], + LastSeen: now, + RetryTimes: 1, + }, + }, + max: 2, + peer: testPeers[1], + err: nil, + finalLen: 2, + check: func(px *Pex) { + p := px.peerlist.peers[testPeers[1]] + require.NotNil(t, p) + require.Equal(t, 0, p.RetryTimes) + require.True(t, p.LastSeen >= now) + }, }, { - "no max", - testPeers[:2], - 0, - testPeers[3], - nil, + name: "reach max", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + { + Addr: testPeers[1], + LastSeen: now, + }, + }, + max: 2, + peer: testPeers[3], + err: ErrPeerlistFull, + finalLen: 2, + }, + { + name: "reach max but kicked old peer", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + { + Addr: testPeers[1], + LastSeen: now - 60*60*24*2, + }, + }, + max: 2, + peer: testPeers[3], + err: nil, + finalLen: 2, + removedPeer: testPeers[1], + }, + { + name: "no max", + peers: []Peer{ + { + Addr: testPeers[0], + LastSeen: now, + }, + { + Addr: testPeers[1], + LastSeen: now, + }, + }, + max: 0, + peer: testPeers[3], + err: nil, + finalLen: 3, }, } @@ -424,14 +503,22 @@ func TestPexAddPeer(t *testing.T) { cfg := NewConfig() cfg.Max = tc.max cfg.DataDirectory = dir - cfg.DefaultConnections = tc.peers + cfg.DefaultConnections = []string{} // create px instance and load peers px, err := New(cfg) require.NoError(t, err) + px.peerlist.setPeers(tc.peers) + err = px.AddPeer(tc.peer) require.Equal(t, tc.err, err) + require.Equal(t, tc.finalLen, len(px.peerlist.peers)) + + if tc.check != nil { + tc.check(px) + } + if err != nil { return } @@ -439,6 +526,11 @@ func TestPexAddPeer(t *testing.T) { // check if the peer is in the peer list _, ok := px.peerlist.peers[tc.peer] require.True(t, ok) + + if tc.removedPeer != "" { + _, ok := px.peerlist.peers[tc.removedPeer] + require.False(t, ok) + } }) } } diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 06c356d00e..faea3da190 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -545,7 +545,7 @@ func (c *NodeConfig) RegisterFlags() { flag.IntVar(&c.MaxConnections, "max-connections", c.MaxConnections, "Maximum number of total connections allowed") flag.IntVar(&c.MaxOutgoingConnections, "max-outgoing-connections", c.MaxOutgoingConnections, "Maximum number of outgoing connections allowed") flag.IntVar(&c.MaxDefaultPeerOutgoingConnections, "max-default-peer-outgoing-connections", c.MaxDefaultPeerOutgoingConnections, "The maximum default peer outgoing connections allowed") - flag.IntVar(&c.PeerlistSize, "peerlist-size", c.PeerlistSize, "The peer list size") + flag.IntVar(&c.PeerlistSize, "peerlist-size", c.PeerlistSize, "Max number of peers to track in peerlist") flag.DurationVar(&c.OutgoingConnectionsRate, "connection-rate", c.OutgoingConnectionsRate, "How often to make an outgoing connection") flag.BoolVar(&c.LocalhostOnly, "localhost-only", c.LocalhostOnly, "Run on localhost and only connect to localhost peers") flag.BoolVar(&c.Arbitrating, "arbitrating", c.Arbitrating, "Run node in arbitrating mode") From bdd9e76ff89f5e2b470152dc60f28e1fe4f1e3c8 Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 14:18:25 +0800 Subject: [PATCH 370/399] Fixups --- src/daemon/daemon.go | 18 ++---- src/daemon/messages.go | 99 ++++++++++++++++++++++++-------- src/daemon/messages_test.go | 54 ----------------- src/daemon/mock_daemoner_test.go | 5 -- src/daemon/pex/peerlist.go | 30 ++-------- src/daemon/pex/peerlist_test.go | 76 +++++++++++++++--------- src/daemon/pex/pex.go | 6 +- src/daemon/pex/pex_test.go | 77 +++++++++++-------------- 8 files changed, 168 insertions(+), 197 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index e777572330..e17b3c9333 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -233,7 +233,6 @@ type daemoner interface { DisconnectNow(addr string, r gnet.DisconnectReason) error PexConfig() pex.Config AddPeers(addrs []string) int - IncreaseRetryTimes(addr string) RecordPeerHeight(addr string, gnetID, height uint64) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) HeadBkSeq() (uint64, bool, error) @@ -910,12 +909,12 @@ func (dm *Daemon) onDisconnectEvent(e DisconnectEvent) { case ErrDisconnectNoIntroduction, ErrDisconnectVersionNotSupported, ErrDisconnectSelf: - dm.IncreaseRetryTimes(e.Addr) - } - - switch e.Reason.Error() { - case "read failed: EOF": - dm.IncreaseRetryTimes(e.Addr) + dm.pex.IncreaseRetryTimes(e.Addr) + default: + switch e.Reason.Error() { + case "read failed: EOF": + dm.pex.IncreaseRetryTimes(e.Addr) + } } } @@ -1335,11 +1334,6 @@ func (dm *Daemon) AddPeers(addrs []string) int { return dm.pex.AddPeers(addrs) } -// IncreaseRetryTimes increases the retry times of given peer -func (dm *Daemon) IncreaseRetryTimes(addr string) { - dm.pex.IncreaseRetryTimes(addr) -} - // ResetRetryTimes reset the retry times of given peer func (dm *Daemon) ResetRetryTimes(addr string) { dm.pex.ResetRetryTimes(addr) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 7ce793b416..a3473961a1 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -209,8 +209,29 @@ func (gpm *GivePeersMessage) process(d daemoner) { if d.PexConfig().Disabled { return } + peers := gpm.GetPeers() - logger.Debugf("Got %d peers via PEX: %s", len(peers), strings.Join(peers, ", ")) + + if len(peers) == 0 { + return + } + + // Cap the number of peers printed in the log to prevent log spam abuse + peersToFmt := peers + if len(peersToFmt) > 1 { + peersToFmt = peersToFmt[:1] + } + peersStr := strings.Join(peersToFmt, ", ") + if len(peers) != len(peersToFmt) { + peersStr += fmt.Sprintf(" and %d more", len(peers)-len(peersToFmt)) + } + + logger.WithFields(logrus.Fields{ + "addr": gpm.c.Addr, + "gnetID": gpm.c.ConnID, + "peers": peersStr, + "count": len(peers), + }).Debug("Received peers via PEX") d.AddPeers(peers) } @@ -308,6 +329,7 @@ func (intro *IntroductionMessage) process(d daemoner) { case pex.ErrPeerlistFull: reason = ErrDisconnectPeerlistFull // Send more peers before disconnecting + logger.WithFields(fields).Debug("Sending peers before disconnecting due to peer list full") if err := d.sendRandomPeers(addr); err != nil { logger.WithError(err).WithFields(fields).Warning("sendRandomPeers failed") } @@ -338,30 +360,28 @@ func (intro *IntroductionMessage) process(d daemoner) { func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { addr := intro.c.Addr + fields := logrus.Fields{ + "addr": addr, + "gnetID": intro.c.ConnID, + } + // Disconnect if this is a self connection (we have the same mirror value) if intro.Mirror == d.Mirror() { - logger.WithFields(logrus.Fields{ - "addr": addr, - "mirror": intro.Mirror, - }).Info("Remote mirror value matches ours") + logger.WithFields(fields).WithField("mirror", intro.Mirror).Info("Remote mirror value matches ours") return nil, ErrDisconnectSelf } // Disconnect if peer version is not within the supported range dc := d.DaemonConfig() if intro.ProtocolVersion < dc.MinProtocolVersion { - logger.WithFields(logrus.Fields{ - "addr": addr, + logger.WithFields(fields).WithFields(logrus.Fields{ "protocolVersion": intro.ProtocolVersion, "minProtocolVersion": dc.MinProtocolVersion, }).Info("protocol version below minimum supported protocol version") return nil, ErrDisconnectVersionNotSupported } - logger.WithFields(logrus.Fields{ - "addr": addr, - "protocolVersion": intro.ProtocolVersion, - }).Debug("Peer protocol version accepted") + logger.WithFields(fields).WithField("protocolVersion", intro.ProtocolVersion).Debug("Peer protocol version accepted") // v24 does not send blockchain pubkey or user agent // v25 sends blockchain pubkey and user agent @@ -371,14 +391,13 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.WithField("addr", addr).Info("Extra data length does not meet the minimum requirement") + logger.WithFields(fields).Info("Extra data length does not meet the minimum requirement") return nil, ErrDisconnectInvalidExtraData } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) if d.BlockchainPubkey() != bcPubKey { - logger.WithFields(logrus.Fields{ - "addr": addr, + logger.WithFields(fields).WithFields(logrus.Fields{ "pubkey": bcPubKey.Hex(), "daemonPubkey": d.BlockchainPubkey().Hex(), }).Info("Blockchain pubkey does not match") @@ -388,13 +407,13 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { userAgentSerialized := intro.Extra[len(bcPubKey):] userAgent, _, err := encoder.DeserializeString(userAgentSerialized, useragent.MaxLen) if err != nil { - logger.WithError(err).Info("Extra data user agent string could not be deserialized") + logger.WithError(err).WithFields(fields).Info("Extra data user agent string could not be deserialized") return nil, ErrDisconnectInvalidExtraData } userAgentData, err = useragent.Parse(useragent.Sanitize(userAgent)) if err != nil { - logger.WithError(err).WithField("userAgent", userAgent).Info("User agent is invalid") + logger.WithError(err).WithFields(fields).WithField("userAgent", userAgent).Info("User agent is invalid") return nil, ErrDisconnectInvalidUserAgent } } @@ -415,11 +434,16 @@ func (ping *PingMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err // process Sends a PongMessage to the sender of PingMessage func (ping *PingMessage) process(d daemoner) { + fields := logrus.Fields{ + "addr": ping.c.Addr, + "gnetID": ping.c.ConnID, + } + if d.DaemonConfig().LogPings { - logger.WithField("addr", ping.c.Addr).Debug("Replying to ping") + logger.WithFields(fields).Debug("Replying to ping") } if err := d.SendMessage(ping.c.Addr, &PongMessage{}); err != nil { - logger.WithField("addr", ping.c.Addr).WithError(err).Error("Send PongMessage failed") + logger.WithFields(fields).WithError(err).Error("Send PongMessage failed") } } @@ -432,7 +456,10 @@ func (pong *PongMessage) Handle(mc *gnet.MessageContext, daemon interface{}) err // There is nothing to do; gnet updates Connection.LastMessage internally // when this is received if daemon.(*Daemon).Config.LogPings { - logger.WithField("addr", mc.Addr).Debug("Received pong") + logger.WithFields(logrus.Fields{ + "addr": mc.Addr, + "gnetID": mc.ConnID, + }).Debug("Received pong") } return nil } @@ -468,9 +495,11 @@ func (dm *DisconnectMessage) Handle(mc *gnet.MessageContext, daemon interface{}) func (dm *DisconnectMessage) process(d daemoner) { logger.WithFields(logrus.Fields{ "addr": dm.c.Addr, + "gnetID": dm.c.ConnID, "code": dm.ReasonCode, "reason": DisconnectCodeToReason(dm.ReasonCode), }).Infof("DisconnectMessage received") + if err := d.DisconnectNow(dm.c.Addr, ErrDisconnectReceivedDisconnect); err != nil { logger.WithError(err).WithField("addr", dm.c.Addr).Warning("DisconnectNow") } @@ -503,6 +532,11 @@ func (gbm *GetBlocksMessage) process(d daemoner) { return } + fields := logrus.Fields{ + "addr": gbm.c.Addr, + "gnetID": gbm.c.ConnID, + } + // Record this as this peer's highest block d.RecordPeerHeight(gbm.c.Addr, gbm.c.ConnID, gbm.LastBlock) // Fetch and return signed blocks since LastBlock @@ -516,11 +550,11 @@ func (gbm *GetBlocksMessage) process(d daemoner) { return } - logger.Debugf("Got %d blocks since %d", len(blocks), gbm.LastBlock) + logger.WithFields(fields).Debugf("Got %d blocks since %d", len(blocks), gbm.LastBlock) m := NewGiveBlocksMessage(blocks) if err := d.SendMessage(gbm.c.Addr, m); err != nil { - logger.WithField("addr", gbm.c.Addr).WithError(err).Error("Send GiveBlocksMessage failed") + logger.WithFields(fields).WithError(err).Error("Send GiveBlocksMessage failed") } } @@ -645,6 +679,11 @@ func (abm *AnnounceBlocksMessage) process(d daemoner) { return } + fields := logrus.Fields{ + "addr": abm.c.Addr, + "gnetID": abm.c.ConnID, + } + headBkSeq, ok, err := d.HeadBkSeq() if err != nil { logger.WithError(err).Error("AnnounceBlocksMessage Visor.HeadBkSeq failed") @@ -663,7 +702,7 @@ func (abm *AnnounceBlocksMessage) process(d daemoner) { // If client is not caught up, won't attempt to get block m := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) if err := d.SendMessage(abm.c.Addr, m); err != nil { - logger.WithError(err).WithField("addr", abm.c.Addr).Error("Send GetBlocksMessage") + logger.WithError(err).WithFields(fields).Error("Send GetBlocksMessage") } } @@ -702,9 +741,14 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { return } + fields := logrus.Fields{ + "addr": atm.c.Addr, + "gnetID": atm.c.ConnID, + } + unknown, err := d.GetUnconfirmedUnknown(atm.Transactions) if err != nil { - logger.WithField("addr", atm.c.Addr).WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") + logger.WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") return } @@ -714,7 +758,7 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { m := NewGetTxnsMessage(unknown) if err := d.SendMessage(atm.c.Addr, m); err != nil { - logger.WithField("addr", atm.c.Addr).WithError(err).Error("Send GetTxnsMessage failed") + logger.WithFields(fields).WithError(err).Error("Send GetTxnsMessage failed") } } @@ -743,6 +787,11 @@ func (gtm *GetTxnsMessage) process(d daemoner) { return } + fields := logrus.Fields{ + "addr": gtm.c.Addr, + "gnetID": gtm.c.ConnID, + } + // Locate all txns from the unconfirmed pool known, err := d.GetUnconfirmedKnown(gtm.Transactions) if err != nil { @@ -756,7 +805,7 @@ func (gtm *GetTxnsMessage) process(d daemoner) { // Reply to sender with GiveTxnsMessage m := NewGiveTxnsMessage(known) if err := d.SendMessage(gtm.c.Addr, m); err != nil { - logger.WithError(err).WithField("addr", gtm.c.Addr).Error("Send GiveTxnsMessage") + logger.WithError(err).WithFields(fields).Error("Send GiveTxnsMessage") } } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 3d53c923d5..9fef9c0f74 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -13,7 +13,6 @@ import ( "github.com/skycoin/skycoin/src/cipher/encoder" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon/gnet" - "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/util/useragent" ) @@ -28,19 +27,14 @@ func TestIntroductionMessage(t *testing.T) { protocolVersion uint32 minProtocolVersion uint32 mirror uint32 - setHasIncomingPortErr error recordMessageEventErr error pubkey cipher.PubKey disconnectReason gnet.DisconnectReason disconnectErr error - addPeerArg string - addPeerErr error connectionIntroduced *connection connectionIntroducedErr error requestBlocksFromAddrErr error announceAllTxnsErr error - recordUserAgentErr error - sendRandomPeersErr error } tt := []struct { @@ -64,8 +58,6 @@ func TestIntroductionMessage(t *testing.T) { Outgoing: true, }, }, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, }, intro: &IntroductionMessage{ Mirror: 10001, @@ -106,8 +98,6 @@ func TestIntroductionMessage(t *testing.T) { }, }, }, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, }, intro: &IntroductionMessage{ Mirror: 10001, @@ -133,8 +123,6 @@ func TestIntroductionMessage(t *testing.T) { }, }, }, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, }, intro: &IntroductionMessage{ Mirror: 10001, @@ -238,36 +226,6 @@ func TestIntroductionMessage(t *testing.T) { mirror: 10000, protocolVersion: 1, pubkey: pubkey, - addPeerArg: "121.121.121.121:6000", - addPeerErr: nil, - connectionIntroduced: &connection{ - Addr: "121.121.121.121:12345", - ConnectionDetails: ConnectionDetails{ - ListenPort: 6000, - UserAgent: useragent.Data{ - Coin: "skycoin", - Version: "0.24.1", - Remark: "foo", - }, - }, - }, - }, - intro: &IntroductionMessage{ - Mirror: 10001, - ProtocolVersion: 1, - ListenPort: 6000, - }, - }, - { - name: "incoming connection peer list full", - addr: "121.121.121.121:12345", - mockValue: daemonMockValue{ - mirror: 10000, - protocolVersion: 1, - pubkey: pubkey, - addPeerArg: "121.121.121.121:6000", - addPeerErr: pex.ErrPeerlistFull, - disconnectReason: ErrDisconnectPeerlistFull, connectionIntroduced: &connection{ Addr: "121.121.121.121:12345", ConnectionDetails: ConnectionDetails{ @@ -325,24 +283,12 @@ func TestIntroductionMessage(t *testing.T) { }, }) d.On("Mirror").Return(tc.mockValue.mirror) - d.On("SetHasIncomingPort", tc.addr).Return(tc.mockValue.setHasIncomingPortErr) d.On("recordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) - d.On("ResetRetryTimes", tc.mockValue.addPeerArg) d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) - d.On("IncreaseRetryTimes", tc.addr) - d.On("RemoveFromExpectingIntroductions", tc.addr) - d.On("AddPeer", tc.mockValue.addPeerArg).Return(tc.mockValue.addPeerErr) d.On("connectionIntroduced", tc.addr, tc.gnetID, tc.intro, mock.Anything).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) - d.On("SendRandomPeers", tc.addr).Return(tc.mockValue.sendRandomPeersErr) - - var userAgent useragent.Data - if tc.mockValue.connectionIntroduced != nil { - userAgent = tc.mockValue.connectionIntroduced.UserAgent - } - d.On("RecordUserAgent", tc.mockValue.addPeerArg, userAgent).Return(tc.mockValue.recordUserAgentErr) err := tc.intro.Handle(mc, d) require.NoError(t, err) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index 9d16afb5c4..64bdbc7bca 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -277,11 +277,6 @@ func (_m *mockDaemoner) HeadBkSeq() (uint64, bool, error) { return r0, r1, r2 } -// IncreaseRetryTimes provides a mock function with given fields: addr -func (_m *mockDaemoner) IncreaseRetryTimes(addr string) { - _m.Called(addr) -} - // InjectTransaction provides a mock function with given fields: txn func (_m *mockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { ret := _m.Called(txn) diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index 639134feaa..e1ee4966ae 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -187,7 +187,7 @@ func zeroRetryTimes(p Peer) bool { } // isExchangeable filters exchangeable peers -var isExchangeable = []Filter{hasIncomingPort, isPublic, zeroRetryTimes} +var isExchangeable = []Filter{hasIncomingPort, isPublic} // removePeer removes peer func (pl *peerlist) removePeer(addr string) { @@ -330,46 +330,24 @@ func (pl *peerlist) resetAllRetryTimes() { } } -// findWorstPeer returns the a peer not seen in the longest time, if that time is over 1 day, -// else it returns a peer with the highest retry times, if the retry times are more than 0, -// else it returns nil -func (pl *peerlist) findWorstPeer() *Peer { - now := time.Now().UTC().Unix() - lastSeen := now - retries := 0 +func (pl *peerlist) findOldestUntrustedPeer() *Peer { var oldest *Peer - var mostRetries *Peer for _, p := range pl.peers { if p.Trusted || p.Private { continue } - if p.LastSeen < lastSeen { - lastSeen = p.LastSeen + if oldest == nil || p.LastSeen < oldest.LastSeen { oldest = p } - - if p.RetryTimes > retries { - retries = p.RetryTimes - mostRetries = p - } - } - - if oldest == nil && mostRetries == nil { - return nil } - if oldest != nil && now-oldest.LastSeen > 60*60*24 { + if oldest != nil { p := *oldest return &p } - if mostRetries != nil && mostRetries.RetryTimes > 0 { - p := *mostRetries - return &p - } - return nil } diff --git a/src/daemon/pex/peerlist_test.go b/src/daemon/pex/peerlist_test.go index 21418062a8..a02d83beb2 100644 --- a/src/daemon/pex/peerlist_test.go +++ b/src/daemon/pex/peerlist_test.go @@ -330,21 +330,28 @@ func TestPeerListSetTrusted(t *testing.T) { } } -func TestPeerlistFindWorstPeer(t *testing.T) { - notOldPeer := Peer{ - Addr: "3.3.3.3:6060", - LastSeen: time.Now().UTC().Unix() - 60, - RetryTimes: 0, +func TestPeerlistFindOldestUntrustedPeer(t *testing.T) { + peer1 := Peer{ + Addr: "1.1.1.1:6060", + LastSeen: time.Now().UTC().Unix() - 60*60*24*2, } - oldPeer := Peer{ - Addr: "1.1.1.1:6060", - LastSeen: time.Now().UTC().Unix() - 60*60*24*2, - RetryTimes: 0, + peer2 := Peer{ + Addr: "2.2.2.2:6060", + LastSeen: time.Now().UTC().Unix() - 60*60*24*7, } - retriedPeer := Peer{ - Addr: "2.2.2.2:6060", - LastSeen: time.Now().UTC().Unix() - 60, - RetryTimes: 1, + peer3 := Peer{ + Addr: "3.3.3.3:6060", + LastSeen: time.Now().UTC().Unix() - 60, + } + trustedPeer := Peer{ + Addr: "4.4.4.4:6060", + LastSeen: time.Now().UTC().Unix() - 60*60*24*30, + Trusted: true, + } + privatePeer := Peer{ + Addr: "5.5.5.5:6060", + LastSeen: time.Now().UTC().Unix() - 60*60*24*30, + Private: true, } cases := []struct { @@ -359,38 +366,53 @@ func TestPeerlistFindWorstPeer(t *testing.T) { }, { - name: "no worst peer", + name: "no untrusted public peers", initPeers: []Peer{ - notOldPeer, + trustedPeer, + privatePeer, }, expect: nil, }, { - name: "old peer", + name: "one peer", initPeers: []Peer{ - oldPeer, - retriedPeer, + peer1, }, - expect: &oldPeer, + expect: &peer1, }, { - name: "retried peer", + name: "3 peers ignore trusted", initPeers: []Peer{ - notOldPeer, - retriedPeer, + peer1, + trustedPeer, + peer2, + peer3, }, - expect: &retriedPeer, + expect: &peer2, + }, + + { + name: "3 peers ignore private", + initPeers: []Peer{ + peer1, + privatePeer, + peer2, + peer3, + }, + expect: &peer2, }, } for _, tc := range cases { - pl := newPeerlist() - pl.setPeers(tc.initPeers) + t.Run(tc.name, func(t *testing.T) { + pl := newPeerlist() + pl.setPeers(tc.initPeers) - p := pl.findWorstPeer() - require.Equal(t, tc.expect, p) + p := pl.findOldestUntrustedPeer() + require.Equal(t, tc.expect, p) + }) } } diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index 25f5e35ba3..893647340f 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -440,12 +440,12 @@ func (px *Pex) AddPeer(addr string) error { } if px.isFull() { - worstPeer := px.peerlist.findWorstPeer() - if worstPeer == nil { + oldestPeer := px.peerlist.findOldestUntrustedPeer() + if oldestPeer == nil || time.Now().UTC().Unix()-oldestPeer.LastSeen < 60*60*24 { return ErrPeerlistFull } - px.peerlist.removePeer(worstPeer.Addr) + px.peerlist.removePeer(oldestPeer.Addr) if px.isFull() { // This should never happen, but if it does, don't return an error diff --git a/src/daemon/pex/pex_test.go b/src/daemon/pex/pex_test.go index 6c00aeb817..fd2294e5a9 100644 --- a/src/daemon/pex/pex_test.go +++ b/src/daemon/pex/pex_test.go @@ -424,7 +424,7 @@ func TestPexAddPeer(t *testing.T) { }, { Addr: testPeers[1], - LastSeen: now, + LastSeen: now - 60, RetryTimes: 1, }, }, @@ -436,7 +436,7 @@ func TestPexAddPeer(t *testing.T) { p := px.peerlist.peers[testPeers[1]] require.NotNil(t, p) require.Equal(t, 0, p.RetryTimes) - require.True(t, p.LastSeen >= now) + require.True(t, p.LastSeen > now-60) }, }, { @@ -680,94 +680,81 @@ func TestPexRandomExchangeable(t *testing.T) { expectPeers []Peer }{ { - "n=0 exchangeable=0", - []Peer{ + name: "n=0 exchangeable=0", + peers: []Peer{ Peer{Addr: testPeers[0], Private: true, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: true, HasIncomingPort: true}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 0, - 0, - []Peer{}, + n: 0, + expectN: 0, + expectPeers: []Peer{}, }, { - "n=0 exchangeable=1", - []Peer{ + name: "n=0 exchangeable=1", + peers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: true, HasIncomingPort: true}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 0, - 1, - []Peer{ + n: 0, + expectN: 1, + expectPeers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, }, }, { - "n=0 exchangeable=2", - []Peer{ + name: "n=0 exchangeable=2", + peers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 0, - 2, - []Peer{ + n: 0, + expectN: 2, + expectPeers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: false, HasIncomingPort: true}, }, }, { - "n=1 exchangeable=0", - []Peer{ + name: "n=1 exchangeable=0", + peers: []Peer{ Peer{Addr: testPeers[0], Private: true, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: true, HasIncomingPort: true}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 1, - 0, - []Peer{}, + n: 1, + expectN: 0, + expectPeers: []Peer{}, }, { - "n=1 exchangeable=1", - []Peer{ + name: "n=1 exchangeable=1", + peers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: false, HasIncomingPort: false}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 1, - 1, - []Peer{ + n: 1, + expectN: 1, + expectPeers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, }, }, { - "n=1 exchangeable=2", - []Peer{ + name: "n=1 exchangeable=2", + peers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, }, - 1, - 1, - []Peer{ + n: 1, + expectN: 1, + expectPeers: []Peer{ Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, Peer{Addr: testPeers[1], Private: false, HasIncomingPort: true}, }, }, - { - "n=2 exchangeable=1", - []Peer{ - Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, - Peer{Addr: testPeers[1], Private: false, HasIncomingPort: true, RetryTimes: 1}, - Peer{Addr: testPeers[2], Private: true, HasIncomingPort: true}, - }, - 2, - 1, - []Peer{ - Peer{Addr: testPeers[0], Private: false, HasIncomingPort: true}, - }, - }, } for _, tc := range tt { From 349d74791e1ab6f93b8fe2051bb59c4644895198 Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 14:33:39 +0800 Subject: [PATCH 371/399] Fixups --- src/daemon/daemon.go | 9 +++++++-- src/daemon/messages.go | 4 ++-- src/daemon/pex/peerlist.go | 1 - src/daemon/pex/pex_test.go | 7 +++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index e17b3c9333..2d77c9a53a 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "reflect" + "strings" "sync" "time" @@ -930,6 +931,10 @@ func (dm *Daemon) onConnectFailure(c ConnectFailureEvent) { if err := dm.connections.remove(c.Addr, 0); err != nil { logger.Critical().WithField("addr", c.Addr).WithError(err).Error("connections.remove") } + + if strings.HasSuffix(c.Error.Error(), "connect: connection refused") { + dm.pex.IncreaseRetryTimes(c.Addr) + } } // onGnetDisconnect triggered when a gnet.Connection terminates @@ -1259,13 +1264,13 @@ func (dm *Daemon) connectionIntroduced(addr string, gnetID uint64, m *Introducti } } - dm.pex.ResetRetryTimes(listenAddr) - if err := dm.pex.SetUserAgent(listenAddr, c.UserAgent); err != nil { logger.Critical().WithError(err).WithFields(fields).Error("pex.SetUserAgent failed") return nil, err } + dm.pex.ResetRetryTimes(listenAddr) + return c, nil } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index a3473961a1..a4722d874a 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -218,8 +218,8 @@ func (gpm *GivePeersMessage) process(d daemoner) { // Cap the number of peers printed in the log to prevent log spam abuse peersToFmt := peers - if len(peersToFmt) > 1 { - peersToFmt = peersToFmt[:1] + if len(peersToFmt) > 30 { + peersToFmt = peersToFmt[:30] } peersStr := strings.Join(peersToFmt, ", ") if len(peers) != len(peersToFmt) { diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index e1ee4966ae..c45a03f46f 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -121,7 +121,6 @@ func (pl *peerlist) addPeers(addrs []string) { func (pl *peerlist) seen(addr string) { if p, ok := pl.peers[addr]; ok && p != nil { p.Seen() - p.ResetRetryTimes() } } diff --git a/src/daemon/pex/pex_test.go b/src/daemon/pex/pex_test.go index fd2294e5a9..2ae724aa28 100644 --- a/src/daemon/pex/pex_test.go +++ b/src/daemon/pex/pex_test.go @@ -423,9 +423,8 @@ func TestPexAddPeer(t *testing.T) { LastSeen: now, }, { - Addr: testPeers[1], - LastSeen: now - 60, - RetryTimes: 1, + Addr: testPeers[1], + LastSeen: now - 60, }, }, max: 2, @@ -435,7 +434,7 @@ func TestPexAddPeer(t *testing.T) { check: func(px *Pex) { p := px.peerlist.peers[testPeers[1]] require.NotNil(t, p) - require.Equal(t, 0, p.RetryTimes) + // Peer should have been marked as seen require.True(t, p.LastSeen > now-60) }, }, From 5d1b002c6ae99f72147089052d075fbff5d5bf9b Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 14:36:31 +0800 Subject: [PATCH 372/399] Fixups --- src/daemon/pex/pex.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/daemon/pex/pex.go b/src/daemon/pex/pex.go index 893647340f..c794f1bf7c 100644 --- a/src/daemon/pex/pex.go +++ b/src/daemon/pex/pex.go @@ -302,7 +302,11 @@ func (px *Pex) Run() error { case <-clearOldTicker.C: // Remove peers we haven't seen in a while if !px.Config.Disabled && !px.Config.NetworkDisabled { - px.peerlist.clearOld(px.Config.Expiration) + func() { + px.Lock() + defer px.Unlock() + px.peerlist.clearOld(px.Config.Expiration) + }() } case <-px.quit: return nil @@ -310,12 +314,6 @@ func (px *Pex) Run() error { } } -func (px *Pex) clearOld(since time.Duration) { - px.Lock() - defer px.Unlock() - px.peerlist.clearOld(since) -} - // Shutdown notifies the pex service to exist func (px *Pex) Shutdown() { logger.Info("Shutting down pex") @@ -422,7 +420,7 @@ func (px *Pex) save() error { } // AddPeer adds a peer to the peer list, given an address. If the peer list is -// full, it will try to remove an old or unreachable peer to make room. +// full, it will try to remove an old peer to make room. // If no room can be made, ErrPeerlistFull is returned func (px *Pex) AddPeer(addr string) error { px.Lock() @@ -448,9 +446,10 @@ func (px *Pex) AddPeer(addr string) error { px.peerlist.removePeer(oldestPeer.Addr) if px.isFull() { - // This should never happen, but if it does, don't return an error + // This can happen if the node is run with a peers.json file that has more peers + // than the max peerlist size, then the peers.json file isn't truncated to the max peerlist size. + // It is not an error. // The max is a soft limit; exceeding the max will not crash the program. - // If this did occur, it is a bug that should be fixed logger.Critical().Error("AddPeer: after removing the worst peer, the peerlist was still full") } } From 59630baeca203ebd48902f3f516c8bc1d0383152 Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 15:03:54 +0800 Subject: [PATCH 373/399] FIxups --- src/daemon/pex/peerlist.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/daemon/pex/peerlist.go b/src/daemon/pex/peerlist.go index c45a03f46f..97588189bf 100644 --- a/src/daemon/pex/peerlist.go +++ b/src/daemon/pex/peerlist.go @@ -181,10 +181,6 @@ func canTry(p Peer) bool { return p.CanTry() } -func zeroRetryTimes(p Peer) bool { - return p.RetryTimes == 0 -} - // isExchangeable filters exchangeable peers var isExchangeable = []Filter{hasIncomingPort, isPublic} From 8b573618e9d145e83edb99f13e0f0519470cc244 Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 16:56:04 +0800 Subject: [PATCH 374/399] Move visor parameters to params package and parameterize burn factor --- cmd/newcoin/newcoin.go | 27 ++++----- fiber.toml | 3 +- src/api/explorer.go | 14 ++--- src/api/explorer_test.go | 15 ++--- src/api/health.go | 4 +- src/api/integration/integration_test.go | 9 +-- src/api/spend.go | 4 +- src/cli/create_rawtx.go | 3 +- src/daemon/gateway.go | 5 +- src/params/distribution.go | 41 +++++++++++++ src/params/distribution_test.go | 57 ++++++++++++++++++ src/params/droplet.go | 43 ++++++++++++++ src/params/droplet_test.go | 37 ++++++++++++ src/params/init.go | 52 +++++++++++++++++ src/{visor/parameters.go => params/params.go} | 13 ++++- src/skycoin/parameters.go | 30 ++++++---- src/skycoin/parameters_test.go | 3 +- src/skycoin/skycoin.go | 12 ++-- src/skycoin/testdata/test.fiber.toml | 3 + src/util/fee/fee.go | 35 ++--------- src/util/fee/fee_test.go | 21 +++---- src/visor/blockchain_verify_test.go | 25 ++++---- src/visor/distribution.go | 52 +---------------- src/visor/distribution_test.go | 55 +----------------- src/visor/verify.go | 3 +- src/visor/visor.go | 58 +------------------ src/visor/visor_test.go | 48 ++++----------- src/wallet/wallet_test.go | 15 ++--- template/{visor.template => params.template} | 13 ++++- 29 files changed, 381 insertions(+), 319 deletions(-) create mode 100644 src/params/distribution.go create mode 100644 src/params/distribution_test.go create mode 100644 src/params/droplet.go create mode 100644 src/params/droplet_test.go create mode 100644 src/params/init.go rename src/{visor/parameters.go => params/params.go} (93%) rename template/{visor.template => params.template} (79%) diff --git a/cmd/newcoin/newcoin.go b/cmd/newcoin/newcoin.go index dec3e083a9..64fd1d1342 100644 --- a/cmd/newcoin/newcoin.go +++ b/cmd/newcoin/newcoin.go @@ -93,9 +93,9 @@ func createCoinCommand() cli.Command { Value: "coin_test.template", }, cli.StringFlag{ - Name: "visor-template-file, vt", - Usage: "visor template file", - Value: "visor.template", + Name: "params-template-file, pt", + Usage: "params template file", + Value: "params.template", }, cli.StringFlag{ Name: "config-dir, cd", @@ -121,7 +121,7 @@ func createCoinCommand() cli.Command { coinTemplateFile := c.String("coin-template-file") coinTestTemplateFile := c.String("coin-test-template-file") - visorTemplateFile := c.String("visor-template-file") + paramsTemplateFile := c.String("params-template-file") // check that the coin template file exists if _, err := os.Stat(filepath.Join(templateDir, coinTemplateFile)); os.IsNotExist(err) { @@ -131,8 +131,8 @@ func createCoinCommand() cli.Command { if _, err := os.Stat(filepath.Join(templateDir, coinTestTemplateFile)); os.IsNotExist(err) { return err } - // check that the visor template file exists - if _, err := os.Stat(filepath.Join(templateDir, visorTemplateFile)); os.IsNotExist(err) { + // check that the params template file exists + if _, err := os.Stat(filepath.Join(templateDir, paramsTemplateFile)); os.IsNotExist(err) { return err } @@ -145,7 +145,7 @@ func createCoinCommand() cli.Command { return err } - // -- parse template and create new coin.go and visor parameters.go -- // + // -- parse template and create new coin.go and config blockchain.go -- // config, err := skycoin.NewParameters(configFile, configDir) if err != nil { @@ -179,12 +179,13 @@ func createCoinCommand() cli.Command { } defer coinTestFile.Close() - visorParamsFile, err := os.Create("./src/visor/parameters.go") + paramsFilePath := "./src/params/params.go" + paramsFile, err := os.Create(paramsFilePath) if err != nil { - log.Errorf("failed to create new visor parameters.go") + log.Errorf("failed to create new file %s", paramsFilePath) return err } - defer visorParamsFile.Close() + defer paramsFile.Close() // change dir so that text/template can parse the file err = os.Chdir(templateDir) @@ -196,7 +197,7 @@ func createCoinCommand() cli.Command { templateFiles := []string{ coinTemplateFile, coinTestTemplateFile, - visorTemplateFile, + paramsTemplateFile, } t := template.New(coinTemplateFile) @@ -231,9 +232,9 @@ func createCoinCommand() cli.Command { return err } - err = t.ExecuteTemplate(visorParamsFile, visorTemplateFile, config.Visor) + err = t.ExecuteTemplate(paramsFile, paramsTemplateFile, config.Params) if err != nil { - log.Error("failed to parse visor params template variables") + log.Error("failed to parse params template variables") return err } diff --git a/fiber.toml b/fiber.toml index b9fd846120..25dfbb286d 100644 --- a/fiber.toml +++ b/fiber.toml @@ -21,7 +21,7 @@ peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" #port = 6000 #web_interface_port = 6420 -[visor] +[params] #max_coin_supply = 1e8 #distribution_addresses_total = 100 #initial_unlocked_count = 25 @@ -29,6 +29,7 @@ peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" #unlocked_time_internal = 60 * 60 * 24 * 365 #max_droplet_precision = 3 #default_max_block_size = 32 * 1024 +#coinhour_burn_factor = 2 distribution_addresses = [ "R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ", "2EYM4WFHe4Dgz6kjAdUkM6Etep7ruz2ia6h", diff --git a/src/api/explorer.go b/src/api/explorer.go index f48c99e6cf..3fd70e9885 100644 --- a/src/api/explorer.go +++ b/src/api/explorer.go @@ -7,10 +7,10 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/droplet" wh "github.com/skycoin/skycoin/src/util/http" - "github.com/skycoin/skycoin/src/visor" ) // CoinSupply records the coin supply info @@ -57,7 +57,7 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { return } - unlockedAddrs := visor.GetUnlockedDistributionAddresses() + unlockedAddrs := params.GetUnlockedDistributionAddresses() // Search map of unlocked addresses // used to filter unspents unlockedAddrSet := newStringSet(unlockedAddrs) @@ -78,8 +78,8 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { } // "total supply" is the number of coins unlocked. - // Each distribution address was allocated visor.DistributionAddressInitialBalance coins. - totalSupply := uint64(len(unlockedAddrs)) * visor.DistributionAddressInitialBalance + // Each distribution address was allocated params.DistributionAddressInitialBalance coins. + totalSupply := uint64(len(unlockedAddrs)) * params.DistributionAddressInitialBalance totalSupply *= droplet.Multiplier // "current supply" is the number of coins distributed from the unlocked pool @@ -99,7 +99,7 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { return } - maxSupplyStr, err := droplet.ToString(visor.MaxCoinSupply * droplet.Multiplier) + maxSupplyStr, err := droplet.ToString(params.MaxCoinSupply * droplet.Multiplier) if err != nil { err = fmt.Errorf("Failed to convert coins to string: %v", err) wh.Error500(w, err.Error()) @@ -107,7 +107,7 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { } // locked distribution addresses - lockedAddrs := visor.GetLockedDistributionAddresses() + lockedAddrs := params.GetLockedDistributionAddresses() lockedAddrSet := newStringSet(lockedAddrs) // get total coins hours which excludes locked distribution addresses @@ -149,7 +149,7 @@ func coinSupplyHandler(gateway Gatewayer) http.HandlerFunc { CurrentCoinHourSupply: strconv.FormatUint(currentCoinHours, 10), TotalCoinHourSupply: strconv.FormatUint(totalCoinHours, 10), UnlockedAddresses: unlockedAddrs, - LockedAddresses: visor.GetLockedDistributionAddresses(), + LockedAddresses: params.GetLockedDistributionAddresses(), } wh.SendJSONOr500(logger, w, cs) diff --git a/src/api/explorer_test.go b/src/api/explorer_test.go index 88f35764ed..100c2398a1 100644 --- a/src/api/explorer_test.go +++ b/src/api/explorer_test.go @@ -15,6 +15,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/util/droplet" @@ -22,7 +23,7 @@ import ( ) func makeSuccessCoinSupplyResult(t *testing.T, allUnspents readable.UnspentOutputsSummary) *CoinSupply { - unlockedAddrs := visor.GetUnlockedDistributionAddresses() + unlockedAddrs := params.GetUnlockedDistributionAddresses() var unlockedSupply uint64 // check confirmed unspents only // Search map of unlocked addresses @@ -37,8 +38,8 @@ func makeSuccessCoinSupplyResult(t *testing.T, allUnspents readable.UnspentOutpu } } // "total supply" is the number of coins unlocked. - // Each distribution address was allocated visor.DistributionAddressInitialBalance coins. - totalSupply := uint64(len(unlockedAddrs)) * visor.DistributionAddressInitialBalance + // Each distribution address was allocated params.DistributionAddressInitialBalance coins. + totalSupply := uint64(len(unlockedAddrs)) * params.DistributionAddressInitialBalance totalSupply *= droplet.Multiplier // "current supply" is the number of coins distribution from the unlocked pool @@ -50,11 +51,11 @@ func makeSuccessCoinSupplyResult(t *testing.T, allUnspents readable.UnspentOutpu totalSupplyStr, err := droplet.ToString(totalSupply) require.NoError(t, err) - maxSupplyStr, err := droplet.ToString(visor.MaxCoinSupply * droplet.Multiplier) + maxSupplyStr, err := droplet.ToString(params.MaxCoinSupply * droplet.Multiplier) require.NoError(t, err) // locked distribution addresses - lockedAddrs := visor.GetLockedDistributionAddresses() + lockedAddrs := params.GetLockedDistributionAddresses() lockedAddrSet := newStringSet(lockedAddrs) // get total coins hours which excludes locked distribution addresses @@ -84,7 +85,7 @@ func makeSuccessCoinSupplyResult(t *testing.T, allUnspents readable.UnspentOutpu CurrentCoinHourSupply: strconv.FormatUint(currentCoinHours, 10), TotalCoinHourSupply: strconv.FormatUint(totalCoinHours, 10), UnlockedAddresses: unlockedAddrs, - LockedAddresses: visor.GetLockedDistributionAddresses(), + LockedAddresses: params.GetLockedDistributionAddresses(), } return &cs } @@ -247,7 +248,7 @@ func TestGetTransactionsForAddress(t *testing.T) { } func TestCoinSupply(t *testing.T) { - unlockedAddrs := visor.GetUnlockedDistributionAddresses() + unlockedAddrs := params.GetUnlockedDistributionAddresses() successGatewayGetUnspentOutputsResult := readable.UnspentOutputsSummary{ HeadOutputs: readable.UnspentOutputs{ readable.UnspentOutput{ diff --git a/src/api/health.go b/src/api/health.go index e71c4bf318..c961839ab9 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -5,8 +5,8 @@ import ( "net/http" "time" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" - "github.com/skycoin/skycoin/src/util/fee" wh "github.com/skycoin/skycoin/src/util/http" ) @@ -81,7 +81,7 @@ func healthHandler(c muxConfig, csrfStore *CSRFStore, gateway Gatewayer) http.Ha GUIEnabled: c.enableGUI, JSON20RPCEnabled: c.enableJSON20RPC, WalletAPIEnabled: walletAPIEnabled, - BurnFactor: fee.BurnFactor, + BurnFactor: params.CoinHourBurnFactor, }) } } diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 257be27e4c..1d7ba6c9f8 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -28,6 +28,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/util/droplet" @@ -4653,9 +4654,9 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { tLog(t, "spendableHours", spendableHours) coins := rand.Intn(int(totalCoins)) + 1 - coins -= coins % int(visor.MaxDropletDivisor()) + coins -= coins % int(params.MaxDropletDivisor()) if coins == 0 { - coins = int(visor.MaxDropletDivisor()) + coins = int(params.MaxDropletDivisor()) } hours := rand.Intn(int(spendableHours + 1)) nOutputs := rand.Intn(maxOutputs) + 1 @@ -4690,9 +4691,9 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { remainingHours = 0 } else { receiverCoins := rand.Intn(remainingCoins) + 1 - receiverCoins -= receiverCoins % int(visor.MaxDropletDivisor()) + receiverCoins -= receiverCoins % int(params.MaxDropletDivisor()) if receiverCoins == 0 { - receiverCoins = int(visor.MaxDropletDivisor()) + receiverCoins = int(params.MaxDropletDivisor()) } var err error diff --git a/src/api/spend.go b/src/api/spend.go index 3e47a94a6f..4cff7e64c5 100644 --- a/src/api/spend.go +++ b/src/api/spend.go @@ -12,10 +12,10 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/util/droplet" "github.com/skycoin/skycoin/src/util/fee" wh "github.com/skycoin/skycoin/src/util/http" - "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/blockdb" "github.com/skycoin/skycoin/src/wallet" ) @@ -369,7 +369,7 @@ func (r createTransactionRequest) Validate() error { return fmt.Errorf("to[%d].coins must not be zero", i) } - if to.Coins.Value()%visor.MaxDropletDivisor() != 0 { + if to.Coins.Value()%params.MaxDropletDivisor() != 0 { return fmt.Errorf("to[%d].coins has too many decimal places", i) } } diff --git a/src/cli/create_rawtx.go b/src/cli/create_rawtx.go index c8bfb25e55..20913468b3 100644 --- a/src/cli/create_rawtx.go +++ b/src/cli/create_rawtx.go @@ -9,6 +9,7 @@ import ( "os" "strings" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/droplet" "github.com/skycoin/skycoin/src/util/fee" @@ -539,7 +540,7 @@ func CreateRawTx(c GetOutputser, wlt *wallet.Wallet, inAddrs []string, chgAddr s return nil, err } - if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, visor.DefaultMaxBlockSize); err != nil { + if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.DefaultMaxBlockSize); err != nil { return nil, err } if err := visor.VerifySingleTxnHardConstraints(*txn, head, inUxsFiltered); err != nil { diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index bd9f8ed5a1..04fb1098b6 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -12,6 +12,7 @@ import ( "github.com/skycoin/skycoin/src/daemon/gnet" "github.com/skycoin/skycoin/src/daemon/pex" "github.com/skycoin/skycoin/src/daemon/strand" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/dbutil" "github.com/skycoin/skycoin/src/visor/historydb" @@ -881,7 +882,7 @@ func (gw *Gateway) GetRichlist(includeDistribution bool) (visor.Richlist, error) } } - lockedAddrs := visor.GetLockedDistributionAddresses() + lockedAddrs := params.GetLockedDistributionAddresses() addrsMap := make(map[string]struct{}, len(lockedAddrs)) for _, a := range lockedAddrs { addrsMap[a] = struct{}{} @@ -893,7 +894,7 @@ func (gw *Gateway) GetRichlist(includeDistribution bool) (visor.Richlist, error) } if !includeDistribution { - unlockedAddrs := visor.GetUnlockedDistributionAddresses() + unlockedAddrs := params.GetUnlockedDistributionAddresses() for _, a := range unlockedAddrs { addrsMap[a] = struct{}{} } diff --git a/src/params/distribution.go b/src/params/distribution.go new file mode 100644 index 0000000000..5e13a410a2 --- /dev/null +++ b/src/params/distribution.go @@ -0,0 +1,41 @@ +package params + +// GetDistributionAddresses returns a copy of the hardcoded distribution addresses array. +// Each address has 1,000,000 coins. There are 100 addresses. +func GetDistributionAddresses() []string { + addrs := make([]string, len(distributionAddresses)) + for i := range distributionAddresses { + addrs[i] = distributionAddresses[i] + } + return addrs +} + +// GetUnlockedDistributionAddresses returns distribution addresses that are unlocked, i.e. they have spendable outputs +func GetUnlockedDistributionAddresses() []string { + // The first InitialUnlockedCount (25) addresses are unlocked by default. + // Subsequent addresses will be unlocked at a rate of UnlockAddressRate (5) per year, + // after the InitialUnlockedCount (25) addresses have no remaining balance. + // The unlock timer will be enabled manually once the + // InitialUnlockedCount (25) addresses are distributed. + + // NOTE: To have automatic unlocking, transaction verification would have + // to be handled in visor rather than in coin.Transactions.Visor(), because + // the coin package is agnostic to the state of the blockchain and cannot reference it. + // Instead of automatic unlocking, we can hardcode the timestamp at which the first 30% + // is distributed, then compute the unlocked addresses easily here. + + addrs := make([]string, InitialUnlockedCount) + copy(addrs[:], distributionAddresses[:InitialUnlockedCount]) + return addrs +} + +// GetLockedDistributionAddresses returns distribution addresses that are locked, i.e. they have unspendable outputs +func GetLockedDistributionAddresses() []string { + // TODO -- once we reach 30% distribution, we can hardcode the + // initial timestamp for releasing more coins + addrs := make([]string, DistributionAddressesTotal-InitialUnlockedCount) + for i := range distributionAddresses[InitialUnlockedCount:] { + addrs[i] = distributionAddresses[InitialUnlockedCount+uint64(i)] + } + return addrs +} diff --git a/src/params/distribution_test.go b/src/params/distribution_test.go new file mode 100644 index 0000000000..c7997c7bdd --- /dev/null +++ b/src/params/distribution_test.go @@ -0,0 +1,57 @@ +package params + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDistributionAddressArrays(t *testing.T) { + require.Len(t, GetDistributionAddresses(), 100) + + // At the time of this writing, there should be 25 addresses in the + // unlocked pool and 75 in the locked pool. + require.Len(t, GetUnlockedDistributionAddresses(), 25) + require.Len(t, GetLockedDistributionAddresses(), 75) + + all := GetDistributionAddresses() + allMap := make(map[string]struct{}) + for _, a := range all { + // Check no duplicate address in distribution addresses + _, ok := allMap[a] + require.False(t, ok) + allMap[a] = struct{}{} + } + + unlocked := GetUnlockedDistributionAddresses() + unlockedMap := make(map[string]struct{}) + for _, a := range unlocked { + // Check no duplicate address in unlocked addresses + _, ok := unlockedMap[a] + require.False(t, ok) + + // Check unlocked address in set of all addresses + _, ok = allMap[a] + require.True(t, ok) + + unlockedMap[a] = struct{}{} + } + + locked := GetLockedDistributionAddresses() + lockedMap := make(map[string]struct{}) + for _, a := range locked { + // Check no duplicate address in locked addresses + _, ok := lockedMap[a] + require.False(t, ok) + + // Check locked address in set of all addresses + _, ok = allMap[a] + require.True(t, ok) + + // Check locked address not in unlocked addresses + _, ok = unlockedMap[a] + require.False(t, ok) + + lockedMap[a] = struct{}{} + } +} diff --git a/src/params/droplet.go b/src/params/droplet.go new file mode 100644 index 0000000000..fe06ffc8ba --- /dev/null +++ b/src/params/droplet.go @@ -0,0 +1,43 @@ +package params + +import ( + "errors" + + "github.com/skycoin/skycoin/src/util/droplet" +) + +var ( + // ErrInvalidDecimals is returned by DropletPrecisionCheck if a coin amount has an invalid number of decimal places + ErrInvalidDecimals = errors.New("invalid amount, too many decimal places") + + // maxDropletDivisor represents the modulus divisor when checking droplet precision rules. + // It is computed from MaxDropletPrecision in init() + maxDropletDivisor uint64 +) + +// MaxDropletDivisor represents the modulus divisor when checking droplet precision rules. +func MaxDropletDivisor() uint64 { + // The value is wrapped in a getter to make it immutable to external packages + return maxDropletDivisor +} + +// DropletPrecisionCheck checks if an amount of coins is valid given decimal place restrictions +func DropletPrecisionCheck(amount uint64) error { + if amount%maxDropletDivisor != 0 { + return ErrInvalidDecimals + } + return nil +} + +func calculateDivisor(precision uint64) uint64 { + if precision > droplet.Exponent { + panic("precision must be <= droplet.Exponent") + } + + n := droplet.Exponent - precision + var i uint64 = 1 + for k := uint64(0); k < n; k++ { + i = i * 10 + } + return i +} diff --git a/src/params/droplet_test.go b/src/params/droplet_test.go new file mode 100644 index 0000000000..7e63e56923 --- /dev/null +++ b/src/params/droplet_test.go @@ -0,0 +1,37 @@ +package params + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + _require "github.com/skycoin/skycoin/src/testutil/require" +) + +func TestCalculateDivisor(t *testing.T) { + cases := []struct { + precision uint64 + divisor uint64 + }{ + {0, 1e6}, + {1, 1e5}, + {2, 1e4}, + {3, 1e3}, + {4, 1e2}, + {5, 1e1}, + {6, 1}, + } + + for _, tc := range cases { + name := fmt.Sprintf("calculateDivisor(%d)=%d", tc.precision, tc.divisor) + t.Run(name, func(t *testing.T) { + divisor := calculateDivisor(tc.precision) + require.Equal(t, tc.divisor, divisor, "%d != %d", tc.divisor, divisor) + }) + } + + _require.PanicsWithLogMessage(t, "precision must be <= droplet.Exponent", func() { + calculateDivisor(7) + }) +} diff --git a/src/params/init.go b/src/params/init.go new file mode 100644 index 0000000000..d4a632feb3 --- /dev/null +++ b/src/params/init.go @@ -0,0 +1,52 @@ +package params + +import ( + "fmt" + "os" + "strconv" +) + +func init() { + loadCoinHourBurnFactor() + + // Compute maxDropletDivisor from precision + maxDropletDivisor = calculateDivisor(MaxDropletPrecision) + + sanityCheck() +} + +func sanityCheck() { + if InitialUnlockedCount > DistributionAddressesTotal { + panic("unlocked addresses > total distribution addresses") + } + + if uint64(len(distributionAddresses)) != DistributionAddressesTotal { + panic("available distribution addresses > total allowed distribution addresses") + } + + if DistributionAddressInitialBalance*DistributionAddressesTotal > MaxCoinSupply { + panic("total balance in distribution addresses > max coin supply") + } + + if MaxCoinSupply%DistributionAddressesTotal != 0 { + panic("MaxCoinSupply should be perfectly divisible by DistributionAddressesTotal") + } +} + +func loadCoinHourBurnFactor() { + xs := os.Getenv("COINHOUR_BURN_FACTOR") + if xs == "" { + return + } + + x, err := strconv.ParseUint(xs, 10, 64) + if err != nil { + panic(fmt.Sprintf("Invalid COINHOUR_BURN_FACTOR %q: %v", xs, err)) + } + + if x <= 1 { + panic(fmt.Sprintf("CoinHourBurnFactor must be > 1")) + } + + CoinHourBurnFactor = x +} diff --git a/src/visor/parameters.go b/src/params/params.go similarity index 93% rename from src/visor/parameters.go rename to src/params/params.go index c3ca8d3c99..d57feb9b00 100644 --- a/src/visor/parameters.go +++ b/src/params/params.go @@ -1,4 +1,4 @@ -package visor +package params /* CODE GENERATED AUTOMATICALLY WITH FIBER COIN CREATOR @@ -20,12 +20,19 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = 31536000 // in seconds - // MaxDropletPrecision represents the decimal precision of droplets - MaxDropletPrecision uint64 = 3 //DefaultMaxBlockSize is max block size DefaultMaxBlockSize int = 32768 // in bytes ) +var ( + // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var) + CoinHourBurnFactor uint64 = 2 + // MaxDropletPrecision represents the decimal precision of droplets + MaxDropletPrecision uint64 = 3 +) + +// distributionAddresses are addresses that received coins from the genesis address in the first block, +// used to calculate current and max supply and do distribution timelocking var distributionAddresses = [DistributionAddressesTotal]string{ "R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ", "2EYM4WFHe4Dgz6kjAdUkM6Etep7ruz2ia6h", diff --git a/src/skycoin/parameters.go b/src/skycoin/parameters.go index 62a568ee3a..4765712602 100644 --- a/src/skycoin/parameters.go +++ b/src/skycoin/parameters.go @@ -9,8 +9,8 @@ import ( // Parameters records fiber coin parameters type Parameters struct { - Node NodeParameters `mapstructure:"node"` - Visor VisorParameters `mapstructure:"visor"` + Node NodeParameters `mapstructure:"node"` + Params ParamsParameters `mapstructure:"params"` } // NodeParameters records the node's configurable parameters @@ -30,8 +30,8 @@ type NodeParameters struct { DataDirectory string } -// VisorParameters are the parameters used to generate parameters.go in visor -type VisorParameters struct { +// ParamsParameters are the parameters used to generate config/blockchain.go +type ParamsParameters struct { // MaxCoinSupply is the maximum supply of coins MaxCoinSupply uint64 `mapstructure:"max_coin_supply"` @@ -58,7 +58,12 @@ type VisorParameters struct { //DefaultMaxBlockSize is max block size DefaultMaxBlockSize int `mapstructure:"default_max_block_size"` + // Addresses that received coins from the genesis address in the first block, + // used to calculate current and max supply and do distribution timelocking DistributionAddresses []string `mapstructure:"distribution_addresses"` + + // BurnFactor inverse fraction of coinhours that must be burned (can be overridden with COINHOUR_BURN_FACTOR env var) + CoinHourBurnFactor uint64 `mapstructure:"coinhour_burn_factor"` } // NewParameters loads blockchain config parameters from a config file @@ -108,12 +113,13 @@ func setDefaults() { viper.SetDefault("build.commit", "") viper.SetDefault("build.branch", "") - // visor parameter defaults - viper.SetDefault("visor.max_coin_supply", 1e8) - viper.SetDefault("visor.distribution_addresses_total", 100) - viper.SetDefault("visor.initial_unlocked_count", 25) - viper.SetDefault("visor.unlock_address_rate", 5) - viper.SetDefault("visor.unlock_time_interval", 60*60*24*365) - viper.SetDefault("visor.max_droplet_precision", 3) - viper.SetDefault("visor.default_max_block_size", 32*1024) + // params defaults + viper.SetDefault("params.max_coin_supply", 1e8) + viper.SetDefault("params.distribution_addresses_total", 100) + viper.SetDefault("params.initial_unlocked_count", 25) + viper.SetDefault("params.unlock_address_rate", 5) + viper.SetDefault("params.unlock_time_interval", 60*60*24*365) + viper.SetDefault("params.max_droplet_precision", 3) + viper.SetDefault("params.default_max_block_size", 32*1024) + viper.SetDefault("params.coinhour_burn_factor", 2) } diff --git a/src/skycoin/parameters_test.go b/src/skycoin/parameters_test.go index 0d8a86738c..0397bd48ff 100644 --- a/src/skycoin/parameters_test.go +++ b/src/skycoin/parameters_test.go @@ -31,7 +31,7 @@ func TestNewParameters(t *testing.T) { PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", WebInterfacePort: 6420, }, - Visor: VisorParameters{ + Params: ParamsParameters{ MaxCoinSupply: 1e8, DistributionAddressesTotal: 100, InitialUnlockedCount: 25, @@ -39,6 +39,7 @@ func TestNewParameters(t *testing.T) { UnlockTimeInterval: 60 * 60 * 24 * 365, MaxDropletPrecision: 3, DefaultMaxBlockSize: 32 * 1024, + CoinHourBurnFactor: 3, }, }, coinConfig) } diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 66a08f8d65..78520341db 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -22,10 +22,10 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/apputil" "github.com/skycoin/skycoin/src/util/certutil" - "github.com/skycoin/skycoin/src/util/fee" "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skycoin/src/visor" "github.com/skycoin/skycoin/src/visor/dbutil" @@ -201,7 +201,7 @@ func (c *Coin) Run() error { } } - c.logger.Infof("Coinhour burn factor is %d", fee.BurnFactor) + c.logger.Infof("Coinhour burn factor is %d", params.CoinHourBurnFactor) d, err = daemon.NewDaemon(dconf, db) if err != nil { @@ -536,20 +536,20 @@ func InitTransaction(UxID string, genesisSecKey cipher.SecKey) coin.Transaction output := cipher.MustSHA256FromHex(UxID) tx.PushInput(output) - addrs := visor.GetDistributionAddresses() + addrs := params.GetDistributionAddresses() if len(addrs) != 100 { log.Panic("Should have 100 distribution addresses") } // 1 million per address, measured in droplets - if visor.DistributionAddressInitialBalance != 1e6 { - log.Panic("visor.DistributionAddressInitialBalance expected to be 1e6*1e6") + if params.DistributionAddressInitialBalance != 1e6 { + log.Panic("params.DistributionAddressInitialBalance expected to be 1e6*1e6") } for i := range addrs { addr := cipher.MustDecodeBase58Address(addrs[i]) - tx.PushOutput(addr, visor.DistributionAddressInitialBalance*1e6, 1) + tx.PushOutput(addr, params.DistributionAddressInitialBalance*1e6, 1) } seckeys := make([]cipher.SecKey, 1) diff --git a/src/skycoin/testdata/test.fiber.toml b/src/skycoin/testdata/test.fiber.toml index cc993ad3ee..ff01faa842 100644 --- a/src/skycoin/testdata/test.fiber.toml +++ b/src/skycoin/testdata/test.fiber.toml @@ -18,3 +18,6 @@ default_connections = [ ] launch_browser = true peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" + +[params] +coinhour_burn_factor = 3 diff --git a/src/util/fee/fee.go b/src/util/fee/fee.go index fed4703a0a..c6ff20103e 100644 --- a/src/util/fee/fee.go +++ b/src/util/fee/fee.go @@ -5,36 +5,11 @@ package fee import ( "errors" - "fmt" - "os" - "strconv" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" ) -var ( - // BurnFactor inverse fraction of coinhours that must be burned (can be overridden with COINHOUR_BURN_FACTOR env var) - BurnFactor uint64 = 2 -) - -func init() { - xs := os.Getenv("COINHOUR_BURN_FACTOR") - if xs == "" { - return - } - - x, err := strconv.ParseUint(xs, 10, 64) - if err != nil { - panic(fmt.Sprintf("Invalid COINHOUR_BURN_FACTOR %q: %v", xs, err)) - } - - if x <= 1 { - panic(fmt.Sprintf("BurnFactor must be > 1")) - } - - BurnFactor = x -} - var ( // ErrTxnNoFee is returned if a transaction has no coinhour fee ErrTxnNoFee = errors.New("Transaction has zero coinhour fee") @@ -47,7 +22,7 @@ var ( ) // VerifyTransactionFee performs additional transaction verification at the unconfirmed pool level. -// This checks tunable parameters that should prevent the transaction from +// This checks tunable params that should prevent the transaction from // entering the blockchain, but cannot be done at the blockchain level because // they may be changed. func VerifyTransactionFee(t *coin.Transaction, fee uint64) error { @@ -85,10 +60,10 @@ func VerifyTransactionFeeForHours(hours, fee uint64) error { } // RequiredFee returns the coinhours fee required for an amount of hours -// The required fee is calculated as hours/BurnFactor, rounded up. +// The required fee is calculated as hours/CoinHourBurnFactor, rounded up. func RequiredFee(hours uint64) uint64 { - feeHours := hours / BurnFactor - if hours%BurnFactor != 0 { + feeHours := hours / params.CoinHourBurnFactor + if hours%params.CoinHourBurnFactor != 0 { feeHours++ } diff --git a/src/util/fee/fee_test.go b/src/util/fee/fee_test.go index d97f6cf319..bb04d5f6ca 100644 --- a/src/util/fee/fee_test.go +++ b/src/util/fee/fee_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/testutil" ) @@ -99,7 +100,7 @@ var burnFactor10VerifyTxnFeeTestCases = []verifyTxnFeeTestCase{ } func TestVerifyTransactionFee(t *testing.T) { - originalBurnFactor := BurnFactor + originalBurnFactor := params.CoinHourBurnFactor emptyTxn := &coin.Transaction{} hours, err := emptyTxn.OutputHours() @@ -165,16 +166,16 @@ func TestVerifyTransactionFee(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == BurnFactor { + if tcc.burnFactor == params.CoinHourBurnFactor { tested = true } for _, tc := range tcc.cases { name := fmt.Sprintf("burnFactor=%d input=%d output=%d", tcc.burnFactor, tc.inputHours, tc.outputHours) t.Run(name, func(t *testing.T) { - BurnFactor = tcc.burnFactor + params.CoinHourBurnFactor = tcc.burnFactor defer func() { - BurnFactor = originalBurnFactor + params.CoinHourBurnFactor = originalBurnFactor }() txn := &coin.Transaction{} @@ -189,7 +190,7 @@ func TestVerifyTransactionFee(t *testing.T) { } } - require.True(t, tested, "configured BurnFactor=%d has not been tested", BurnFactor) + require.True(t, tested, "configured params.CoinHourBurnFactor=%d has not been tested", params.CoinHourBurnFactor) } type requiredFeeTestCase struct { @@ -252,7 +253,7 @@ var burnFactor10RequiredFeeTestCases = []requiredFeeTestCase{ } func TestRequiredFee(t *testing.T) { - originalBurnFactor := BurnFactor + originalBurnFactor := params.CoinHourBurnFactor cases := []struct { burnFactor uint64 @@ -265,16 +266,16 @@ func TestRequiredFee(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == BurnFactor { + if tcc.burnFactor == params.CoinHourBurnFactor { tested = true } for _, tc := range tcc.cases { name := fmt.Sprintf("burnFactor=%d hours=%d fee=%d", tcc.burnFactor, tc.hours, tc.fee) t.Run(name, func(t *testing.T) { - BurnFactor = tcc.burnFactor + params.CoinHourBurnFactor = tcc.burnFactor defer func() { - BurnFactor = originalBurnFactor + params.CoinHourBurnFactor = originalBurnFactor }() fee := RequiredFee(tc.hours) @@ -286,7 +287,7 @@ func TestRequiredFee(t *testing.T) { } } - require.True(t, tested, "configured BurnFactor=%d has not been tested", BurnFactor) + require.True(t, tested, "configured params.CoinHourBurnFactor=%d has not been tested", params.CoinHourBurnFactor) } func TestTransactionFee(t *testing.T) { diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 9b8d8413bf..a56c4ffd6d 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -10,6 +10,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/visor/blockdb" "github.com/skycoin/skycoin/src/visor/dbutil" @@ -346,7 +347,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // create normal spending txn uxs := coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) txn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) - err = verifySingleTxnSoftHardConstraints(txn, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) require.NoError(t, err) // Transaction size exceeds maxSize @@ -360,12 +361,12 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { hours += ux.Body.Hours } txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 0) - err = verifySingleTxnSoftHardConstraints(txn, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) requireSoftViolation(t, "Transaction has zero coinhour fee", err) // Invalid transaction fee, part 2 txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 1) - err = verifySingleTxnSoftHardConstraints(txn, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) requireSoftViolation(t, "Transaction coinhour fee minimum not met", err) // Transaction locking is tested by TestVerifyTransactionIsLocked @@ -373,7 +374,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // Test invalid header hash originInnerHash := txn.InnerHash txn.InnerHash = cipher.SHA256{} - err = verifySingleTxnSoftHardConstraints(txn, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) requireHardViolation(t, "InnerHash does not match computed hash", err) // Set back the originInnerHash @@ -400,7 +401,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { require.NoError(t, err) // A UxOut does not exist, it was already spent - err = verifySingleTxnSoftHardConstraints(txn, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) expectedErr := NewErrTxnViolatesHardConstraint(blockdb.NewErrUnspentNotExist(txn.In[0].Hex())) require.Equal(t, expectedErr, err) @@ -409,21 +410,21 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { _, key := cipher.GenerateKeyPair() toAddr2 := testutil.MakeAddress() tx2 := makeSpendTx(t, uxs, []cipher.SecKey{key, key}, toAddr2, 5e6) - err = verifySingleTxnSoftHardConstraints(tx2, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(tx2, params.DefaultMaxBlockSize) requireHardViolation(t, "Signature not valid for output being spent", err) // Create lost coin transaction uxs2 := coin.CreateUnspents(b.Head, txn) toAddr3 := testutil.MakeAddress() lostCoinTx := makeLostCoinTx(coin.UxArray{uxs2[1]}, []cipher.SecKey{genSecret}, toAddr3, 10e5) - err = verifySingleTxnSoftHardConstraints(lostCoinTx, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.DefaultMaxBlockSize) requireHardViolation(t, "Transactions may not destroy coins", err) // Create transaction with duplicate UxOuts uxs = coin.CreateUnspents(b.Head, txn) toAddr4 := testutil.MakeAddress() dupUxOutTx := makeDuplicateUxOutTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr4, 1e6) - err = verifySingleTxnSoftHardConstraints(dupUxOutTx, DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.DefaultMaxBlockSize) requireHardViolation(t, "Duplicate output in transaction", err) } @@ -474,7 +475,7 @@ func TestVerifyTxnFeeCoinHoursAdditionFails(t *testing.T) { testutil.RequireError(t, coinHoursErr, "UxOut.CoinHours addition of earned coin hours overflow") // VerifySingleTxnSoftConstraints should fail on this, when trying to calculate the TransactionFee - err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, DefaultMaxBlockSize) + err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.DefaultMaxBlockSize) testutil.RequireError(t, err, NewErrTxnViolatesSoftConstraint(coinHoursErr).Error()) // VerifySingleTxnHardConstraints should fail on this, when performing the extra check of @@ -486,7 +487,7 @@ func TestVerifyTxnFeeCoinHoursAdditionFails(t *testing.T) { } func TestVerifyTransactionIsLocked(t *testing.T) { - for _, addr := range GetLockedDistributionAddresses() { + for _, addr := range params.GetLockedDistributionAddresses() { t.Run(fmt.Sprintf("IsLocked: %s", addr), func(t *testing.T) { testVerifyTransactionAddressLocking(t, addr, errors.New("Transaction has locked address inputs")) }) @@ -494,7 +495,7 @@ func TestVerifyTransactionIsLocked(t *testing.T) { } func TestVerifyTransactionIsUnlocked(t *testing.T) { - for _, addr := range GetUnlockedDistributionAddresses() { + for _, addr := range params.GetUnlockedDistributionAddresses() { t.Run(fmt.Sprintf("IsUnlocked: %s", addr), func(t *testing.T) { testVerifyTransactionAddressLocking(t, addr, nil) }) @@ -552,7 +553,7 @@ func testVerifyTransactionAddressLocking(t *testing.T, toAddr string, expectedEr }) require.NoError(t, err) - err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, DefaultMaxBlockSize) + err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.DefaultMaxBlockSize) if expectedErr == nil { require.NoError(t, err) } else { diff --git a/src/visor/distribution.go b/src/visor/distribution.go index f0817ff377..593815267e 100644 --- a/src/visor/distribution.go +++ b/src/visor/distribution.go @@ -2,60 +2,12 @@ package visor import ( "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" ) -// Note: parameters.go contains many constants used in this file -// they are the ones generated from the fiber config file. - -func init() { - if MaxCoinSupply%DistributionAddressesTotal != 0 { - panic("MaxCoinSupply should be perfectly divisible by DistributionAddressesTotal") - } -} - -// GetDistributionAddresses returns a copy of the hardcoded distribution addresses array. -// Each address has 1,000,000 coins. There are 100 addresses. -func GetDistributionAddresses() []string { - addrs := make([]string, len(distributionAddresses)) - for i := range distributionAddresses { - addrs[i] = distributionAddresses[i] - } - return addrs -} - -// GetUnlockedDistributionAddresses returns distribution addresses that are unlocked, i.e. they have spendable outputs -func GetUnlockedDistributionAddresses() []string { - // The first InitialUnlockedCount (25) addresses are unlocked by default. - // Subsequent addresses will be unlocked at a rate of UnlockAddressRate (5) per year, - // after the InitialUnlockedCount (25) addresses have no remaining balance. - // The unlock timer will be enabled manually once the - // InitialUnlockedCount (25) addresses are distributed. - - // NOTE: To have automatic unlocking, transaction verification would have - // to be handled in visor rather than in coin.Transactions.Visor(), because - // the coin package is agnostic to the state of the blockchain and cannot reference it. - // Instead of automatic unlocking, we can hardcode the timestamp at which the first 30% - // is distributed, then compute the unlocked addresses easily here. - - addrs := make([]string, InitialUnlockedCount) - copy(addrs[:], distributionAddresses[:InitialUnlockedCount]) - return addrs -} - -// GetLockedDistributionAddresses returns distribution addresses that are locked, i.e. they have unspendable outputs -func GetLockedDistributionAddresses() []string { - // TODO -- once we reach 30% distribution, we can hardcode the - // initial timestamp for releasing more coins - addrs := make([]string, DistributionAddressesTotal-InitialUnlockedCount) - for i := range distributionAddresses[InitialUnlockedCount:] { - addrs[i] = distributionAddresses[InitialUnlockedCount+uint64(i)] - } - return addrs -} - // TransactionIsLocked returns true if the transaction spends locked outputs func TransactionIsLocked(inUxs coin.UxArray) bool { - lockedAddrs := GetLockedDistributionAddresses() + lockedAddrs := params.GetLockedDistributionAddresses() lockedAddrsMap := make(map[string]struct{}) for _, a := range lockedAddrs { lockedAddrsMap[a] = struct{}{} diff --git a/src/visor/distribution_test.go b/src/visor/distribution_test.go index 28b111dea8..19b15f20f3 100644 --- a/src/visor/distribution_test.go +++ b/src/visor/distribution_test.go @@ -7,58 +7,9 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" ) -func TestDistributionAddressArrays(t *testing.T) { - require.Len(t, GetDistributionAddresses(), 100) - - // At the time of this writing, there should be 25 addresses in the - // unlocked pool and 75 in the locked pool. - require.Len(t, GetUnlockedDistributionAddresses(), 25) - require.Len(t, GetLockedDistributionAddresses(), 75) - - all := GetDistributionAddresses() - allMap := make(map[string]struct{}) - for _, a := range all { - // Check no duplicate address in distribution addresses - _, ok := allMap[a] - require.False(t, ok) - allMap[a] = struct{}{} - } - - unlocked := GetUnlockedDistributionAddresses() - unlockedMap := make(map[string]struct{}) - for _, a := range unlocked { - // Check no duplicate address in unlocked addresses - _, ok := unlockedMap[a] - require.False(t, ok) - - // Check unlocked address in set of all addresses - _, ok = allMap[a] - require.True(t, ok) - - unlockedMap[a] = struct{}{} - } - - locked := GetLockedDistributionAddresses() - lockedMap := make(map[string]struct{}) - for _, a := range locked { - // Check no duplicate address in locked addresses - _, ok := lockedMap[a] - require.False(t, ok) - - // Check locked address in set of all addresses - _, ok = allMap[a] - require.True(t, ok) - - // Check locked address not in unlocked addresses - _, ok = unlockedMap[a] - require.False(t, ok) - - lockedMap[a] = struct{}{} - } -} - func TestTransactionIsLocked(t *testing.T) { test := func(addrStr string, expectedIsLocked bool) { addr := cipher.MustDecodeBase58Address(addrStr) @@ -74,11 +25,11 @@ func TestTransactionIsLocked(t *testing.T) { require.Equal(t, expectedIsLocked, isLocked) } - for _, a := range GetLockedDistributionAddresses() { + for _, a := range params.GetLockedDistributionAddresses() { test(a, true) } - for _, a := range GetUnlockedDistributionAddresses() { + for _, a := range params.GetUnlockedDistributionAddresses() { test(a, false) } diff --git a/src/visor/verify.go b/src/visor/verify.go index 0d3f9d5e86..42e3a26251 100644 --- a/src/visor/verify.go +++ b/src/visor/verify.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/util/fee" ) @@ -166,7 +167,7 @@ func verifyTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.U // Reject transactions that do not conform to decimal restrictions for _, o := range txn.Out { - if err := DropletPrecisionCheck(o.Coins); err != nil { + if err := params.DropletPrecisionCheck(o.Coins); err != nil { return err } } diff --git a/src/visor/visor.go b/src/visor/visor.go index 94b7b6c0f8..d0e2df727c 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -21,7 +21,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" - "github.com/skycoin/skycoin/src/util/droplet" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skycoin/src/util/timeutil" "github.com/skycoin/skycoin/src/visor/blockdb" @@ -32,62 +32,8 @@ import ( var ( logger = logging.MustGetLogger("visor") - - // errInvalidDecimals is returned by DropletPrecisionCheck if a coin amount has an invalid number of decimal places - errInvalidDecimals = errors.New("invalid amount, too many decimal places") - - // maxDropletDivisor represents the modulus divisor when checking droplet precision rules. - // It is computed from MaxDropletPrecision in init() - maxDropletDivisor uint64 ) -// MaxDropletDivisor represents the modulus divisor when checking droplet precision rules. -func MaxDropletDivisor() uint64 { - // The value is wrapped in a getter to make it immutable to external packages - return maxDropletDivisor -} - -func init() { - sanityCheck() - // Compute maxDropletDivisor from precision - maxDropletDivisor = calculateDivisor(MaxDropletPrecision) -} - -func sanityCheck() { - if InitialUnlockedCount > DistributionAddressesTotal { - logger.Panic("unlocked addresses > total distribution addresses") - } - - if uint64(len(distributionAddresses)) != DistributionAddressesTotal { - logger.Panic("available distribution addresses > total allowed distribution addresses") - } - - if DistributionAddressInitialBalance*DistributionAddressesTotal > MaxCoinSupply { - logger.Panic("total balance in distribution addresses > max coin supply") - } -} - -func calculateDivisor(precision uint64) uint64 { - if precision > droplet.Exponent { - logger.Panic("precision must be <= droplet.Exponent") - } - - n := droplet.Exponent - precision - var i uint64 = 1 - for k := uint64(0); k < n; k++ { - i = i * 10 - } - return i -} - -// DropletPrecisionCheck checks if an amount of coins is valid given decimal place restrictions -func DropletPrecisionCheck(amount uint64) error { - if amount%maxDropletDivisor != 0 { - return errInvalidDecimals - } - return nil -} - // Config configuration parameters for the Visor type Config struct { // Is this the master blockchain @@ -139,7 +85,7 @@ func NewVisorConfig() Config { BlockchainPubkey: cipher.PubKey{}, BlockchainSeckey: cipher.SecKey{}, - MaxBlockSize: DefaultMaxBlockSize, + MaxBlockSize: params.DefaultMaxBlockSize, GenesisAddress: cipher.Address{}, GenesisSignature: cipher.Sig{}, diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index 8836275414..a3ad079a19 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -19,6 +19,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/testutil" _require "github.com/skycoin/skycoin/src/testutil/require" "github.com/skycoin/skycoin/src/util/fee" @@ -323,7 +324,7 @@ func TestVisorCreateBlock(t *testing.T) { uxs := coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) nUnspents := 100 - txn := makeUnspentsTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, nUnspents, maxDropletDivisor) + txn := makeUnspentsTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, nUnspents, params.MaxDropletDivisor()) var known bool var softErr *ErrTxnViolatesSoftConstraint @@ -399,7 +400,7 @@ func TestVisorCreateBlock(t *testing.T) { foundInvalidCoins := false for _, txn := range txns { for _, o := range txn.Out { - if err := DropletPrecisionCheck(o.Coins); err != nil { + if err := params.DropletPrecisionCheck(o.Coins); err != nil { foundInvalidCoins = true break } @@ -474,7 +475,7 @@ func TestVisorCreateBlock(t *testing.T) { // Check that decimal rules are enforced for i, txn := range blockTxns { for j, o := range txn.Out { - err := DropletPrecisionCheck(o.Coins) + err := params.DropletPrecisionCheck(o.Coins) require.NoError(t, err, "txout %d.%d coins=%d", i, j, o.Coins) } } @@ -607,11 +608,11 @@ func TestVisorInjectTransaction(t *testing.T) { // Create a transaction with invalid decimal places // It's still injected, because this is considered a soft error - invalidCoins := coins + (maxDropletDivisor / 10) + invalidCoins := coins + (params.MaxDropletDivisor() / 10) txn = makeSpendTx(t, uxs, []cipher.SecKey{genSecret, genSecret}, toAddr, invalidCoins) _, softErr, err = v.InjectTransaction(txn) require.NoError(t, err) - testutil.RequireError(t, softErr.Err, errInvalidDecimals.Error()) + testutil.RequireError(t, softErr.Err, params.ErrInvalidDecimals.Error()) err = db.View("", func(tx *dbutil.Tx) error { length, err := unconfirmed.Len(tx) @@ -673,33 +674,6 @@ func makeOverflowHoursSpendTx(uxs coin.UxArray, keys []cipher.SecKey, toAddr cip return spendTx } -func TestVisorCalculatePrecision(t *testing.T) { - cases := []struct { - precision uint64 - divisor uint64 - }{ - {0, 1e6}, - {1, 1e5}, - {2, 1e4}, - {3, 1e3}, - {4, 1e2}, - {5, 1e1}, - {6, 1}, - } - - for _, tc := range cases { - name := fmt.Sprintf("calculateDivisor(%d)=%d", tc.precision, tc.divisor) - t.Run(name, func(t *testing.T) { - divisor := calculateDivisor(tc.precision) - require.Equal(t, tc.divisor, divisor, "%d != %d", tc.divisor, divisor) - }) - } - - _require.PanicsWithLogMessage(t, "precision must be <= droplet.Exponent", func() { - calculateDivisor(7) - }) -} - func makeTestData(t *testing.T, n int) ([]historydb.Transaction, []coin.SignedBlock, []UnconfirmedTransaction, uint64) { // nolint: unparam var txns []historydb.Transaction var blocks []coin.SignedBlock @@ -1994,11 +1968,11 @@ func TestRefreshUnconfirmed(t *testing.T) { // Create a transaction with invalid decimal places // It's still injected, because this is considered a soft error // This transaction will stay invalid on refresh - invalidCoins := coins + (maxDropletDivisor / 10) + invalidCoins := coins + (params.MaxDropletDivisor() / 10) alwaysInvalidTxn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, invalidCoins) _, softErr, err = v.InjectTransaction(alwaysInvalidTxn) require.NoError(t, err) - testutil.RequireError(t, softErr.Err, errInvalidDecimals.Error()) + testutil.RequireError(t, softErr.Err, params.ErrInvalidDecimals.Error()) err = db.View("", func(tx *dbutil.Tx) error { length, err := unconfirmed.Len(tx) @@ -2028,7 +2002,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // The first txn remains valid, // the second txn remains invalid, // the third txn becomes valid - v.Config.MaxBlockSize = DefaultMaxBlockSize + v.Config.MaxBlockSize = params.DefaultMaxBlockSize hashes, err := v.RefreshUnconfirmed() require.NoError(t, err) require.Equal(t, []cipher.SHA256{sometimesInvalidTxn.Hash()}, hashes) @@ -2046,7 +2020,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // The first txn was valid, became invalid, and is now valid again // The second txn was always invalid // The third txn was invalid, became valid, became invalid, and is now valid again - v.Config.MaxBlockSize = DefaultMaxBlockSize + v.Config.MaxBlockSize = params.DefaultMaxBlockSize hashes, err = v.RefreshUnconfirmed() require.NoError(t, err) @@ -3058,7 +3032,7 @@ func TestVerifyTxnVerbose(t *testing.T) { } if v.Config.MaxBlockSize == 0 { - v.Config.MaxBlockSize = DefaultMaxBlockSize + v.Config.MaxBlockSize = params.DefaultMaxBlockSize } var isConfirmed bool diff --git a/src/wallet/wallet_test.go b/src/wallet/wallet_test.go index 5e918fcc46..e93358236a 100644 --- a/src/wallet/wallet_test.go +++ b/src/wallet/wallet_test.go @@ -18,6 +18,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/cipher/encrypt" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/testutil" "github.com/skycoin/skycoin/src/util/fee" "github.com/skycoin/skycoin/src/util/logging" @@ -1239,7 +1240,7 @@ var burnFactor10TestCases = []distributeSpendHoursTestCase{ } func TestWalletDistributeSpendHours(t *testing.T) { - originalBurnFactor := fee.BurnFactor + originalBurnFactor := params.CoinHourBurnFactor cases := []struct { burnFactor uint64 @@ -1252,15 +1253,15 @@ func TestWalletDistributeSpendHours(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == fee.BurnFactor { + if tcc.burnFactor == params.CoinHourBurnFactor { tested = true } for _, tc := range tcc.cases { t.Run(tc.name, func(t *testing.T) { - fee.BurnFactor = tcc.burnFactor + params.CoinHourBurnFactor = tcc.burnFactor defer func() { - fee.BurnFactor = originalBurnFactor + params.CoinHourBurnFactor = originalBurnFactor }() changeHours, addrHours, totalHours := DistributeSpendHours(tc.inputHours, tc.nAddrs, tc.haveChange) @@ -1283,9 +1284,9 @@ func TestWalletDistributeSpendHours(t *testing.T) { } t.Run(fmt.Sprintf("burn-factor-%d-range", tcc.burnFactor), func(t *testing.T) { - fee.BurnFactor = tcc.burnFactor + params.CoinHourBurnFactor = tcc.burnFactor defer func() { - fee.BurnFactor = originalBurnFactor + params.CoinHourBurnFactor = originalBurnFactor }() // Tests over range of values @@ -1332,7 +1333,7 @@ func TestWalletDistributeSpendHours(t *testing.T) { }) } - require.True(t, tested, "configured BurnFactor=%d has not been tested", fee.BurnFactor) + require.True(t, tested, "configured BurnFactor=%d has not been tested", params.CoinHourBurnFactor) } func uxBalancesEqual(a, b []UxBalance) bool { diff --git a/template/visor.template b/template/params.template similarity index 79% rename from template/visor.template rename to template/params.template index 59a30959cb..9ae4d8ba85 100644 --- a/template/visor.template +++ b/template/params.template @@ -1,4 +1,4 @@ -package visor +package params /* CODE GENERATED AUTOMATICALLY WITH FIBER COIN CREATOR @@ -20,12 +20,19 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = {{.UnlockTimeInterval}} // in seconds - // MaxDropletPrecision represents the decimal precision of droplets - MaxDropletPrecision uint64 = {{.MaxDropletPrecision}} //DefaultMaxBlockSize is max block size DefaultMaxBlockSize int = {{.DefaultMaxBlockSize}} // in bytes ) +var ( + // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var) + CoinHourBurnFactor uint64 = 2 + // MaxDropletPrecision represents the decimal precision of droplets + MaxDropletPrecision uint64 = {{.MaxDropletPrecision}} +) + +// distributionAddresses are addresses that received coins from the genesis address in the first block, +// used to calculate current and max supply and do distribution timelocking var distributionAddresses = [DistributionAddressesTotal]string{ {{- range $index, $address := .DistributionAddresses}} "{{$address -}}", From f11db95f88207527f1078665ad932fb69bde5eca Mon Sep 17 00:00:00 2001 From: gz-c Date: Thu, 1 Nov 2018 23:58:09 +0800 Subject: [PATCH 375/399] Make burn factor configurable in different scenarios --- cmd/newcoin/newcoin.go | 45 +++----- cmd/skycoin/skycoin.go | 26 +++-- fiber.toml | 2 + src/api/integration/integration_test.go | 6 +- src/cli/create_rawtx.go | 4 +- src/daemon/daemon.go | 18 +-- src/daemon/gateway.go | 8 +- src/daemon/messages.go | 18 +-- src/daemon/mock_daemoner_test.go | 50 ++++---- src/params/init.go | 6 +- src/params/params.go | 4 +- src/skycoin/config.go | 35 ++++++ src/skycoin/parameters.go | 28 +++-- src/skycoin/parameters_test.go | 8 +- src/skycoin/skycoin.go | 6 +- src/skycoin/testdata/test.fiber.toml | 2 + src/util/fee/fee.go | 21 ++-- src/util/fee/fee_test.go | 36 ++---- src/visor/blockchain.go | 4 +- src/visor/blockchain_verify_test.go | 26 ++--- src/visor/daemon_visor_test.go | 10 +- src/visor/mock_blockchainer_test.go | 10 +- ...ck_unconfirmed_transaction_pooler_test.go} | 108 +++++++++--------- src/visor/unconfirmed.go | 14 +-- src/visor/verify.go | 8 +- src/visor/visor.go | 86 ++++++++------ src/visor/visor_test.go | 46 ++++---- src/visor/visor_wallet.go | 17 +-- src/wallet/wallet.go | 69 +++++------ src/wallet/wallet_test.go | 8 +- template/coin.template | 26 +++-- template/params.template | 6 +- 32 files changed, 408 insertions(+), 353 deletions(-) rename src/visor/{mock_unconfirmed_txn_pooler_test.go => mock_unconfirmed_transaction_pooler_test.go} (69%) diff --git a/cmd/newcoin/newcoin.go b/cmd/newcoin/newcoin.go index 64fd1d1342..634049819d 100644 --- a/cmd/newcoin/newcoin.go +++ b/cmd/newcoin/newcoin.go @@ -23,23 +23,6 @@ const ( Version = "0.1" ) -// CoinTemplateParameters represents parameters used to generate the new coin files. -type CoinTemplateParameters struct { - CoinName string - Version string - PeerListURL string - Port int - WebInterfacePort int - DataDirectory string - GenesisSignatureStr string - GenesisAddressStr string - BlockchainPubkeyStr string - BlockchainSeckeyStr string - GenesisTimestamp uint64 - GenesisCoinVolume uint64 - DefaultConnections []string -} - var ( app = cli.NewApp() log = logging.MustGetLogger("newcoin") @@ -207,19 +190,21 @@ func createCoinCommand() cli.Command { return err } - err = t.ExecuteTemplate(coinFile, coinTemplateFile, CoinTemplateParameters{ - CoinName: coinName, - PeerListURL: config.Node.PeerListURL, - Port: config.Node.Port, - WebInterfacePort: config.Node.WebInterfacePort, - DataDirectory: "$HOME/." + coinName, - GenesisSignatureStr: config.Node.GenesisSignatureStr, - GenesisAddressStr: config.Node.GenesisAddressStr, - BlockchainPubkeyStr: config.Node.BlockchainPubkeyStr, - BlockchainSeckeyStr: config.Node.BlockchainSeckeyStr, - GenesisTimestamp: config.Node.GenesisTimestamp, - GenesisCoinVolume: config.Node.GenesisCoinVolume, - DefaultConnections: config.Node.DefaultConnections, + err = t.ExecuteTemplate(coinFile, coinTemplateFile, skycoin.NodeParameters{ + CoinName: coinName, + PeerListURL: config.Node.PeerListURL, + Port: config.Node.Port, + WebInterfacePort: config.Node.WebInterfacePort, + DataDirectory: "$HOME/." + coinName, + GenesisSignatureStr: config.Node.GenesisSignatureStr, + GenesisAddressStr: config.Node.GenesisAddressStr, + BlockchainPubkeyStr: config.Node.BlockchainPubkeyStr, + BlockchainSeckeyStr: config.Node.BlockchainSeckeyStr, + GenesisTimestamp: config.Node.GenesisTimestamp, + GenesisCoinVolume: config.Node.GenesisCoinVolume, + DefaultConnections: config.Node.DefaultConnections, + UnconfirmedBurnFactor: config.Node.UnconfirmedBurnFactor, + CreateBlockBurnFactor: config.Node.CreateBlockBurnFactor, }) if err != nil { log.Error("failed to parse coin template variables") diff --git a/cmd/skycoin/skycoin.go b/cmd/skycoin/skycoin.go index 210950e5c1..b298567461 100644 --- a/cmd/skycoin/skycoin.go +++ b/cmd/skycoin/skycoin.go @@ -61,18 +61,20 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ - CoinName: CoinName, - GenesisSignatureStr: GenesisSignatureStr, - GenesisAddressStr: GenesisAddressStr, - GenesisCoinVolume: GenesisCoinVolume, - GenesisTimestamp: GenesisTimestamp, - BlockchainPubkeyStr: BlockchainPubkeyStr, - BlockchainSeckeyStr: BlockchainSeckeyStr, - DefaultConnections: DefaultConnections, - PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", - Port: 6000, - WebInterfacePort: 6420, - DataDirectory: "$HOME/.skycoin", + CoinName: CoinName, + GenesisSignatureStr: GenesisSignatureStr, + GenesisAddressStr: GenesisAddressStr, + GenesisCoinVolume: GenesisCoinVolume, + GenesisTimestamp: GenesisTimestamp, + BlockchainPubkeyStr: BlockchainPubkeyStr, + BlockchainSeckeyStr: BlockchainSeckeyStr, + DefaultConnections: DefaultConnections, + PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", + Port: 6000, + WebInterfacePort: 6420, + DataDirectory: "$HOME/.skycoin", + UnconfirmedBurnFactor: 10, + CreateBlockBurnFactor: 10, }) parseFlags = true diff --git a/fiber.toml b/fiber.toml index 25dfbb286d..1f60e2119c 100644 --- a/fiber.toml +++ b/fiber.toml @@ -20,6 +20,8 @@ default_connections = [ peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" #port = 6000 #web_interface_port = 6420 +unconfirmed_burn_factor = 10 +create_block_burn_factor = 10 [params] #max_coin_supply = 1e8 diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index 1d7ba6c9f8..d3eb4dbec1 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -3863,7 +3863,7 @@ func TestLiveWalletCreateTransactionSpecific(t *testing.T) { w, totalCoins, totalHours, password := prepareAndCheckWallet(t, c, 2e6, 20) - remainingHours := fee.RemainingHours(totalHours) + remainingHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) require.True(t, remainingHours > 1) addresses := make([]string, len(w.Entries)) @@ -4619,7 +4619,7 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { return } - remainingHours := fee.RemainingHours(totalHours) + remainingHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) require.True(t, remainingHours > 1) assertTxnOutputCount := func(t *testing.T, changeAddress string, nOutputs int, result *api.CreateTransactionResponse) { @@ -4650,7 +4650,7 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { tLog(t, "totalCoins", totalCoins) tLog(t, "totalHours", totalHours) - spendableHours := fee.RemainingHours(totalHours) + spendableHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) tLog(t, "spendableHours", spendableHours) coins := rand.Intn(int(totalCoins)) + 1 diff --git a/src/cli/create_rawtx.go b/src/cli/create_rawtx.go index 20913468b3..910d1ba0ae 100644 --- a/src/cli/create_rawtx.go +++ b/src/cli/create_rawtx.go @@ -540,7 +540,7 @@ func CreateRawTx(c GetOutputser, wlt *wallet.Wallet, inAddrs []string, chgAddr s return nil, err } - if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.DefaultMaxBlockSize); err != nil { + if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.DefaultMaxBlockSize, params.CoinHourBurnFactor); err != nil { return nil, err } if err := visor.VerifySingleTxnHardConstraints(*txn, head, inUxsFiltered); err != nil { @@ -667,7 +667,7 @@ func makeChangeOut(outs []wallet.UxBalance, chgAddr string, toAddrs []SendAmount nAddrs := uint64(len(toAddrs)) changeHours, addrHours, totalOutHours := wallet.DistributeSpendHours(totalInHours, nAddrs, haveChange) - if err := fee.VerifyTransactionFeeForHours(totalOutHours, totalInHours-totalOutHours); err != nil { + if err := fee.VerifyTransactionFeeForHours(totalOutHours, totalInHours-totalOutHours, params.CoinHourBurnFactor); err != nil { return nil, err } diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 098fa447d0..9591565d46 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -67,7 +67,7 @@ func NewConfig() Config { Pex: pex.NewConfig(), Gateway: NewGatewayConfig(), Messages: NewMessagesConfig(), - Visor: visor.NewVisorConfig(), + Visor: visor.NewConfig(), } } @@ -242,9 +242,8 @@ type daemoner interface { GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) HeadBkSeq() (uint64, bool, error) ExecuteSignedBlock(b coin.SignedBlock) error - GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) + FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) - InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) Mirror() uint32 DaemonConfig() DaemonConfig BlockchainPubkey() cipher.PubKey @@ -252,6 +251,7 @@ type daemoner interface { AnnounceAllTxns() error RecordUserAgent(addr string, userAgent useragent.Data) error + injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) } @@ -1345,9 +1345,9 @@ func (dm *Daemon) ExecuteSignedBlock(b coin.SignedBlock) error { return dm.visor.ExecuteSignedBlock(b) } -// GetUnconfirmedUnknown returns unconfirmed txn hashes with known ones removed -func (dm *Daemon) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { - return dm.visor.GetUnconfirmedUnknown(txns) +// FilterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { + return dm.visor.FilterUnconfirmedKnown(txns) } // GetUnconfirmedKnown returns unconfirmed txn hashes with known ones removed @@ -1355,11 +1355,11 @@ func (dm *Daemon) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, return dm.visor.GetUnconfirmedKnown(txns) } -// InjectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not +// injectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not // already in the blockchain. // The bool return value is whether or not the transaction was already in the pool. // If the transaction violates hard constraints, it is rejected, and error will not be nil. // If the transaction only violates soft constraints, it is still injected, and the soft constraint violation is returned. -func (dm *Daemon) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { - return dm.visor.InjectTransaction(txn) +func (dm *Daemon) injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { + return dm.visor.InjectForeignTransaction(txn) } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 04fb1098b6..d3b8aca30b 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -487,14 +487,14 @@ func (gw *Gateway) GetTransactionVerbose(txid cipher.SHA256) (*visor.Transaction // InjectBroadcastTransaction injects transaction to the unconfirmed pool and broadcasts it. // If the transaction violates either hard or soft constraints, it is not broadcast. // This method is to be used by user-initiated transaction injections. -// For transactions received over the network, use daemon.InjectTransaction and check the result to +// For transactions received over the network, use daemon.injectTransaction and check the result to // decide on repropagation. func (gw *Gateway) InjectBroadcastTransaction(txn coin.Transaction) error { var err error gw.strand("InjectBroadcastTransaction", func() { err = gw.v.WithUpdateTx("gateway.InjectBroadcastTransaction", func(tx *dbutil.Tx) error { if _, err := gw.v.InjectTransactionStrictTx(tx, txn); err != nil { - logger.WithError(err).Error("InjectTransactionStrict failed") + logger.WithError(err).Error("InjectUserTransaction failed") return err } @@ -617,9 +617,9 @@ func (gw *Gateway) Spend(wltID string, password []byte, coins uint64, dest ciphe } // WARNING: This is not safe from races once we remove strand - _, err = gw.v.InjectTransactionStrict(*txn) + _, err = gw.v.InjectUserTransaction(*txn) if err != nil { - logger.WithError(err).Error("InjectTransactionStrict failed") + logger.WithError(err).Error("InjectUserTransaction failed") return } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index cf65fd934a..f98ce033d1 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -549,7 +549,7 @@ func (gbm *GetBlocksMessage) process(d daemoner) { // GiveBlocksMessage sent in response to GetBlocksMessage, or unsolicited type GiveBlocksMessage struct { - Blocks []coin.SignedBlock + Blocks []coin.SignedBlock `enc:",maxlen=128"` c *gnet.MessageContext `enc:"-"` } @@ -697,7 +697,7 @@ type SendingTxnsMessage interface { // AnnounceTxnsMessage tells a peer that we have these transactions type AnnounceTxnsMessage struct { - Transactions []cipher.SHA256 + Transactions []cipher.SHA256 `enc:",maxlen=256` c *gnet.MessageContext `enc:"-"` } @@ -725,9 +725,9 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { return } - unknown, err := d.GetUnconfirmedUnknown(atm.Transactions) + unknown, err := d.FilterUnconfirmedKnown(atm.Transactions) if err != nil { - logger.WithField("addr", atm.c.Addr).WithError(err).Error("AnnounceTxnsMessage Visor.GetUnconfirmedUnknown failed") + logger.WithField("addr", atm.c.Addr).WithError(err).Error("AnnounceTxnsMessage Visor.FilterUnconfirmedKnown failed") return } @@ -785,12 +785,12 @@ func (gtm *GetTxnsMessage) process(d daemoner) { // GiveTxnsMessage tells the transaction of given hashes type GiveTxnsMessage struct { - Transactions coin.Transactions + Transactions []coin.Transaction `enc:",maxlen=256"` c *gnet.MessageContext `enc:"-"` } // NewGiveTxnsMessage creates GiveTxnsMessage -func NewGiveTxnsMessage(txns coin.Transactions) *GiveTxnsMessage { +func NewGiveTxnsMessage(txns []coin.Transaction) *GiveTxnsMessage { return &GiveTxnsMessage{ Transactions: txns, } @@ -798,7 +798,7 @@ func NewGiveTxnsMessage(txns coin.Transactions) *GiveTxnsMessage { // GetFiltered returns transactions hashes func (gtm *GiveTxnsMessage) GetFiltered() []cipher.SHA256 { - return gtm.Transactions.Hashes() + return coin.Transactions(gtm.Transactions).Hashes() } // Handle handle message @@ -819,13 +819,13 @@ func (gtm *GiveTxnsMessage) process(d daemoner) { // Only announce transactions that are new to us, so that peers can't spam relays // It is not necessary to inject all of the transactions inside a database transaction, // since each is independent - known, softErr, err := d.InjectTransaction(txn) + known, softErr, err := d.injectTransaction(txn) if err != nil { logger.WithError(err).WithField("txid", txn.Hash().Hex()).Warning("Failed to record transaction") continue } else if softErr != nil { logger.WithError(err).WithField("txid", txn.Hash().Hex()).Warning("Transaction soft violation") - continue + // Allow soft txn violations to rebroadcast } else if known { logger.WithField("txid", txn.Hash().Hex()).Debug("Duplicate transaction") continue diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index e7b3c14947..bb72337816 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -180,22 +180,22 @@ func (_m *mockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { return r0 } -// GetSignedBlocksSince provides a mock function with given fields: seq, count -func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { - ret := _m.Called(seq, count) +// FilterUnconfirmedKnown provides a mock function with given fields: txns +func (_m *mockDaemoner) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { + ret := _m.Called(txns) - var r0 []coin.SignedBlock - if rf, ok := ret.Get(0).(func(uint64, uint64) []coin.SignedBlock); ok { - r0 = rf(seq, count) + var r0 []cipher.SHA256 + if rf, ok := ret.Get(0).(func([]cipher.SHA256) []cipher.SHA256); ok { + r0 = rf(txns) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]coin.SignedBlock) + r0 = ret.Get(0).([]cipher.SHA256) } } var r1 error - if rf, ok := ret.Get(1).(func(uint64, uint64) error); ok { - r1 = rf(seq, count) + if rf, ok := ret.Get(1).(func([]cipher.SHA256) error); ok { + r1 = rf(txns) } else { r1 = ret.Error(1) } @@ -203,22 +203,22 @@ func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.S return r0, r1 } -// GetUnconfirmedKnown provides a mock function with given fields: txns -func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { - ret := _m.Called(txns) +// GetSignedBlocksSince provides a mock function with given fields: seq, count +func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { + ret := _m.Called(seq, count) - var r0 coin.Transactions - if rf, ok := ret.Get(0).(func([]cipher.SHA256) coin.Transactions); ok { - r0 = rf(txns) + var r0 []coin.SignedBlock + if rf, ok := ret.Get(0).(func(uint64, uint64) []coin.SignedBlock); ok { + r0 = rf(seq, count) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(coin.Transactions) + r0 = ret.Get(0).([]coin.SignedBlock) } } var r1 error - if rf, ok := ret.Get(1).(func([]cipher.SHA256) error); ok { - r1 = rf(txns) + if rf, ok := ret.Get(1).(func(uint64, uint64) error); ok { + r1 = rf(seq, count) } else { r1 = ret.Error(1) } @@ -226,16 +226,16 @@ func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transact return r0, r1 } -// GetUnconfirmedUnknown provides a mock function with given fields: txns -func (_m *mockDaemoner) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// GetUnconfirmedKnown provides a mock function with given fields: txns +func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { ret := _m.Called(txns) - var r0 []cipher.SHA256 - if rf, ok := ret.Get(0).(func([]cipher.SHA256) []cipher.SHA256); ok { + var r0 coin.Transactions + if rf, ok := ret.Get(0).(func([]cipher.SHA256) coin.Transactions); ok { r0 = rf(txns) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cipher.SHA256) + r0 = ret.Get(0).(coin.Transactions) } } @@ -282,8 +282,8 @@ func (_m *mockDaemoner) IncreaseRetryTimes(addr string) { _m.Called(addr) } -// InjectTransaction provides a mock function with given fields: txn -func (_m *mockDaemoner) InjectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { +// injectTransaction provides a mock function with given fields: txn +func (_m *mockDaemoner) injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { ret := _m.Called(txn) var r0 bool diff --git a/src/params/init.go b/src/params/init.go index d4a632feb3..75c41432b9 100644 --- a/src/params/init.go +++ b/src/params/init.go @@ -16,6 +16,10 @@ func init() { } func sanityCheck() { + if CoinHourBurnFactor <= 1 { + panic("CoinHourBurnFactor must be > 1") + } + if InitialUnlockedCount > DistributionAddressesTotal { panic("unlocked addresses > total distribution addresses") } @@ -45,7 +49,7 @@ func loadCoinHourBurnFactor() { } if x <= 1 { - panic(fmt.Sprintf("CoinHourBurnFactor must be > 1")) + panic("COINHOUR_BURN_FACTOR must be > 1") } CoinHourBurnFactor = x diff --git a/src/params/params.go b/src/params/params.go index d57feb9b00..f6fc83fc61 100644 --- a/src/params/params.go +++ b/src/params/params.go @@ -25,8 +25,10 @@ const ( ) var ( - // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var) + // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var), + // used when creating a transaction CoinHourBurnFactor uint64 = 2 + // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = 3 ) diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 06c356d00e..e48cb11d21 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -14,6 +14,7 @@ import ( "github.com/skycoin/skycoin/src/api" "github.com/skycoin/skycoin/src/cipher" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/readable" "github.com/skycoin/skycoin/src/util/file" "github.com/skycoin/skycoin/src/util/useragent" @@ -139,6 +140,13 @@ type NodeConfig struct { // Reset the database if integrity checks fail, and continue running ResetCorruptDB bool + // Maximum size of blocks in bytes + MaxBlockSize int + // Coin hour burn factor to apply to unconfirmed txns (received over the network, or when refreshing the pool) + UnconfirmedBurnFactor uint64 + // Coin hour burn factor to apply when creating blocks + CreateBlockBurnFactor uint64 + // Wallets // Defaults to ${DataDirectory}/wallets/ WalletDirectory string @@ -258,6 +266,11 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { VerifyDB: false, ResetCorruptDB: false, + // Blockchain/transaction validation + MaxBlockSize: params.DefaultMaxBlockSize, + UnconfirmedBurnFactor: params.CoinHourBurnFactor, + CreateBlockBurnFactor: params.CoinHourBurnFactor, + // Wallets WalletDirectory: "", WalletCryptoType: string(wallet.CryptoTypeScryptChacha20poly1305), @@ -395,6 +408,24 @@ func (c *Config) postProcess() error { return errors.New("-max-outgoing-connections cannot be higher than -max-connections") } + if c.Node.MaxBlockSize <= 0 { + return errors.New("-max-block-size must be > 0") + } + + if c.Node.UnconfirmedBurnFactor < 2 { + return errors.New("-unconfirmed-burn-factor must be >= 2") + } + if c.Node.UnconfirmedBurnFactor < params.CoinHourBurnFactor { + return fmt.Errorf("-unconfirmed-burn-factor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + } + + if c.Node.CreateBlockBurnFactor < 2 { + return errors.New("-create-block-burn-factor must be >= 2") + } + if c.Node.CreateBlockBurnFactor < params.CoinHourBurnFactor { + return fmt.Errorf("-create-block-burn-factor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + } + return nil } @@ -534,6 +565,10 @@ func (c *NodeConfig) RegisterFlags() { // Key Configuration Data flag.BoolVar(&c.RunMaster, "master", c.RunMaster, "run the daemon as blockchain master server") + flag.IntVar(&c.MaxBlockSize, "max-block-size", c.MaxBlockSize, "maximum size of blocks") + flag.Uint64Var(&c.UnconfirmedBurnFactor, "burn-factor-unconfirmed", c.UnconfirmedBurnFactor, "coinhour burn factor to apply when verifying unconfirmed transactions") + flag.Uint64Var(&c.CreateBlockBurnFactor, "burn-factor-create-block", c.CreateBlockBurnFactor, "coinhour burn factor to apply to transactions when creating blocks") + flag.StringVar(&c.BlockchainPubkeyStr, "master-public-key", c.BlockchainPubkeyStr, "public key of the master chain") flag.StringVar(&c.BlockchainSeckeyStr, "master-secret-key", c.BlockchainSeckeyStr, "secret key, set for master") diff --git a/src/skycoin/parameters.go b/src/skycoin/parameters.go index 4765712602..776490c355 100644 --- a/src/skycoin/parameters.go +++ b/src/skycoin/parameters.go @@ -15,17 +15,19 @@ type Parameters struct { // NodeParameters records the node's configurable parameters type NodeParameters struct { - CoinName string `mapstructure:"coin_name"` - PeerListURL string `mapstructure:"peer_list_url"` - Port int `mapstructure:"port"` - WebInterfacePort int `mapstructure:"web_interface_port"` - GenesisSignatureStr string `mapstructure:"genesis_signature_str"` - GenesisAddressStr string `mapstructure:"genesis_address_str"` - BlockchainPubkeyStr string `mapstructure:"blockchain_pubkey_str"` - BlockchainSeckeyStr string `mapstructure:"blockchain_seckey_str"` - GenesisTimestamp uint64 `mapstructure:"genesis_timestamp"` - GenesisCoinVolume uint64 `mapstructure:"genesis_coin_volume"` - DefaultConnections []string `mapstructure:"default_connections"` + CoinName string `mapstructure:"coin_name"` + PeerListURL string `mapstructure:"peer_list_url"` + Port int `mapstructure:"port"` + WebInterfacePort int `mapstructure:"web_interface_port"` + GenesisSignatureStr string `mapstructure:"genesis_signature_str"` + GenesisAddressStr string `mapstructure:"genesis_address_str"` + BlockchainPubkeyStr string `mapstructure:"blockchain_pubkey_str"` + BlockchainSeckeyStr string `mapstructure:"blockchain_seckey_str"` + GenesisTimestamp uint64 `mapstructure:"genesis_timestamp"` + GenesisCoinVolume uint64 `mapstructure:"genesis_coin_volume"` + DefaultConnections []string `mapstructure:"default_connections"` + UnconfirmedBurnFactor uint64 `mapstructure:"unconfirmed_burn_factor"` + CreateBlockBurnFactor uint64 `mapstructure:"create_block_burn_factor"` DataDirectory string } @@ -62,7 +64,7 @@ type ParamsParameters struct { // used to calculate current and max supply and do distribution timelocking DistributionAddresses []string `mapstructure:"distribution_addresses"` - // BurnFactor inverse fraction of coinhours that must be burned (can be overridden with COINHOUR_BURN_FACTOR env var) + // CoinHourBurnFactor inverse fraction of coinhours that must be burned, this value is used when creating transactions CoinHourBurnFactor uint64 `mapstructure:"coinhour_burn_factor"` } @@ -122,4 +124,6 @@ func setDefaults() { viper.SetDefault("params.max_droplet_precision", 3) viper.SetDefault("params.default_max_block_size", 32*1024) viper.SetDefault("params.coinhour_burn_factor", 2) + viper.SetDefault("params.unconfirmed_burn_factor", 2) + viper.SetDefault("params.create_block_burn_factor", 2) } diff --git a/src/skycoin/parameters_test.go b/src/skycoin/parameters_test.go index 0397bd48ff..47687ef572 100644 --- a/src/skycoin/parameters_test.go +++ b/src/skycoin/parameters_test.go @@ -27,9 +27,11 @@ func TestNewParameters(t *testing.T) { "172.104.85.6:6000", "139.162.7.132:6000", }, - Port: 6000, - PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", - WebInterfacePort: 6420, + Port: 6000, + PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", + WebInterfacePort: 6420, + UnconfirmedBurnFactor: 10, + CreateBlockBurnFactor: 9, }, Params: ParamsParameters{ MaxCoinSupply: 1e8, diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 78520341db..e87276b586 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -201,7 +201,7 @@ func (c *Coin) Run() error { } } - c.logger.Infof("Coinhour burn factor is %d", params.CoinHourBurnFactor) + c.logger.Infof("Coinhour burn factor for creating transactions is %d", params.CoinHourBurnFactor) d, err = daemon.NewDaemon(dconf, db) if err != nil { @@ -380,6 +380,10 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Visor.BlockchainPubkey = c.config.Node.blockchainPubkey dc.Visor.BlockchainSeckey = c.config.Node.blockchainSeckey + dc.Visor.MaxBlockSize = c.config.Node.MaxBlockSize + dc.Visor.UnconfirmedBurnFactor = c.config.Node.UnconfirmedBurnFactor + dc.Visor.CreateBlockBurnFactor = c.config.Node.CreateBlockBurnFactor + dc.Visor.GenesisAddress = c.config.Node.genesisAddress dc.Visor.GenesisSignature = c.config.Node.genesisSignature dc.Visor.GenesisTimestamp = c.config.Node.GenesisTimestamp diff --git a/src/skycoin/testdata/test.fiber.toml b/src/skycoin/testdata/test.fiber.toml index ff01faa842..f7a3848b08 100644 --- a/src/skycoin/testdata/test.fiber.toml +++ b/src/skycoin/testdata/test.fiber.toml @@ -18,6 +18,8 @@ default_connections = [ ] launch_browser = true peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" +unconfirmed_burn_factor = 10 +create_block_burn_factor = 9 [params] coinhour_burn_factor = 3 diff --git a/src/util/fee/fee.go b/src/util/fee/fee.go index c6ff20103e..77aad98b61 100644 --- a/src/util/fee/fee.go +++ b/src/util/fee/fee.go @@ -7,7 +7,6 @@ import ( "errors" "github.com/skycoin/skycoin/src/coin" - "github.com/skycoin/skycoin/src/params" ) var ( @@ -25,18 +24,18 @@ var ( // This checks tunable params that should prevent the transaction from // entering the blockchain, but cannot be done at the blockchain level because // they may be changed. -func VerifyTransactionFee(t *coin.Transaction, fee uint64) error { +func VerifyTransactionFee(t *coin.Transaction, fee, burnFactor uint64) error { hours, err := t.OutputHours() if err != nil { return err } - return VerifyTransactionFeeForHours(hours, fee) + return VerifyTransactionFeeForHours(hours, fee, burnFactor) } // VerifyTransactionFeeForHours verifies the fee given fee and hours, // where hours is the number of hours in a transaction's outputs, // and hours+fee is the number of hours in a transaction's inputs -func VerifyTransactionFeeForHours(hours, fee uint64) error { +func VerifyTransactionFeeForHours(hours, fee, burnFactor uint64) error { // Require non-zero coinhour fee if fee == 0 { return ErrTxnNoFee @@ -49,7 +48,7 @@ func VerifyTransactionFeeForHours(hours, fee uint64) error { } // Calculate the required fee - requiredFee := RequiredFee(total) + requiredFee := RequiredFee(total, burnFactor) // Ensure that the required fee is met if fee < requiredFee { @@ -60,10 +59,10 @@ func VerifyTransactionFeeForHours(hours, fee uint64) error { } // RequiredFee returns the coinhours fee required for an amount of hours -// The required fee is calculated as hours/CoinHourBurnFactor, rounded up. -func RequiredFee(hours uint64) uint64 { - feeHours := hours / params.CoinHourBurnFactor - if hours%params.CoinHourBurnFactor != 0 { +// The required fee is calculated as hours/burnFact, rounded up. +func RequiredFee(hours, burnFactor uint64) uint64 { + feeHours := hours / burnFactor + if hours%burnFactor != 0 { feeHours++ } @@ -71,8 +70,8 @@ func RequiredFee(hours uint64) uint64 { } // RemainingHours returns the amount of coinhours leftover after paying the fee for the input. -func RemainingHours(hours uint64) uint64 { - fee := RequiredFee(hours) +func RemainingHours(hours, burnFactor uint64) uint64 { + fee := RequiredFee(hours, burnFactor) return hours - fee } diff --git a/src/util/fee/fee_test.go b/src/util/fee/fee_test.go index bb04d5f6ca..f3f12196e5 100644 --- a/src/util/fee/fee_test.go +++ b/src/util/fee/fee_test.go @@ -100,19 +100,17 @@ var burnFactor10VerifyTxnFeeTestCases = []verifyTxnFeeTestCase{ } func TestVerifyTransactionFee(t *testing.T) { - originalBurnFactor := params.CoinHourBurnFactor - emptyTxn := &coin.Transaction{} hours, err := emptyTxn.OutputHours() require.NoError(t, err) require.Equal(t, uint64(0), hours) // A txn with no outputs hours and no coinhours burn fee is valid - err = VerifyTransactionFee(emptyTxn, 0) + err = VerifyTransactionFee(emptyTxn, 0, 2) testutil.RequireError(t, err, ErrTxnNoFee.Error()) // A txn with no outputs hours but with a coinhours burn fee is valid - err = VerifyTransactionFee(emptyTxn, 100) + err = VerifyTransactionFee(emptyTxn, 100, 2) require.NoError(t, err) txn := &coin.Transaction{} @@ -128,31 +126,31 @@ func TestVerifyTransactionFee(t *testing.T) { require.Equal(t, uint64(4e6), hours) // A txn with insufficient net coinhours burn fee is invalid - err = VerifyTransactionFee(txn, 0) + err = VerifyTransactionFee(txn, 0, 2) testutil.RequireError(t, err, ErrTxnNoFee.Error()) - err = VerifyTransactionFee(txn, 1) + err = VerifyTransactionFee(txn, 1, 2) testutil.RequireError(t, err, ErrTxnInsufficientFee.Error()) // A txn with sufficient net coinhours burn fee is valid hours, err = txn.OutputHours() require.NoError(t, err) - err = VerifyTransactionFee(txn, hours) + err = VerifyTransactionFee(txn, hours, 2) require.NoError(t, err) hours, err = txn.OutputHours() require.NoError(t, err) - err = VerifyTransactionFee(txn, hours*10) + err = VerifyTransactionFee(txn, hours*10, 2) require.NoError(t, err) // fee + hours overflows - err = VerifyTransactionFee(txn, math.MaxUint64-3e6) + err = VerifyTransactionFee(txn, math.MaxUint64-3e6, 2) testutil.RequireError(t, err, "Hours and fee overflow") // txn has overflowing output hours txn.Out = append(txn.Out, coin.TransactionOutput{ Hours: math.MaxUint64 - 1e6 - 3e6 + 1, }) - err = VerifyTransactionFee(txn, 10) + err = VerifyTransactionFee(txn, 10, 2) testutil.RequireError(t, err, "Transaction output hours overflow") cases := []struct { @@ -173,18 +171,13 @@ func TestVerifyTransactionFee(t *testing.T) { for _, tc := range tcc.cases { name := fmt.Sprintf("burnFactor=%d input=%d output=%d", tcc.burnFactor, tc.inputHours, tc.outputHours) t.Run(name, func(t *testing.T) { - params.CoinHourBurnFactor = tcc.burnFactor - defer func() { - params.CoinHourBurnFactor = originalBurnFactor - }() - txn := &coin.Transaction{} txn.Out = append(txn.Out, coin.TransactionOutput{ Hours: tc.outputHours, }) require.True(t, tc.inputHours >= tc.outputHours) - err := VerifyTransactionFee(txn, tc.inputHours-tc.outputHours) + err := VerifyTransactionFee(txn, tc.inputHours-tc.outputHours, tcc.burnFactor) require.Equal(t, tc.err, err) }) } @@ -253,8 +246,6 @@ var burnFactor10RequiredFeeTestCases = []requiredFeeTestCase{ } func TestRequiredFee(t *testing.T) { - originalBurnFactor := params.CoinHourBurnFactor - cases := []struct { burnFactor uint64 cases []requiredFeeTestCase @@ -273,15 +264,10 @@ func TestRequiredFee(t *testing.T) { for _, tc := range tcc.cases { name := fmt.Sprintf("burnFactor=%d hours=%d fee=%d", tcc.burnFactor, tc.hours, tc.fee) t.Run(name, func(t *testing.T) { - params.CoinHourBurnFactor = tcc.burnFactor - defer func() { - params.CoinHourBurnFactor = originalBurnFactor - }() - - fee := RequiredFee(tc.hours) + fee := RequiredFee(tc.hours, tcc.burnFactor) require.Equal(t, tc.fee, fee) - remainingHours := RemainingHours(tc.hours) + remainingHours := RemainingHours(tc.hours, tcc.burnFactor) require.Equal(t, tc.hours-fee, remainingHours) }) } diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index 4ee502b112..f55091c8f3 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -397,7 +397,7 @@ func (bc Blockchain) VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Tran // VerifySingleTxnSoftHardConstraints checks that the transaction does not violate hard or soft constraints, // for transactions that are not included in a block. // Hard constraints are checked before soft constraints. -func (bc Blockchain) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error { +func (bc Blockchain) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int, burnFactor uint64) error { // NOTE: Unspent().GetArray() returns an error if not all txn.In can be found // This prevents double spends uxIn, err := bc.Unspent().GetArray(tx, txn.In) @@ -415,7 +415,7 @@ func (bc Blockchain) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin. return err } - return VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, maxSize) + return VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, maxSize, burnFactor) } func (bc Blockchain) verifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error { diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index a56c4ffd6d..429cc37560 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -338,20 +338,20 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { toAddr := testutil.MakeAddress() coins := uint64(10e6) - verifySingleTxnSoftHardConstraints := func(txn coin.Transaction, maxBlockSize int) error { + verifySingleTxnSoftHardConstraints := func(txn coin.Transaction, maxBlockSize int, burnFactor uint64) error { return db.View("", func(tx *dbutil.Tx) error { - return bc.VerifySingleTxnSoftHardConstraints(tx, txn, maxBlockSize) + return bc.VerifySingleTxnSoftHardConstraints(tx, txn, maxBlockSize, burnFactor) }) } // create normal spending txn uxs := coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) txn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) require.NoError(t, err) // Transaction size exceeds maxSize - err = verifySingleTxnSoftHardConstraints(txn, txn.Size()-1) + err = verifySingleTxnSoftHardConstraints(txn, txn.Size()-1, params.CoinHourBurnFactor) requireSoftViolation(t, "Transaction size bigger than max block size", err) // Invalid transaction fee @@ -361,12 +361,12 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { hours += ux.Body.Hours } txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 0) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireSoftViolation(t, "Transaction has zero coinhour fee", err) // Invalid transaction fee, part 2 txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 1) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireSoftViolation(t, "Transaction coinhour fee minimum not met", err) // Transaction locking is tested by TestVerifyTransactionIsLocked @@ -374,7 +374,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // Test invalid header hash originInnerHash := txn.InnerHash txn.InnerHash = cipher.SHA256{} - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireHardViolation(t, "InnerHash does not match computed hash", err) // Set back the originInnerHash @@ -401,7 +401,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { require.NoError(t, err) // A UxOut does not exist, it was already spent - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) expectedErr := NewErrTxnViolatesHardConstraint(blockdb.NewErrUnspentNotExist(txn.In[0].Hex())) require.Equal(t, expectedErr, err) @@ -410,21 +410,21 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { _, key := cipher.GenerateKeyPair() toAddr2 := testutil.MakeAddress() tx2 := makeSpendTx(t, uxs, []cipher.SecKey{key, key}, toAddr2, 5e6) - err = verifySingleTxnSoftHardConstraints(tx2, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(tx2, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireHardViolation(t, "Signature not valid for output being spent", err) // Create lost coin transaction uxs2 := coin.CreateUnspents(b.Head, txn) toAddr3 := testutil.MakeAddress() lostCoinTx := makeLostCoinTx(coin.UxArray{uxs2[1]}, []cipher.SecKey{genSecret}, toAddr3, 10e5) - err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireHardViolation(t, "Transactions may not destroy coins", err) // Create transaction with duplicate UxOuts uxs = coin.CreateUnspents(b.Head, txn) toAddr4 := testutil.MakeAddress() dupUxOutTx := makeDuplicateUxOutTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr4, 1e6) - err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.DefaultMaxBlockSize) + err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) requireHardViolation(t, "Duplicate output in transaction", err) } @@ -475,7 +475,7 @@ func TestVerifyTxnFeeCoinHoursAdditionFails(t *testing.T) { testutil.RequireError(t, coinHoursErr, "UxOut.CoinHours addition of earned coin hours overflow") // VerifySingleTxnSoftConstraints should fail on this, when trying to calculate the TransactionFee - err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.DefaultMaxBlockSize) + err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) testutil.RequireError(t, err, NewErrTxnViolatesSoftConstraint(coinHoursErr).Error()) // VerifySingleTxnHardConstraints should fail on this, when performing the extra check of @@ -553,7 +553,7 @@ func testVerifyTransactionAddressLocking(t *testing.T, toAddr string, expectedEr }) require.NoError(t, err) - err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.DefaultMaxBlockSize) + err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) if expectedErr == nil { require.NoError(t, err) } else { diff --git a/src/visor/daemon_visor_test.go b/src/visor/daemon_visor_test.go index ead9e576ca..1fddbbb119 100644 --- a/src/visor/daemon_visor_test.go +++ b/src/visor/daemon_visor_test.go @@ -25,7 +25,7 @@ import ( ) func setupSimpleVisor(t *testing.T, db *dbutil.DB, bc *Blockchain) *Visor { - cfg := NewVisorConfig() + cfg := NewConfig() cfg.DBPath = db.Path() pool, err := NewUnconfirmedTransactionPool(db) @@ -60,7 +60,7 @@ func TestVerifyTransactionInvalidFee(t *testing.T) { // Setup a minimal visor v := setupSimpleVisor(t, db, bc) - _, softErr, err := v.InjectTransaction(txn) + _, softErr, err := v.InjectForeignTransaction(txn) require.NoError(t, err) require.NotNil(t, softErr) require.Equal(t, NewErrTxnViolatesSoftConstraint(fee.ErrTxnNoFee), *softErr) @@ -90,7 +90,7 @@ func TestVerifyTransactionInvalidSignature(t *testing.T) { // Setup a minimal visor v := setupSimpleVisor(t, db, bc) - _, softErr, err := v.InjectTransaction(txn) + _, softErr, err := v.InjectForeignTransaction(txn) require.Nil(t, softErr) testutil.RequireError(t, err, NewErrTxnViolatesHardConstraint(errors.New("Invalid number of signatures")).Error()) } @@ -120,7 +120,7 @@ func TestInjectValidTransaction(t *testing.T) { require.Len(t, txns, 0) // Call injectTransaction - _, softErr, err := v.InjectTransaction(txn) + _, softErr, err := v.InjectForeignTransaction(txn) require.Nil(t, softErr) require.NoError(t, err) @@ -156,7 +156,7 @@ func TestInjectTransactionSoftViolationNoFee(t *testing.T) { require.Len(t, txns, 0) // Call injectTransaction - _, softErr, err := v.InjectTransaction(txn) + _, softErr, err := v.InjectForeignTransaction(txn) require.NoError(t, err) require.NotNil(t, softErr) require.Equal(t, NewErrTxnViolatesSoftConstraint(fee.ErrTxnNoFee), *softErr) diff --git a/src/visor/mock_blockchainer_test.go b/src/visor/mock_blockchainer_test.go index 392e549024..fb11740a52 100644 --- a/src/visor/mock_blockchainer_test.go +++ b/src/visor/mock_blockchainer_test.go @@ -341,13 +341,13 @@ func (_m *MockBlockchainer) VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn co return r0 } -// VerifySingleTxnSoftHardConstraints provides a mock function with given fields: tx, txn, maxSize -func (_m *MockBlockchainer) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error { - ret := _m.Called(tx, txn, maxSize) +// VerifySingleTxnSoftHardConstraints provides a mock function with given fields: tx, txn, maxSize, burnFactor +func (_m *MockBlockchainer) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int, burnFactor uint64) error { + ret := _m.Called(tx, txn, maxSize, burnFactor) var r0 error - if rf, ok := ret.Get(0).(func(*dbutil.Tx, coin.Transaction, int) error); ok { - r0 = rf(tx, txn, maxSize) + if rf, ok := ret.Get(0).(func(*dbutil.Tx, coin.Transaction, int, uint64) error); ok { + r0 = rf(tx, txn, maxSize, burnFactor) } else { r0 = ret.Error(0) } diff --git a/src/visor/mock_unconfirmed_txn_pooler_test.go b/src/visor/mock_unconfirmed_transaction_pooler_test.go similarity index 69% rename from src/visor/mock_unconfirmed_txn_pooler_test.go rename to src/visor/mock_unconfirmed_transaction_pooler_test.go index caeb16e018..4dd4079a14 100644 --- a/src/visor/mock_unconfirmed_txn_pooler_test.go +++ b/src/visor/mock_unconfirmed_transaction_pooler_test.go @@ -7,13 +7,13 @@ import coin "github.com/skycoin/skycoin/src/coin" import dbutil "github.com/skycoin/skycoin/src/visor/dbutil" import mock "github.com/stretchr/testify/mock" -// MockUnconfirmedTxnPooler is an autogenerated mock type for the UnconfirmedTxnPooler type -type MockUnconfirmedTxnPooler struct { +// MockUnconfirmedTransactionPooler is an autogenerated mock type for the UnconfirmedTransactionPooler type +type MockUnconfirmedTransactionPooler struct { mock.Mock } // AllRawTransactions provides a mock function with given fields: tx -func (_m *MockUnconfirmedTxnPooler) AllRawTransactions(tx *dbutil.Tx) (coin.Transactions, error) { +func (_m *MockUnconfirmedTransactionPooler) AllRawTransactions(tx *dbutil.Tx) (coin.Transactions, error) { ret := _m.Called(tx) var r0 coin.Transactions @@ -35,8 +35,31 @@ func (_m *MockUnconfirmedTxnPooler) AllRawTransactions(tx *dbutil.Tx) (coin.Tran return r0, r1 } +// FilterKnown provides a mock function with given fields: tx, txns +func (_m *MockUnconfirmedTransactionPooler) FilterKnown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) { + ret := _m.Called(tx, txns) + + var r0 []cipher.SHA256 + if rf, ok := ret.Get(0).(func(*dbutil.Tx, []cipher.SHA256) []cipher.SHA256); ok { + r0 = rf(tx, txns) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]cipher.SHA256) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*dbutil.Tx, []cipher.SHA256) error); ok { + r1 = rf(tx, txns) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ForEach provides a mock function with given fields: tx, f -func (_m *MockUnconfirmedTxnPooler) ForEach(tx *dbutil.Tx, f func(cipher.SHA256, UnconfirmedTransaction) error) error { +func (_m *MockUnconfirmedTransactionPooler) ForEach(tx *dbutil.Tx, f func(cipher.SHA256, UnconfirmedTransaction) error) error { ret := _m.Called(tx, f) var r0 error @@ -50,7 +73,7 @@ func (_m *MockUnconfirmedTxnPooler) ForEach(tx *dbutil.Tx, f func(cipher.SHA256, } // Get provides a mock function with given fields: tx, hash -func (_m *MockUnconfirmedTxnPooler) Get(tx *dbutil.Tx, hash cipher.SHA256) (*UnconfirmedTransaction, error) { +func (_m *MockUnconfirmedTransactionPooler) Get(tx *dbutil.Tx, hash cipher.SHA256) (*UnconfirmedTransaction, error) { ret := _m.Called(tx, hash) var r0 *UnconfirmedTransaction @@ -73,7 +96,7 @@ func (_m *MockUnconfirmedTxnPooler) Get(tx *dbutil.Tx, hash cipher.SHA256) (*Unc } // GetFiltered provides a mock function with given fields: tx, filter -func (_m *MockUnconfirmedTxnPooler) GetFiltered(tx *dbutil.Tx, filter func(UnconfirmedTransaction) bool) ([]UnconfirmedTransaction, error) { +func (_m *MockUnconfirmedTransactionPooler) GetFiltered(tx *dbutil.Tx, filter func(UnconfirmedTransaction) bool) ([]UnconfirmedTransaction, error) { ret := _m.Called(tx, filter) var r0 []UnconfirmedTransaction @@ -96,7 +119,7 @@ func (_m *MockUnconfirmedTxnPooler) GetFiltered(tx *dbutil.Tx, filter func(Uncon } // GetHashes provides a mock function with given fields: tx, filter -func (_m *MockUnconfirmedTxnPooler) GetHashes(tx *dbutil.Tx, filter func(UnconfirmedTransaction) bool) ([]cipher.SHA256, error) { +func (_m *MockUnconfirmedTransactionPooler) GetHashes(tx *dbutil.Tx, filter func(UnconfirmedTransaction) bool) ([]cipher.SHA256, error) { ret := _m.Called(tx, filter) var r0 []cipher.SHA256 @@ -119,7 +142,7 @@ func (_m *MockUnconfirmedTxnPooler) GetHashes(tx *dbutil.Tx, filter func(Unconfi } // GetIncomingOutputs provides a mock function with given fields: tx, bh -func (_m *MockUnconfirmedTxnPooler) GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error) { +func (_m *MockUnconfirmedTransactionPooler) GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error) { ret := _m.Called(tx, bh) var r0 coin.UxArray @@ -142,7 +165,7 @@ func (_m *MockUnconfirmedTxnPooler) GetIncomingOutputs(tx *dbutil.Tx, bh coin.Bl } // GetKnown provides a mock function with given fields: tx, txns -func (_m *MockUnconfirmedTxnPooler) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error) { +func (_m *MockUnconfirmedTransactionPooler) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error) { ret := _m.Called(tx, txns) var r0 coin.Transactions @@ -164,31 +187,8 @@ func (_m *MockUnconfirmedTxnPooler) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256 return r0, r1 } -// GetUnknown provides a mock function with given fields: tx, txns -func (_m *MockUnconfirmedTxnPooler) GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) { - ret := _m.Called(tx, txns) - - var r0 []cipher.SHA256 - if rf, ok := ret.Get(0).(func(*dbutil.Tx, []cipher.SHA256) []cipher.SHA256); ok { - r0 = rf(tx, txns) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]cipher.SHA256) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, []cipher.SHA256) error); ok { - r1 = rf(tx, txns) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetUnspentsOfAddr provides a mock function with given fields: tx, addr -func (_m *MockUnconfirmedTxnPooler) GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher.Address) (coin.UxArray, error) { +func (_m *MockUnconfirmedTransactionPooler) GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher.Address) (coin.UxArray, error) { ret := _m.Called(tx, addr) var r0 coin.UxArray @@ -210,20 +210,20 @@ func (_m *MockUnconfirmedTxnPooler) GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher return r0, r1 } -// InjectTransaction provides a mock function with given fields: tx, bc, t, maxSize -func (_m *MockUnconfirmedTxnPooler) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error) { - ret := _m.Called(tx, bc, t, maxSize) +// InjectTransaction provides a mock function with given fields: tx, bc, t, maxSize, burnFactor +func (_m *MockUnconfirmedTransactionPooler) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, t coin.Transaction, maxSize int, burnFactor uint64) (bool, *ErrTxnViolatesSoftConstraint, error) { + ret := _m.Called(tx, bc, t, maxSize, burnFactor) var r0 bool - if rf, ok := ret.Get(0).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int) bool); ok { - r0 = rf(tx, bc, t, maxSize) + if rf, ok := ret.Get(0).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int, uint64) bool); ok { + r0 = rf(tx, bc, t, maxSize, burnFactor) } else { r0 = ret.Get(0).(bool) } var r1 *ErrTxnViolatesSoftConstraint - if rf, ok := ret.Get(1).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int) *ErrTxnViolatesSoftConstraint); ok { - r1 = rf(tx, bc, t, maxSize) + if rf, ok := ret.Get(1).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int, uint64) *ErrTxnViolatesSoftConstraint); ok { + r1 = rf(tx, bc, t, maxSize, burnFactor) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(*ErrTxnViolatesSoftConstraint) @@ -231,8 +231,8 @@ func (_m *MockUnconfirmedTxnPooler) InjectTransaction(tx *dbutil.Tx, bc Blockcha } var r2 error - if rf, ok := ret.Get(2).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int) error); ok { - r2 = rf(tx, bc, t, maxSize) + if rf, ok := ret.Get(2).(func(*dbutil.Tx, Blockchainer, coin.Transaction, int, uint64) error); ok { + r2 = rf(tx, bc, t, maxSize, burnFactor) } else { r2 = ret.Error(2) } @@ -241,7 +241,7 @@ func (_m *MockUnconfirmedTxnPooler) InjectTransaction(tx *dbutil.Tx, bc Blockcha } // Len provides a mock function with given fields: tx -func (_m *MockUnconfirmedTxnPooler) Len(tx *dbutil.Tx) (uint64, error) { +func (_m *MockUnconfirmedTransactionPooler) Len(tx *dbutil.Tx) (uint64, error) { ret := _m.Called(tx) var r0 uint64 @@ -262,7 +262,7 @@ func (_m *MockUnconfirmedTxnPooler) Len(tx *dbutil.Tx) (uint64, error) { } // RecvOfAddresses provides a mock function with given fields: tx, bh, addrs -func (_m *MockUnconfirmedTxnPooler) RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error) { +func (_m *MockUnconfirmedTransactionPooler) RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error) { ret := _m.Called(tx, bh, addrs) var r0 coin.AddressUxOuts @@ -284,13 +284,13 @@ func (_m *MockUnconfirmedTxnPooler) RecvOfAddresses(tx *dbutil.Tx, bh coin.Block return r0, r1 } -// Refresh provides a mock function with given fields: tx, bc, maxBlockSize -func (_m *MockUnconfirmedTxnPooler) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error) { - ret := _m.Called(tx, bc, maxBlockSize) +// Refresh provides a mock function with given fields: tx, bc, maxBlockSize, burnFactor +func (_m *MockUnconfirmedTransactionPooler) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int, burnFactor uint64) ([]cipher.SHA256, error) { + ret := _m.Called(tx, bc, maxBlockSize, burnFactor) var r0 []cipher.SHA256 - if rf, ok := ret.Get(0).(func(*dbutil.Tx, Blockchainer, int) []cipher.SHA256); ok { - r0 = rf(tx, bc, maxBlockSize) + if rf, ok := ret.Get(0).(func(*dbutil.Tx, Blockchainer, int, uint64) []cipher.SHA256); ok { + r0 = rf(tx, bc, maxBlockSize, burnFactor) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]cipher.SHA256) @@ -298,8 +298,8 @@ func (_m *MockUnconfirmedTxnPooler) Refresh(tx *dbutil.Tx, bc Blockchainer, maxB } var r1 error - if rf, ok := ret.Get(1).(func(*dbutil.Tx, Blockchainer, int) error); ok { - r1 = rf(tx, bc, maxBlockSize) + if rf, ok := ret.Get(1).(func(*dbutil.Tx, Blockchainer, int, uint64) error); ok { + r1 = rf(tx, bc, maxBlockSize, burnFactor) } else { r1 = ret.Error(1) } @@ -308,7 +308,7 @@ func (_m *MockUnconfirmedTxnPooler) Refresh(tx *dbutil.Tx, bc Blockchainer, maxB } // RemoveInvalid provides a mock function with given fields: tx, bc -func (_m *MockUnconfirmedTxnPooler) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error) { +func (_m *MockUnconfirmedTransactionPooler) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error) { ret := _m.Called(tx, bc) var r0 []cipher.SHA256 @@ -331,7 +331,7 @@ func (_m *MockUnconfirmedTxnPooler) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer } // RemoveTransactions provides a mock function with given fields: tx, txns -func (_m *MockUnconfirmedTxnPooler) RemoveTransactions(tx *dbutil.Tx, txns []cipher.SHA256) error { +func (_m *MockUnconfirmedTransactionPooler) RemoveTransactions(tx *dbutil.Tx, txns []cipher.SHA256) error { ret := _m.Called(tx, txns) var r0 error @@ -345,7 +345,7 @@ func (_m *MockUnconfirmedTxnPooler) RemoveTransactions(tx *dbutil.Tx, txns []cip } // SetTransactionsAnnounced provides a mock function with given fields: tx, hashes -func (_m *MockUnconfirmedTxnPooler) SetTransactionsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error { +func (_m *MockUnconfirmedTransactionPooler) SetTransactionsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error { ret := _m.Called(tx, hashes) var r0 error diff --git a/src/visor/unconfirmed.go b/src/visor/unconfirmed.go index e8e750ce16..d3af6cd9c1 100644 --- a/src/visor/unconfirmed.go +++ b/src/visor/unconfirmed.go @@ -199,10 +199,10 @@ func (utp *UnconfirmedTransactionPool) SetTransactionsAnnounced(tx *dbutil.Tx, h // existed in the pool. // If the transaction violates hard constraints, it is rejected. // Soft constraints violations mark a txn as invalid, but the txn is inserted. The soft violation is returned. -func (utp *UnconfirmedTransactionPool) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, txn coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error) { +func (utp *UnconfirmedTransactionPool) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, txn coin.Transaction, maxSize int, burnFactor uint64) (bool, *ErrTxnViolatesSoftConstraint, error) { var isValid int8 = 1 var softErr *ErrTxnViolatesSoftConstraint - if err := bc.VerifySingleTxnSoftHardConstraints(tx, txn, maxSize); err != nil { + if err := bc.VerifySingleTxnSoftHardConstraints(tx, txn, maxSize, burnFactor); err != nil { logger.Warningf("bc.VerifySingleTxnSoftHardConstraints failed for txn %s: %v", txn.TxIDHex(), err) switch err.(type) { case ErrTxnViolatesSoftConstraint: @@ -301,7 +301,7 @@ func (utp *UnconfirmedTransactionPool) RemoveTransactions(tx *dbutil.Tx, txHashe // Refresh checks all unconfirmed txns against the blockchain. // If the transaction becomes invalid it is marked invalid. // If the transaction becomes valid it is marked valid and is returned to the caller. -func (utp *UnconfirmedTransactionPool) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error) { +func (utp *UnconfirmedTransactionPool) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int, burnFactor uint64) ([]cipher.SHA256, error) { utxns, err := utp.txns.getAll(tx) if err != nil { return nil, err @@ -313,7 +313,7 @@ func (utp *UnconfirmedTransactionPool) Refresh(tx *dbutil.Tx, bc Blockchainer, m for _, utxn := range utxns { utxn.Checked = now.UnixNano() - err := bc.VerifySingleTxnSoftHardConstraints(tx, utxn.Transaction, maxBlockSize) + err := bc.VerifySingleTxnSoftHardConstraints(tx, utxn.Transaction, maxBlockSize, burnFactor) switch err.(type) { case ErrTxnViolatesSoftConstraint, ErrTxnViolatesHardConstraint: @@ -365,8 +365,8 @@ func (utp *UnconfirmedTransactionPool) RemoveInvalid(tx *dbutil.Tx, bc Blockchai return removeUtxns, nil } -// GetUnknown returns txn hashes with known ones removed -func (utp *UnconfirmedTransactionPool) GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) { +// FilterKnown returns txn hashes with known ones removed +func (utp *UnconfirmedTransactionPool) FilterKnown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) { var unknown []cipher.SHA256 for _, h := range txns { @@ -380,7 +380,7 @@ func (utp *UnconfirmedTransactionPool) GetUnknown(tx *dbutil.Tx, txns []cipher.S return unknown, nil } -// GetKnown returns all known coin.Transactions from the pool, given hashes to select +// GetKnown returns all known transactions from the pool, given hashes to select func (utp *UnconfirmedTransactionPool) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error) { var known coin.Transactions diff --git a/src/visor/verify.go b/src/visor/verify.go index 42e3a26251..12c555b595 100644 --- a/src/visor/verify.go +++ b/src/visor/verify.go @@ -139,15 +139,15 @@ func (e ErrTxnViolatesUserConstraint) Error() string { // * That the transaction burn enough coin hours (the fee) // * That if that transaction does not spend from a locked distribution address // * That the transaction does not create outputs with a higher decimal precision than is allowed -func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error { - if err := verifyTxnSoftConstraints(txn, headTime, uxIn, maxSize); err != nil { +func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int, burnFactor uint64) error { + if err := verifyTxnSoftConstraints(txn, headTime, uxIn, maxSize, burnFactor); err != nil { return NewErrTxnViolatesSoftConstraint(err) } return nil } -func verifyTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error { +func verifyTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int, burnFactor uint64) error { if txn.Size() > maxSize { return errTxnExceedsMaxBlockSize } @@ -157,7 +157,7 @@ func verifyTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.U return err } - if err := fee.VerifyTransactionFee(&txn, f); err != nil { + if err := fee.VerifyTransactionFee(&txn, f, burnFactor); err != nil { return err } diff --git a/src/visor/visor.go b/src/visor/visor.go index d0e2df727c..62008ad977 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -39,15 +39,20 @@ type Config struct { // Is this the master blockchain IsMaster bool - //Public key of blockchain authority + // Public key of blockchain authority BlockchainPubkey cipher.PubKey - //Secret key of blockchain authority (if master) + // Secret key of blockchain authority (if master) BlockchainSeckey cipher.SecKey // Maximum size of a block, in bytes. MaxBlockSize int + // Burn factor to apply to unconfirmed transactions (received over the network, or when refreshing the pool) + UnconfirmedBurnFactor uint64 + // Burn factor to apply when creating blocks + CreateBlockBurnFactor uint64 + // Where the blockchain is saved BlockchainFile string // Where the block signatures are saved @@ -75,17 +80,17 @@ type Config struct { WalletCryptoType wallet.CryptoType } -// NewVisorConfig put cap on block size, not on transactions/block -//Skycoin transactions are smaller than Bitcoin transactions so skycoin has -//a higher transactions per second for the same block size -func NewVisorConfig() Config { +// NewConfig creates Config +func NewConfig() Config { c := Config{ IsMaster: false, BlockchainPubkey: cipher.PubKey{}, BlockchainSeckey: cipher.SecKey{}, - MaxBlockSize: params.DefaultMaxBlockSize, + MaxBlockSize: params.DefaultMaxBlockSize, + UnconfirmedBurnFactor: params.CoinHourBurnFactor, + CreateBlockBurnFactor: params.CoinHourBurnFactor, GenesisAddress: cipher.Address{}, GenesisSignature: cipher.Sig{}, @@ -104,13 +109,25 @@ func (c Config) Verify() error { } } + if c.UnconfirmedBurnFactor < params.CoinHourBurnFactor { + return fmt.Errorf("UnconfirmedBurnFactor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + } + + if c.CreateBlockBurnFactor < params.CoinHourBurnFactor { + return fmt.Errorf("CreateBlockBurnFactor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + } + + if c.MaxBlockSize <= 0 { + return errors.New("MaxBlockSize must be > 0") + } + return nil } //go:generate go install //go:generate mockery -name Historyer -case underscore -inpkg -testonly //go:generate mockery -name Blockchainer -case underscore -inpkg -testonly -//go:generate mockery -name UnconfirmedTxnPooler -case underscore -inpkg -testonly +//go:generate mockery -name UnconfirmedTransactionPooler -case underscore -inpkg -testonly // Historyer is the interface that provides methods for accessing history data that are parsed from blockchain. type Historyer interface { @@ -142,20 +159,20 @@ type Blockchainer interface { ExecuteBlock(tx *dbutil.Tx, sb *coin.SignedBlock) error VerifyBlockTxnConstraints(tx *dbutil.Tx, txn coin.Transaction) error VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Transaction) error - VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error + VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int, burnFactor uint64) error TransactionFee(tx *dbutil.Tx, hours uint64) coin.FeeCalculator } -// UnconfirmedTxnPooler is the interface that provides methods for +// UnconfirmedTransactionPooler is the interface that provides methods for // accessing the unconfirmed transaction pool -type UnconfirmedTxnPooler interface { +type UnconfirmedTransactionPooler interface { SetTransactionsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error - InjectTransaction(tx *dbutil.Tx, bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error) + InjectTransaction(tx *dbutil.Tx, bc Blockchainer, t coin.Transaction, maxSize int, burnFactor uint64) (bool, *ErrTxnViolatesSoftConstraint, error) AllRawTransactions(tx *dbutil.Tx) (coin.Transactions, error) RemoveTransactions(tx *dbutil.Tx, txns []cipher.SHA256) error - Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error) + Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int, burnFactor uint64) ([]cipher.SHA256, error) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error) - GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) + FilterKnown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error) RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error) GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error) @@ -171,7 +188,7 @@ type UnconfirmedTxnPooler interface { type Visor struct { Config Config DB *dbutil.DB - Unconfirmed UnconfirmedTxnPooler + Unconfirmed UnconfirmedTransactionPooler Blockchain Blockchainer Wallets *wallet.Service StartedAt time.Time @@ -190,6 +207,10 @@ func NewVisor(c Config, db *dbutil.DB) (*Visor, error) { return nil, err } + logger.Infof("Max block size is %d", c.MaxBlockSize) + logger.Infof("Coinhour burn factor for verifying unconfirmed transactions is %d", c.UnconfirmedBurnFactor) + logger.Infof("Coinhour burn factor for transactions when creating blocks is %d", c.CreateBlockBurnFactor) + // Loads wallet wltServConfig := wallet.Config{ WalletDir: c.WalletDirectory, @@ -384,7 +405,7 @@ func (vs *Visor) RefreshUnconfirmed() ([]cipher.SHA256, error) { var hashes []cipher.SHA256 if err := vs.DB.Update("RefreshUnconfirmed", func(tx *dbutil.Tx) error { var err error - hashes, err = vs.Unconfirmed.Refresh(tx, vs.Blockchain, vs.Config.MaxBlockSize) + hashes, err = vs.Unconfirmed.Refresh(tx, vs.Blockchain, vs.Config.MaxBlockSize, vs.Config.UnconfirmedBurnFactor) return err }); err != nil { return nil, err @@ -430,7 +451,7 @@ func (vs *Visor) createBlock(tx *dbutil.Tx, when uint64) (coin.SignedBlock, erro // Filter transactions that violate all constraints var filteredTxns coin.Transactions for _, txn := range txns { - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxBlockSize); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxBlockSize, vs.Config.CreateBlockBurnFactor); err != nil { switch err.(type) { case ErrTxnViolatesHardConstraint, ErrTxnViolatesSoftConstraint: logger.Warningf("Transaction %s violates constraints: %v", txn.TxIDHex(), err) @@ -861,18 +882,19 @@ func (vs *Visor) getBlocksVerbose(tx *dbutil.Tx, getBlocks func(*dbutil.Tx) ([]c return blocks, inputs, nil } -// InjectTransaction records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not +// InjectForeignTransaction records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not // already in the blockchain. // The bool return value is whether or not the transaction was already in the pool. // If the transaction violates hard constraints, it is rejected, and error will not be nil. // If the transaction only violates soft constraints, it is still injected, and the soft constraint violation is returned. -func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error) { +// This method is intended for transactions received over the network. +func (vs *Visor) InjectForeignTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error) { var known bool var softErr *ErrTxnViolatesSoftConstraint - if err := vs.DB.Update("InjectTransaction", func(tx *dbutil.Tx) error { + if err := vs.DB.Update("InjectForeignTransaction", func(tx *dbutil.Tx) error { var err error - known, softErr, err = vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize) + known, softErr, err = vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize, vs.Config.UnconfirmedBurnFactor) return err }); err != nil { return false, nil, err @@ -881,14 +903,14 @@ func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesS return known, softErr, nil } -// InjectTransactionStrict records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not +// InjectUserTransaction records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not // already in the blockchain. // The bool return value is whether or not the transaction was already in the pool. // If the transaction violates hard or soft constraints, it is rejected, and error will not be nil. -func (vs *Visor) InjectTransactionStrict(txn coin.Transaction) (bool, error) { +func (vs *Visor) InjectUserTransaction(txn coin.Transaction) (bool, error) { var known bool - if err := vs.DB.Update("InjectTransactionStrict", func(tx *dbutil.Tx) error { + if err := vs.DB.Update("InjectUserTransaction", func(tx *dbutil.Tx) error { var err error known, err = vs.InjectTransactionStrictTx(tx, txn) return err @@ -909,13 +931,13 @@ func (vs *Visor) InjectTransactionStrictTx(tx *dbutil.Tx, txn coin.Transaction) return false, err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxBlockSize); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { return false, err } - known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize) + known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor) if softErr != nil { - logger.WithError(softErr).Warning("InjectTransactionStrict vs.Unconfirmed.InjectTransaction returned a softErr unexpectedly") + logger.WithError(softErr).Warning("InjectUserTransaction vs.Unconfirmed.InjectTransaction returned a softErr unexpectedly") } return known, err @@ -1870,13 +1892,13 @@ func (vs *Visor) GetUnconfirmedTxn(hash cipher.SHA256) (*UnconfirmedTransaction, return txn, nil } -// GetUnconfirmedUnknown returns unconfirmed txn hashes with known ones removed -func (vs *Visor) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// FilterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed +func (vs *Visor) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { var hashes []cipher.SHA256 - if err := vs.DB.View("GetUnconfirmedUnknown", func(tx *dbutil.Tx) error { + if err := vs.DB.View("FilterUnconfirmedKnown", func(tx *dbutil.Tx) error { var err error - hashes, err = vs.Unconfirmed.GetUnknown(tx, txns) + hashes, err = vs.Unconfirmed.FilterKnown(tx, txns) return err }); err != nil { return nil, err @@ -2176,7 +2198,7 @@ func (vs *Visor) VerifyTxnVerbose(txn *coin.Transaction) ([]wallet.UxBalance, bo return err } - if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, vs.Config.MaxBlockSize); err != nil { + if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { return err } diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index a3ad079a19..81f96ee525 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -276,7 +276,7 @@ func TestVisorCreateBlock(t *testing.T) { his := historydb.New() - cfg := NewVisorConfig() + cfg := NewConfig() cfg.DBPath = db.Path() cfg.IsMaster = false cfg.BlockchainPubkey = genPublic @@ -330,7 +330,7 @@ func TestVisorCreateBlock(t *testing.T) { var softErr *ErrTxnViolatesSoftConstraint err = db.Update("", func(tx *dbutil.Tx) error { var err error - known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize) + known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, params.CoinHourBurnFactor) return err }) require.NoError(t, err) @@ -414,7 +414,7 @@ func TestVisorCreateBlock(t *testing.T) { var softErr *ErrTxnViolatesSoftConstraint err = db.Update("", func(tx *dbutil.Tx) error { var err error - known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize) + known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, params.CoinHourBurnFactor) return err }) require.False(t, known) @@ -497,7 +497,7 @@ func TestVisorInjectTransaction(t *testing.T) { his := historydb.New() - cfg := NewVisorConfig() + cfg := NewConfig() cfg.DBPath = db.Path() cfg.IsMaster = false cfg.BlockchainPubkey = genPublic @@ -548,7 +548,7 @@ func TestVisorInjectTransaction(t *testing.T) { // Create a transaction with valid decimal places txn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, coins) - known, softErr, err := v.InjectTransaction(txn) + known, softErr, err := v.InjectForeignTransaction(txn) require.False(t, known) require.Nil(t, softErr) require.NoError(t, err) @@ -576,7 +576,7 @@ func TestVisorInjectTransaction(t *testing.T) { // Check transactions with overflowing output coins fail txn = makeOverflowCoinsSpendTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr) - _, softErr, err = v.InjectTransaction(txn) + _, softErr, err = v.InjectForeignTransaction(txn) require.IsType(t, ErrTxnViolatesHardConstraint{}, err) testutil.RequireError(t, err.(ErrTxnViolatesHardConstraint).Err, "Output coins overflow") require.Nil(t, softErr) @@ -593,7 +593,7 @@ func TestVisorInjectTransaction(t *testing.T) { // It should not be injected; when injecting a txn, the overflowing output hours is treated // as a hard constraint. It is only a soft constraint when the txn is included in a signed block. txn = makeOverflowHoursSpendTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr) - _, softErr, err = v.InjectTransaction(txn) + _, softErr, err = v.InjectForeignTransaction(txn) require.Nil(t, softErr) require.IsType(t, ErrTxnViolatesHardConstraint{}, err) testutil.RequireError(t, err.(ErrTxnViolatesHardConstraint).Err, "Transaction output hours overflow") @@ -610,7 +610,7 @@ func TestVisorInjectTransaction(t *testing.T) { // It's still injected, because this is considered a soft error invalidCoins := coins + (params.MaxDropletDivisor() / 10) txn = makeSpendTx(t, uxs, []cipher.SecKey{genSecret, genSecret}, toAddr, invalidCoins) - _, softErr, err = v.InjectTransaction(txn) + _, softErr, err = v.InjectForeignTransaction(txn) require.NoError(t, err) testutil.RequireError(t, softErr.Err, params.ErrInvalidDecimals.Error()) @@ -626,7 +626,7 @@ func TestVisorInjectTransaction(t *testing.T) { uxs = coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) txn = makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, coins) txn.Out[0].Address = cipher.Address{} - known, err = v.InjectTransactionStrict(txn) + known, err = v.InjectUserTransaction(txn) require.False(t, known) require.IsType(t, ErrTxnViolatesUserConstraint{}, err) testutil.RequireError(t, err, "Transaction violates user constraint: Transaction output is sent to the null address") @@ -1920,7 +1920,7 @@ func TestRefreshUnconfirmed(t *testing.T) { his := historydb.New() - cfg := NewVisorConfig() + cfg := NewConfig() cfg.DBPath = db.Path() cfg.IsMaster = true cfg.BlockchainSeckey = genSecret @@ -1952,7 +1952,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // Create a valid transaction that will remain valid validTxn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, coins) - known, softErr, err := v.InjectTransaction(validTxn) + known, softErr, err := v.InjectForeignTransaction(validTxn) require.False(t, known) require.Nil(t, softErr) require.NoError(t, err) @@ -1970,7 +1970,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // This transaction will stay invalid on refresh invalidCoins := coins + (params.MaxDropletDivisor() / 10) alwaysInvalidTxn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, invalidCoins) - _, softErr, err = v.InjectTransaction(alwaysInvalidTxn) + _, softErr, err = v.InjectForeignTransaction(alwaysInvalidTxn) require.NoError(t, err) testutil.RequireError(t, softErr.Err, params.ErrInvalidDecimals.Error()) @@ -1987,7 +1987,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // This transaction will become valid on refresh (by increasing MaxBlockSize) v.Config.MaxBlockSize = 1 sometimesInvalidTxn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) - _, softErr, err = v.InjectTransaction(sometimesInvalidTxn) + _, softErr, err = v.InjectForeignTransaction(sometimesInvalidTxn) require.NoError(t, err) testutil.RequireError(t, softErr.Err, errTxnExceedsMaxBlockSize.Error()) @@ -2050,7 +2050,7 @@ func TestRemoveInvalidUnconfirmedDoubleSpendArbitrating(t *testing.T) { his := historydb.New() - cfg := NewVisorConfig() + cfg := NewConfig() cfg.DBPath = db.Path() cfg.IsMaster = true cfg.Arbitrating = true @@ -2085,7 +2085,7 @@ func TestRemoveInvalidUnconfirmedDoubleSpendArbitrating(t *testing.T) { var coins uint64 = 10e6 txn1 := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, genAddress, coins) - known, softErr, err := v.InjectTransaction(txn1) + known, softErr, err := v.InjectForeignTransaction(txn1) require.False(t, known) require.Nil(t, softErr) require.NoError(t, err) @@ -2100,7 +2100,7 @@ func TestRemoveInvalidUnconfirmedDoubleSpendArbitrating(t *testing.T) { var fee uint64 = 1 txn2 := makeSpendTxWithFee(t, uxs, []cipher.SecKey{genSecret}, genAddress, coins, fee) - known, softErr, err = v.InjectTransaction(txn2) + known, softErr, err = v.InjectForeignTransaction(txn2) require.False(t, known) require.Nil(t, softErr) require.NoError(t, err) @@ -2661,7 +2661,7 @@ func TestGetCreateTransactionAuxs(t *testing.T) { db, shutdown := testutil.PrepareDB(t) defer shutdown() - unconfirmed := &MockUnconfirmedTxnPooler{} + unconfirmed := &MockUnconfirmedTransactionPooler{} bc := &MockBlockchainer{} unspent := &MockUnspentPooler{} require.Implements(t, (*blockdb.UnspentPooler)(nil), unspent) @@ -3074,17 +3074,17 @@ func (h *historyerMock2) ForEachTxn(tx *dbutil.Tx, f func(cipher.SHA256, *histor return nil } -// UnconfirmedTxnPoolerMock2 embeds UnconfirmedTxnPoolerMock, and rewrite the GetFiltered method -type UnconfirmedTxnPoolerMock2 struct { - MockUnconfirmedTxnPooler +// MockUnconfirmedTransactionPooler2 embeds UnconfirmedTxnPoolerMock, and rewrite the GetFiltered method +type MockUnconfirmedTransactionPooler2 struct { + MockUnconfirmedTransactionPooler txns []UnconfirmedTransaction } -func NewUnconfirmedTransactionPoolerMock2() *UnconfirmedTxnPoolerMock2 { - return &UnconfirmedTxnPoolerMock2{} +func NewUnconfirmedTransactionPoolerMock2() *MockUnconfirmedTransactionPooler2 { + return &MockUnconfirmedTransactionPooler2{} } -func (m *UnconfirmedTxnPoolerMock2) GetFiltered(tx *dbutil.Tx, f func(tx UnconfirmedTransaction) bool) ([]UnconfirmedTransaction, error) { +func (m *MockUnconfirmedTransactionPooler2) GetFiltered(tx *dbutil.Tx, f func(tx UnconfirmedTransaction) bool) ([]UnconfirmedTransaction, error) { var txns []UnconfirmedTransaction for i := range m.txns { if f(m.txns[i]) { diff --git a/src/visor/visor_wallet.go b/src/visor/visor_wallet.go index be5e175a6a..4b48b7caa9 100644 --- a/src/visor/visor_wallet.go +++ b/src/visor/visor_wallet.go @@ -5,6 +5,7 @@ package visor import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/skycoin/skycoin/src/visor/dbutil" "github.com/skycoin/skycoin/src/wallet" ) @@ -102,16 +103,16 @@ func (vs *Visor) GetWalletUnconfirmedTransactionsVerbose(wltID string) ([]Unconf } // CreateTransaction creates a transaction based upon the parameters in wallet.CreateTransactionParams -func (vs *Visor) CreateTransaction(params wallet.CreateTransactionParams) (*coin.Transaction, []wallet.UxBalance, error) { - if err := params.Validate(); err != nil { +func (vs *Visor) CreateTransaction(p wallet.CreateTransactionParams) (*coin.Transaction, []wallet.UxBalance, error) { + if err := p.Validate(); err != nil { return nil, nil, err } var txn *coin.Transaction var inputs []wallet.UxBalance - if err := vs.Wallets.ViewSecrets(params.Wallet.ID, params.Wallet.Password, func(w *wallet.Wallet) error { - // Get all addresses from the wallet for checking params against + if err := vs.Wallets.ViewSecrets(p.Wallet.ID, p.Wallet.Password, func(w *wallet.Wallet) error { + // Get all addresses from the wallet for checking p against allAddrs, err := w.GetSkycoinAddresses() if err != nil { return err @@ -124,13 +125,13 @@ func (vs *Visor) CreateTransaction(params wallet.CreateTransactionParams) (*coin return err } - auxs, err := vs.getCreateTransactionAuxs(tx, params, allAddrs) + auxs, err := vs.getCreateTransactionAuxs(tx, p, allAddrs) if err != nil { return err } // Create and sign transaction - txn, inputs, err = w.CreateAndSignTransactionAdvanced(params, auxs, head.Time()) + txn, inputs, err = w.CreateAndSignTransactionAdvanced(p, auxs, head.Time()) if err != nil { logger.WithError(err).Error("CreateAndSignTransactionAdvanced failed") return err @@ -144,7 +145,7 @@ func (vs *Visor) CreateTransaction(params wallet.CreateTransactionParams) (*coin return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } @@ -201,7 +202,7 @@ func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coin return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } diff --git a/src/wallet/wallet.go b/src/wallet/wallet.go index 9fa7f0231d..a9289bed8c 100644 --- a/src/wallet/wallet.go +++ b/src/wallet/wallet.go @@ -20,6 +20,7 @@ import ( "github.com/skycoin/skycoin/src/cipher" "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/params" "github.com/shopspring/decimal" @@ -1196,8 +1197,8 @@ func (w *Wallet) CreateAndSignTransaction(auxs coin.AddressUxOuts, headTime, coi haveChange := changeCoins > 0 changeHours, addrHours, outputHours := DistributeSpendHours(spending.Hours, 1, haveChange) - logger.Infof("wallet.CreateAndSignTransaction: spending.Hours=%d, fee.VerifyTransactionFeeForHours(%d, %d)", spending.Hours, outputHours, spending.Hours-outputHours) - if err := fee.VerifyTransactionFeeForHours(outputHours, spending.Hours-outputHours); err != nil { + logger.Infof("wallet.CreateAndSignTransaction: spending.Hours=%d, fee.VerifyTransactionFeeForHours(%d, %d, %d)", spending.Hours, outputHours, spending.Hours-outputHours, params.CoinHourBurnFactor) + if err := fee.VerifyTransactionFeeForHours(outputHours, spending.Hours-outputHours, params.CoinHourBurnFactor); err != nil { logger.Warningf("wallet.CreateAndSignTransaction: fee.VerifyTransactionFeeForHours failed: %v", err) return nil, err } @@ -1228,13 +1229,13 @@ func (w *Wallet) CreateAndSignTransaction(auxs coin.AddressUxOuts, headTime, coi // if the coinhour cost of adding that output is less than the coinhours that would be lost as change // If receiving hours are not explicitly specified, hours are allocated amongst the receiving outputs proportional to the number of coins being sent to them. // If the change address is not specified, the address whose bytes are lexically sorted first is chosen from the owners of the outputs being spent. -func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams, auxs coin.AddressUxOuts, headTime uint64) (*coin.Transaction, []UxBalance, error) { - if err := params.Validate(); err != nil { +func (w *Wallet) CreateAndSignTransactionAdvanced(p CreateTransactionParams, auxs coin.AddressUxOuts, headTime uint64) (*coin.Transaction, []UxBalance, error) { + if err := p.Validate(); err != nil { return nil, nil, err } - if params.Wallet.ID != w.Filename() { - return nil, nil, NewError(errors.New("params.Wallet.ID does not match wallet")) + if p.Wallet.ID != w.Filename() { + return nil, nil, NewError(errors.New("p.Wallet.ID does not match wallet")) } if w.IsEncrypted() { @@ -1273,7 +1274,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams // calculate total coins and minimum hours to send var totalOutCoins uint64 var requestedHours uint64 - for _, to := range params.To { + for _, to := range p.To { totalOutCoins, err = coin.AddUint64(totalOutCoins, to.Coins) if err != nil { return nil, nil, NewError(fmt.Errorf("total output coins error: %v", err)) @@ -1317,20 +1318,20 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams txn.PushInput(spend.Hash) } - feeHours := fee.RequiredFee(totalInputHours) + feeHours := fee.RequiredFee(totalInputHours, params.CoinHourBurnFactor) if feeHours == 0 { return nil, nil, fee.ErrTxnNoFee } remainingHours := totalInputHours - feeHours - switch params.HoursSelection.Type { + switch p.HoursSelection.Type { case HoursSelectionTypeManual: - txn.Out = append(txn.Out, params.To...) + txn.Out = append(txn.Out, p.To...) case HoursSelectionTypeAuto: var addrHours []uint64 - switch params.HoursSelection.Mode { + switch p.HoursSelection.Mode { case HoursSelectionModeShare: // multiply remaining hours after fee burn with share factor hours, err := coin.Uint64ToInt64(remainingHours) @@ -1338,14 +1339,14 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams return nil, nil, err } - allocatedHoursInt := params.HoursSelection.ShareFactor.Mul(decimal.New(hours, 0)).IntPart() + allocatedHoursInt := p.HoursSelection.ShareFactor.Mul(decimal.New(hours, 0)).IntPart() allocatedHours, err := coin.Int64ToUint64(allocatedHoursInt) if err != nil { return nil, nil, err } - toCoins := make([]uint64, len(params.To)) - for i, to := range params.To { + toCoins := make([]uint64, len(p.To)) + for i, to := range p.To { toCoins[i] = to.Coins } @@ -1357,7 +1358,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams return nil, nil, ErrInvalidHoursSelectionType } - for i, out := range params.To { + for i, out := range p.To { out.Hours = addrHours[i] txn.Out = append(txn.Out, out) } @@ -1408,7 +1409,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams } // Calculate the new fee for this new amount of hours - newFee := fee.RequiredFee(newTotalHours) + newFee := fee.RequiredFee(newTotalHours, params.CoinHourBurnFactor) if newFee < feeHours { err := errors.New("updated fee after adding extra input for change is unexpectedly less than it was initially") logger.WithError(err).Error() @@ -1446,19 +1447,19 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams // With auto share mode, if there are leftover hours and change couldn't be force-added, // recalculate that share ratio at 100% - if changeCoins == 0 && changeHours > 0 && params.HoursSelection.Type == HoursSelectionTypeAuto && params.HoursSelection.Mode == HoursSelectionModeShare { + if changeCoins == 0 && changeHours > 0 && p.HoursSelection.Type == HoursSelectionTypeAuto && p.HoursSelection.Mode == HoursSelectionModeShare { oneDecimal := decimal.New(1, 0) - if params.HoursSelection.ShareFactor.Equal(oneDecimal) { + if p.HoursSelection.ShareFactor.Equal(oneDecimal) { return nil, nil, errors.New("share factor is 1.0 but changeHours > 0 unexpectedly") } - params.HoursSelection.ShareFactor = &oneDecimal - return w.CreateAndSignTransactionAdvanced(params, auxs, headTime) + p.HoursSelection.ShareFactor = &oneDecimal + return w.CreateAndSignTransactionAdvanced(p, auxs, headTime) } if changeCoins > 0 { var changeAddress cipher.Address - if params.ChangeAddress != nil { - changeAddress = *params.ChangeAddress + if p.ChangeAddress != nil { + changeAddress = *p.ChangeAddress } else { // Choose a change address from the unspent outputs // Sort spends by address, comparing bytes, and use the first @@ -1499,7 +1500,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams inputs[i] = uxBalance } - if err := verifyCreatedTransactionInvariants(params, txn, inputs); err != nil { + if err := verifyCreatedTransactionInvariants(p, txn, inputs); err != nil { logger.Critical().Errorf("CreateAndSignTransactionAdvanced created transaction that violates invariants, aborting: %v", err) return nil, nil, fmt.Errorf("Created transaction that violates invariants, this is a bug: %v", err) } @@ -1510,7 +1511,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(params CreateTransactionParams // verifyCreatedTransactionInvariants checks that the transaction that was created matches expectations. // Does not call visor verification methods because that causes import cycle. // daemon.Gateway checks that the transaction passes additional visor verification methods. -func verifyCreatedTransactionInvariants(params CreateTransactionParams, txn *coin.Transaction, inputs []UxBalance) error { +func verifyCreatedTransactionInvariants(p CreateTransactionParams, txn *coin.Transaction, inputs []UxBalance) error { for _, o := range txn.Out { // No outputs should be sent to the null address if o.Address.Null() { @@ -1522,20 +1523,20 @@ func verifyCreatedTransactionInvariants(params CreateTransactionParams, txn *coi } } - if len(txn.Out) != len(params.To) && len(txn.Out) != len(params.To)+1 { + if len(txn.Out) != len(p.To) && len(txn.Out) != len(p.To)+1 { return errors.New("Transaction has unexpected number of outputs") } - for i, o := range txn.Out[:len(params.To)] { - if o.Address != params.To[i].Address { + for i, o := range txn.Out[:len(p.To)] { + if o.Address != p.To[i].Address { return errors.New("Output address does not match requested address") } - if o.Coins != params.To[i].Coins { + if o.Coins != p.To[i].Coins { return errors.New("Output coins does not match requested coins") } - if params.To[i].Hours != 0 && o.Hours != params.To[i].Hours { + if p.To[i].Hours != 0 && o.Hours != p.To[i].Hours { return errors.New("Output hours does not match requested hours") } } @@ -1598,7 +1599,7 @@ func verifyCreatedTransactionInvariants(params CreateTransactionParams, txn *coi return errors.New("Total input hours is less than the output hours") } - if inputHours-outputHours < fee.RequiredFee(inputHours) { + if inputHours-outputHours < fee.RequiredFee(inputHours, params.CoinHourBurnFactor) { return errors.New("Transaction will not satisy required fee") } @@ -1617,7 +1618,7 @@ func verifyCreatedTransactionInvariants(params CreateTransactionParams, txn *coi // an array of length nAddrs with the hours to give to each destination address, // and a sum of these values. func DistributeSpendHours(inputHours, nAddrs uint64, haveChange bool) (uint64, []uint64, uint64) { - feeHours := fee.RequiredFee(inputHours) + feeHours := fee.RequiredFee(inputHours, params.CoinHourBurnFactor) remainingHours := inputHours - feeHours var changeHours uint64 @@ -1971,7 +1972,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa have.Coins += firstNonzero.Coins have.Hours += firstNonzero.Hours - if have.Coins >= coins && fee.RemainingHours(have.Hours) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { return spending, nil } @@ -1989,7 +1990,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa } } - if have.Coins >= coins && fee.RemainingHours(have.Hours) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { return spending, nil } @@ -2002,7 +2003,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa have.Coins += ux.Coins have.Hours += ux.Hours - if have.Coins >= coins && fee.RemainingHours(have.Hours) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { return spending, nil } } diff --git a/src/wallet/wallet_test.go b/src/wallet/wallet_test.go index e93358236a..c5efa2db9d 100644 --- a/src/wallet/wallet_test.go +++ b/src/wallet/wallet_test.go @@ -1277,7 +1277,7 @@ func TestWalletDistributeSpendHours(t *testing.T) { require.Equal(t, outputHours, totalHours) if tc.inputHours != 0 { - err := fee.VerifyTransactionFeeForHours(outputHours, tc.inputHours-outputHours) + err := fee.VerifyTransactionFeeForHours(outputHours, tc.inputHours-outputHours, params.CoinHourBurnFactor) require.NoError(t, err) } }) @@ -1304,13 +1304,13 @@ func TestWalletDistributeSpendHours(t *testing.T) { } if haveChange { - remainingHours := (inputHours - fee.RequiredFee(inputHours)) + remainingHours := (inputHours - fee.RequiredFee(inputHours, params.CoinHourBurnFactor)) splitRemainingHours := remainingHours / 2 require.True(t, changeHours == splitRemainingHours || changeHours == splitRemainingHours+1) require.Equal(t, splitRemainingHours, sumAddrHours) } else { require.Equal(t, uint64(0), changeHours) - require.Equal(t, inputHours-fee.RequiredFee(inputHours), sumAddrHours) + require.Equal(t, inputHours-fee.RequiredFee(inputHours, params.CoinHourBurnFactor), sumAddrHours) } outputHours := sumAddrHours + changeHours @@ -1318,7 +1318,7 @@ func TestWalletDistributeSpendHours(t *testing.T) { require.Equal(t, outputHours, totalHours) if inputHours != 0 { - err := fee.VerifyTransactionFeeForHours(outputHours, inputHours-outputHours) + err := fee.VerifyTransactionFeeForHours(outputHours, inputHours-outputHours, params.CoinHourBurnFactor) require.NoError(t, err) } diff --git a/template/coin.template b/template/coin.template index ee1e647eee..a42114778d 100755 --- a/template/coin.template +++ b/template/coin.template @@ -57,18 +57,20 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ - CoinName: CoinName, - GenesisSignatureStr: GenesisSignatureStr, - GenesisAddressStr: GenesisAddressStr, - GenesisCoinVolume: GenesisCoinVolume, - GenesisTimestamp: GenesisTimestamp, - BlockchainPubkeyStr: BlockchainPubkeyStr, - BlockchainSeckeyStr: BlockchainSeckeyStr, - DefaultConnections: DefaultConnections, - PeerListURL: "{{.PeerListURL}}", - Port: {{.Port}}, - WebInterfacePort: {{.WebInterfacePort}}, - DataDirectory: "{{.DataDirectory}}", + CoinName: CoinName, + GenesisSignatureStr: GenesisSignatureStr, + GenesisAddressStr: GenesisAddressStr, + GenesisCoinVolume: GenesisCoinVolume, + GenesisTimestamp: GenesisTimestamp, + BlockchainPubkeyStr: BlockchainPubkeyStr, + BlockchainSeckeyStr: BlockchainSeckeyStr, + DefaultConnections: DefaultConnections, + PeerListURL: "{{.PeerListURL}}", + Port: {{.Port}}, + WebInterfacePort: {{.WebInterfacePort}}, + DataDirectory: "{{.DataDirectory}}", + UnconfirmedBurnFactor: {{.UnconfirmedBurnFactor}}, + CreateBlockBurnFactor: {{.CreateBlockBurnFactor}}, }) parseFlags = true diff --git a/template/params.template b/template/params.template index 9ae4d8ba85..090e05bb1c 100644 --- a/template/params.template +++ b/template/params.template @@ -25,8 +25,10 @@ const ( ) var ( - // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var) - CoinHourBurnFactor uint64 = 2 + // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var), + // used when creating a transaction + CoinHourBurnFactor uint64 = {{.CoinHourBurnFactor}} + // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = {{.MaxDropletPrecision}} ) From 96d559532c1c2aad016e4c8264d3e1b6e4f4afa9 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 00:00:24 +0800 Subject: [PATCH 376/399] Fix lint --- src/daemon/messages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index f98ce033d1..9a0acd3224 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -697,7 +697,7 @@ type SendingTxnsMessage interface { // AnnounceTxnsMessage tells a peer that we have these transactions type AnnounceTxnsMessage struct { - Transactions []cipher.SHA256 `enc:",maxlen=256` + Transactions []cipher.SHA256 `enc:",maxlen=256"` c *gnet.MessageContext `enc:"-"` } From 84002f9fd3646474912248e9e162df2574454ec6 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 1 Nov 2018 15:11:55 -0400 Subject: [PATCH 377/399] [lib] refs #1191 - Connection states and filters in API endpoints. SKY_cipher_ChkSig => SKY_cipher_VerifyAddressSignedHash [====] Synthesis: Tested: 137 | Passing: 137 | Failing: 0 | Crashing: 0 --- include/api.client.go.h | 7 ++++ include/skyerrors.h | 2 +- lib/cgo/api.client.go | 48 +++++++++++++++++-------- lib/cgo/tests/check_coin.transactions.c | 10 +++--- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/include/api.client.go.h b/include/api.client.go.h index 4dfe4e7cf1..58838440ff 100644 --- a/include/api.client.go.h +++ b/include/api.client.go.h @@ -2,3 +2,10 @@ typedef struct{ GoInt_ N; BOOL IncludeDistribution; } api__RichlistParams; + +typedef struct{ + // Comma separated list of connection states ("pending", "connected", "introduced") + GoString_ States; + GoString_ Direction; +} api__NetworkConnectionsFilter; + diff --git a/include/skyerrors.h b/include/skyerrors.h index 8f2783cfc3..94380c38fb 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -65,7 +65,7 @@ #define SKY_ErrInvalidBytesLength 0x02000015 #define SKY_ErrInvalidPubKey 0x02000016 #define SKY_ErrInvalidSecKey 0x02000017 -#define SKY_ErrInvalidSigPubKeyRecovery 0x02000018 +#define SKY_ErrInvalidSigPubKeyRecovery 0x02000018 #define SKY_ErrInvalidSecKeyHex 0x02000019 #define SKY_ErrInvalidAddressForSig 0x0200001A #define SKY_ErrInvalidHashForSig 0x0200001B diff --git a/lib/cgo/api.client.go b/lib/cgo/api.client.go index 41c4a1f091..bc9f4c8ad8 100644 --- a/lib/cgo/api.client.go +++ b/lib/cgo/api.client.go @@ -1,9 +1,12 @@ package main import ( + "reflect" + "strings" "unsafe" api "github.com/skycoin/skycoin/src/api" + daemon "github.com/skycoin/skycoin/src/daemon" ) /* @@ -477,14 +480,31 @@ func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 * return } +type _networkConnectionsFilter struct { + States string + Direction string +} + +func parseNetworkConnectionsFilter(_filter *C.api__NetworkConnectionsFilter, filter *api.NetworkConnectionsFilter) { + __filter := (*_networkConnectionsFilter)(unsafe.Pointer(_filter)) + states := strings.Split(string(__filter.States), ",") + filter.States = make([]daemon.ConnectionState, len(states)) + for i, state := range states { + filter.States[i] = daemon.ConnectionState(state) + } + filter.Direction = string(__filter.Direction) +} + //export SKY_api_Client_NetworkConnections -func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { +func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _filters *C.api__NetworkConnectionsFilter, _arg0 *C.Handle) (____error_code uint32) { c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - __arg0, ____return_err := c.NetworkConnections() + var filters api.NetworkConnectionsFilter + parseNetworkConnectionsFilter(_filters, &filters) + __arg0, ____return_err := c.NetworkConnections(&filters) ____error_code = libErrorCode(____return_err) if ____return_err == nil { *_arg0 = registerHandle(__arg0) @@ -492,47 +512,47 @@ func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _arg0 *C.Handle) (__ return } -//export SKY_api_Client_NetworkDefaultConnections -func SKY_api_Client_NetworkDefaultConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { +//export SKY_api_Client_NetworkDefaultPeers +func SKY_api_Client_NetworkDefaultPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - __arg0, ____return_err := c.NetworkDefaultConnections() + __arg0, ____return_err := c.NetworkDefaultPeers() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerHandle(__arg0) + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) } return } -//export SKY_api_Client_NetworkTrustedConnections -func SKY_api_Client_NetworkTrustedConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { +//export SKY_api_Client_NetworkTrustedPeers +func SKY_api_Client_NetworkTrustedPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - __arg0, ____return_err := c.NetworkTrustedConnections() + __arg0, ____return_err := c.NetworkTrustedPeers() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerHandle(__arg0) + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) } return } -//export SKY_api_Client_NetworkExchangeableConnections -func SKY_api_Client_NetworkExchangeableConnections(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { +//export SKY_api_Client_NetworkExchangedPeers +func SKY_api_Client_NetworkExchangedPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { c, okc := lookupClientHandle(_c) if !okc { ____error_code = SKY_BAD_HANDLE return } - __arg0, ____return_err := c.NetworkExchangeableConnections() + __arg0, ____return_err := c.NetworkExchangedPeers() ____error_code = libErrorCode(____return_err) if ____return_err == nil { - *_arg0 = registerHandle(__arg0) + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) } return } diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 62c50fa1bf..98995b3ffb 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -114,7 +114,7 @@ Test(coin_transaction, TestTransactionVerify) ptx = makeTransaction(&handle); memset(ptx->Sigs.data, 0, sizeof(cipher__Sig)); result = SKY_coin_Transaction_Verify(handle); - cr_assert(result == SKY_ErrInvalidSigForPubKey); + cr_assert(result == SKY_ErrInvalidSigPubKeyRecovery); // Output coins are 0 ptx = makeTransaction(&handle); @@ -483,14 +483,14 @@ Test(coin_transactions, TestTransactionSignInputs, SKY_ABORT) result = SKY_cipher_AddSHA256(&hash, ((cipher__SHA256 *)ptx->In.data) + 1, &addHash2); cr_assert(result == SKY_OK); - result = SKY_cipher_ChkSig(&addr, &addHash, (cipher__Sig *)ptx->Sigs.data); + result = SKY_cipher_VerifyAddressSignedHash(&addr, &addHash, (cipher__Sig *)ptx->Sigs.data); cr_assert(result == SKY_OK); result = - SKY_cipher_ChkSig(&addr2, &addHash2, ((cipher__Sig *)ptx->Sigs.data) + 1); + SKY_cipher_VerifyAddressSignedHash(&addr2, &addHash2, ((cipher__Sig *)ptx->Sigs.data) + 1); cr_assert(result == SKY_OK); - result = SKY_cipher_ChkSig(&addr, &hash, ((cipher__Sig *)ptx->Sigs.data) + 1); + result = SKY_cipher_VerifyAddressSignedHash(&addr, &hash, ((cipher__Sig *)ptx->Sigs.data) + 1); cr_assert(result == SKY_ERROR); - result = SKY_cipher_ChkSig(&addr2, &hash, (cipher__Sig *)ptx->Sigs.data); + result = SKY_cipher_VerifyAddressSignedHash(&addr2, &hash, (cipher__Sig *)ptx->Sigs.data); cr_assert(result == SKY_ERROR); } From 449322d116e8a7faab2b29ebf6f4f18157a090f1 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 1 Nov 2018 21:53:00 -0400 Subject: [PATCH 378/399] [ci] refs #1996 - Try gcc@7 formula with xcode8.3 image ... since gcc@6 fails as follows ``` $ CC=gcc-6 make test-libc mkdir -p build/usr/tmp build/usr/lib build/usr/include mkdir -p build/libskycoin bin include rm -Rf build/libskycoin/libskycoin.a go build -buildmode=c-archive -o build/libskycoin/libskycoin.a ./lib/cgo/api.webrpc.client.go ./lib/cgo/cipher.address.go ./lib/cgo/cipher.bitcoin.go ./lib/cgo/cipher.crypto.go ./lib/cgo/cipher.hash.go ./lib/cgo/cli.create_rawtx.go ./lib/cgo/coin.outputs.go ./lib/cgo/libsky_error.go ./lib/cgo/libsky_handle.go ./lib/cgo/libsky_mem.go ./lib/cgo/main.go ./lib/cgo/wallet.wallet.go ./lib/cgo/wallet_option.go # crypto/x509 In file included from /usr/include/Availability.h:190:0, from /usr/include/sys/time.h:69, from /usr/include/sys/sysctl.h:82, from /Users/travis/.gimme/versions/go1.11.1.darwin.amd64/src/crypto/x509/root_cgo_darwin.go:14: /System/Library/Frameworks/CoreFoundation.framework/Headers/CFDateFormatter.h:53:34: error: "introduced" undeclared here (not in a function) kCFISO8601DateFormatWithYear API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) = (1UL << 0), ^ /System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:777:39: error: "deprecated" undeclared here (not in a function) const CFStringRef kCFURLLabelColorKey API_DEPRECATED("Use NSURLLabelColorKey", macosx(10.6, 10.12), ios(4.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0)); ^ /System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:777:39: error: "message" undeclared here (not in a function) const CFStringRef kCFURLLabelColorKey API_DEPRECATE const CFStringRef kCFURLLabelColorKey A 10.12), io const CFStringRef kCFURLLabelColorKey A0, 10.0)); ^ In file included from /System/Library/Frameworks/Security.framework/HeadeIn file included from /System/Library/Frameworks/Security.framework/HeadeIn file included from /System/Library/Frameworks/Security.frarom /Users/travis/.gimme/versions/go1.11.1.darwin.amd64/src/crypto/x509/root_cgo_darwin.go:17: /System/Library/Frameworks/Security.framework/Headers/Authorization.h:192:7: error: variably modified "bytes" at file scope char bytes[kAuthorizationExternalFormLength]; ^~~~~ make: *** [build/libskycoin/libskycoin.a] Error 2 ``` p.s. commented out previous build steps to speed up the build --- .travis.yml | 38 ++++++++++++++++---------------- ci-scripts/install-travis-gcc.sh | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88f16553c5..cc709d49d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,25 +61,25 @@ before_script: - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start; fi script: - - make lint - - make test-386 - - make test-amd64 - # Stable integration tests - - make integration-test-stable - # Stable integration tests without CSRF - - make integration-test-stable-disable-csrf - # Disable wallet api test - - make integration-test-disable-wallet-api - # Disable seed api test - - make integration-test-disable-seed-api - # Enable seed api test - - make integration-test-enable-seed-api - # Disable GUI test - - make integration-test-disable-gui - # Enable auth test - - make integration-test-auth - # Stable integration tests without unconfirmed transactions - - make integration-test-db-no-unconfirmed +# - make lint +# - make test-386 +# - make test-amd64 +# # Stable integration tests +# - make integration-test-stable +# # Stable integration tests without CSRF +# - make integration-test-stable-disable-csrf +# # Disable wallet api test +# - make integration-test-disable-wallet-api +# # Disable seed api test +# - make integration-test-disable-seed-api +# # Enable seed api test +# - make integration-test-enable-seed-api +# # Disable GUI test +# - make integration-test-disable-gui +# # Enable auth test +# - make integration-test-auth +# # Stable integration tests without unconfirmed transactions +# - make integration-test-db-no-unconfirmed # libskycoin tests - CC=gcc-6 make test-libc # TODO: test pyskycoin diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index c894c2d01e..c2580591e8 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -8,7 +8,7 @@ fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update echo 'Available versions (gcc)' && brew list --versions gcc - brew list gcc@6 &>/dev/null || brew install gcc@6 || brew link --overwrite gcc@6 + brew list gcc@7 &>/dev/null || brew install gcc@6 || brew link --overwrite gcc@6 fi cd $TRAVIS_BUILD_DIR From 241058a48e1c92f3e236c2015a0c39cfa76766a0 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 10:41:55 +0800 Subject: [PATCH 379/399] Use Warning log level for intro extra data problems --- src/daemon/messages.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 9a0acd3224..316d4bbaf7 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -394,7 +394,7 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.WithField("addr", addr).Info("Extra data length does not meet the minimum requirement") + logger.WithField("addr", addr).Warning("Extra data length does not meet the minimum requirement") return nil, ErrDisconnectInvalidExtraData } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) @@ -411,13 +411,13 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { userAgentSerialized := intro.Extra[len(bcPubKey):] userAgent, _, err := encoder.DeserializeString(userAgentSerialized, useragent.MaxLen) if err != nil { - logger.WithError(err).Info("Extra data user agent string could not be deserialized") + logger.WithError(err).Warning("Extra data user agent string could not be deserialized") return nil, ErrDisconnectInvalidExtraData } userAgentData, err = useragent.Parse(useragent.Sanitize(userAgent)) if err != nil { - logger.WithError(err).WithField("userAgent", userAgent).Info("User agent is invalid") + logger.WithError(err).WithField("userAgent", userAgent).Warning("User agent is invalid") return nil, ErrDisconnectInvalidUserAgent } } From 69a7b1e4a00892af089631211634b440e7f02675 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 10:43:04 +0800 Subject: [PATCH 380/399] Use Warning log level for intro extra data problems --- src/daemon/messages.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/daemon/messages.go b/src/daemon/messages.go index a4722d874a..a085097a61 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -391,7 +391,7 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { if len(intro.Extra) > 0 { var bcPubKey cipher.PubKey if len(intro.Extra) < len(bcPubKey) { - logger.WithFields(fields).Info("Extra data length does not meet the minimum requirement") + logger.WithFields(fields).Warning("Extra data length does not meet the minimum requirement") return nil, ErrDisconnectInvalidExtraData } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) @@ -400,20 +400,20 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { logger.WithFields(fields).WithFields(logrus.Fields{ "pubkey": bcPubKey.Hex(), "daemonPubkey": d.BlockchainPubkey().Hex(), - }).Info("Blockchain pubkey does not match") + }).Warning("Blockchain pubkey does not match") return nil, ErrDisconnectBlockchainPubkeyNotMatched } userAgentSerialized := intro.Extra[len(bcPubKey):] userAgent, _, err := encoder.DeserializeString(userAgentSerialized, useragent.MaxLen) if err != nil { - logger.WithError(err).WithFields(fields).Info("Extra data user agent string could not be deserialized") + logger.WithError(err).WithFields(fields).Warning("Extra data user agent string could not be deserialized") return nil, ErrDisconnectInvalidExtraData } userAgentData, err = useragent.Parse(useragent.Sanitize(userAgent)) if err != nil { - logger.WithError(err).WithFields(fields).WithField("userAgent", userAgent).Info("User agent is invalid") + logger.WithError(err).WithFields(fields).WithField("userAgent", userAgent).Warning("User agent is invalid") return nil, ErrDisconnectInvalidUserAgent } } From b28c908f2f6ec1e40cecc00aa39ab6dc2191ddaf Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 10:43:50 +0800 Subject: [PATCH 381/399] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8de8b60e0..dd2a35fd25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - `/api/v1/network/connection*` field `"connected_at"` added to connection object - `/api/v1/network/connections` now includes incoming connections. Filters are added to query connections by state and direction - `/api/v1/resendUnconfirmedTxns` is now a `POST` method, previously was a `GET` method +- Transactions that violation soft constraints will propagate through the network ### Removed From 9ba2c845d19bd7592e53a107009c11f1ae57612e Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 10:46:33 +0800 Subject: [PATCH 382/399] Switch unconfirmed and create block burn factor back to 2 --- cmd/skycoin/skycoin.go | 4 ++-- fiber.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/skycoin/skycoin.go b/cmd/skycoin/skycoin.go index b298567461..034edd30c8 100644 --- a/cmd/skycoin/skycoin.go +++ b/cmd/skycoin/skycoin.go @@ -73,8 +73,8 @@ var ( Port: 6000, WebInterfacePort: 6420, DataDirectory: "$HOME/.skycoin", - UnconfirmedBurnFactor: 10, - CreateBlockBurnFactor: 10, + UnconfirmedBurnFactor: 2, + CreateBlockBurnFactor: 2, }) parseFlags = true diff --git a/fiber.toml b/fiber.toml index 1f60e2119c..2245256201 100644 --- a/fiber.toml +++ b/fiber.toml @@ -20,8 +20,8 @@ default_connections = [ peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" #port = 6000 #web_interface_port = 6420 -unconfirmed_burn_factor = 10 -create_block_burn_factor = 10 +unconfirmed_burn_factor = 2 +create_block_burn_factor = 2 [params] #max_coin_supply = 1e8 From 407202622fa1e2081d7c793863e22a0c3cab513f Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 2 Nov 2018 00:25:35 -0400 Subject: [PATCH 383/399] [ci] refs #1996 - Create and brew install new formula gcc@64 --- .travis.yml | 2 +- ci-scripts/install-travis-gcc.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc709d49d2..3481e379d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: - os: osx # Do not start osx build for PR if: type != pull_request - osx_image: xcode8.3 + osx_image: xcode8 env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=30s before_install: diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index c2580591e8..4d14409ebb 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -7,8 +7,13 @@ fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update - echo 'Available versions (gcc)' && brew list --versions gcc - brew list gcc@7 &>/dev/null || brew install gcc@6 || brew link --overwrite gcc@6 + echo 'Available versions (gcc)' + brew list --versions gcc + echo 'Installing gcc@64 formula' + cd "$(brew --repository)/Library/Taps/homebrew/homebrew-core" + git show 42d31bba7772fb01f9ba442d9ee98b33a6e7a055:Formula/gcc\@6.rb > Formula/gcc\@64.rb + sed -i '' -e 's/GccAT6/GccAT64/g' Formula/gcc\@64.rb + brew install gcc@64 || brew link --overwrite gcc\@64 fi cd $TRAVIS_BUILD_DIR From c486aac09112d68366887506138e7656d4b205e8 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 2 Nov 2018 00:40:30 -0400 Subject: [PATCH 384/399] [ci] refs #1996 - Overwrite gcc\@6 formula (instead of creating new one) --- ci-scripts/install-travis-gcc.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index 4d14409ebb..8ac0f7421e 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -6,14 +6,15 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + echo 'Updating packages database' brew update echo 'Available versions (gcc)' brew list --versions gcc - echo 'Installing gcc@64 formula' + echo 'Creating gcc@64 formula' cd "$(brew --repository)/Library/Taps/homebrew/homebrew-core" - git show 42d31bba7772fb01f9ba442d9ee98b33a6e7a055:Formula/gcc\@6.rb > Formula/gcc\@64.rb - sed -i '' -e 's/GccAT6/GccAT64/g' Formula/gcc\@64.rb - brew install gcc@64 || brew link --overwrite gcc\@64 + git show 42d31bba7772fb01f9ba442d9ee98b33a6e7a055:Formula/gcc\@6.rb > Formula/gcc\@6.rb + echo 'Installing gcc@6 (6.4.0-2)' + brew install gcc\@6 || brew link --overwrite gcc\@6 fi cd $TRAVIS_BUILD_DIR From bdec63369833c8842d195083a442618bf2a3430b Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 2 Nov 2018 00:55:33 -0400 Subject: [PATCH 385/399] [ci] refs #1996 - Restore Travis build steps --- .travis.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3481e379d4..c3f17e71be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,25 +61,25 @@ before_script: - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start; fi script: -# - make lint -# - make test-386 -# - make test-amd64 -# # Stable integration tests -# - make integration-test-stable -# # Stable integration tests without CSRF -# - make integration-test-stable-disable-csrf -# # Disable wallet api test -# - make integration-test-disable-wallet-api -# # Disable seed api test -# - make integration-test-disable-seed-api -# # Enable seed api test -# - make integration-test-enable-seed-api -# # Disable GUI test -# - make integration-test-disable-gui -# # Enable auth test -# - make integration-test-auth -# # Stable integration tests without unconfirmed transactions -# - make integration-test-db-no-unconfirmed + - make lint + - make test-386 + - make test-amd64 + # Stable integration tests + - make integration-test-stable + # Stable integration tests without CSRF + - make integration-test-stable-disable-csrf + # Disable wallet api test + - make integration-test-disable-wallet-api + # Disable seed api test + - make integration-test-disable-seed-api + # Enable seed api test + - make integration-test-enable-seed-api + # Disable GUI test + - make integration-test-disable-gui + # Enable auth test + - make integration-test-auth + # Stable integration tests without unconfirmed transactions + - make integration-test-db-no-unconfirmed # libskycoin tests - CC=gcc-6 make test-libc # TODO: test pyskycoin From 98872d009b36601b96be03e2731c8eb413d6c8c3 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 2 Nov 2018 00:58:38 -0400 Subject: [PATCH 386/399] [ci] refs #1996 - Minor typos in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c3f17e71be..d0069cf5d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ script: - make test-amd64 # Stable integration tests - make integration-test-stable - # Stable integration tests without CSRF + # Stable integration tests without CSRF - make integration-test-stable-disable-csrf # Disable wallet api test - make integration-test-disable-wallet-api From 1904ae94fc2955233683715164025986fde73086 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 13:43:54 +0800 Subject: [PATCH 387/399] Clean up public/private daemon methods --- src/daemon/daemon.go | 359 ++++++++++++++----------------- src/daemon/gateway.go | 48 ++--- src/daemon/gnet/pool.go | 16 +- src/daemon/gnet/pool_test.go | 9 +- src/daemon/messages.go | 117 +++++----- src/daemon/messages_test.go | 10 +- src/daemon/mock_daemoner_test.go | 267 +++++++++++------------ 7 files changed, 392 insertions(+), 434 deletions(-) diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 948a152f12..0739bc6c81 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -6,6 +6,7 @@ package daemon import ( "errors" "fmt" + "math/rand" "reflect" "strings" "sync" @@ -190,6 +191,8 @@ type DaemonConfig struct { // nolint: golint // User agent (sent in introduction messages) UserAgent useragent.Data userAgent string // parsed from UserAgent in preprocess() + // Random nonce value for detecting self-connection in introduction messages + Mirror uint32 } // NewDaemonConfig creates daemon config @@ -220,6 +223,7 @@ func NewDaemonConfig() DaemonConfig { BlockCreationInterval: 10, UnconfirmedRefreshRate: time.Minute, UnconfirmedRemoveInvalidRate: time.Minute, + Mirror: rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32(), } } @@ -228,24 +232,21 @@ func NewDaemonConfig() DaemonConfig { // daemoner Daemon interface type daemoner interface { - SendMessage(addr string, msg gnet.Message) error - BroadcastMessage(msg gnet.Message) error Disconnect(addr string, r gnet.DisconnectReason) error - DisconnectNow(addr string, r gnet.DisconnectReason) error - PexConfig() pex.Config - AddPeers(addrs []string) int - RecordPeerHeight(addr string, gnetID, height uint64) - GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) - HeadBkSeq() (uint64, bool, error) - ExecuteSignedBlock(b coin.SignedBlock) error - FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) - GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) - Mirror() uint32 - DaemonConfig() DaemonConfig - BlockchainPubkey() cipher.PubKey - RequestBlocksFromAddr(addr string) error - AnnounceAllTxns() error - + sendMessage(addr string, msg gnet.Message) error + broadcastMessage(msg gnet.Message) (int, error) + disconnectNow(addr string, r gnet.DisconnectReason) error + addPeers(addrs []string) int + recordPeerHeight(addr string, gnetID, height uint64) + getSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) + headBkSeq() (uint64, bool, error) + executeSignedBlock(b coin.SignedBlock) error + filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) + getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) + requestBlocksFromAddr(addr string) error + announceAllTxns() error + daemonConfig() DaemonConfig + pexConfig() pex.Config injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) @@ -508,8 +509,9 @@ loop: } m := NewGetPeersMessage() - if err := dm.BroadcastMessage(m); err != nil { + if _, err := dm.broadcastMessage(m); err != nil { logger.WithError(err).Error("Broadcast GetPeersMessage failed") + continue } case <-clearStaleConnectionsTicker.C: @@ -576,7 +578,7 @@ loop: // Create blocks, if master chain elapser.Register("blockCreationTicker.C") if dm.visor.Config.IsMaster { - sb, err := dm.CreateAndPublishBlock() + sb, err := dm.createAndPublishBlock() if err != nil { logger.WithError(err).Error("Failed to create and publish block") continue @@ -600,8 +602,8 @@ loop: continue } // Announce these transactions - if err := dm.AnnounceTxns(validTxns); err != nil { - logger.WithError(err).Warning("AnnounceTxns failed") + if err := dm.announceTxns(validTxns); err != nil { + logger.WithError(err).Warning("announceTxns failed") } case <-unconfirmedRemoveInvalidTicker.C: @@ -618,14 +620,14 @@ loop: case <-blocksRequestTicker.C: elapser.Register("blocksRequestTicker") - if err := dm.RequestBlocks(); err != nil { - logger.WithError(err).Warning("RequestBlocks failed") + if err := dm.requestBlocks(); err != nil { + logger.WithError(err).Warning("requestBlocks failed") } case <-blocksAnnounceTicker.C: elapser.Register("blocksAnnounceTicker") - if err := dm.AnnounceBlocks(); err != nil { - logger.WithError(err).Warning("AnnounceBlocks failed") + if err := dm.announceBlocks(); err != nil { + logger.WithError(err).Warning("announceBlocks failed") } case setupErr = <-errC: @@ -878,8 +880,8 @@ func (dm *Daemon) onConnectEvent(e ConnectEvent) { logger.WithFields(fields).Debug("Sending introduction message") - m := NewIntroductionMessage(dm.Messages.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) - if err := dm.SendMessage(e.Addr, m); err != nil { + m := NewIntroductionMessage(dm.Config.Mirror, dm.Config.ProtocolVersion, dm.pool.Pool.Config.Port, dm.Config.BlockchainPubkey, dm.Config.userAgent) + if err := dm.sendMessage(e.Addr, m); err != nil { logger.WithFields(fields).WithError(err).Error("Send IntroductionMessage failed") return } @@ -993,19 +995,19 @@ func (dm *Daemon) handleMessageSendResult(r gnet.SendResult) { } if m, ok := r.Message.(*DisconnectMessage); ok { - if err := dm.DisconnectNow(r.Addr, m.reason); err != nil { - logger.WithError(err).WithField("addr", r.Addr).Warning("DisconnectNow") + if err := dm.disconnectNow(r.Addr, m.reason); err != nil { + logger.WithError(err).WithField("addr", r.Addr).Warning("disconnectNow") } } } -// RequestBlocks Sends a GetBlocksMessage to all connections -func (dm *Daemon) RequestBlocks() error { +// requestBlocks sends a GetBlocksMessage to all connections +func (dm *Daemon) requestBlocks() error { if dm.Config.DisableNetworking { return ErrNetworkingDisabled } - headSeq, ok, err := dm.HeadBkSeq() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { return err } @@ -1015,21 +1017,21 @@ func (dm *Daemon) RequestBlocks() error { m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - err = dm.BroadcastMessage(m) - if err != nil { + if _, err := dm.broadcastMessage(m); err != nil { logger.WithError(err).Debug("Broadcast GetBlocksMessage failed") + return err } - return err + return nil } -// AnnounceBlocks sends an AnnounceBlocksMessage to all connections -func (dm *Daemon) AnnounceBlocks() error { +// announceBlocks sends an AnnounceBlocksMessage to all connections +func (dm *Daemon) announceBlocks() error { if dm.Config.DisableNetworking { return ErrNetworkingDisabled } - headSeq, ok, err := dm.HeadBkSeq() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { return err } @@ -1039,70 +1041,16 @@ func (dm *Daemon) AnnounceBlocks() error { m := NewAnnounceBlocksMessage(headSeq) - err = dm.BroadcastMessage(m) - if err != nil { + if _, err := dm.broadcastMessage(m); err != nil { logger.WithError(err).Debug("Broadcast AnnounceBlocksMessage failed") - } - - return err -} - -// AnnounceAllTxns announces local unconfirmed transactions -func (dm *Daemon) AnnounceAllTxns() error { - if dm.Config.DisableNetworking { - return ErrNetworkingDisabled - } - - // Get local unconfirmed transaction hashes. - hashes, err := dm.visor.GetAllValidUnconfirmedTxHashes() - if err != nil { return err } - // Divide hashes into multiple sets of max size - hashesSet := divideHashes(hashes, dm.Config.MaxTxnAnnounceNum) - - for _, hs := range hashesSet { - m := NewAnnounceTxnsMessage(hs) - if err = dm.BroadcastMessage(m); err != nil { - break - } - } - - if err != nil { - logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") - } - - return err -} - -func divideHashes(hashes []cipher.SHA256, n int) [][]cipher.SHA256 { - if len(hashes) == 0 { - return [][]cipher.SHA256{} - } - - var j int - var hashesArray [][]cipher.SHA256 - - if len(hashes) > n { - for i := range hashes { - if len(hashes[j:i]) == n { - hs := make([]cipher.SHA256, n) - copy(hs, hashes[j:i]) - hashesArray = append(hashesArray, hs) - j = i - } - } - } - - hs := make([]cipher.SHA256, len(hashes)-j) - copy(hs, hashes[j:]) - hashesArray = append(hashesArray, hs) - return hashesArray + return nil } -// AnnounceTxns announces given transaction hashes. -func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { +// announceTxns announces given transaction hashes +func (dm *Daemon) announceTxns(txns []cipher.SHA256) error { if dm.Config.DisableNetworking { return ErrNetworkingDisabled } @@ -1113,30 +1061,34 @@ func (dm *Daemon) AnnounceTxns(txns []cipher.SHA256) error { m := NewAnnounceTxnsMessage(txns) - err := dm.BroadcastMessage(m) - if err != nil { + if _, err := dm.broadcastMessage(m); err != nil { logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") + return err } - return err + return nil } -// RequestBlocksFromAddr sends a GetBlocksMessage to one connected address -func (dm *Daemon) RequestBlocksFromAddr(addr string) error { +// createAndPublishBlock creates a block from unconfirmed transactions and sends it to the network. +// Will panic if not running as a master chain. +// Will not create a block if outgoing connections are disabled. +// If the block was created but the broadcast failed, the error will be non-nil but the +// SignedBlock value will not be empty. +// TODO -- refactor this method -- it should either always create a block and maybe broadcast it, +// or use a database transaction to rollback block publishing if broadcast failed (however, this will cause a slow DB write) +func (dm *Daemon) createAndPublishBlock() (*coin.SignedBlock, error) { if dm.Config.DisableNetworking { - return ErrNetworkingDisabled + return nil, ErrNetworkingDisabled } - headSeq, ok, err := dm.visor.HeadBkSeq() + sb, err := dm.visor.CreateAndExecuteBlock() if err != nil { - return err - } - if !ok { - return errors.New("Cannot request blocks from addr, there is no head block") + return nil, err } - m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) - return dm.SendMessage(addr, m) + err = dm.broadcastBlock(sb) + + return &sb, err } // ResendUnconfirmedTxns resends all unconfirmed transactions and returns the hashes that were successfully rebroadcast. @@ -1168,69 +1120,65 @@ func (dm *Daemon) BroadcastTransaction(t coin.Transaction) error { return ErrNetworkingDisabled } - l, err := dm.pool.Pool.Size() - if err != nil { - return err - } - - logger.Debugf("BroadcastTransaction to %d conns", l) - m := NewGiveTxnsMessage(coin.Transactions{t}) - if err := dm.BroadcastMessage(m); err != nil { + n, err := dm.broadcastMessage(m) + if err != nil { logger.WithError(err).Error("Broadcast GiveTxnsMessage failed") return err } + logger.Debugf("BroadcastTransaction to %d conns", n) + return nil } -// CreateAndPublishBlock creates a block from unconfirmed transactions and sends it to the network. -// Will panic if not running as a master chain. -// Will not create a block if outgoing connections are disabled. -// If the block was created but the broadcast failed, the error will be non-nil but the -// SignedBlock value will not be empty. -// TODO -- refactor this method -- it should either always create a block and maybe broadcast it, -// or use a database transaction to rollback block publishing if broadcast failed (however, this will cause a slow DB write) -func (dm *Daemon) CreateAndPublishBlock() (*coin.SignedBlock, error) { +// Disconnect sends a DisconnectMessage to a peer. After the DisconnectMessage is sent, the peer is disconnected. +// This allows all pending messages to be sent. Any message queued after a DisconnectMessage is unlikely to be sent +// to the peer (but possible). +func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { + logger.WithFields(logrus.Fields{ + "addr": addr, + "reason": r, + }).Debug("Sending DisconnectMessage") + return dm.sendMessage(addr, NewDisconnectMessage(r)) +} + +// Implements private daemoner interface methods: + +// requestBlocksFromAddr sends a GetBlocksMessage to one connected address +func (dm *Daemon) requestBlocksFromAddr(addr string) error { if dm.Config.DisableNetworking { - return nil, ErrNetworkingDisabled + return ErrNetworkingDisabled } - sb, err := dm.visor.CreateAndExecuteBlock() + headSeq, ok, err := dm.visor.HeadBkSeq() if err != nil { - return nil, err + return err + } + if !ok { + return errors.New("Cannot request blocks from addr, there is no head block") } - err = dm.broadcastBlock(sb) - - return &sb, err + m := NewGetBlocksMessage(headSeq, dm.Config.BlocksResponseCount) + return dm.sendMessage(addr, m) } -// Sends a signed block to all connections. +// broadcastBlock sends a signed block to all connections func (dm *Daemon) broadcastBlock(sb coin.SignedBlock) error { if dm.Config.DisableNetworking { return ErrNetworkingDisabled } m := NewGiveBlocksMessage([]coin.SignedBlock{sb}) - return dm.BroadcastMessage(m) -} - -// Mirror returns the message mirror -func (dm *Daemon) Mirror() uint32 { - return dm.Messages.Mirror + _, err := dm.broadcastMessage(m) + return err } -// DaemonConfig returns the daemon config -func (dm *Daemon) DaemonConfig() DaemonConfig { +// daemonConfig returns the daemon config +func (dm *Daemon) daemonConfig() DaemonConfig { return dm.Config } -// BlockchainPubkey returns the blockchain pubkey -func (dm *Daemon) BlockchainPubkey() cipher.PubKey { - return dm.Config.BlockchainPubkey -} - // connectionIntroduced transfers a connection to the "introduced" state in the connections state machine // and updates other state func (dm *Daemon) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) { @@ -1283,20 +1231,69 @@ func (dm *Daemon) sendRandomPeers(addr string) error { } m := NewGivePeersMessage(peers) - return dm.SendMessage(addr, m) + return dm.sendMessage(addr, m) } -// Implements pooler interface +// announceAllTxns announces local unconfirmed transactions +func (dm *Daemon) announceAllTxns() error { + if dm.Config.DisableNetworking { + return ErrNetworkingDisabled + } -// SendMessage sends a Message to a Connection and pushes the result onto the SendResults channel. -func (dm *Daemon) SendMessage(addr string, msg gnet.Message) error { + // Get local unconfirmed transaction hashes. + hashes, err := dm.visor.GetAllValidUnconfirmedTxHashes() + if err != nil { + return err + } + + // Divide hashes into multiple sets of max size + hashesSet := divideHashes(hashes, dm.Config.MaxTxnAnnounceNum) + + for _, hs := range hashesSet { + m := NewAnnounceTxnsMessage(hs) + if _, err := dm.broadcastMessage(m); err != nil { + logger.WithError(err).Debug("Broadcast AnnounceTxnsMessage failed") + return err + } + } + + return nil +} + +func divideHashes(hashes []cipher.SHA256, n int) [][]cipher.SHA256 { + if len(hashes) == 0 { + return [][]cipher.SHA256{} + } + + var j int + var hashesArray [][]cipher.SHA256 + + if len(hashes) > n { + for i := range hashes { + if len(hashes[j:i]) == n { + hs := make([]cipher.SHA256, n) + copy(hs, hashes[j:i]) + hashesArray = append(hashesArray, hs) + j = i + } + } + } + + hs := make([]cipher.SHA256, len(hashes)-j) + copy(hs, hashes[j:]) + hashesArray = append(hashesArray, hs) + return hashesArray +} + +// sendMessage sends a Message to a Connection and pushes the result onto the SendResults channel. +func (dm *Daemon) sendMessage(addr string, msg gnet.Message) error { return dm.pool.Pool.SendMessage(addr, msg) } -// BroadcastMessage sends a Message to all introduced connections in the Pool -func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { +// broadcastMessage sends a Message to all introduced connections in the Pool +func (dm *Daemon) broadcastMessage(msg gnet.Message) (int, error) { if dm.Config.DisableNetworking { - return ErrNetworkingDisabled + return 0, ErrNetworkingDisabled } conns := dm.connections.all() @@ -1310,73 +1307,51 @@ func (dm *Daemon) BroadcastMessage(msg gnet.Message) error { return dm.pool.Pool.BroadcastMessage(msg, addrs) } -// Disconnect sends a DisconnectMessage to a peer. After the DisconnectMessage is sent, the peer is disconnected. -// This allows all pending messages to be sent. Any message queued after a DisconnectMessage is unlikely to be sent -// to the peer (but possible). -func (dm *Daemon) Disconnect(addr string, r gnet.DisconnectReason) error { - logger.WithFields(logrus.Fields{ - "addr": addr, - "reason": r, - }).Debug("Sending DisconnectMessage") - return dm.SendMessage(addr, NewDisconnectMessage(r)) -} - -// DisconnectNow disconnects from a peer immediately without sending a DisconnectMessage. Any pending messages +// disconnectNow disconnects from a peer immediately without sending a DisconnectMessage. Any pending messages // will not be sent to the peer. -func (dm *Daemon) DisconnectNow(addr string, r gnet.DisconnectReason) error { +func (dm *Daemon) disconnectNow(addr string, r gnet.DisconnectReason) error { return dm.pool.Pool.Disconnect(addr, r) } -// Implements pexer interface - -// PexConfig returns the pex config -func (dm *Daemon) PexConfig() pex.Config { +// pexConfig returns the pex config +func (dm *Daemon) pexConfig() pex.Config { return dm.pex.Config } -// AddPeers adds peers to the pex -func (dm *Daemon) AddPeers(addrs []string) int { +// addPeers adds peers to the pex +func (dm *Daemon) addPeers(addrs []string) int { return dm.pex.AddPeers(addrs) } -// ResetRetryTimes reset the retry times of given peer -func (dm *Daemon) ResetRetryTimes(addr string) { - dm.pex.ResetRetryTimes(addr) -} - -// Implements chain height store - -// RecordPeerHeight records the height of specific peer -func (dm *Daemon) RecordPeerHeight(addr string, gnetID, height uint64) { +// recordPeerHeight records the height of specific peer +func (dm *Daemon) recordPeerHeight(addr string, gnetID, height uint64) { if err := dm.connections.SetHeight(addr, gnetID, height); err != nil { logger.Critical().WithError(err).WithField("addr", addr).Error("connections.SetHeight failed") } } -// Implements visorer interface - -// GetSignedBlocksSince returns N signed blocks since given seq -func (dm *Daemon) GetSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) { +// getSignedBlocksSince returns N signed blocks since given seq +func (dm *Daemon) getSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) { return dm.visor.GetSignedBlocksSince(seq, count) } -// HeadBkSeq returns the head block sequence -func (dm *Daemon) HeadBkSeq() (uint64, bool, error) { +// headBkSeq returns the head block sequence +func (dm *Daemon) headBkSeq() (uint64, bool, error) { return dm.visor.HeadBkSeq() } -// ExecuteSignedBlock executes the signed block -func (dm *Daemon) ExecuteSignedBlock(b coin.SignedBlock) error { +// executeSignedBlock executes the signed block +func (dm *Daemon) executeSignedBlock(b coin.SignedBlock) error { return dm.visor.ExecuteSignedBlock(b) } -// FilterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (dm *Daemon) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// filterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { return dm.visor.FilterUnconfirmedKnown(txns) } -// GetUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (dm *Daemon) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { +// getUnconfirmedKnown returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { return dm.visor.GetUnconfirmedKnown(txns) } diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index d3b8aca30b..36cdf84bbb 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -125,6 +125,30 @@ func newConnection(dc *connection, gc *gnet.Connection, pp *pex.Peer) Connection return c } +// newConnection creates a Connection from daemon.connection, gnet.Connection and pex.Peer +func (gw *Gateway) newConnection(c *connection) (*Connection, error) { + if c == nil { + return nil, nil + } + + gc, err := gw.d.pool.Pool.GetConnection(c.Addr) + if err != nil { + return nil, err + } + + var pp *pex.Peer + listenAddr := c.ListenAddr() + if listenAddr != "" { + p, ok := gw.d.pex.GetPeer(listenAddr) + if ok { + pp = &p + } + } + + cc := newConnection(c, gc, pp) + return &cc, nil +} + // GetConnections returns solicited (outgoing) connections func (gw *Gateway) GetConnections(f func(c Connection) bool) ([]Connection, error) { var conns []Connection @@ -191,30 +215,6 @@ func (gw *Gateway) GetConnection(addr string) (*Connection, error) { return gw.newConnection(c) } -// newConnection creates a Connection from daemon.connection, gnet.Connection and pex.Peer -func (gw *Gateway) newConnection(c *connection) (*Connection, error) { - if c == nil { - return nil, nil - } - - gc, err := gw.d.pool.Pool.GetConnection(c.Addr) - if err != nil { - return nil, err - } - - var pp *pex.Peer - listenAddr := c.ListenAddr() - if listenAddr != "" { - p, ok := gw.d.pex.GetPeer(listenAddr) - if ok { - pp = &p - } - } - - cc := newConnection(c, gc, pp) - return &cc, nil -} - // Disconnect disconnects a connection by gnet ID func (gw *Gateway) Disconnect(gnetID uint64) error { var err error diff --git a/src/daemon/gnet/pool.go b/src/daemon/gnet/pool.go index fa31b41bf2..8b870ce1a6 100644 --- a/src/daemon/gnet/pool.go +++ b/src/daemon/gnet/pool.go @@ -943,21 +943,25 @@ func (pool *ConnectionPool) SendMessage(addr string, msg Message) error { // BroadcastMessage sends a Message to all connections specified in addrs. // If a connection does not exist for a given address, it is skipped. // If no messages were written to any connection, an error is returned. -func (pool *ConnectionPool) BroadcastMessage(msg Message, addrs []string) error { +// Returns the number of connections that the message was queued for sending to. +// Note that actual sending can still fail later, if the connection drops before the message is sent. +func (pool *ConnectionPool) BroadcastMessage(msg Message, addrs []string) (int, error) { if pool.Config.DebugPrint { logger.WithField("msgType", reflect.TypeOf(msg)).Debug("BroadcastMessage") } if len(addrs) == 0 { - return ErrNoAddresses + return 0, ErrNoAddresses } - fullWriteQueue := 0 + sentTo := 0 + if err := pool.strand("BroadcastMessage", func() error { if len(pool.pool) == 0 { return ErrPoolEmpty } + fullWriteQueue := 0 foundConns := 0 for _, addr := range addrs { @@ -980,12 +984,14 @@ func (pool *ConnectionPool) BroadcastMessage(msg Message, addrs []string) error return ErrNoReachableConnections } + sentTo = foundConns - fullWriteQueue + return nil }); err != nil { - return err + return 0, err } - return nil + return sentTo, nil } // Unpacks incoming bytes to a Message and calls the message handler. If diff --git a/src/daemon/gnet/pool_test.go b/src/daemon/gnet/pool_test.go index ace8e3dfb0..c2086707de 100644 --- a/src/daemon/gnet/pool_test.go +++ b/src/daemon/gnet/pool_test.go @@ -1084,13 +1084,14 @@ func TestPoolBroadcastMessage(t *testing.T) { require.NotEmpty(t, addrs) m := NewByteMessage(88) - err = p.BroadcastMessage(m, addrs) + n, err := p.BroadcastMessage(m, addrs) require.NoError(t, err) + require.Equal(t, 2, n) - err = p.BroadcastMessage(m, []string{}) + _, err = p.BroadcastMessage(m, []string{}) require.Equal(t, ErrNoAddresses, err) - err = p.BroadcastMessage(m, []string{"1.1.1.1"}) + _, err = p.BroadcastMessage(m, []string{"1.1.1.1"}) require.Equal(t, ErrNoMatchingConnections, err) // Spam the connections with so much data that their write queue overflows, @@ -1103,7 +1104,7 @@ func TestPoolBroadcastMessage(t *testing.T) { for i := 0; i < attempts; i++ { go func() { defer wg.Done() - err := p.BroadcastMessage(m, addrs) + _, err := p.BroadcastMessage(m, addrs) if err == ErrNoReachableConnections { once.Do(func() { gotErr = true diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 4a34d8614c..296ea7b698 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -4,10 +4,8 @@ import ( "encoding/binary" "errors" "fmt" - "math/rand" "net" "strings" - "time" "github.com/sirupsen/logrus" @@ -87,15 +85,12 @@ func (msc *MessagesConfig) Register() { // Messages messages struct type Messages struct { Config MessagesConfig - // Magic value for detecting self-connection - Mirror uint32 } // NewMessages creates Messages func NewMessages(c MessagesConfig) *Messages { return &Messages{ Config: c, - Mirror: rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Uint32(), } } @@ -158,7 +153,7 @@ func (gpm *GetPeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process Notifies the Pex instance that peers were requested func (gpm *GetPeersMessage) process(d daemoner) { - if d.PexConfig().Disabled { + if d.pexConfig().Disabled { return } @@ -206,7 +201,7 @@ func (gpm *GivePeersMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process Notifies the Pex instance that peers were received func (gpm *GivePeersMessage) process(d daemoner) { - if d.PexConfig().Disabled { + if d.pexConfig().Disabled { return } @@ -233,7 +228,7 @@ func (gpm *GivePeersMessage) process(d daemoner) { "count": len(peers), }).Debug("Received peers via PEX") - d.AddPeers(peers) + d.addPeers(peers) } // IntroductionMessage is sent on first connect by both parties @@ -345,15 +340,15 @@ func (intro *IntroductionMessage) process(d daemoner) { } // Request blocks immediately after they're confirmed - if err := d.RequestBlocksFromAddr(addr); err != nil { - logger.WithError(err).WithFields(fields).Warning("RequestBlocksFromAddr") + if err := d.requestBlocksFromAddr(addr); err != nil { + logger.WithError(err).WithFields(fields).Warning("requestBlocksFromAddr") } else { logger.WithFields(fields).Debug("Requested blocks") } // Announce unconfirmed txns - if err := d.AnnounceAllTxns(); err != nil { - logger.WithError(err).Warning("AnnounceAllTxns failed") + if err := d.announceAllTxns(); err != nil { + logger.WithError(err).Warning("announceAllTxns failed") } } @@ -365,14 +360,15 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { "gnetID": intro.c.ConnID, } + dc := d.daemonConfig() + // Disconnect if this is a self connection (we have the same mirror value) - if intro.Mirror == d.Mirror() { + if intro.Mirror == dc.Mirror { logger.WithFields(fields).WithField("mirror", intro.Mirror).Info("Remote mirror value matches ours") return nil, ErrDisconnectSelf } // Disconnect if peer version is not within the supported range - dc := d.DaemonConfig() if intro.ProtocolVersion < dc.MinProtocolVersion { logger.WithFields(fields).WithFields(logrus.Fields{ "protocolVersion": intro.ProtocolVersion, @@ -396,10 +392,10 @@ func (intro *IntroductionMessage) verify(d daemoner) (*useragent.Data, error) { } copy(bcPubKey[:], intro.Extra[:len(bcPubKey)]) - if d.BlockchainPubkey() != bcPubKey { + if dc.BlockchainPubkey != bcPubKey { logger.WithFields(fields).WithFields(logrus.Fields{ "pubkey": bcPubKey.Hex(), - "daemonPubkey": d.BlockchainPubkey().Hex(), + "daemonPubkey": dc.BlockchainPubkey.Hex(), }).Warning("Blockchain pubkey does not match") return nil, ErrDisconnectBlockchainPubkeyNotMatched } @@ -439,10 +435,10 @@ func (ping *PingMessage) process(d daemoner) { "gnetID": ping.c.ConnID, } - if d.DaemonConfig().LogPings { + if d.daemonConfig().LogPings { logger.WithFields(fields).Debug("Replying to ping") } - if err := d.SendMessage(ping.c.Addr, &PongMessage{}); err != nil { + if err := d.sendMessage(ping.c.Addr, &PongMessage{}); err != nil { logger.WithFields(fields).WithError(err).Error("Send PongMessage failed") } } @@ -500,8 +496,8 @@ func (dm *DisconnectMessage) process(d daemoner) { "reason": DisconnectCodeToReason(dm.ReasonCode), }).Infof("DisconnectMessage received") - if err := d.DisconnectNow(dm.c.Addr, ErrDisconnectReceivedDisconnect); err != nil { - logger.WithError(err).WithField("addr", dm.c.Addr).Warning("DisconnectNow") + if err := d.disconnectNow(dm.c.Addr, ErrDisconnectReceivedDisconnect); err != nil { + logger.WithError(err).WithField("addr", dm.c.Addr).Warning("disconnectNow") } } @@ -528,7 +524,7 @@ func (gbm *GetBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process should send number to be requested, with request func (gbm *GetBlocksMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { + if d.daemonConfig().DisableNetworking { return } @@ -538,9 +534,9 @@ func (gbm *GetBlocksMessage) process(d daemoner) { } // Record this as this peer's highest block - d.RecordPeerHeight(gbm.c.Addr, gbm.c.ConnID, gbm.LastBlock) + d.recordPeerHeight(gbm.c.Addr, gbm.c.ConnID, gbm.LastBlock) // Fetch and return signed blocks since LastBlock - blocks, err := d.GetSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) + blocks, err := d.getSignedBlocksSince(gbm.LastBlock, gbm.RequestedBlocks) if err != nil { logger.WithError(err).Error("Get signed blocks failed") return @@ -553,7 +549,7 @@ func (gbm *GetBlocksMessage) process(d daemoner) { logger.WithFields(fields).Debugf("Got %d blocks since %d", len(blocks), gbm.LastBlock) m := NewGiveBlocksMessage(blocks) - if err := d.SendMessage(gbm.c.Addr, m); err != nil { + if err := d.sendMessage(gbm.c.Addr, m); err != nil { logger.WithFields(fields).WithError(err).Error("Send GiveBlocksMessage failed") } } @@ -572,14 +568,14 @@ func NewGiveBlocksMessage(blocks []coin.SignedBlock) *GiveBlocksMessage { } // Handle handle message -func (gbm *GiveBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { - gbm.c = mc - return daemon.(daemoner).recordMessageEvent(gbm, mc) +func (m *GiveBlocksMessage) Handle(mc *gnet.MessageContext, daemon interface{}) error { + m.c = mc + return daemon.(daemoner).recordMessageEvent(m, mc) } // process process message -func (gbm *GiveBlocksMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { +func (m *GiveBlocksMessage) process(d daemoner) { + if d.daemonConfig().DisableNetworking { logger.Critical().Info("Visor disabled, ignoring GiveBlocksMessage") return } @@ -588,9 +584,9 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { // It is not necessary that the blocks be executed together in a single transaction. processed := 0 - maxSeq, ok, err := d.HeadBkSeq() + maxSeq, ok, err := d.headBkSeq() if err != nil { - logger.WithError(err).Error("visor.HeadBkSeq failed") + logger.WithError(err).Error("d.headBkSeq failed") return } if !ok { @@ -598,7 +594,7 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { return } - for _, b := range gbm.Blocks { + for _, b := range m.Blocks { // To minimize waste when receiving multiple responses from peers // we only break out of the loop if the block itself is invalid. // E.g. if we request 20 blocks since 0 from 2 peers, and one peer @@ -609,7 +605,7 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { continue } - err := d.ExecuteSignedBlock(b) + err := d.executeSignedBlock(b) if err == nil { logger.Critical().WithField("seq", b.Block.Head.BkSeq).Info("Added new block") processed++ @@ -624,9 +620,9 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { return } - headBkSeq, ok, err := d.HeadBkSeq() + headBkSeq, ok, err := d.headBkSeq() if err != nil { - logger.WithError(err).Error("visor.HeadBkSeq failed") + logger.WithError(err).Error("d.headBkSeq failed") return } if !ok { @@ -641,14 +637,14 @@ func (gbm *GiveBlocksMessage) process(d daemoner) { } // Announce our new blocks to peers - m1 := NewAnnounceBlocksMessage(headBkSeq) - if err := d.BroadcastMessage(m1); err != nil { + abm := NewAnnounceBlocksMessage(headBkSeq) + if _, err := d.broadcastMessage(abm); err != nil { logger.WithError(err).Warning("Broadcast AnnounceBlocksMessage failed") } // Request more blocks - m2 := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) - if err := d.BroadcastMessage(m2); err != nil { + gbm := NewGetBlocksMessage(headBkSeq, d.daemonConfig().BlocksResponseCount) + if _, err := d.broadcastMessage(gbm); err != nil { logger.WithError(err).Warning("Broadcast GetBlocksMessage failed") } } @@ -675,7 +671,7 @@ func (abm *AnnounceBlocksMessage) Handle(mc *gnet.MessageContext, daemon interfa // process process message func (abm *AnnounceBlocksMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { + if d.daemonConfig().DisableNetworking { return } @@ -684,9 +680,9 @@ func (abm *AnnounceBlocksMessage) process(d daemoner) { "gnetID": abm.c.ConnID, } - headBkSeq, ok, err := d.HeadBkSeq() + headBkSeq, ok, err := d.headBkSeq() if err != nil { - logger.WithError(err).Error("AnnounceBlocksMessage Visor.HeadBkSeq failed") + logger.WithError(err).Error("AnnounceBlocksMessage d.headBkSeq failed") return } if !ok { @@ -700,8 +696,8 @@ func (abm *AnnounceBlocksMessage) process(d daemoner) { // TODO: Should this be block get request for current sequence? // If client is not caught up, won't attempt to get block - m := NewGetBlocksMessage(headBkSeq, d.DaemonConfig().BlocksResponseCount) - if err := d.SendMessage(abm.c.Addr, m); err != nil { + m := NewGetBlocksMessage(headBkSeq, d.daemonConfig().BlocksResponseCount) + if err := d.sendMessage(abm.c.Addr, m); err != nil { logger.WithError(err).WithFields(fields).Error("Send GetBlocksMessage") } } @@ -737,7 +733,7 @@ func (atm *AnnounceTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface // process process message func (atm *AnnounceTxnsMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { + if d.daemonConfig().DisableNetworking { return } @@ -746,9 +742,9 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { "gnetID": atm.c.ConnID, } - unknown, err := d.FilterUnconfirmedKnown(atm.Transactions) + unknown, err := d.filterUnconfirmedKnown(atm.Transactions) if err != nil { - logger.WithError(err).Error("AnnounceTxnsMessage Visor.FilterUnconfirmedKnown failed") + logger.WithError(err).Error("AnnounceTxnsMessage d.filterUnconfirmedKnown failed") return } @@ -757,7 +753,7 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { } m := NewGetTxnsMessage(unknown) - if err := d.SendMessage(atm.c.Addr, m); err != nil { + if err := d.sendMessage(atm.c.Addr, m); err != nil { logger.WithFields(fields).WithError(err).Error("Send GetTxnsMessage failed") } } @@ -783,7 +779,7 @@ func (gtm *GetTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) e // process process message func (gtm *GetTxnsMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { + if d.daemonConfig().DisableNetworking { return } @@ -793,9 +789,9 @@ func (gtm *GetTxnsMessage) process(d daemoner) { } // Locate all txns from the unconfirmed pool - known, err := d.GetUnconfirmedKnown(gtm.Transactions) + known, err := d.getUnconfirmedKnown(gtm.Transactions) if err != nil { - logger.WithError(err).Error("GetTxnsMessage Visor.GetUnconfirmedKnown failed") + logger.WithError(err).Error("GetTxnsMessage d.getUnconfirmedKnown failed") return } if len(known) == 0 { @@ -804,7 +800,7 @@ func (gtm *GetTxnsMessage) process(d daemoner) { // Reply to sender with GiveTxnsMessage m := NewGiveTxnsMessage(known) - if err := d.SendMessage(gtm.c.Addr, m); err != nil { + if err := d.sendMessage(gtm.c.Addr, m); err != nil { logger.WithError(err).WithFields(fields).Error("Send GiveTxnsMessage") } } @@ -835,7 +831,7 @@ func (gtm *GiveTxnsMessage) Handle(mc *gnet.MessageContext, daemon interface{}) // process process message func (gtm *GiveTxnsMessage) process(d daemoner) { - if d.DaemonConfig().DisableNetworking { + if d.daemonConfig().DisableNetworking { return } @@ -860,12 +856,15 @@ func (gtm *GiveTxnsMessage) process(d daemoner) { hashes = append(hashes, txn.Hash()) } + if len(hashes) == 0 { + return + } + // Announce these transactions to peers - if len(hashes) != 0 { - logger.Debugf("Announce %d transactions", len(hashes)) - m := NewAnnounceTxnsMessage(hashes) - if err := d.BroadcastMessage(m); err != nil { - logger.WithError(err).Warning("Broadcast AnnounceTxnsMessage failed") - } + m := NewAnnounceTxnsMessage(hashes) + if n, err := d.broadcastMessage(m); err != nil { + logger.WithError(err).Warning("Broadcast AnnounceTxnsMessage failed") + } else { + logger.Debugf("Announced %d transactions to %d peers", len(hashes), n) } } diff --git a/src/daemon/messages_test.go b/src/daemon/messages_test.go index 9fef9c0f74..299917b5df 100644 --- a/src/daemon/messages_test.go +++ b/src/daemon/messages_test.go @@ -274,21 +274,21 @@ func TestIntroductionMessage(t *testing.T) { tc.intro.c = mc d := &mockDaemoner{} - d.On("DaemonConfig").Return(DaemonConfig{ + d.On("daemonConfig").Return(DaemonConfig{ ProtocolVersion: int32(tc.mockValue.protocolVersion), MinProtocolVersion: int32(tc.mockValue.minProtocolVersion), UserAgent: useragent.Data{ Coin: "skycoin", Version: "0.24.1", }, + Mirror: tc.mockValue.mirror, + BlockchainPubkey: tc.mockValue.pubkey, }) - d.On("Mirror").Return(tc.mockValue.mirror) d.On("recordMessageEvent", tc.intro, mc).Return(tc.mockValue.recordMessageEventErr) - d.On("BlockchainPubkey").Return(tc.mockValue.pubkey) d.On("Disconnect", tc.addr, tc.mockValue.disconnectReason).Return(tc.mockValue.disconnectErr) d.On("connectionIntroduced", tc.addr, tc.gnetID, tc.intro, mock.Anything).Return(tc.mockValue.connectionIntroduced, tc.mockValue.connectionIntroducedErr) - d.On("RequestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) - d.On("AnnounceAllTxns").Return(tc.mockValue.announceAllTxnsErr) + d.On("requestBlocksFromAddr", tc.addr).Return(tc.mockValue.requestBlocksFromAddrErr) + d.On("announceAllTxns").Return(tc.mockValue.announceAllTxnsErr) err := tc.intro.Handle(mc, d) require.NoError(t, err) diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index 9c90bb565c..2392d454c5 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -15,80 +15,27 @@ type mockDaemoner struct { mock.Mock } -// connectionIntroduced provides a mock function with given fields: addr, gnetID, m, userAgent -func (_m *mockDaemoner) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) { - ret := _m.Called(addr, gnetID, m, userAgent) - - var r0 *connection - if rf, ok := ret.Get(0).(func(string, uint64, *IntroductionMessage, *useragent.Data) *connection); ok { - r0 = rf(addr, gnetID, m, userAgent) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*connection) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, uint64, *IntroductionMessage, *useragent.Data) error); ok { - r1 = rf(addr, gnetID, m, userAgent) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// injectTransaction provides a mock function with given fields: txn -func (_m *mockDaemoner) injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { - ret := _m.Called(txn) - - var r0 bool - if rf, ok := ret.Get(0).(func(coin.Transaction) bool); ok { - r0 = rf(txn) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 *visor.ErrTxnViolatesSoftConstraint - if rf, ok := ret.Get(1).(func(coin.Transaction) *visor.ErrTxnViolatesSoftConstraint); ok { - r1 = rf(txn) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*visor.ErrTxnViolatesSoftConstraint) - } - } - - var r2 error - if rf, ok := ret.Get(2).(func(coin.Transaction) error); ok { - r2 = rf(txn) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// recordMessageEvent provides a mock function with given fields: m, c -func (_m *mockDaemoner) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error { - ret := _m.Called(m, c) +// addPeers provides a mock function with given fields: addrs +func (_m *mockDaemoner) addPeers(addrs []string) int { + ret := _m.Called(addrs) - var r0 error - if rf, ok := ret.Get(0).(func(asyncMessage, *gnet.MessageContext) error); ok { - r0 = rf(m, c) + var r0 int + if rf, ok := ret.Get(0).(func([]string) int); ok { + r0 = rf(addrs) } else { - r0 = ret.Error(0) + r0 = ret.Get(0).(int) } return r0 } -// sendRandomPeers provides a mock function with given fields: addr -func (_m *mockDaemoner) sendRandomPeers(addr string) error { - ret := _m.Called(addr) +// announceAllTxns provides a mock function with given fields: +func (_m *mockDaemoner) announceAllTxns() error { + ret := _m.Called() var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(addr) + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() } else { r0 = ret.Error(0) } @@ -96,66 +43,52 @@ func (_m *mockDaemoner) sendRandomPeers(addr string) error { return r0 } -// AddPeers provides a mock function with given fields: addrs -func (_m *mockDaemoner) AddPeers(addrs []string) int { - ret := _m.Called(addrs) +// broadcastMessage provides a mock function with given fields: msg +func (_m *mockDaemoner) broadcastMessage(msg gnet.Message) (int, error) { + ret := _m.Called(msg) var r0 int - if rf, ok := ret.Get(0).(func([]string) int); ok { - r0 = rf(addrs) + if rf, ok := ret.Get(0).(func(gnet.Message) int); ok { + r0 = rf(msg) } else { r0 = ret.Get(0).(int) } - return r0 -} - -// AnnounceAllTxns provides a mock function with given fields: -func (_m *mockDaemoner) AnnounceAllTxns() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() + var r1 error + if rf, ok := ret.Get(1).(func(gnet.Message) error); ok { + r1 = rf(msg) } else { - r0 = ret.Error(0) + r1 = ret.Error(1) } - return r0 + return r0, r1 } -// BlockchainPubkey provides a mock function with given fields: -func (_m *mockDaemoner) BlockchainPubkey() cipher.PubKey { - ret := _m.Called() +// connectionIntroduced provides a mock function with given fields: addr, gnetID, m, userAgent +func (_m *mockDaemoner) connectionIntroduced(addr string, gnetID uint64, m *IntroductionMessage, userAgent *useragent.Data) (*connection, error) { + ret := _m.Called(addr, gnetID, m, userAgent) - var r0 cipher.PubKey - if rf, ok := ret.Get(0).(func() cipher.PubKey); ok { - r0 = rf() + var r0 *connection + if rf, ok := ret.Get(0).(func(string, uint64, *IntroductionMessage, *useragent.Data) *connection); ok { + r0 = rf(addr, gnetID, m, userAgent) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(cipher.PubKey) + r0 = ret.Get(0).(*connection) } } - return r0 -} - -// BroadcastMessage provides a mock function with given fields: msg -func (_m *mockDaemoner) BroadcastMessage(msg gnet.Message) error { - ret := _m.Called(msg) - - var r0 error - if rf, ok := ret.Get(0).(func(gnet.Message) error); ok { - r0 = rf(msg) + var r1 error + if rf, ok := ret.Get(1).(func(string, uint64, *IntroductionMessage, *useragent.Data) error); ok { + r1 = rf(addr, gnetID, m, userAgent) } else { - r0 = ret.Error(0) + r1 = ret.Error(1) } - return r0 + return r0, r1 } -// DaemonConfig provides a mock function with given fields: -func (_m *mockDaemoner) DaemonConfig() DaemonConfig { +// daemonConfig provides a mock function with given fields: +func (_m *mockDaemoner) daemonConfig() DaemonConfig { ret := _m.Called() var r0 DaemonConfig @@ -168,8 +101,8 @@ func (_m *mockDaemoner) DaemonConfig() DaemonConfig { return r0 } -// Disconnect provides a mock function with given fields: addr, r -func (_m *mockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { +// disconnectNow provides a mock function with given fields: addr, r +func (_m *mockDaemoner) disconnectNow(addr string, r gnet.DisconnectReason) error { ret := _m.Called(addr, r) var r0 error @@ -182,22 +115,8 @@ func (_m *mockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { return r0 } -// DisconnectNow provides a mock function with given fields: addr, r -func (_m *mockDaemoner) DisconnectNow(addr string, r gnet.DisconnectReason) error { - ret := _m.Called(addr, r) - - var r0 error - if rf, ok := ret.Get(0).(func(string, gnet.DisconnectReason) error); ok { - r0 = rf(addr, r) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// ExecuteSignedBlock provides a mock function with given fields: b -func (_m *mockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { +// executeSignedBlock provides a mock function with given fields: b +func (_m *mockDaemoner) executeSignedBlock(b coin.SignedBlock) error { ret := _m.Called(b) var r0 error @@ -210,8 +129,8 @@ func (_m *mockDaemoner) ExecuteSignedBlock(b coin.SignedBlock) error { return r0 } -// FilterUnconfirmedKnown provides a mock function with given fields: txns -func (_m *mockDaemoner) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// filterUnconfirmedKnown provides a mock function with given fields: txns +func (_m *mockDaemoner) filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { ret := _m.Called(txns) var r0 []cipher.SHA256 @@ -233,8 +152,8 @@ func (_m *mockDaemoner) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.S return r0, r1 } -// GetSignedBlocksSince provides a mock function with given fields: seq, count -func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { +// getSignedBlocksSince provides a mock function with given fields: seq, count +func (_m *mockDaemoner) getSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { ret := _m.Called(seq, count) var r0 []coin.SignedBlock @@ -256,8 +175,8 @@ func (_m *mockDaemoner) GetSignedBlocksSince(seq uint64, count uint64) ([]coin.S return r0, r1 } -// GetUnconfirmedKnown provides a mock function with given fields: txns -func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { +// getUnconfirmedKnown provides a mock function with given fields: txns +func (_m *mockDaemoner) getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { ret := _m.Called(txns) var r0 coin.Transactions @@ -279,8 +198,8 @@ func (_m *mockDaemoner) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transact return r0, r1 } -// HeadBkSeq provides a mock function with given fields: -func (_m *mockDaemoner) HeadBkSeq() (uint64, bool, error) { +// headBkSeq provides a mock function with given fields: +func (_m *mockDaemoner) headBkSeq() (uint64, bool, error) { ret := _m.Called() var r0 uint64 @@ -307,22 +226,38 @@ func (_m *mockDaemoner) HeadBkSeq() (uint64, bool, error) { return r0, r1, r2 } -// Mirror provides a mock function with given fields: -func (_m *mockDaemoner) Mirror() uint32 { - ret := _m.Called() +// injectTransaction provides a mock function with given fields: txn +func (_m *mockDaemoner) injectTransaction(txn coin.Transaction) (bool, *visor.ErrTxnViolatesSoftConstraint, error) { + ret := _m.Called(txn) - var r0 uint32 - if rf, ok := ret.Get(0).(func() uint32); ok { - r0 = rf() + var r0 bool + if rf, ok := ret.Get(0).(func(coin.Transaction) bool); ok { + r0 = rf(txn) } else { - r0 = ret.Get(0).(uint32) + r0 = ret.Get(0).(bool) } - return r0 + var r1 *visor.ErrTxnViolatesSoftConstraint + if rf, ok := ret.Get(1).(func(coin.Transaction) *visor.ErrTxnViolatesSoftConstraint); ok { + r1 = rf(txn) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*visor.ErrTxnViolatesSoftConstraint) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(coin.Transaction) error); ok { + r2 = rf(txn) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } -// PexConfig provides a mock function with given fields: -func (_m *mockDaemoner) PexConfig() pex.Config { +// pexConfig provides a mock function with given fields: +func (_m *mockDaemoner) pexConfig() pex.Config { ret := _m.Called() var r0 pex.Config @@ -335,13 +270,27 @@ func (_m *mockDaemoner) PexConfig() pex.Config { return r0 } -// RecordPeerHeight provides a mock function with given fields: addr, gnetID, height -func (_m *mockDaemoner) RecordPeerHeight(addr string, gnetID uint64, height uint64) { +// recordMessageEvent provides a mock function with given fields: m, c +func (_m *mockDaemoner) recordMessageEvent(m asyncMessage, c *gnet.MessageContext) error { + ret := _m.Called(m, c) + + var r0 error + if rf, ok := ret.Get(0).(func(asyncMessage, *gnet.MessageContext) error); ok { + r0 = rf(m, c) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// recordPeerHeight provides a mock function with given fields: addr, gnetID, height +func (_m *mockDaemoner) recordPeerHeight(addr string, gnetID uint64, height uint64) { _m.Called(addr, gnetID, height) } -// RequestBlocksFromAddr provides a mock function with given fields: addr -func (_m *mockDaemoner) RequestBlocksFromAddr(addr string) error { +// requestBlocksFromAddr provides a mock function with given fields: addr +func (_m *mockDaemoner) requestBlocksFromAddr(addr string) error { ret := _m.Called(addr) var r0 error @@ -354,8 +303,8 @@ func (_m *mockDaemoner) RequestBlocksFromAddr(addr string) error { return r0 } -// SendMessage provides a mock function with given fields: addr, msg -func (_m *mockDaemoner) SendMessage(addr string, msg gnet.Message) error { +// sendMessage provides a mock function with given fields: addr, msg +func (_m *mockDaemoner) sendMessage(addr string, msg gnet.Message) error { ret := _m.Called(addr, msg) var r0 error @@ -367,3 +316,31 @@ func (_m *mockDaemoner) SendMessage(addr string, msg gnet.Message) error { return r0 } + +// sendRandomPeers provides a mock function with given fields: addr +func (_m *mockDaemoner) sendRandomPeers(addr string) error { + ret := _m.Called(addr) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(addr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Disconnect provides a mock function with given fields: addr, r +func (_m *mockDaemoner) Disconnect(addr string, r gnet.DisconnectReason) error { + ret := _m.Called(addr, r) + + var r0 error + if rf, ok := ret.Get(0).(func(string, gnet.DisconnectReason) error); ok { + r0 = rf(addr, r) + } else { + r0 = ret.Error(0) + } + + return r0 +} From 34565f9e9461b0e555b1e4bb17bdeeaaede01c82 Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 14:03:20 +0800 Subject: [PATCH 388/399] Rename --- CHANGELOG.md | 2 +- README.md | 4 ++-- docker/images/mainnet/README.md | 12 +++++------ src/daemon/daemon.go | 8 ++++---- src/skycoin/config.go | 14 ++++++------- src/skycoin/skycoin.go | 2 +- src/visor/blockchain.go | 2 +- src/visor/blockdb/blocksigs.go | 6 +++--- src/visor/visor.go | 36 ++++++++++++++++----------------- src/visor/visor_test.go | 20 +++++++++--------- 10 files changed, 53 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b173c5906..3b0f9d319b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -410,7 +410,7 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - #383 Error during installation from skycoin source code - #375 Node can't recovery from zero connections - #376 Explorer api `/explorer/address` does not return spend transactions -- #373 Master node will be closed if there're no transactions need to execute +- #373 Block publisher node will be closed if there're no transactions need to execute - #360 Node will crash when do ctrl+c while downloading blocks - #350 Wallet name always 'undefined' after loading wallet from seed diff --git a/README.md b/README.md index ec93f0a426..e8b0f4a99c 100644 --- a/README.md +++ b/README.md @@ -573,13 +573,13 @@ Instructions for doing this: 0. Follow the steps in [pre-release testing](#pre-release-testing) 0. Make a PR merging `develop` into `master` 0. Review the PR and merge it -0. Tag the master branch with the version number. Version tags start with `v`, e.g. `v0.20.0`. +0. Tag the `master` branch with the version number. Version tags start with `v`, e.g. `v0.20.0`. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line with `git tag -as v0.20.0 $COMMIT_ID`, but Github will not recognize it as a "release". 0. Make sure that the client runs properly from the `master` branch 0. Release builds are created and uploaded by travis. To do it manually, checkout the `master` branch and follow the [create release builds](electron/README.md) instructions. -If there are problems discovered after merging to master, start over, and increment the 3rd version number. +If there are problems discovered after merging to `master`, start over, and increment the 3rd version number. For example, `v0.20.0` becomes `v0.20.1`, for minor fixes. #### Pre-release testing diff --git a/docker/images/mainnet/README.md b/docker/images/mainnet/README.md index 7a562a811e..122774e621 100644 --- a/docker/images/mainnet/README.md +++ b/docker/images/mainnet/README.md @@ -114,15 +114,15 @@ To get a full list of skycoin's parameters, just run $ docker run --rm skycoin/skycoin:develop -help ``` -To run multiple nodes concurrently in the same host, it is highly recommended to create separate volumes for each node. For example, in order to run a master node along with the one launched above, it is necessary to execute +To run multiple nodes concurrently in the same host, it is highly recommended to create separate volumes for each node. For example, in order to run a block publisher node along with the one launched above, it is necessary to execute ```sh -$ docker volume create skycoin-master-data -$ docker volume create skycoin-master-wallet -$ docker run -d -v skycoin-master-data:/data/.skycoin \ - -v skycoin-master-wallet:/wallet \ +$ docker volume create skycoin-block-publisher-data +$ docker volume create skycoin-block-publisher-wallet +$ docker run -d -v skycoin-block-publisher-data:/data/.skycoin \ + -v skycoin-block-publisher-wallet:/wallet \ -p 6001:6000 -p 6421:6420 \ - --name skycoin-master-stable skycoin/skycoin -master + --name skycoin-block-publisher-stable skycoin/skycoin -block-publisher ``` Notice that the host's port must be changed since collisions of two services listening at the same port are not allowed by the low-level operating system socket libraries. diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 0739bc6c81..9e7ef0ce7e 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -411,7 +411,7 @@ func (dm *Daemon) Run() error { blockInterval := time.Duration(dm.Config.BlockCreationInterval) blockCreationTicker := time.NewTicker(time.Second * blockInterval) - if !dm.visor.Config.IsMaster { + if !dm.visor.Config.IsBlockPublisher { blockCreationTicker.Stop() } @@ -575,9 +575,9 @@ loop: } case <-blockCreationTicker.C: - // Create blocks, if master chain + // Create blocks, if block publisher elapser.Register("blockCreationTicker.C") - if dm.visor.Config.IsMaster { + if dm.visor.Config.IsBlockPublisher { sb, err := dm.createAndPublishBlock() if err != nil { logger.WithError(err).Error("Failed to create and publish block") @@ -1070,7 +1070,7 @@ func (dm *Daemon) announceTxns(txns []cipher.SHA256) error { } // createAndPublishBlock creates a block from unconfirmed transactions and sends it to the network. -// Will panic if not running as a master chain. +// Will panic if not running as a block publisher. // Will not create a block if outgoing connections are disabled. // If the block was created but the broadcast failed, the error will be non-nil but the // SignedBlock value will not be empty. diff --git a/src/skycoin/config.go b/src/skycoin/config.go index bac7011932..5481488e99 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -158,7 +158,7 @@ type NodeConfig struct { // Load custom peers from disk CustomPeersFile string - RunMaster bool + RunBlockPublisher bool /* Developer options */ @@ -282,7 +282,7 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { HTTPIdleTimeout: time.Second * 120, // Centralized network configuration - RunMaster: false, + RunBlockPublisher: false, /* Developer options */ // Enable cpu profiling @@ -358,8 +358,8 @@ func (c *Config) postProcess() error { c.Node.DBPath = replaceHome(c.Node.DBPath, home) } - if c.Node.RunMaster { - // Run in arbitrating mode if the node is master + if c.Node.RunBlockPublisher { + // Run in arbitrating mode if the node is block publisher c.Node.Arbitrating = true } @@ -563,14 +563,14 @@ func (c *NodeConfig) RegisterFlags() { flag.StringVar(&c.UserAgentRemark, "user-agent-remark", c.UserAgentRemark, "additional remark to include in the user agent sent over the wire protocol") // Key Configuration Data - flag.BoolVar(&c.RunMaster, "master", c.RunMaster, "run the daemon as blockchain master server") + flag.BoolVar(&c.RunBlockPublisher, "block-publisher", c.RunBlockPublisher, "run the daemon as a block publisher") flag.IntVar(&c.MaxBlockSize, "max-block-size", c.MaxBlockSize, "maximum size of blocks") flag.Uint64Var(&c.UnconfirmedBurnFactor, "burn-factor-unconfirmed", c.UnconfirmedBurnFactor, "coinhour burn factor to apply when verifying unconfirmed transactions") flag.Uint64Var(&c.CreateBlockBurnFactor, "burn-factor-create-block", c.CreateBlockBurnFactor, "coinhour burn factor to apply to transactions when creating blocks") - flag.StringVar(&c.BlockchainPubkeyStr, "master-public-key", c.BlockchainPubkeyStr, "public key of the master chain") - flag.StringVar(&c.BlockchainSeckeyStr, "master-secret-key", c.BlockchainSeckeyStr, "secret key, set for master") + flag.StringVar(&c.BlockchainPubkeyStr, "blockchain-public-key", c.BlockchainPubkeyStr, "public key of the blockchain") + flag.StringVar(&c.BlockchainSeckeyStr, "blockchain-secret-key", c.BlockchainSeckeyStr, "secret key of the blockchain") flag.StringVar(&c.GenesisAddressStr, "genesis-address", c.GenesisAddressStr, "genesis address") flag.StringVar(&c.GenesisSignatureStr, "genesis-signature", c.GenesisSignatureStr, "genesis block signature") diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index e87276b586..e8b6fbbbc6 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -375,7 +375,7 @@ func (c *Coin) ConfigureDaemon() daemon.Config { c.config.Node.OutgoingConnectionsRate = time.Millisecond } dc.Daemon.OutgoingRate = c.config.Node.OutgoingConnectionsRate - dc.Visor.IsMaster = c.config.Node.RunMaster + dc.Visor.IsBlockPublisher = c.config.Node.RunBlockPublisher dc.Visor.BlockchainPubkey = c.config.Node.blockchainPubkey dc.Visor.BlockchainSeckey = c.config.Node.blockchainSeckey diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index f55091c8f3..330c67b5c9 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -103,7 +103,7 @@ func CreateBuckets(db *dbutil.DB) error { // BlockchainConfig configures Blockchain options type BlockchainConfig struct { - // Arbitrating mode: if in arbitrating mode, when master node execute blocks, + // Arbitrating mode: if in arbitrating mode, when block publishing node execute blocks, // the invalid transaction will be skipped and continue the next; otherwise, // node will throw the error and return. Arbitrating bool diff --git a/src/visor/blockdb/blocksigs.go b/src/visor/blockdb/blocksigs.go index efac4e010d..eebd108cb1 100644 --- a/src/visor/blockdb/blocksigs.go +++ b/src/visor/blockdb/blocksigs.go @@ -12,14 +12,14 @@ var ( ) // blockSigs manages known blockSigs as received. -// TODO -- support out of order blocks. This requires a change to the +// TODO -- support out of order blocks. This requires a change to the // message protocol to support ranges similar to bitcoin's locator hashes. // We also need to keep track of whether a block has been executed so that // as continuity is established we can execute chains of blocks. // TODO -- Since we will need to hold blocks that cannot be verified // immediately against the blockchain, we need to be able to hold multiple -// blockSigs per BkSeq, or use hashes as keys. For now, this is not a -// problem assuming the signed blocks created from master are valid blocks, +// blockSigs per BkSeq, or use hashes as keys. For now, this is not a +// problem assuming the signed blocks created by a block publisher are valid blocks, // because we can check the signature independently of the blockchain. type blockSigs struct{} diff --git a/src/visor/visor.go b/src/visor/visor.go index 62008ad977..0e8f26465a 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -36,13 +36,13 @@ var ( // Config configuration parameters for the Visor type Config struct { - // Is this the master blockchain - IsMaster bool + // Is this a block publishing node + IsBlockPublisher bool - // Public key of blockchain authority + // Public key of the blockchain BlockchainPubkey cipher.PubKey - // Secret key of blockchain authority (if master) + // Secret key of the blockchain (required if block publisher) BlockchainSeckey cipher.SecKey // Maximum size of a block, in bytes. @@ -83,7 +83,7 @@ type Config struct { // NewConfig creates Config func NewConfig() Config { c := Config{ - IsMaster: false, + IsBlockPublisher: false, BlockchainPubkey: cipher.PubKey{}, BlockchainSeckey: cipher.SecKey{}, @@ -103,9 +103,9 @@ func NewConfig() Config { // Verify verifies the configuration func (c Config) Verify() error { - if c.IsMaster { + if c.IsBlockPublisher { if c.BlockchainPubkey != cipher.MustPubKeyFromSecKey(c.BlockchainSeckey) { - return errors.New("Cannot run in master: invalid seckey for pubkey") + return errors.New("Cannot run as block publisher: invalid seckey for pubkey") } } @@ -184,7 +184,7 @@ type UnconfirmedTransactionPooler interface { Len(tx *dbutil.Tx) (uint64, error) } -// Visor manages the Blockchain as both a Master and a Normal +// Visor manages the blockchain type Visor struct { Config Config DB *dbutil.DB @@ -199,8 +199,8 @@ type Visor struct { // NewVisor creates a Visor for managing the blockchain database func NewVisor(c Config, db *dbutil.DB) (*Visor, error) { logger.Info("Creating new visor") - if c.IsMaster { - logger.Info("Visor is master") + if c.IsBlockPublisher { + logger.Info("Visor running in block publisher mode") } if err := c.Verify(); err != nil { @@ -377,7 +377,7 @@ func (vs *Visor) maybeCreateGenesisBlock(tx *dbutil.Tx) error { var sb coin.SignedBlock // record the signature of genesis block - if vs.Config.IsMaster { + if vs.Config.IsBlockPublisher { sb = vs.signBlock(*b) logger.Infof("Genesis block signature=%s", sb.Sig.Hex()) } else { @@ -432,8 +432,8 @@ func (vs *Visor) RemoveInvalidUnconfirmed() ([]cipher.SHA256, error) { // CreateBlock creates a SignedBlock from pending transactions func (vs *Visor) createBlock(tx *dbutil.Tx, when uint64) (coin.SignedBlock, error) { - if !vs.Config.IsMaster { - logger.Panic("Only master chain can create blocks") + if !vs.Config.IsBlockPublisher { + logger.Panic("Only a block publisher node can create blocks") } // Gather all unconfirmed transactions @@ -519,7 +519,7 @@ func (vs *Visor) CreateAndExecuteBlock() (coin.SignedBlock, error) { } // ExecuteSignedBlock adds a block to the blockchain, or returns error. -// Blocks must be executed in sequence, and be signed by the master server +// Blocks must be executed in sequence, and be signed by a block publisher node func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error { return vs.DB.Update("ExecuteSignedBlock", func(tx *dbutil.Tx) error { return vs.executeSignedBlock(tx, b) @@ -527,7 +527,7 @@ func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error { } // executeSignedBlock adds a block to the blockchain, or returns error. -// Blocks must be executed in sequence, and be signed by the master server +// Blocks must be executed in sequence, and be signed by a block publisher node func (vs *Visor) executeSignedBlock(tx *dbutil.Tx, b coin.SignedBlock) error { if err := b.VerifySignature(vs.Config.BlockchainPubkey); err != nil { return err @@ -551,10 +551,10 @@ func (vs *Visor) executeSignedBlock(tx *dbutil.Tx, b coin.SignedBlock) error { return vs.history.ParseBlock(tx, b.Block) } -// signBlock signs a block for master. Will panic if anything is invalid +// signBlock signs a block for a block publisher node. Will panic if anything is invalid func (vs *Visor) signBlock(b coin.Block) coin.SignedBlock { - if !vs.Config.IsMaster { - logger.Panic("Only master chain can sign blocks") + if !vs.Config.IsBlockPublisher { + logger.Panic("Only a block publisher node can sign blocks") } sig := cipher.MustSignHash(b.HashHeader(), vs.Config.BlockchainSeckey) diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index 81f96ee525..a18cff16b5 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -278,7 +278,7 @@ func TestVisorCreateBlock(t *testing.T) { cfg := NewConfig() cfg.DBPath = db.Path() - cfg.IsMaster = false + cfg.IsBlockPublisher = false cfg.BlockchainPubkey = genPublic cfg.GenesisAddress = genAddress @@ -290,8 +290,8 @@ func TestVisorCreateBlock(t *testing.T) { history: his, } - // CreateBlock panics if called when not master - _require.PanicsWithLogMessage(t, "Only master chain can create blocks", func() { + // CreateBlock panics if called when not a block publisher + _require.PanicsWithLogMessage(t, "Only a block publisher node can create blocks", func() { err := db.Update("", func(tx *dbutil.Tx) error { _, err := v.createBlock(tx, when) return err @@ -299,7 +299,7 @@ func TestVisorCreateBlock(t *testing.T) { require.NoError(t, err) }) - v.Config.IsMaster = true + v.Config.IsBlockPublisher = true v.Config.BlockchainSeckey = genSecret addGenesisBlockToVisor(t, v) @@ -499,7 +499,7 @@ func TestVisorInjectTransaction(t *testing.T) { cfg := NewConfig() cfg.DBPath = db.Path() - cfg.IsMaster = false + cfg.IsBlockPublisher = false cfg.BlockchainPubkey = genPublic cfg.GenesisAddress = genAddress @@ -511,8 +511,8 @@ func TestVisorInjectTransaction(t *testing.T) { history: his, } - // CreateBlock panics if called when not master - _require.PanicsWithLogMessage(t, "Only master chain can create blocks", func() { + // CreateBlock panics if called when not a block publisher + _require.PanicsWithLogMessage(t, "Only a block publisher node can create blocks", func() { err := db.Update("", func(tx *dbutil.Tx) error { _, err := v.createBlock(tx, when) return err @@ -520,7 +520,7 @@ func TestVisorInjectTransaction(t *testing.T) { require.NoError(t, err) }) - v.Config.IsMaster = true + v.Config.IsBlockPublisher = true v.Config.BlockchainSeckey = genSecret addGenesisBlockToVisor(t, v) @@ -1922,7 +1922,7 @@ func TestRefreshUnconfirmed(t *testing.T) { cfg := NewConfig() cfg.DBPath = db.Path() - cfg.IsMaster = true + cfg.IsBlockPublisher = true cfg.BlockchainSeckey = genSecret cfg.BlockchainPubkey = genPublic cfg.GenesisAddress = genAddress @@ -2052,7 +2052,7 @@ func TestRemoveInvalidUnconfirmedDoubleSpendArbitrating(t *testing.T) { cfg := NewConfig() cfg.DBPath = db.Path() - cfg.IsMaster = true + cfg.IsBlockPublisher = true cfg.Arbitrating = true cfg.BlockchainPubkey = genPublic cfg.GenesisAddress = genAddress From 51c921057a32462ee0474a2a45e61d2997ee54f3 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Fri, 2 Nov 2018 02:36:31 -0400 Subject: [PATCH 389/399] [lib] refs #1191 - Rename sha256xor error vars ... as specified in review https://github.com/skycoin/skycoin/pull/1639#pullrequestreview-170955680 ErrSHA256orMissingPassword => ErrMissingPassword ErrLenghtDataOverflowMaxUint32 => ErrDataTooLarge ErrInvalidDataChecksumNotMatched => ErrInvalidChecksum ErrInvalidBlockSizeMultiple32Bytes => ErrInvalidBlockSize ErrSHA256orInvalidPassword => ErrInvalidPassword ErrReadDataHashFailedLength => ErrReadDataHashFailed [====] Synthesis: Tested: 137 | Passing: 137 | Failing: 0 | Crashing: 0 --- include/skyerrors.h | 16 +++--- lib/cgo/libsky_error.go | 90 ++++++++++++++++----------------- src/cipher/encrypt/sha256xor.go | 36 ++++++------- 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/include/skyerrors.h b/include/skyerrors.h index 93aba64259..cea60a1edb 100644 --- a/include/skyerrors.h +++ b/include/skyerrors.h @@ -84,14 +84,14 @@ #define SKY_ErrBitcoinWIFInvalidChecksum 0x02000028 #define SKY_ErrEmptySeed 0x02000029 #define SKY_ErrInvalidSig 0x0200002A -#define SKY_ErrSHA256orMissingPassword 0x0200002B -#define SKY_ErrLenghtDataOverflowMaxUint32 0x0200002C +#define SKY_ErrMissingPassword 0x0200002B +#define SKY_ErrDataTooLarge 0x0200002C #define SKY_ErrInvalidChecksumLength 0x0200002D -#define SKY_ErrInvalidDataChecksumNotMatched 0x0200002E +#define SKY_ErrInvalidChecksum 0x0200002E #define SKY_ErrInvalidNonceLength 0x0200002F -#define SKY_ErrInvalidBlockSizeMultiple32Bytes 0x02000030 -#define SKY_ErrReadDataHashFailedLength 0x02000031 -#define SKY_ErrSHA256orInvalidPassword 0x02000032 +#define SKY_ErrInvalidBlockSize 0x02000030 +#define SKY_ErrReadDataHashFailed 0x02000031 +#define SKY_ErrInvalidPassword 0x02000032 #define SKY_ErrReadDataLengthFailed 0x02000033 #define SKY_ErrInvalidDataLength 0x02000034 @@ -171,9 +171,9 @@ #define SKY_ErrInvalidEncryptedField 0x0B000004 #define SKY_ErrWalletEncrypted 0x0B000005 #define SKY_ErrWalletNotEncrypted 0x0B000006 -#define SKY_ErrMissingPassword 0x0B000007 +#define SKY_ErrWalletMissingPassword 0x0B000007 #define SKY_ErrMissingEncrypt 0x0B000008 -#define SKY_ErrInvalidPassword 0x0B000009 +#define SKY_ErrWalletInvalidPassword 0x0B000009 #define SKY_ErrMissingSeed 0x0B00000A #define SKY_ErrMissingAuthenticated 0x0B00000B #define SKY_ErrWrongCryptoType 0x0B00000C diff --git a/lib/cgo/libsky_error.go b/lib/cgo/libsky_error.go index 4d940b32fe..206a58f0ea 100644 --- a/lib/cgo/libsky_error.go +++ b/lib/cgo/libsky_error.go @@ -154,22 +154,22 @@ const ( SKY_ErrEmptySeed // SKY_ErrInvalidSig Invalid signature SKY_ErrInvalidSig - // SKY_ErrSHA256orMissingPassword missing password - SKY_ErrSHA256orMissingPassword - // SKY_ErrSHA256LenghtDataOverflowMaxUint32 data length overflowed, it must <= math.MaxUint32(4294967295) - SKY_ErrLenghtDataOverflowMaxUint32 + // SKY_ErrMissingPassword missing password + SKY_ErrMissingPassword + // SKY_SKY_ErrDataTooLarge data length overflowed, it must <= math.MaxUint32(4294967295) + SKY_ErrDataTooLarge // SKY_ErrInvalidChecksumLength invalid checksum length SKY_ErrInvalidChecksumLength - // SKY_ErrInvalidDataChecksumNotMatched invalid data, checksum is not matched - SKY_ErrInvalidDataChecksumNotMatched + // SKY_ErrInvalidChecksum invalid data, checksum is not matched + SKY_ErrInvalidChecksum // SKY_ErrInvalidNonceLength invalid nonce length SKY_ErrInvalidNonceLength - // SKY_ErrInvalidBlockSizeMultiple32Bytes invalid block size, must be multiple of 32 bytes - SKY_ErrInvalidBlockSizeMultiple32Bytes - // SKY_ErrReadDataHashFailedLength read data hash failed: read length != 32 - SKY_ErrReadDataHashFailedLength - // SKY_ErrSHA256orInvalidPassword invalid password SHA256or - SKY_ErrSHA256orInvalidPassword + // SKY_ErrInvalidBlockSize invalid block size, must be multiple of 32 bytes + SKY_ErrInvalidBlockSize + // SKY_ErrReadDataHashFailed read data hash failed: read length != 32 + SKY_ErrReadDataHashFailed + // SKY_ErrInvalidPassword invalid password SHA256or + SKY_ErrInvalidPassword // SKY_ErrReadDataLengthFailed read data length failed SKY_ErrReadDataLengthFailed // SKY_ErrInvalidDataLength invalid data length @@ -339,12 +339,12 @@ const ( SKY_ErrWalletEncrypted // SKY_ErrWalletNotEncrypted is returned when trying to decrypt unencrypted wallet SKY_ErrWalletNotEncrypted - // SKY_ErrMissingPassword is returned when trying to create wallet with encryption, but password is not provided. - SKY_ErrMissingPassword + // SKY_ErrWalletMissingPassword is returned when trying to create wallet with encryption, but password is not provided. + SKY_ErrWalletMissingPassword // SKY_ErrMissingEncrypt is returned when trying to create wallet with password, but options.Encrypt is not set. SKY_ErrMissingEncrypt - // SKY_ErrInvalidPassword is returned if decrypts secrets failed - SKY_ErrInvalidPassword + // SKY_ErrWalletInvalidPassword is returned if decrypts secrets failed + SKY_ErrWalletInvalidPassword // SKY_ErrMissingSeed is returned when trying to create wallet without a seed SKY_ErrMissingSeed // SKY_ErrMissingAuthenticated is returned if try to decrypt a scrypt chacha20poly1305 encrypted wallet, and find no authenticated metadata. @@ -460,33 +460,33 @@ var ( cipher.ErrInvalidSigPubKeyRecovery: SKY_ErrInvalidSigPubKeyRecovery, // Removed in ea0aafbffb76 // cipher.ErrInvalidSecKeyHex: SKY_ErrInvalidSecKeyHex, - cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, - cipher.ErrInvalidHashForSig: SKY_ErrInvalidHashForSig, - cipher.ErrPubKeyRecoverMismatch: SKY_ErrPubKeyRecoverMismatch, - cipher.ErrInvalidSigInvalidPubKey: SKY_ErrInvalidSigInvalidPubKey, - cipher.ErrInvalidSigValidity: SKY_ErrInvalidSigValidity, - cipher.ErrInvalidSigForMessage: SKY_ErrInvalidSigForMessage, - cipher.ErrInvalidSecKyVerification: SKY_ErrInvalidSecKyVerification, - cipher.ErrNullPubKeyFromSecKey: SKY_ErrNullPubKeyFromSecKey, - cipher.ErrInvalidDerivedPubKeyFromSecKey: SKY_ErrInvalidDerivedPubKeyFromSecKey, - cipher.ErrInvalidPubKeyFromHash: SKY_ErrInvalidPubKeyFromHash, - cipher.ErrPubKeyFromSecKeyMismatch: SKY_ErrPubKeyFromSecKeyMismatch, - cipher.ErrInvalidLength: SKY_ErrInvalidLength, - cipher.ErrBitcoinWIFInvalidFirstByte: SKY_ErrBitcoinWIFInvalidFirstByte, - cipher.ErrBitcoinWIFInvalidSuffix: SKY_ErrBitcoinWIFInvalidSuffix, - cipher.ErrBitcoinWIFInvalidChecksum: SKY_ErrBitcoinWIFInvalidChecksum, - cipher.ErrEmptySeed: SKY_ErrEmptySeed, - cipher.ErrInvalidSig: SKY_ErrInvalidSig, - encrypt.ErrSHA256orMissingPassword: SKY_ErrSHA256orMissingPassword, - encrypt.ErrLenghtDataOverflowMaxUint32: SKY_ErrLenghtDataOverflowMaxUint32, - encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, - encrypt.ErrInvalidDataChecksumNotMatched: SKY_ErrInvalidDataChecksumNotMatched, - encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, - encrypt.ErrInvalidBlockSizeMultiple32Bytes: SKY_ErrInvalidBlockSizeMultiple32Bytes, - encrypt.ErrReadDataHashFailedLength: SKY_ErrReadDataHashFailedLength, - encrypt.ErrSHA256orInvalidPassword: SKY_ErrSHA256orInvalidPassword, - encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, - encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, + cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, + cipher.ErrInvalidHashForSig: SKY_ErrInvalidHashForSig, + cipher.ErrPubKeyRecoverMismatch: SKY_ErrPubKeyRecoverMismatch, + cipher.ErrInvalidSigInvalidPubKey: SKY_ErrInvalidSigInvalidPubKey, + cipher.ErrInvalidSigValidity: SKY_ErrInvalidSigValidity, + cipher.ErrInvalidSigForMessage: SKY_ErrInvalidSigForMessage, + cipher.ErrInvalidSecKyVerification: SKY_ErrInvalidSecKyVerification, + cipher.ErrNullPubKeyFromSecKey: SKY_ErrNullPubKeyFromSecKey, + cipher.ErrInvalidDerivedPubKeyFromSecKey: SKY_ErrInvalidDerivedPubKeyFromSecKey, + cipher.ErrInvalidPubKeyFromHash: SKY_ErrInvalidPubKeyFromHash, + cipher.ErrPubKeyFromSecKeyMismatch: SKY_ErrPubKeyFromSecKeyMismatch, + cipher.ErrInvalidLength: SKY_ErrInvalidLength, + cipher.ErrBitcoinWIFInvalidFirstByte: SKY_ErrBitcoinWIFInvalidFirstByte, + cipher.ErrBitcoinWIFInvalidSuffix: SKY_ErrBitcoinWIFInvalidSuffix, + cipher.ErrBitcoinWIFInvalidChecksum: SKY_ErrBitcoinWIFInvalidChecksum, + cipher.ErrEmptySeed: SKY_ErrEmptySeed, + cipher.ErrInvalidSig: SKY_ErrInvalidSig, + encrypt.ErrMissingPassword: SKY_ErrMissingPassword, + encrypt.ErrDataTooLarge: SKY_ErrDataTooLarge, + encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, + encrypt.ErrInvalidChecksum: SKY_ErrInvalidChecksum, + encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, + encrypt.ErrInvalidBlockSize: SKY_ErrInvalidBlockSize, + encrypt.ErrReadDataHashFailed: SKY_ErrReadDataHashFailed, + encrypt.ErrInvalidPassword: SKY_ErrInvalidPassword, + encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, + encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, // cli cli.ErrTemporaryInsufficientBalance: SKY_ErrTemporaryInsufficientBalance, @@ -549,9 +549,9 @@ var ( wallet.ErrInvalidEncryptedField: SKY_ErrInvalidEncryptedField, wallet.ErrWalletEncrypted: SKY_ErrWalletEncrypted, wallet.ErrWalletNotEncrypted: SKY_ErrWalletNotEncrypted, - wallet.ErrMissingPassword: SKY_ErrMissingPassword, + wallet.ErrMissingPassword: SKY_ErrWalletMissingPassword, wallet.ErrMissingEncrypt: SKY_ErrMissingEncrypt, - wallet.ErrInvalidPassword: SKY_ErrInvalidPassword, + wallet.ErrInvalidPassword: SKY_ErrWalletInvalidPassword, wallet.ErrMissingSeed: SKY_ErrMissingSeed, wallet.ErrMissingAuthenticated: SKY_ErrMissingAuthenticated, wallet.ErrWrongCryptoType: SKY_ErrWrongCryptoType, diff --git a/src/cipher/encrypt/sha256xor.go b/src/cipher/encrypt/sha256xor.go index a8fd76fad1..cb1dc55983 100644 --- a/src/cipher/encrypt/sha256xor.go +++ b/src/cipher/encrypt/sha256xor.go @@ -27,16 +27,16 @@ const ( // Error definition var ( - ErrSHA256orMissingPassword = errors.New("missing password") - ErrLenghtDataOverflowMaxUint32 = errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") - ErrInvalidChecksumLength = errors.New("invalid checksum length") - ErrInvalidDataChecksumNotMatched = errors.New("invalid data, checksum is not matched") - ErrInvalidNonceLength = errors.New("invalid nonce length") - ErrInvalidBlockSizeMultiple32Bytes = errors.New("invalid block size, must be multiple of 32 bytes") - ErrReadDataHashFailedLength = errors.New("read data hash failed: read length != 32") - ErrSHA256orInvalidPassword = errors.New("invalid password") - ErrReadDataLengthFailed = errors.New("read data length failed") - ErrInvalidDataLength = errors.New("invalid data length") + ErrMissingPassword = errors.New("missing password") + ErrDataTooLarge = errors.New("data length overflowed, it must <= math.MaxUint32(4294967295)") + ErrInvalidChecksumLength = errors.New("invalid checksum length") + ErrInvalidChecksum = errors.New("invalid data, checksum is not matched") + ErrInvalidNonceLength = errors.New("invalid nonce length") + ErrInvalidBlockSize = errors.New("invalid block size, must be multiple of 32 bytes") + ErrReadDataHashFailed = errors.New("read data hash failed: read length != 32") + ErrInvalidPassword = errors.New("invalid password") + ErrReadDataLengthFailed = errors.New("read data length failed") + ErrInvalidDataLength = errors.New("invalid data length") ) // DefaultSha256Xor default sha256xor encryptor @@ -57,11 +57,11 @@ type Sha256Xor struct{} // 6> Finally, the data format is: base64() func (s Sha256Xor) Encrypt(data []byte, password []byte) ([]byte, error) { if len(password) == 0 { - return nil, ErrSHA256orMissingPassword + return nil, ErrMissingPassword } if uint(len(data)) > math.MaxUint32 { - return nil, ErrLenghtDataOverflowMaxUint32 + return nil, ErrDataTooLarge } // Sets data length prefix @@ -125,7 +125,7 @@ func (s Sha256Xor) Encrypt(data []byte, password []byte) ([]byte, error) { // Decrypt decrypts the data func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { if len(password) == 0 { - return nil, ErrSHA256orMissingPassword + return nil, ErrMissingPassword } // Base64 decodes data @@ -157,7 +157,7 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { // Checks the checksum csh := cipher.SumSHA256(buf.Bytes()) if csh != checkSum { - return nil, ErrInvalidDataChecksumNotMatched + return nil, ErrInvalidChecksum } // Gets the nonce @@ -182,7 +182,7 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != sha256XorBlockSize { - return nil, ErrInvalidBlockSizeMultiple32Bytes + return nil, ErrInvalidBlockSize } // Decodes the block @@ -201,12 +201,12 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { } if n != 32 { - return nil, ErrReadDataHashFailedLength + return nil, ErrReadDataHashFailed } // Checks the hash if dataHash != cipher.SumSHA256(buf.Bytes()) { - return nil, ErrSHA256orInvalidPassword + return nil, ErrInvalidPassword } // Reads out the data length @@ -222,7 +222,7 @@ func (s Sha256Xor) Decrypt(data []byte, password []byte) ([]byte, error) { l := binary.LittleEndian.Uint32(dataLenBytes) if l > math.MaxUint32 { - return nil, ErrLenghtDataOverflowMaxUint32 + return nil, ErrDataTooLarge } if l > uint32(buf.Len()) { From 6b187163bc90a71e58734486c7b6956886946c7a Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 15:36:28 +0800 Subject: [PATCH 390/399] Split block size params up --- cmd/newcoin/newcoin.go | 20 ++------ cmd/skycoin/skycoin.go | 30 +++++------ fiber.toml | 26 +++++----- src/cli/create_rawtx.go | 2 +- src/daemon/gateway.go | 2 +- src/params/params.go | 4 +- src/skycoin/config.go | 24 +++++---- src/skycoin/parameters.go | 74 ++++++++++++++++------------ src/skycoin/parameters_test.go | 14 +++--- src/skycoin/skycoin.go | 1 + src/skycoin/testdata/test.fiber.toml | 3 ++ src/visor/blockchain_verify_test.go | 20 ++++---- src/visor/visor.go | 42 +++++++++++----- src/visor/visor_test.go | 30 +++++------ src/visor/visor_wallet.go | 4 +- template/coin.template | 30 +++++------ template/params.template | 4 +- 17 files changed, 183 insertions(+), 147 deletions(-) diff --git a/cmd/newcoin/newcoin.go b/cmd/newcoin/newcoin.go index 634049819d..1acc340691 100644 --- a/cmd/newcoin/newcoin.go +++ b/cmd/newcoin/newcoin.go @@ -190,22 +190,10 @@ func createCoinCommand() cli.Command { return err } - err = t.ExecuteTemplate(coinFile, coinTemplateFile, skycoin.NodeParameters{ - CoinName: coinName, - PeerListURL: config.Node.PeerListURL, - Port: config.Node.Port, - WebInterfacePort: config.Node.WebInterfacePort, - DataDirectory: "$HOME/." + coinName, - GenesisSignatureStr: config.Node.GenesisSignatureStr, - GenesisAddressStr: config.Node.GenesisAddressStr, - BlockchainPubkeyStr: config.Node.BlockchainPubkeyStr, - BlockchainSeckeyStr: config.Node.BlockchainSeckeyStr, - GenesisTimestamp: config.Node.GenesisTimestamp, - GenesisCoinVolume: config.Node.GenesisCoinVolume, - DefaultConnections: config.Node.DefaultConnections, - UnconfirmedBurnFactor: config.Node.UnconfirmedBurnFactor, - CreateBlockBurnFactor: config.Node.CreateBlockBurnFactor, - }) + config.Node.CoinName = coinName + config.Node.DataDirectory = "$HOME/." + coinName + + err = t.ExecuteTemplate(coinFile, coinTemplateFile, config.Node) if err != nil { log.Error("failed to parse coin template variables") return err diff --git a/cmd/skycoin/skycoin.go b/cmd/skycoin/skycoin.go index 034edd30c8..5666f8785d 100644 --- a/cmd/skycoin/skycoin.go +++ b/cmd/skycoin/skycoin.go @@ -61,20 +61,22 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ - CoinName: CoinName, - GenesisSignatureStr: GenesisSignatureStr, - GenesisAddressStr: GenesisAddressStr, - GenesisCoinVolume: GenesisCoinVolume, - GenesisTimestamp: GenesisTimestamp, - BlockchainPubkeyStr: BlockchainPubkeyStr, - BlockchainSeckeyStr: BlockchainSeckeyStr, - DefaultConnections: DefaultConnections, - PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", - Port: 6000, - WebInterfacePort: 6420, - DataDirectory: "$HOME/.skycoin", - UnconfirmedBurnFactor: 2, - CreateBlockBurnFactor: 2, + CoinName: CoinName, + GenesisSignatureStr: GenesisSignatureStr, + GenesisAddressStr: GenesisAddressStr, + GenesisCoinVolume: GenesisCoinVolume, + GenesisTimestamp: GenesisTimestamp, + BlockchainPubkeyStr: BlockchainPubkeyStr, + BlockchainSeckeyStr: BlockchainSeckeyStr, + DefaultConnections: DefaultConnections, + PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", + Port: 6000, + WebInterfacePort: 6420, + DataDirectory: "$HOME/.skycoin", + UnconfirmedBurnFactor: 2, + CreateBlockBurnFactor: 2, + MaxBlockSize: 32768, + MaxUnconfirmedTransactionSize: 32768, }) parseFlags = true diff --git a/fiber.toml b/fiber.toml index 2245256201..5e68f20b72 100644 --- a/fiber.toml +++ b/fiber.toml @@ -18,20 +18,22 @@ default_connections = [ "139.162.7.132:6000", ] peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" -#port = 6000 -#web_interface_port = 6420 -unconfirmed_burn_factor = 2 -create_block_burn_factor = 2 +# port = 6000 +# web_interface_port = 6420 +# unconfirmed_burn_factor = 2 +# create_block_burn_factor = 2 +# max_block_size = 32 * 1024 +# max_unconfirmed_transaction_size = 32 * 1024 [params] -#max_coin_supply = 1e8 -#distribution_addresses_total = 100 -#initial_unlocked_count = 25 -#unlock_addresss_rate = 5 -#unlocked_time_internal = 60 * 60 * 24 * 365 -#max_droplet_precision = 3 -#default_max_block_size = 32 * 1024 -#coinhour_burn_factor = 2 +# max_coin_supply = 1e8 +# distribution_addresses_total = 100 +# initial_unlocked_count = 25 +# unlock_addresss_rate = 5 +# unlocked_time_internal = 60 * 60 * 24 * 365 +# max_droplet_precision = 3 +# max_user_transaction_size = 32 * 1024 +# coinhour_burn_factor = 2 distribution_addresses = [ "R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ", "2EYM4WFHe4Dgz6kjAdUkM6Etep7ruz2ia6h", diff --git a/src/cli/create_rawtx.go b/src/cli/create_rawtx.go index 910d1ba0ae..029e98e230 100644 --- a/src/cli/create_rawtx.go +++ b/src/cli/create_rawtx.go @@ -540,7 +540,7 @@ func CreateRawTx(c GetOutputser, wlt *wallet.Wallet, inAddrs []string, chgAddr s return nil, err } - if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.DefaultMaxBlockSize, params.CoinHourBurnFactor); err != nil { + if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { return nil, err } if err := visor.VerifySingleTxnHardConstraints(*txn, head, inUxsFiltered); err != nil { diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 36cdf84bbb..399eeed8d7 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -493,7 +493,7 @@ func (gw *Gateway) InjectBroadcastTransaction(txn coin.Transaction) error { var err error gw.strand("InjectBroadcastTransaction", func() { err = gw.v.WithUpdateTx("gateway.InjectBroadcastTransaction", func(tx *dbutil.Tx) error { - if _, err := gw.v.InjectTransactionStrictTx(tx, txn); err != nil { + if _, err := gw.v.InjectTransactionUserTx(tx, txn); err != nil { logger.WithError(err).Error("InjectUserTransaction failed") return err } diff --git a/src/params/params.go b/src/params/params.go index f6fc83fc61..2266f02e95 100644 --- a/src/params/params.go +++ b/src/params/params.go @@ -20,8 +20,8 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = 31536000 // in seconds - //DefaultMaxBlockSize is max block size - DefaultMaxBlockSize int = 32768 // in bytes + // MaxUserTransactionSize is the maximum size of a user-created transaction + MaxUserTransactionSize int = 32768 // in bytes ) var ( diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 5481488e99..256c91ab80 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -140,8 +140,10 @@ type NodeConfig struct { // Reset the database if integrity checks fail, and continue running ResetCorruptDB bool - // Maximum size of blocks in bytes + // Maximum size of blocks in bytes to apply when creating blocks MaxBlockSize int + // Maximum size of a transaction in bytes to apply to unconfirmed txns (received over the network, or when refreshing the pool) + MaxUnconfirmedTransactionSize int // Coin hour burn factor to apply to unconfirmed txns (received over the network, or when refreshing the pool) UnconfirmedBurnFactor uint64 // Coin hour burn factor to apply when creating blocks @@ -267,9 +269,10 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { ResetCorruptDB: false, // Blockchain/transaction validation - MaxBlockSize: params.DefaultMaxBlockSize, - UnconfirmedBurnFactor: params.CoinHourBurnFactor, - CreateBlockBurnFactor: params.CoinHourBurnFactor, + MaxUnconfirmedTransactionSize: params.MaxUserTransactionSize, + MaxBlockSize: 32 * 1024, + UnconfirmedBurnFactor: params.CoinHourBurnFactor, + CreateBlockBurnFactor: params.CoinHourBurnFactor, // Wallets WalletDirectory: "", @@ -409,7 +412,11 @@ func (c *Config) postProcess() error { } if c.Node.MaxBlockSize <= 0 { - return errors.New("-max-block-size must be > 0") + return errors.New("-block-size must be > 0") + } + + if c.Node.MaxUnconfirmedTransactionSize <= 0 { + return errors.New("-unconfirmed-txn-size must be > 0") } if c.Node.UnconfirmedBurnFactor < 2 { @@ -562,13 +569,12 @@ func (c *NodeConfig) RegisterFlags() { flag.StringVar(&c.UserAgentRemark, "user-agent-remark", c.UserAgentRemark, "additional remark to include in the user agent sent over the wire protocol") - // Key Configuration Data - flag.BoolVar(&c.RunBlockPublisher, "block-publisher", c.RunBlockPublisher, "run the daemon as a block publisher") - - flag.IntVar(&c.MaxBlockSize, "max-block-size", c.MaxBlockSize, "maximum size of blocks") + flag.IntVar(&c.MaxUnconfirmedTransactionSize, "unconfirmed-txn-size", c.MaxUnconfirmedTransactionSize, "maximum size of an unconfirmed transaction") + flag.IntVar(&c.MaxBlockSize, "block-size", c.MaxBlockSize, "maximum size of a block") flag.Uint64Var(&c.UnconfirmedBurnFactor, "burn-factor-unconfirmed", c.UnconfirmedBurnFactor, "coinhour burn factor to apply when verifying unconfirmed transactions") flag.Uint64Var(&c.CreateBlockBurnFactor, "burn-factor-create-block", c.CreateBlockBurnFactor, "coinhour burn factor to apply to transactions when creating blocks") + flag.BoolVar(&c.RunBlockPublisher, "block-publisher", c.RunBlockPublisher, "run the daemon as a block publisher") flag.StringVar(&c.BlockchainPubkeyStr, "blockchain-public-key", c.BlockchainPubkeyStr, "public key of the blockchain") flag.StringVar(&c.BlockchainSeckeyStr, "blockchain-secret-key", c.BlockchainSeckeyStr, "secret key of the blockchain") diff --git a/src/skycoin/parameters.go b/src/skycoin/parameters.go index 776490c355..75215d485d 100644 --- a/src/skycoin/parameters.go +++ b/src/skycoin/parameters.go @@ -15,20 +15,38 @@ type Parameters struct { // NodeParameters records the node's configurable parameters type NodeParameters struct { - CoinName string `mapstructure:"coin_name"` - PeerListURL string `mapstructure:"peer_list_url"` - Port int `mapstructure:"port"` - WebInterfacePort int `mapstructure:"web_interface_port"` - GenesisSignatureStr string `mapstructure:"genesis_signature_str"` - GenesisAddressStr string `mapstructure:"genesis_address_str"` - BlockchainPubkeyStr string `mapstructure:"blockchain_pubkey_str"` - BlockchainSeckeyStr string `mapstructure:"blockchain_seckey_str"` - GenesisTimestamp uint64 `mapstructure:"genesis_timestamp"` - GenesisCoinVolume uint64 `mapstructure:"genesis_coin_volume"` - DefaultConnections []string `mapstructure:"default_connections"` - UnconfirmedBurnFactor uint64 `mapstructure:"unconfirmed_burn_factor"` - CreateBlockBurnFactor uint64 `mapstructure:"create_block_burn_factor"` - + // Port is the default port that the wire protocol communicates over + Port int `mapstructure:"port"` + // WebInterfacePort is the default port that the web/gui interface serves on + WebInterfacePort int `mapstructure:"web_interface_port"` + // GenesisSignatureStr is a hex-encoded signature of the genesis block input + GenesisSignatureStr string `mapstructure:"genesis_signature_str"` + // GenesisAddressStr is the skycoin address that the genesis coins were sent to in the genesis block + GenesisAddressStr string `mapstructure:"genesis_address_str"` + // BlockchainPubkeyStr is a hex-encoded public key used to validate published blocks + BlockchainPubkeyStr string `mapstructure:"blockchain_pubkey_str"` + // BlockchainSeckey is a hex-encoded secret key required for block publishing. + // It must correspond to BlockchainPubkeyStr + BlockchainSeckeyStr string `mapstructure:"blockchain_seckey_str"` + // GenesisTimestamp is the timestamp of the genesis block + GenesisTimestamp uint64 `mapstructure:"genesis_timestamp"` + // GenesisCoinVolume is the total number of coins in the genesis block + GenesisCoinVolume uint64 `mapstructure:"genesis_coin_volume"` + // DefaultConnections are the default "trusted" connections a node will try to connect to for bootstrapping + DefaultConnections []string `mapstructure:"default_connections"` + // PeerlistURL is a URL pointing to a newline-separated list of ip:ports that are used for bootstrapping (but they are not "trusted") + PeerListURL string `mapstructure:"peer_list_url"` + // UnconfirmedBurnFactor is the burn factor to apply when verifying unconfirmed transactions + UnconfirmedBurnFactor uint64 `mapstructure:"unconfirmed_burn_factor"` + // CreateBlockBurnFactor is the burn factor to apply to transactions when publishing blocks + CreateBlockBurnFactor uint64 `mapstructure:"create_block_burn_factor"` + // MaxBlockSize is the maximum size of blocks when publishing blocks + MaxBlockSize int `mapstructure:"max_block_size"` + // MaxUnconfirmedTransactionSize is the maximum size of an unconfirmed transaction + MaxUnconfirmedTransactionSize int `mapstructure:"max_unconfirmed_transaction_size"` + + // These fields are set by cmd/newcoin and are not configured in the fiber.toml file + CoinName string DataDirectory string } @@ -36,34 +54,24 @@ type NodeParameters struct { type ParamsParameters struct { // MaxCoinSupply is the maximum supply of coins MaxCoinSupply uint64 `mapstructure:"max_coin_supply"` - // DistributionAddressesTotal is the number of distribution addresses DistributionAddressesTotal uint64 `mapstructure:"distribution_addresses_total"` - // DistributionAddressInitialBalance is the initial balance of each distribution address DistributionAddressInitialBalance uint64 - // InitialUnlockedCount is the initial number of unlocked addresses InitialUnlockedCount uint64 `mapstructure:"initial_unlocked_count"` - // UnlockAddressRate is the number of addresses to unlock per unlock time interval UnlockAddressRate uint64 `mapstructure:"unlock_address_rate"` - - // UnlockTimeInterval is the distribution address unlock time interval, measured in seconds - // Once the InitialUnlockedCount is exhausted, - // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval + // UnlockTimeInterval is the distribution address unlock time interval, measured in seconds. + // Once the InitialUnlockedCount is exhausted, UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 `mapstructure:"unlock_time_interval"` - // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 `mapstructure:"max_droplet_precision"` - - //DefaultMaxBlockSize is max block size - DefaultMaxBlockSize int `mapstructure:"default_max_block_size"` - - // Addresses that received coins from the genesis address in the first block, + // MaxUserTransactionSize is max size of a user-created transaction (typically equal to the max size of a block) + MaxUserTransactionSize int `mapstructure:"max_user_transaction_size"` + // DistributionAddresses are addresses that received coins from the genesis address in the first block, // used to calculate current and max supply and do distribution timelocking DistributionAddresses []string `mapstructure:"distribution_addresses"` - // CoinHourBurnFactor inverse fraction of coinhours that must be burned, this value is used when creating transactions CoinHourBurnFactor uint64 `mapstructure:"coinhour_burn_factor"` } @@ -110,6 +118,10 @@ func setDefaults() { viper.SetDefault("node.genesis_coin_volume", 100e12) viper.SetDefault("node.port", 6000) viper.SetDefault("node.web_interface_port", 6420) + viper.SetDefault("node.max_block_size", 32*1024) + viper.SetDefault("node.max_unconfirmed_transaction_size", 32*1024) + viper.SetDefault("node.unconfirmed_burn_factor", 2) + viper.SetDefault("node.create_block_burn_factor", 2) // build defaults viper.SetDefault("build.commit", "") @@ -122,8 +134,6 @@ func setDefaults() { viper.SetDefault("params.unlock_address_rate", 5) viper.SetDefault("params.unlock_time_interval", 60*60*24*365) viper.SetDefault("params.max_droplet_precision", 3) - viper.SetDefault("params.default_max_block_size", 32*1024) viper.SetDefault("params.coinhour_burn_factor", 2) - viper.SetDefault("params.unconfirmed_burn_factor", 2) - viper.SetDefault("params.create_block_burn_factor", 2) + viper.SetDefault("params.max_user_transaction_size", 32*1024) } diff --git a/src/skycoin/parameters_test.go b/src/skycoin/parameters_test.go index 47687ef572..6ed0c096ea 100644 --- a/src/skycoin/parameters_test.go +++ b/src/skycoin/parameters_test.go @@ -27,11 +27,13 @@ func TestNewParameters(t *testing.T) { "172.104.85.6:6000", "139.162.7.132:6000", }, - Port: 6000, - PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", - WebInterfacePort: 6420, - UnconfirmedBurnFactor: 10, - CreateBlockBurnFactor: 9, + Port: 6000, + PeerListURL: "https://downloads.skycoin.net/blockchain/peers.txt", + WebInterfacePort: 6420, + UnconfirmedBurnFactor: 10, + CreateBlockBurnFactor: 9, + MaxBlockSize: 1111, + MaxUnconfirmedTransactionSize: 777, }, Params: ParamsParameters{ MaxCoinSupply: 1e8, @@ -40,8 +42,8 @@ func TestNewParameters(t *testing.T) { UnlockAddressRate: 5, UnlockTimeInterval: 60 * 60 * 24 * 365, MaxDropletPrecision: 3, - DefaultMaxBlockSize: 32 * 1024, CoinHourBurnFactor: 3, + MaxUserTransactionSize: 999, }, }, coinConfig) } diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index e8b6fbbbc6..366c776495 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -381,6 +381,7 @@ func (c *Coin) ConfigureDaemon() daemon.Config { dc.Visor.BlockchainSeckey = c.config.Node.blockchainSeckey dc.Visor.MaxBlockSize = c.config.Node.MaxBlockSize + dc.Visor.MaxUnconfirmedTransactionSize = c.config.Node.MaxUnconfirmedTransactionSize dc.Visor.UnconfirmedBurnFactor = c.config.Node.UnconfirmedBurnFactor dc.Visor.CreateBlockBurnFactor = c.config.Node.CreateBlockBurnFactor diff --git a/src/skycoin/testdata/test.fiber.toml b/src/skycoin/testdata/test.fiber.toml index f7a3848b08..48f0f2aa2c 100644 --- a/src/skycoin/testdata/test.fiber.toml +++ b/src/skycoin/testdata/test.fiber.toml @@ -20,6 +20,9 @@ launch_browser = true peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" unconfirmed_burn_factor = 10 create_block_burn_factor = 9 +max_block_size = 1111 +max_unconfirmed_transaction_size = 777 [params] coinhour_burn_factor = 3 +max_user_transaction_size = 999 diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 429cc37560..461b67ec10 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -347,7 +347,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // create normal spending txn uxs := coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) txn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) require.NoError(t, err) // Transaction size exceeds maxSize @@ -361,12 +361,12 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { hours += ux.Body.Hours } txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 0) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireSoftViolation(t, "Transaction has zero coinhour fee", err) // Invalid transaction fee, part 2 txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 1) - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireSoftViolation(t, "Transaction coinhour fee minimum not met", err) // Transaction locking is tested by TestVerifyTransactionIsLocked @@ -374,7 +374,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // Test invalid header hash originInnerHash := txn.InnerHash txn.InnerHash = cipher.SHA256{} - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireHardViolation(t, "InnerHash does not match computed hash", err) // Set back the originInnerHash @@ -401,7 +401,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { require.NoError(t, err) // A UxOut does not exist, it was already spent - err = verifySingleTxnSoftHardConstraints(txn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) expectedErr := NewErrTxnViolatesHardConstraint(blockdb.NewErrUnspentNotExist(txn.In[0].Hex())) require.Equal(t, expectedErr, err) @@ -410,21 +410,21 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { _, key := cipher.GenerateKeyPair() toAddr2 := testutil.MakeAddress() tx2 := makeSpendTx(t, uxs, []cipher.SecKey{key, key}, toAddr2, 5e6) - err = verifySingleTxnSoftHardConstraints(tx2, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(tx2, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireHardViolation(t, "Signature not valid for output being spent", err) // Create lost coin transaction uxs2 := coin.CreateUnspents(b.Head, txn) toAddr3 := testutil.MakeAddress() lostCoinTx := makeLostCoinTx(coin.UxArray{uxs2[1]}, []cipher.SecKey{genSecret}, toAddr3, 10e5) - err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireHardViolation(t, "Transactions may not destroy coins", err) // Create transaction with duplicate UxOuts uxs = coin.CreateUnspents(b.Head, txn) toAddr4 := testutil.MakeAddress() dupUxOutTx := makeDuplicateUxOutTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr4, 1e6) - err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.MaxUserTransactionSize, params.CoinHourBurnFactor) requireHardViolation(t, "Duplicate output in transaction", err) } @@ -475,7 +475,7 @@ func TestVerifyTxnFeeCoinHoursAdditionFails(t *testing.T) { testutil.RequireError(t, coinHoursErr, "UxOut.CoinHours addition of earned coin hours overflow") // VerifySingleTxnSoftConstraints should fail on this, when trying to calculate the TransactionFee - err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) testutil.RequireError(t, err, NewErrTxnViolatesSoftConstraint(coinHoursErr).Error()) // VerifySingleTxnHardConstraints should fail on this, when performing the extra check of @@ -553,7 +553,7 @@ func testVerifyTransactionAddressLocking(t *testing.T, toAddr string, expectedEr }) require.NoError(t, err) - err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.DefaultMaxBlockSize, params.CoinHourBurnFactor) + err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) if expectedErr == nil { require.NoError(t, err) } else { diff --git a/src/visor/visor.go b/src/visor/visor.go index 0e8f26465a..ff47fa08ac 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -45,7 +45,11 @@ type Config struct { // Secret key of the blockchain (required if block publisher) BlockchainSeckey cipher.SecKey - // Maximum size of a block, in bytes. + // Maximum size of a txn, in bytes for user created transactions + MaxUserTransactionSize int + // Maximum size of a txn, in bytes for unconfirmed transactions + MaxUnconfirmedTransactionSize int + // Maximum size of a block, in bytes for creating blocks MaxBlockSize int // Burn factor to apply to unconfirmed transactions (received over the network, or when refreshing the pool) @@ -88,9 +92,11 @@ func NewConfig() Config { BlockchainPubkey: cipher.PubKey{}, BlockchainSeckey: cipher.SecKey{}, - MaxBlockSize: params.DefaultMaxBlockSize, - UnconfirmedBurnFactor: params.CoinHourBurnFactor, - CreateBlockBurnFactor: params.CoinHourBurnFactor, + MaxUserTransactionSize: params.MaxUserTransactionSize, + MaxUnconfirmedTransactionSize: params.MaxUserTransactionSize, + MaxBlockSize: 32 * 1024, + UnconfirmedBurnFactor: params.CoinHourBurnFactor, + CreateBlockBurnFactor: params.CoinHourBurnFactor, GenesisAddress: cipher.Address{}, GenesisSignature: cipher.Sig{}, @@ -121,6 +127,16 @@ func (c Config) Verify() error { return errors.New("MaxBlockSize must be > 0") } + if c.MaxUnconfirmedTransactionSize <= 0 { + return errors.New("UnconfirmedBlockMaxBlockSize must be > 0") + } + if c.MaxUserTransactionSize <= 0 { + return errors.New("MaxUserTransactionSize must be > 0") + } + if c.MaxUserTransactionSize > c.MaxBlockSize { + return fmt.Errorf("MaxUserTransactionSize must be < MaxBlockSize (%d)", c.MaxBlockSize) + } + return nil } @@ -208,6 +224,8 @@ func NewVisor(c Config, db *dbutil.DB) (*Visor, error) { } logger.Infof("Max block size is %d", c.MaxBlockSize) + logger.Infof("Max user txn size is %d", c.MaxUserTransactionSize) + logger.Infof("Max unconfirmed txn size is %d", c.MaxUnconfirmedTransactionSize) logger.Infof("Coinhour burn factor for verifying unconfirmed transactions is %d", c.UnconfirmedBurnFactor) logger.Infof("Coinhour burn factor for transactions when creating blocks is %d", c.CreateBlockBurnFactor) @@ -405,7 +423,7 @@ func (vs *Visor) RefreshUnconfirmed() ([]cipher.SHA256, error) { var hashes []cipher.SHA256 if err := vs.DB.Update("RefreshUnconfirmed", func(tx *dbutil.Tx) error { var err error - hashes, err = vs.Unconfirmed.Refresh(tx, vs.Blockchain, vs.Config.MaxBlockSize, vs.Config.UnconfirmedBurnFactor) + hashes, err = vs.Unconfirmed.Refresh(tx, vs.Blockchain, vs.Config.MaxUnconfirmedTransactionSize, vs.Config.UnconfirmedBurnFactor) return err }); err != nil { return nil, err @@ -894,7 +912,7 @@ func (vs *Visor) InjectForeignTransaction(txn coin.Transaction) (bool, *ErrTxnVi if err := vs.DB.Update("InjectForeignTransaction", func(tx *dbutil.Tx) error { var err error - known, softErr, err = vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize, vs.Config.UnconfirmedBurnFactor) + known, softErr, err = vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxUnconfirmedTransactionSize, vs.Config.UnconfirmedBurnFactor) return err }); err != nil { return false, nil, err @@ -912,7 +930,7 @@ func (vs *Visor) InjectUserTransaction(txn coin.Transaction) (bool, error) { if err := vs.DB.Update("InjectUserTransaction", func(tx *dbutil.Tx) error { var err error - known, err = vs.InjectTransactionStrictTx(tx, txn) + known, err = vs.InjectTransactionUserTx(tx, txn) return err }); err != nil { return false, err @@ -921,21 +939,21 @@ func (vs *Visor) InjectUserTransaction(txn coin.Transaction) (bool, error) { return known, nil } -// InjectTransactionStrictTx records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not +// InjectTransactionUserTx records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not // already in the blockchain. // The bool return value is whether or not the transaction was already in the pool. // If the transaction violates hard or soft constraints, it is rejected, and error will not be nil. // This method is only exported for use by the daemon gateway's InjectBroadcastTransaction method. -func (vs *Visor) InjectTransactionStrictTx(tx *dbutil.Tx, txn coin.Transaction) (bool, error) { +func (vs *Visor) InjectTransactionUserTx(tx *dbutil.Tx, txn coin.Transaction) (bool, error) { if err := VerifySingleTxnUserConstraints(txn); err != nil { return false, err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { return false, err } - known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor) + known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor) if softErr != nil { logger.WithError(softErr).Warning("InjectUserTransaction vs.Unconfirmed.InjectTransaction returned a softErr unexpectedly") } @@ -2198,7 +2216,7 @@ func (vs *Visor) VerifyTxnVerbose(txn *coin.Transaction) ([]wallet.UxBalance, bo return err } - if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { + if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { return err } diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index a18cff16b5..cb10487be3 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -1982,13 +1982,15 @@ func TestRefreshUnconfirmed(t *testing.T) { }) require.NoError(t, err) - // Create a transaction that exceeds MaxBlockSize + // Create a transaction that exceeds MaxUnconfirmedTransactionSize // It's still injected, because this is considered a soft error - // This transaction will become valid on refresh (by increasing MaxBlockSize) - v.Config.MaxBlockSize = 1 + // This transaction will become valid on refresh (by increasing MaxUnconfirmedTransactionSize) + originalMaxUnconfirmedTxnSize := v.Config.MaxUnconfirmedTransactionSize + v.Config.MaxUnconfirmedTransactionSize = 1 sometimesInvalidTxn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) _, softErr, err = v.InjectForeignTransaction(sometimesInvalidTxn) require.NoError(t, err) + require.NotNil(t, softErr) testutil.RequireError(t, softErr.Err, errTxnExceedsMaxBlockSize.Error()) err = db.View("", func(tx *dbutil.Tx) error { @@ -2002,7 +2004,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // The first txn remains valid, // the second txn remains invalid, // the third txn becomes valid - v.Config.MaxBlockSize = params.DefaultMaxBlockSize + v.Config.MaxUnconfirmedTransactionSize = originalMaxUnconfirmedTxnSize hashes, err := v.RefreshUnconfirmed() require.NoError(t, err) require.Equal(t, []cipher.SHA256{sometimesInvalidTxn.Hash()}, hashes) @@ -2011,7 +2013,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // The first txn becomes invalid, // the second txn remains invalid, // the third txn becomes invalid again - v.Config.MaxBlockSize = 1 + v.Config.MaxUnconfirmedTransactionSize = 1 hashes, err = v.RefreshUnconfirmed() require.NoError(t, err) require.Nil(t, hashes) @@ -2020,7 +2022,7 @@ func TestRefreshUnconfirmed(t *testing.T) { // The first txn was valid, became invalid, and is now valid again // The second txn was always invalid // The third txn was invalid, became valid, became invalid, and is now valid again - v.Config.MaxBlockSize = params.DefaultMaxBlockSize + v.Config.MaxUnconfirmedTransactionSize = originalMaxUnconfirmedTxnSize hashes, err = v.RefreshUnconfirmed() require.NoError(t, err) @@ -2864,7 +2866,7 @@ func TestVerifyTxnVerbose(t *testing.T) { balances []wallet.UxBalance err error - maxBlockSize int + maxUserTransactionSize int getArrayRet coin.UxArray getArrayErr error @@ -2947,10 +2949,10 @@ func TestVerifyTxnVerbose(t *testing.T) { getArrayRet: inputs[:1], }, { - name: "transaction violate soft constraints, transaction size bigger than max block size", - maxBlockSize: 1, - txn: txn, - err: ErrTxnViolatesSoftConstraint{errors.New("Transaction size bigger than max block size")}, + name: "transaction violate soft constraints, transaction size bigger than max block size", + maxUserTransactionSize: 1, + txn: txn, + err: ErrTxnViolatesSoftConstraint{errors.New("Transaction size bigger than max block size")}, getArrayRet: inputs[:1], }, @@ -3027,12 +3029,12 @@ func TestVerifyTxnVerbose(t *testing.T) { DB: db, history: history, Config: Config{ - MaxBlockSize: tc.maxBlockSize, + MaxUserTransactionSize: tc.maxUserTransactionSize, }, } - if v.Config.MaxBlockSize == 0 { - v.Config.MaxBlockSize = params.DefaultMaxBlockSize + if v.Config.MaxUserTransactionSize == 0 { + v.Config.MaxUserTransactionSize = NewConfig().MaxUserTransactionSize } var isConfirmed bool diff --git a/src/visor/visor_wallet.go b/src/visor/visor_wallet.go index 4b48b7caa9..1c1a0adb6d 100644 --- a/src/visor/visor_wallet.go +++ b/src/visor/visor_wallet.go @@ -145,7 +145,7 @@ func (vs *Visor) CreateTransaction(p wallet.CreateTransactionParams) (*coin.Tran return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } @@ -202,7 +202,7 @@ func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coin return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxBlockSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } diff --git a/template/coin.template b/template/coin.template index a42114778d..1202e524e1 100755 --- a/template/coin.template +++ b/template/coin.template @@ -57,20 +57,22 @@ var ( } nodeConfig = skycoin.NewNodeConfig(ConfigMode, skycoin.NodeParameters{ - CoinName: CoinName, - GenesisSignatureStr: GenesisSignatureStr, - GenesisAddressStr: GenesisAddressStr, - GenesisCoinVolume: GenesisCoinVolume, - GenesisTimestamp: GenesisTimestamp, - BlockchainPubkeyStr: BlockchainPubkeyStr, - BlockchainSeckeyStr: BlockchainSeckeyStr, - DefaultConnections: DefaultConnections, - PeerListURL: "{{.PeerListURL}}", - Port: {{.Port}}, - WebInterfacePort: {{.WebInterfacePort}}, - DataDirectory: "{{.DataDirectory}}", - UnconfirmedBurnFactor: {{.UnconfirmedBurnFactor}}, - CreateBlockBurnFactor: {{.CreateBlockBurnFactor}}, + CoinName: CoinName, + GenesisSignatureStr: GenesisSignatureStr, + GenesisAddressStr: GenesisAddressStr, + GenesisCoinVolume: GenesisCoinVolume, + GenesisTimestamp: GenesisTimestamp, + BlockchainPubkeyStr: BlockchainPubkeyStr, + BlockchainSeckeyStr: BlockchainSeckeyStr, + DefaultConnections: DefaultConnections, + PeerListURL: "{{.PeerListURL}}", + Port: {{.Port}}, + WebInterfacePort: {{.WebInterfacePort}}, + DataDirectory: "{{.DataDirectory}}", + UnconfirmedBurnFactor: {{.UnconfirmedBurnFactor}}, + CreateBlockBurnFactor: {{.CreateBlockBurnFactor}}, + MaxBlockSize: {{.MaxBlockSize}}, + MaxUnconfirmedTransactionSize: {{.MaxUnconfirmedTransactionSize}}, }) parseFlags = true diff --git a/template/params.template b/template/params.template index 090e05bb1c..03784c33b8 100644 --- a/template/params.template +++ b/template/params.template @@ -20,8 +20,8 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = {{.UnlockTimeInterval}} // in seconds - //DefaultMaxBlockSize is max block size - DefaultMaxBlockSize int = {{.DefaultMaxBlockSize}} // in bytes + // MaxUserTransactionSize is the maximum size of a user-created transaction + MaxUserTransactionSize int = {{.MaxUserTransactionSize}} // in bytes ) var ( From 426724d12229f37ef496d6c22099b943901a70be Mon Sep 17 00:00:00 2001 From: gz-c Date: Fri, 2 Nov 2018 15:47:58 +0800 Subject: [PATCH 391/399] Improve block/txn size configuration --- README.md | 19 +++++++++++++++++++ src/params/init.go | 23 +++++++++++++++++++++++ src/params/params.go | 5 +++-- src/skycoin/config.go | 4 ++++ src/skycoin/skycoin.go | 1 + src/visor/visor.go | 19 ++++++------------- src/visor/visor_test.go | 13 ++++++++----- src/visor/visor_wallet.go | 4 ++-- template/params.template | 5 +++-- 9 files changed, 69 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e8b0f4a99c..95f7a11dd9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ scratch, to remedy the rough edges in the Bitcoin design. - [Contributing a node to the network](#contributing-a-node-to-the-network) - [Creating a new coin](#creating-a-new-coin) - [Running with a custom coin hour burn factor](#running-with-a-custom-coin-hour-burn-factor) +- [Running with a custom max transaction size](#running-with-a-custom-max-transaction-size) - [URI Specification](#uri-specification) - [Wire protocol user agent](#wire-protocol-user-agent) - [Development](#development) @@ -228,6 +229,24 @@ The coin hour burn factor can be configured with a `COINHOUR_BURN_FACTOR` envvar COINHOUR_BURN_FACTOR=999 ./run-client.sh ``` +This burn factor applies to user-created transactions. + +To control the burn factor in other scenarios, use `-burn-factor-unconfirmed` and `-burn-factor-create-block`. + +## Running with a custom max transaction size + +```sh +MAX_USER_TXN_SIZE=1024 ./run-client.sh +``` + +This maximum transaction size applies to user-created transactions. + +To control the transaction size for unconfirmed transactions, use `-unconfirmed-txn-size`. + +To control the max block size, use `-block-size`. + +Transaction and block size are measured in bytes. + ## URI Specification Skycoin URIs obey the same rules as specified in Bitcoin's [BIP21](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki). diff --git a/src/params/init.go b/src/params/init.go index 75c41432b9..10e14be924 100644 --- a/src/params/init.go +++ b/src/params/init.go @@ -8,6 +8,7 @@ import ( func init() { loadCoinHourBurnFactor() + loadMaxUserTransactionSize() // Compute maxDropletDivisor from precision maxDropletDivisor = calculateDivisor(MaxDropletPrecision) @@ -20,6 +21,10 @@ func sanityCheck() { panic("CoinHourBurnFactor must be > 1") } + if MaxUserTransactionSize <= 0 { + panic("MaxUserTransactionSize must be > 0") + } + if InitialUnlockedCount > DistributionAddressesTotal { panic("unlocked addresses > total distribution addresses") } @@ -54,3 +59,21 @@ func loadCoinHourBurnFactor() { CoinHourBurnFactor = x } + +func loadMaxUserTransactionSize() { + xs := os.Getenv("MAX_USER_TXN_SIZE") + if xs == "" { + return + } + + x, err := strconv.ParseInt(xs, 10, 32) + if err != nil { + panic(fmt.Sprintf("Invalid MAX_USER_TXN_SIZE %q: %v", xs, err)) + } + + if x <= 0 { + panic("MAX_USER_TXN_SIZE must be > 0") + } + + MaxUserTransactionSize = int(x) +} diff --git a/src/params/params.go b/src/params/params.go index 2266f02e95..28dada2fb3 100644 --- a/src/params/params.go +++ b/src/params/params.go @@ -20,8 +20,6 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = 31536000 // in seconds - // MaxUserTransactionSize is the maximum size of a user-created transaction - MaxUserTransactionSize int = 32768 // in bytes ) var ( @@ -29,6 +27,9 @@ var ( // used when creating a transaction CoinHourBurnFactor uint64 = 2 + // MaxUserTransactionSize is the maximum size of a user-created transaction + MaxUserTransactionSize = 32768 // in bytes + // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = 3 ) diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 256c91ab80..0044f404a8 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -426,6 +426,10 @@ func (c *Config) postProcess() error { return fmt.Errorf("-unconfirmed-burn-factor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) } + if c.Node.MaxBlockSize < params.MaxUserTransactionSize { + return fmt.Errorf("-max-block-size must be >= params.MaxUserTransactionSize (%d)", params.MaxUserTransactionSize) + } + if c.Node.CreateBlockBurnFactor < 2 { return errors.New("-create-block-burn-factor must be >= 2") } diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 366c776495..4f543d86fb 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -202,6 +202,7 @@ func (c *Coin) Run() error { } c.logger.Infof("Coinhour burn factor for creating transactions is %d", params.CoinHourBurnFactor) + c.logger.Infof("Max user transaction size is %d", params.MaxUserTransactionSize) d, err = daemon.NewDaemon(dconf, db) if err != nil { diff --git a/src/visor/visor.go b/src/visor/visor.go index ff47fa08ac..0d00cf959b 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -45,8 +45,6 @@ type Config struct { // Secret key of the blockchain (required if block publisher) BlockchainSeckey cipher.SecKey - // Maximum size of a txn, in bytes for user created transactions - MaxUserTransactionSize int // Maximum size of a txn, in bytes for unconfirmed transactions MaxUnconfirmedTransactionSize int // Maximum size of a block, in bytes for creating blocks @@ -92,7 +90,6 @@ func NewConfig() Config { BlockchainPubkey: cipher.PubKey{}, BlockchainSeckey: cipher.SecKey{}, - MaxUserTransactionSize: params.MaxUserTransactionSize, MaxUnconfirmedTransactionSize: params.MaxUserTransactionSize, MaxBlockSize: 32 * 1024, UnconfirmedBurnFactor: params.CoinHourBurnFactor, @@ -130,11 +127,8 @@ func (c Config) Verify() error { if c.MaxUnconfirmedTransactionSize <= 0 { return errors.New("UnconfirmedBlockMaxBlockSize must be > 0") } - if c.MaxUserTransactionSize <= 0 { - return errors.New("MaxUserTransactionSize must be > 0") - } - if c.MaxUserTransactionSize > c.MaxBlockSize { - return fmt.Errorf("MaxUserTransactionSize must be < MaxBlockSize (%d)", c.MaxBlockSize) + if params.MaxUserTransactionSize > c.MaxBlockSize { + return fmt.Errorf("params.MaxUserTransactionSize must be < MaxBlockSize (%d)", c.MaxBlockSize) } return nil @@ -224,8 +218,7 @@ func NewVisor(c Config, db *dbutil.DB) (*Visor, error) { } logger.Infof("Max block size is %d", c.MaxBlockSize) - logger.Infof("Max user txn size is %d", c.MaxUserTransactionSize) - logger.Infof("Max unconfirmed txn size is %d", c.MaxUnconfirmedTransactionSize) + logger.Infof("Max unconfirmed transaction size is %d", c.MaxUnconfirmedTransactionSize) logger.Infof("Coinhour burn factor for verifying unconfirmed transactions is %d", c.UnconfirmedBurnFactor) logger.Infof("Coinhour burn factor for transactions when creating blocks is %d", c.CreateBlockBurnFactor) @@ -949,11 +942,11 @@ func (vs *Visor) InjectTransactionUserTx(tx *dbutil.Tx, txn coin.Transaction) (b return false, err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { return false, err } - known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor) + known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) if softErr != nil { logger.WithError(softErr).Warning("InjectUserTransaction vs.Unconfirmed.InjectTransaction returned a softErr unexpectedly") } @@ -2216,7 +2209,7 @@ func (vs *Visor) VerifyTxnVerbose(txn *coin.Transaction) ([]wallet.UxBalance, bo return err } - if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { return err } diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index cb10487be3..f97897eef2 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -3028,13 +3028,16 @@ func TestVerifyTxnVerbose(t *testing.T) { Blockchain: bc, DB: db, history: history, - Config: Config{ - MaxUserTransactionSize: tc.maxUserTransactionSize, - }, + Config: Config{}, } - if v.Config.MaxUserTransactionSize == 0 { - v.Config.MaxUserTransactionSize = NewConfig().MaxUserTransactionSize + originalMaxUnconfirmedTxnSize := params.MaxUserTransactionSize + defer func() { + params.MaxUserTransactionSize = originalMaxUnconfirmedTxnSize + }() + + if tc.maxUserTransactionSize != 0 { + params.MaxUserTransactionSize = tc.maxUserTransactionSize } var isConfirmed bool diff --git a/src/visor/visor_wallet.go b/src/visor/visor_wallet.go index 1c1a0adb6d..a1fc6f1bfb 100644 --- a/src/visor/visor_wallet.go +++ b/src/visor/visor_wallet.go @@ -145,7 +145,7 @@ func (vs *Visor) CreateTransaction(p wallet.CreateTransactionParams) (*coin.Tran return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } @@ -202,7 +202,7 @@ func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coin return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, vs.Config.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } diff --git a/template/params.template b/template/params.template index 03784c33b8..1613d0362d 100644 --- a/template/params.template +++ b/template/params.template @@ -20,8 +20,6 @@ const ( // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = {{.UnlockTimeInterval}} // in seconds - // MaxUserTransactionSize is the maximum size of a user-created transaction - MaxUserTransactionSize int = {{.MaxUserTransactionSize}} // in bytes ) var ( @@ -29,6 +27,9 @@ var ( // used when creating a transaction CoinHourBurnFactor uint64 = {{.CoinHourBurnFactor}} + // MaxUserTransactionSize is the maximum size of a user-created transaction + MaxUserTransactionSize = {{.MaxUserTransactionSize}} // in bytes + // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = {{.MaxDropletPrecision}} ) From e1bf55f8e7383b302ddf918bc9c627937ec86712 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 4 Nov 2018 14:57:47 -0500 Subject: [PATCH 392/399] [lib] refs #1191 - Remove wrappers and tests for cipher subpkgs not meant to be part of the libskycoin C API - cipher.poly1305.poly1305 - cipher.ripemd160.ripemd160 - cipher.scrypt.scrypt ... requested in https://github.com/skycoin/skycoin/pull/1639#pullrequestreview-171344692 [====] Synthesis: Tested: 136 | Passing: 136 | Failing: 0 | Crashing: 0 --- lib/cgo/cipher.poly1305.poly1305.go | 26 ---- lib/cgo/cipher.ripemd160.ripemd160.go | 54 --------- lib/cgo/cipher.scrypt.scrypt.go | 33 ------ lib/cgo/tests/check_cipher.scrypt.c | 164 -------------------------- lib/cgo/tests/cipher.testsuite.c | 23 ++-- 5 files changed, 11 insertions(+), 289 deletions(-) delete mode 100644 lib/cgo/cipher.poly1305.poly1305.go delete mode 100644 lib/cgo/cipher.ripemd160.ripemd160.go delete mode 100644 lib/cgo/cipher.scrypt.scrypt.go delete mode 100644 lib/cgo/tests/check_cipher.scrypt.c diff --git a/lib/cgo/cipher.poly1305.poly1305.go b/lib/cgo/cipher.poly1305.poly1305.go deleted file mode 100644 index d62177b205..0000000000 --- a/lib/cgo/cipher.poly1305.poly1305.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -import ( - "unsafe" - - poly1305 "github.com/skycoin/skycoin/src/cipher/poly1305" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_poly1305_Verify -func SKY_poly1305_Verify(_mac *C.GoSlice_, _m []byte, _key *C.GoSlice_, _arg3 *bool) (____error_code uint32) { - mac := (*[16]byte)(unsafe.Pointer(_mac)) - m := *(*[]byte)(unsafe.Pointer(&_m)) - key := (*[32]byte)(unsafe.Pointer(_key)) - __arg3 := poly1305.Verify(mac, m, key) - *_arg3 = __arg3 - return -} diff --git a/lib/cgo/cipher.ripemd160.ripemd160.go b/lib/cgo/cipher.ripemd160.ripemd160.go deleted file mode 100644 index 3ec9eda5a8..0000000000 --- a/lib/cgo/cipher.ripemd160.ripemd160.go +++ /dev/null @@ -1,54 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - "github.com/skycoin/skycoin/src/cipher/ripemd160" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_ripemd160_New -func SKY_ripemd160_New(handle *C.Hash_Handle) (____error_code uint32) { - hash := ripemd160.New() - *handle = registerHashHandle(&hash) - return -} - -//export SKY_ripemd160_Write -func SKY_ripemd160_Write(handle C.Hash_Handle, _p []byte, _nn *int) (____error_code uint32) { - h, ok := lookupHashHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - p := *(*[]byte)(unsafe.Pointer(&_p)) - nn, error := (*h).Write(p) - if error != nil { - ____error_code = SKY_ERROR - return - } - *_nn = nn - return -} - -//export SKY_ripemd160_Sum -func SKY_ripemd160_Sum(handle C.Hash_Handle, _p []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - h, ok := lookupHashHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - p := *(*[]byte)(unsafe.Pointer(&_p)) - __arg1 := (*h).Sum(p) - copyToGoSlice(reflect.ValueOf(__arg1[:]), _arg1) - return -} diff --git a/lib/cgo/cipher.scrypt.scrypt.go b/lib/cgo/cipher.scrypt.scrypt.go deleted file mode 100644 index d2f121b884..0000000000 --- a/lib/cgo/cipher.scrypt.scrypt.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - scrypt "github.com/skycoin/skycoin/src/cipher/scrypt" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_scrypt_Key -func SKY_scrypt_Key(_password, _salt []byte, _N, _r, _p, _keyLen int, _arg2 *C.GoSlice_) (____error_code uint32) { - password := *(*[]byte)(unsafe.Pointer(&_password)) - salt := *(*[]byte)(unsafe.Pointer(&_salt)) - N := _N - r := _r - p := _p - keyLen := _keyLen - __arg2, ____return_err := scrypt.Key(password, salt, N, r, p, keyLen) - ____error_code = libErrorCode(____return_err) - if ____return_err == nil { - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - } - return -} diff --git a/lib/cgo/tests/check_cipher.scrypt.c b/lib/cgo/tests/check_cipher.scrypt.c deleted file mode 100644 index fface05b85..0000000000 --- a/lib/cgo/tests/check_cipher.scrypt.c +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "base64.h" - -#define BUFFER_SIZE 1024 - -TestSuite(cipher_scrypt, .init = setup, .fini = teardown); - -typedef struct { - char* password; - char* salt; - GoInt N, r, p; - GoUint8* output; - GoInt keyLength; - GoInt passwordLength; - GoInt saltLength; -} TESTVECTOR; - -Test(cipher_scrypt, TestKey){ - GoUint8 g1[] = { - 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f, - 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb, - 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a, - 0xc5, 0xe5, 0xa, 0xa1, 0x5f, - }; - GoUint8 g2[] = { - 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18, - 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e, - 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5, - 0x7f, 0x91, 0x96, 0x3c, 0x37, - }; - GoUint8 g3[] = { - 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70, - 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09, - 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f, - 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98, - 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50, - 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa, - 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11, - 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40, - 0x18, 0x79, 0xe6, 0x41, 0xae, - }; - GoUint8 g4[] = { - 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98, - 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52, - }; - GoUint8 g5[] = { - 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b, - 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b, - 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa, - 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d, - 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f, - 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d, - 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89, - 0x06, - }; - GoUint8 g6[] = { - 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78, - 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a, - 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76, - 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9, - 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d, - 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, - 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, - 0x40, - }; - GoUint8 g7[] = { - 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46, - 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8, - 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43, - 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55, - 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24, - 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65, - 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58, - 0x87, - }; - TESTVECTOR good_ones[] = { - {"password", "salt", 2, 10, 10, g1, sizeof(g1) / sizeof(GoUint8), -1, -1}, - {"password", "salt", 16, 100, 100, g2, sizeof(g2) / sizeof(GoUint8), -1, -1}, - {"this is a long \000 password", - "and this is a long \000 salt", - 16384, 8, 1, g3, sizeof(g3) / sizeof(GoUint8), 25, 25}, - {"p", "s", 2, 1, 1, g4, sizeof(g4) / sizeof(GoUint8), -1, -1}, - {"", "", 16, 1, 1, g5, sizeof(g5) / sizeof(GoUint8), -1, -1}, - {"password", "NaCl", 1024, 8, 16, g6, sizeof(g6) / sizeof(GoUint8), -1, -1}, - {"pleaseletmein", "SodiumChloride", 16384, 8, 1, g7, sizeof(g7) / sizeof(GoUint8), -1, -1}, - }; - - GoInt32 maxInt = (GoInt32)(~((GoUint32)0) >> 1); - - TESTVECTOR bad_ones[] = { - {"p", "s", 0, 1, 1, NULL, -1, -1}, // N == 0 - {"p", "s", 1, 1, 1, NULL, -1, -1}, // N == 1 - {"p", "s", 7, 8, 1, NULL, -1, -1}, // N is not power of 2 - {"p", "s", 16, maxInt / 2, maxInt / 2, NULL, -1, -1}, // p * r too large - }; - - GoUint32 errcode; - GoSlice password; - GoSlice salt; - GoUint8 buffer[BUFFER_SIZE]; - coin__UxArray key = {buffer, 0, BUFFER_SIZE}; - - int good_ones_count = sizeof(good_ones) / sizeof(good_ones[0]); - int bad_ones_count = sizeof(bad_ones) / sizeof(bad_ones[0]); - for(int i = 0; i < good_ones_count; i++){ - password.data = good_ones[i].password; - if( good_ones[i].passwordLength < 0) - password.len = strlen(good_ones[i].password); - else - password.len = good_ones[i].passwordLength; - password.cap = password.len; - - salt.data = good_ones[i].salt; - if( good_ones[i].saltLength < 0) - salt.len = strlen(good_ones[i].salt); - else - salt.len = good_ones[i].saltLength; - salt.cap = salt.len; - - errcode = SKY_scrypt_Key(password, salt, - good_ones[i].N, good_ones[i].r, good_ones[i].p, - good_ones[i].keyLength, &key); - cr_assert(errcode == SKY_OK, "SKY_scrypt_Key failed"); - cr_assert(good_ones[i].keyLength == key.len, "SKY_scrypt_Key failed, incorrect generated key length."); - int equal = 1; - for(int j = 0; j < key.len; j++){ - if( ((GoUint8*)key.data)[j] != good_ones[i].output[j]){ - equal = 0; - } - } - cr_assert(equal == 1, "SKY_scrypt_Key failed. Invalid key generated."); - } - - for(int i = 0; i < bad_ones_count; i++){ - password.data = bad_ones[i].password; - if( bad_ones[i].passwordLength < 0) - password.len = strlen(bad_ones[i].password); - else - password.len = bad_ones[i].passwordLength; - password.cap = password.len; - - salt.data = bad_ones[i].salt; - if( bad_ones[i].saltLength < 0) - salt.len = strlen(bad_ones[i].salt); - else - salt.len = bad_ones[i].saltLength; - salt.cap = salt.len; - - errcode = SKY_scrypt_Key(password, salt, - bad_ones[i].N, bad_ones[i].r, bad_ones[i].p, - bad_ones[i].keyLength, &key); - cr_assert(errcode == SKY_ERROR, "SKY_scrypt_Key didn\'t failed"); - } -} diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index a099a7d964..3c3c8bee4a 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -430,18 +430,17 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { cr_assert(eq(type(cipher__Address), addr1, addr2), "%d-th SKY_cipher_AddressFromPubKey and SKY_cipher_AddressFromSecKey must generate same addresses", i); - // TODO : Translate once secp256k1 be part of libskycoin - GoInt validSec; - char bufferSecKey[101]; - strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),65 }; - SKY_secp256k1_VerifySeckey(slseckey,&validSec); - cr_assert(validSec ==1 ,"SKY_secp256k1_VerifySeckey failed"); - - GoInt validPub; - GoSlice slpubkey = { &p,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; - SKY_secp256k1_VerifyPubkey(slpubkey,&validPub); - cr_assert(validPub ==1 ,"SKY_secp256k1_VerifyPubkey failed"); + GoInt validSec; + char bufferSecKey[101]; + strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); + GoSlice slseckey = { bufferSecKey,sizeof(cipher__SecKey),65 }; + SKY_secp256k1_VerifySeckey(slseckey,&validSec); + cr_assert(validSec ==1 ,"SKY_secp256k1_VerifySeckey failed"); + + GoInt validPub; + GoSlice slpubkey = { &p,sizeof(cipher__PubKey), sizeof(cipher__PubKey) }; + SKY_secp256k1_VerifyPubkey(slpubkey,&validPub); + cr_assert(validPub ==1 ,"SKY_secp256k1_VerifyPubkey failed"); // FIXME: without cond : 'not give a valid preprocessing token' bool cond = (!(inputData == NULL && expected->Signatures.len != 0)); From 06c45333be12fde98a8474a16b4f68af0f4abf81 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 5 Nov 2018 14:02:27 +0800 Subject: [PATCH 393/399] Fixups --- CHANGELOG.md | 3 +- README.md | 4 +-- fiber.toml | 2 +- src/api/health.go | 2 +- src/api/integration/integration_test.go | 6 ++-- src/cli/create_rawtx.go | 4 +-- src/daemon/daemon.go | 16 +++++----- src/daemon/gateway.go | 4 +-- src/daemon/messages.go | 8 ++--- src/daemon/mock_daemoner_test.go | 40 ++++++++++++------------- src/params/init.go | 12 ++++---- src/params/params.go | 4 +-- src/skycoin/config.go | 33 ++++++++++---------- src/skycoin/parameters.go | 13 ++++---- src/skycoin/parameters_test.go | 2 +- src/skycoin/skycoin.go | 2 +- src/skycoin/testdata/test.fiber.toml | 2 +- src/util/fee/fee.go | 2 +- src/util/fee/fee_test.go | 8 ++--- src/visor/blockchain_verify_test.go | 22 +++++++------- src/visor/visor.go | 38 +++++++++++------------ src/visor/visor_test.go | 4 +-- src/visor/visor_wallet.go | 4 +-- src/wallet/wallet.go | 18 +++++------ src/wallet/wallet_test.go | 22 +++++++------- template/params.template | 4 +-- 26 files changed, 142 insertions(+), 137 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b0f9d319b..ba65b13b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,8 @@ Make sure to upgrade to v0.25.0 so that your node will continue to connect once - Go application metrics exported at `/api/v2/metrics` (API set `PROMETHEUS`) in Prometheus format - Add `/api/v2/wallet/recover` to recover an encrypted wallet by providing the seed - Add `fiberAddressGen` CLI command to generate distribution addresses for fiber coins -- Coinhour burn factor can be configured at runtime with `COINHOUR_BURN_FACTOR` envvar +- Coinhour burn factor when creating transactions can be configured at runtime with `USER_BURN_FACTOR` envvar +- Max transaction size when creating transactions can be configured at runtime with `MAX_USER_TXN_SIZE` envvar - Daemon configured builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. The builds available for previous versions are configured for desktop client use. - `skycoin-cli` builds will be available on the [releases](https://github.com/skycoin/skycoin/releases) page. - A user agent string is sent in the wire protocol's introduction packet diff --git a/README.md b/README.md index 95f7a11dd9..9017585474 100644 --- a/README.md +++ b/README.md @@ -223,10 +223,10 @@ See the [newcoin tool README](./cmd/newcoin/README.md) The coin hour burn factor is the denominator in the ratio of coinhours that must be burned by a transaction. For example, a burn factor of 2 means 1/2 of hours must be burned. A burn factor of 10 means 1/10 of coin hours must be burned. -The coin hour burn factor can be configured with a `COINHOUR_BURN_FACTOR` envvar. It cannot be configured through the command line. +The coin hour burn factor can be configured with a `USER_BURN_FACTOR` envvar. It cannot be configured through the command line. ```sh -COINHOUR_BURN_FACTOR=999 ./run-client.sh +USER_BURN_FACTOR=999 ./run-client.sh ``` This burn factor applies to user-created transactions. diff --git a/fiber.toml b/fiber.toml index 5e68f20b72..f93ba8a704 100644 --- a/fiber.toml +++ b/fiber.toml @@ -33,7 +33,7 @@ peer_list_url = "https://downloads.skycoin.net/blockchain/peers.txt" # unlocked_time_internal = 60 * 60 * 24 * 365 # max_droplet_precision = 3 # max_user_transaction_size = 32 * 1024 -# coinhour_burn_factor = 2 +# user_burn_factor = 2 distribution_addresses = [ "R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ", "2EYM4WFHe4Dgz6kjAdUkM6Etep7ruz2ia6h", diff --git a/src/api/health.go b/src/api/health.go index c961839ab9..e5731d3c6d 100644 --- a/src/api/health.go +++ b/src/api/health.go @@ -81,7 +81,7 @@ func healthHandler(c muxConfig, csrfStore *CSRFStore, gateway Gatewayer) http.Ha GUIEnabled: c.enableGUI, JSON20RPCEnabled: c.enableJSON20RPC, WalletAPIEnabled: walletAPIEnabled, - BurnFactor: params.CoinHourBurnFactor, + BurnFactor: params.UserBurnFactor, }) } } diff --git a/src/api/integration/integration_test.go b/src/api/integration/integration_test.go index d3eb4dbec1..0fd819501a 100644 --- a/src/api/integration/integration_test.go +++ b/src/api/integration/integration_test.go @@ -3863,7 +3863,7 @@ func TestLiveWalletCreateTransactionSpecific(t *testing.T) { w, totalCoins, totalHours, password := prepareAndCheckWallet(t, c, 2e6, 20) - remainingHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) + remainingHours := fee.RemainingHours(totalHours, params.UserBurnFactor) require.True(t, remainingHours > 1) addresses := make([]string, len(w.Entries)) @@ -4619,7 +4619,7 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { return } - remainingHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) + remainingHours := fee.RemainingHours(totalHours, params.UserBurnFactor) require.True(t, remainingHours > 1) assertTxnOutputCount := func(t *testing.T, changeAddress string, nOutputs int, result *api.CreateTransactionResponse) { @@ -4650,7 +4650,7 @@ func TestLiveWalletCreateTransactionRandom(t *testing.T) { tLog(t, "totalCoins", totalCoins) tLog(t, "totalHours", totalHours) - spendableHours := fee.RemainingHours(totalHours, params.CoinHourBurnFactor) + spendableHours := fee.RemainingHours(totalHours, params.UserBurnFactor) tLog(t, "spendableHours", spendableHours) coins := rand.Intn(int(totalCoins)) + 1 diff --git a/src/cli/create_rawtx.go b/src/cli/create_rawtx.go index 029e98e230..e742b168cb 100644 --- a/src/cli/create_rawtx.go +++ b/src/cli/create_rawtx.go @@ -540,7 +540,7 @@ func CreateRawTx(c GetOutputser, wlt *wallet.Wallet, inAddrs []string, chgAddr s return nil, err } - if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := visor.VerifySingleTxnSoftConstraints(*txn, head.Time, inUxsFiltered, params.MaxUserTransactionSize, params.UserBurnFactor); err != nil { return nil, err } if err := visor.VerifySingleTxnHardConstraints(*txn, head, inUxsFiltered); err != nil { @@ -667,7 +667,7 @@ func makeChangeOut(outs []wallet.UxBalance, chgAddr string, toAddrs []SendAmount nAddrs := uint64(len(toAddrs)) changeHours, addrHours, totalOutHours := wallet.DistributeSpendHours(totalInHours, nAddrs, haveChange) - if err := fee.VerifyTransactionFeeForHours(totalOutHours, totalInHours-totalOutHours, params.CoinHourBurnFactor); err != nil { + if err := fee.VerifyTransactionFeeForHours(totalOutHours, totalInHours-totalOutHours, params.UserBurnFactor); err != nil { return nil, err } diff --git a/src/daemon/daemon.go b/src/daemon/daemon.go index 9e7ef0ce7e..2ef8f97c93 100644 --- a/src/daemon/daemon.go +++ b/src/daemon/daemon.go @@ -241,8 +241,8 @@ type daemoner interface { getSignedBlocksSince(seq, count uint64) ([]coin.SignedBlock, error) headBkSeq() (uint64, bool, error) executeSignedBlock(b coin.SignedBlock) error - filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) - getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) + filterKnownUnconfirmed(txns []cipher.SHA256) ([]cipher.SHA256, error) + getKnownUnconfirmed(txns []cipher.SHA256) (coin.Transactions, error) requestBlocksFromAddr(addr string) error announceAllTxns() error daemonConfig() DaemonConfig @@ -1345,14 +1345,14 @@ func (dm *Daemon) executeSignedBlock(b coin.SignedBlock) error { return dm.visor.ExecuteSignedBlock(b) } -// filterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (dm *Daemon) filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { - return dm.visor.FilterUnconfirmedKnown(txns) +// filterKnownUnconfirmed returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) filterKnownUnconfirmed(txns []cipher.SHA256) ([]cipher.SHA256, error) { + return dm.visor.FilterKnownUnconfirmed(txns) } -// getUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (dm *Daemon) getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { - return dm.visor.GetUnconfirmedKnown(txns) +// getKnownUnconfirmed returns unconfirmed txn hashes with known ones removed +func (dm *Daemon) getKnownUnconfirmed(txns []cipher.SHA256) (coin.Transactions, error) { + return dm.visor.GetKnownUnconfirmed(txns) } // injectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not diff --git a/src/daemon/gateway.go b/src/daemon/gateway.go index 399eeed8d7..1cb939a255 100644 --- a/src/daemon/gateway.go +++ b/src/daemon/gateway.go @@ -493,8 +493,8 @@ func (gw *Gateway) InjectBroadcastTransaction(txn coin.Transaction) error { var err error gw.strand("InjectBroadcastTransaction", func() { err = gw.v.WithUpdateTx("gateway.InjectBroadcastTransaction", func(tx *dbutil.Tx) error { - if _, err := gw.v.InjectTransactionUserTx(tx, txn); err != nil { - logger.WithError(err).Error("InjectUserTransaction failed") + if _, err := gw.v.InjectUserTransactionTx(tx, txn); err != nil { + logger.WithError(err).Error("InjectUserTransactionTx failed") return err } diff --git a/src/daemon/messages.go b/src/daemon/messages.go index 296ea7b698..bead69d2eb 100644 --- a/src/daemon/messages.go +++ b/src/daemon/messages.go @@ -742,9 +742,9 @@ func (atm *AnnounceTxnsMessage) process(d daemoner) { "gnetID": atm.c.ConnID, } - unknown, err := d.filterUnconfirmedKnown(atm.Transactions) + unknown, err := d.filterKnownUnconfirmed(atm.Transactions) if err != nil { - logger.WithError(err).Error("AnnounceTxnsMessage d.filterUnconfirmedKnown failed") + logger.WithError(err).Error("AnnounceTxnsMessage d.filterKnownUnconfirmed failed") return } @@ -789,9 +789,9 @@ func (gtm *GetTxnsMessage) process(d daemoner) { } // Locate all txns from the unconfirmed pool - known, err := d.getUnconfirmedKnown(gtm.Transactions) + known, err := d.getKnownUnconfirmed(gtm.Transactions) if err != nil { - logger.WithError(err).Error("GetTxnsMessage d.getUnconfirmedKnown failed") + logger.WithError(err).Error("GetTxnsMessage d.getKnownUnconfirmed failed") return } if len(known) == 0 { diff --git a/src/daemon/mock_daemoner_test.go b/src/daemon/mock_daemoner_test.go index 2392d454c5..2047c65e7d 100644 --- a/src/daemon/mock_daemoner_test.go +++ b/src/daemon/mock_daemoner_test.go @@ -129,8 +129,8 @@ func (_m *mockDaemoner) executeSignedBlock(b coin.SignedBlock) error { return r0 } -// filterUnconfirmedKnown provides a mock function with given fields: txns -func (_m *mockDaemoner) filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// filterKnownUnconfirmed provides a mock function with given fields: txns +func (_m *mockDaemoner) filterKnownUnconfirmed(txns []cipher.SHA256) ([]cipher.SHA256, error) { ret := _m.Called(txns) var r0 []cipher.SHA256 @@ -152,22 +152,22 @@ func (_m *mockDaemoner) filterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.S return r0, r1 } -// getSignedBlocksSince provides a mock function with given fields: seq, count -func (_m *mockDaemoner) getSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { - ret := _m.Called(seq, count) +// getKnownUnconfirmed provides a mock function with given fields: txns +func (_m *mockDaemoner) getKnownUnconfirmed(txns []cipher.SHA256) (coin.Transactions, error) { + ret := _m.Called(txns) - var r0 []coin.SignedBlock - if rf, ok := ret.Get(0).(func(uint64, uint64) []coin.SignedBlock); ok { - r0 = rf(seq, count) + var r0 coin.Transactions + if rf, ok := ret.Get(0).(func([]cipher.SHA256) coin.Transactions); ok { + r0 = rf(txns) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]coin.SignedBlock) + r0 = ret.Get(0).(coin.Transactions) } } var r1 error - if rf, ok := ret.Get(1).(func(uint64, uint64) error); ok { - r1 = rf(seq, count) + if rf, ok := ret.Get(1).(func([]cipher.SHA256) error); ok { + r1 = rf(txns) } else { r1 = ret.Error(1) } @@ -175,22 +175,22 @@ func (_m *mockDaemoner) getSignedBlocksSince(seq uint64, count uint64) ([]coin.S return r0, r1 } -// getUnconfirmedKnown provides a mock function with given fields: txns -func (_m *mockDaemoner) getUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { - ret := _m.Called(txns) +// getSignedBlocksSince provides a mock function with given fields: seq, count +func (_m *mockDaemoner) getSignedBlocksSince(seq uint64, count uint64) ([]coin.SignedBlock, error) { + ret := _m.Called(seq, count) - var r0 coin.Transactions - if rf, ok := ret.Get(0).(func([]cipher.SHA256) coin.Transactions); ok { - r0 = rf(txns) + var r0 []coin.SignedBlock + if rf, ok := ret.Get(0).(func(uint64, uint64) []coin.SignedBlock); ok { + r0 = rf(seq, count) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(coin.Transactions) + r0 = ret.Get(0).([]coin.SignedBlock) } } var r1 error - if rf, ok := ret.Get(1).(func([]cipher.SHA256) error); ok { - r1 = rf(txns) + if rf, ok := ret.Get(1).(func(uint64, uint64) error); ok { + r1 = rf(seq, count) } else { r1 = ret.Error(1) } diff --git a/src/params/init.go b/src/params/init.go index 10e14be924..39954f3d68 100644 --- a/src/params/init.go +++ b/src/params/init.go @@ -17,8 +17,8 @@ func init() { } func sanityCheck() { - if CoinHourBurnFactor <= 1 { - panic("CoinHourBurnFactor must be > 1") + if UserBurnFactor <= 1 { + panic("UserBurnFactor must be > 1") } if MaxUserTransactionSize <= 0 { @@ -43,21 +43,21 @@ func sanityCheck() { } func loadCoinHourBurnFactor() { - xs := os.Getenv("COINHOUR_BURN_FACTOR") + xs := os.Getenv("USER_BURN_FACTOR") if xs == "" { return } x, err := strconv.ParseUint(xs, 10, 64) if err != nil { - panic(fmt.Sprintf("Invalid COINHOUR_BURN_FACTOR %q: %v", xs, err)) + panic(fmt.Sprintf("Invalid USER_BURN_FACTOR %q: %v", xs, err)) } if x <= 1 { - panic("COINHOUR_BURN_FACTOR must be > 1") + panic("USER_BURN_FACTOR must be > 1") } - CoinHourBurnFactor = x + UserBurnFactor = x } func loadMaxUserTransactionSize() { diff --git a/src/params/params.go b/src/params/params.go index 28dada2fb3..92dbd2646a 100644 --- a/src/params/params.go +++ b/src/params/params.go @@ -23,9 +23,9 @@ const ( ) var ( - // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var), + // UserBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `USER_BURN_FACTOR` env var), // used when creating a transaction - CoinHourBurnFactor uint64 = 2 + UserBurnFactor uint64 = 2 // MaxUserTransactionSize is the maximum size of a user-created transaction MaxUserTransactionSize = 32768 // in bytes diff --git a/src/skycoin/config.go b/src/skycoin/config.go index 0044f404a8..7a9523909d 100644 --- a/src/skycoin/config.go +++ b/src/skycoin/config.go @@ -270,9 +270,9 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { // Blockchain/transaction validation MaxUnconfirmedTransactionSize: params.MaxUserTransactionSize, - MaxBlockSize: 32 * 1024, - UnconfirmedBurnFactor: params.CoinHourBurnFactor, - CreateBlockBurnFactor: params.CoinHourBurnFactor, + MaxBlockSize: params.MaxUserTransactionSize, + UnconfirmedBurnFactor: params.UserBurnFactor, + CreateBlockBurnFactor: params.UserBurnFactor, // Wallets WalletDirectory: "", @@ -284,9 +284,7 @@ func NewNodeConfig(mode string, node NodeParameters) NodeConfig { HTTPWriteTimeout: time.Second * 60, HTTPIdleTimeout: time.Second * 120, - // Centralized network configuration RunBlockPublisher: false, - /* Developer options */ // Enable cpu profiling ProfileCPU: false, @@ -306,7 +304,8 @@ func (c *Config) postProcess() error { if help { flag.Usage() fmt.Println("Additional environment variables:") - fmt.Println("* COINHOUR_BURN_FACTOR - Set the coin hour burn factor required for transactions. Must be > 1.") + fmt.Println("* USER_BURN_FACTOR - Set the coin hour burn factor required for user-created transactions. Must be > 1.") + fmt.Println("* MAX_USER_TXN_SIZE - Set the maximum transaction size (in bytes) allowed for user-created transactions. Must be > 183.") os.Exit(0) } @@ -414,27 +413,29 @@ func (c *Config) postProcess() error { if c.Node.MaxBlockSize <= 0 { return errors.New("-block-size must be > 0") } + if c.Node.MaxBlockSize < params.MaxUserTransactionSize { + return fmt.Errorf("-max-block-size must be >= params.MaxUserTransactionSize (%d)", params.MaxUserTransactionSize) + } if c.Node.MaxUnconfirmedTransactionSize <= 0 { return errors.New("-unconfirmed-txn-size must be > 0") } + if c.Node.MaxUnconfirmedTransactionSize < params.MaxUserTransactionSize { + return fmt.Errorf("-unconfirmed-txn-size must be >= params.MaxUserTransactionSize (%d)", params.MaxUserTransactionSize) + } if c.Node.UnconfirmedBurnFactor < 2 { return errors.New("-unconfirmed-burn-factor must be >= 2") } - if c.Node.UnconfirmedBurnFactor < params.CoinHourBurnFactor { - return fmt.Errorf("-unconfirmed-burn-factor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) - } - - if c.Node.MaxBlockSize < params.MaxUserTransactionSize { - return fmt.Errorf("-max-block-size must be >= params.MaxUserTransactionSize (%d)", params.MaxUserTransactionSize) + if c.Node.UnconfirmedBurnFactor < params.UserBurnFactor { + return fmt.Errorf("-unconfirmed-burn-factor must be >= params.UserBurnFactor (%d)", params.UserBurnFactor) } if c.Node.CreateBlockBurnFactor < 2 { return errors.New("-create-block-burn-factor must be >= 2") } - if c.Node.CreateBlockBurnFactor < params.CoinHourBurnFactor { - return fmt.Errorf("-create-block-burn-factor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + if c.Node.CreateBlockBurnFactor < params.UserBurnFactor { + return fmt.Errorf("-create-block-burn-factor must be >= params.UserBurnFactor (%d)", params.UserBurnFactor) } return nil @@ -575,8 +576,8 @@ func (c *NodeConfig) RegisterFlags() { flag.IntVar(&c.MaxUnconfirmedTransactionSize, "unconfirmed-txn-size", c.MaxUnconfirmedTransactionSize, "maximum size of an unconfirmed transaction") flag.IntVar(&c.MaxBlockSize, "block-size", c.MaxBlockSize, "maximum size of a block") - flag.Uint64Var(&c.UnconfirmedBurnFactor, "burn-factor-unconfirmed", c.UnconfirmedBurnFactor, "coinhour burn factor to apply when verifying unconfirmed transactions") - flag.Uint64Var(&c.CreateBlockBurnFactor, "burn-factor-create-block", c.CreateBlockBurnFactor, "coinhour burn factor to apply to transactions when creating blocks") + flag.Uint64Var(&c.UnconfirmedBurnFactor, "burn-factor-unconfirmed", c.UnconfirmedBurnFactor, "coinhour burn factor applied to unconfirmed transactions") + flag.Uint64Var(&c.CreateBlockBurnFactor, "burn-factor-create-block", c.CreateBlockBurnFactor, "coinhour burn factor applied when creating blocks") flag.BoolVar(&c.RunBlockPublisher, "block-publisher", c.RunBlockPublisher, "run the daemon as a block publisher") flag.StringVar(&c.BlockchainPubkeyStr, "blockchain-public-key", c.BlockchainPubkeyStr, "public key of the blockchain") diff --git a/src/skycoin/parameters.go b/src/skycoin/parameters.go index 75215d485d..4d65f56e75 100644 --- a/src/skycoin/parameters.go +++ b/src/skycoin/parameters.go @@ -13,7 +13,8 @@ type Parameters struct { Params ParamsParameters `mapstructure:"params"` } -// NodeParameters records the node's configurable parameters +// NodeParameters configures the default CLI options for the skycoin node. +// These parameters are loaded via cmd/skycoin/skycoin.go into src/skycoin/skycoin.go. type NodeParameters struct { // Port is the default port that the wire protocol communicates over Port int `mapstructure:"port"` @@ -50,7 +51,9 @@ type NodeParameters struct { DataDirectory string } -// ParamsParameters are the parameters used to generate config/blockchain.go +// ParamsParameters are the parameters used to generate params/params.go. +// These parameters are exposed in an importable package `params` because they +// may need to be imported by libraries that would not know the node's configured CLI options. type ParamsParameters struct { // MaxCoinSupply is the maximum supply of coins MaxCoinSupply uint64 `mapstructure:"max_coin_supply"` @@ -72,8 +75,8 @@ type ParamsParameters struct { // DistributionAddresses are addresses that received coins from the genesis address in the first block, // used to calculate current and max supply and do distribution timelocking DistributionAddresses []string `mapstructure:"distribution_addresses"` - // CoinHourBurnFactor inverse fraction of coinhours that must be burned, this value is used when creating transactions - CoinHourBurnFactor uint64 `mapstructure:"coinhour_burn_factor"` + // UserBurnFactor inverse fraction of coinhours that must be burned, this value is used when creating transactions + UserBurnFactor uint64 `mapstructure:"user_burn_factor"` } // NewParameters loads blockchain config parameters from a config file @@ -134,6 +137,6 @@ func setDefaults() { viper.SetDefault("params.unlock_address_rate", 5) viper.SetDefault("params.unlock_time_interval", 60*60*24*365) viper.SetDefault("params.max_droplet_precision", 3) - viper.SetDefault("params.coinhour_burn_factor", 2) + viper.SetDefault("params.user_burn_factor", 2) viper.SetDefault("params.max_user_transaction_size", 32*1024) } diff --git a/src/skycoin/parameters_test.go b/src/skycoin/parameters_test.go index 6ed0c096ea..66280d2e2d 100644 --- a/src/skycoin/parameters_test.go +++ b/src/skycoin/parameters_test.go @@ -42,7 +42,7 @@ func TestNewParameters(t *testing.T) { UnlockAddressRate: 5, UnlockTimeInterval: 60 * 60 * 24 * 365, MaxDropletPrecision: 3, - CoinHourBurnFactor: 3, + UserBurnFactor: 3, MaxUserTransactionSize: 999, }, }, coinConfig) diff --git a/src/skycoin/skycoin.go b/src/skycoin/skycoin.go index 4f543d86fb..daccb604f5 100644 --- a/src/skycoin/skycoin.go +++ b/src/skycoin/skycoin.go @@ -201,7 +201,7 @@ func (c *Coin) Run() error { } } - c.logger.Infof("Coinhour burn factor for creating transactions is %d", params.CoinHourBurnFactor) + c.logger.Infof("Coinhour burn factor for creating transactions is %d", params.UserBurnFactor) c.logger.Infof("Max user transaction size is %d", params.MaxUserTransactionSize) d, err = daemon.NewDaemon(dconf, db) diff --git a/src/skycoin/testdata/test.fiber.toml b/src/skycoin/testdata/test.fiber.toml index 48f0f2aa2c..2c4396e8ed 100644 --- a/src/skycoin/testdata/test.fiber.toml +++ b/src/skycoin/testdata/test.fiber.toml @@ -24,5 +24,5 @@ max_block_size = 1111 max_unconfirmed_transaction_size = 777 [params] -coinhour_burn_factor = 3 +user_burn_factor = 3 max_user_transaction_size = 999 diff --git a/src/util/fee/fee.go b/src/util/fee/fee.go index 77aad98b61..798dd4d604 100644 --- a/src/util/fee/fee.go +++ b/src/util/fee/fee.go @@ -59,7 +59,7 @@ func VerifyTransactionFeeForHours(hours, fee, burnFactor uint64) error { } // RequiredFee returns the coinhours fee required for an amount of hours -// The required fee is calculated as hours/burnFact, rounded up. +// The required fee is calculated as hours/burnFactor, rounded up. func RequiredFee(hours, burnFactor uint64) uint64 { feeHours := hours / burnFactor if hours%burnFactor != 0 { diff --git a/src/util/fee/fee_test.go b/src/util/fee/fee_test.go index f3f12196e5..010b994900 100644 --- a/src/util/fee/fee_test.go +++ b/src/util/fee/fee_test.go @@ -164,7 +164,7 @@ func TestVerifyTransactionFee(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == params.CoinHourBurnFactor { + if tcc.burnFactor == params.UserBurnFactor { tested = true } @@ -183,7 +183,7 @@ func TestVerifyTransactionFee(t *testing.T) { } } - require.True(t, tested, "configured params.CoinHourBurnFactor=%d has not been tested", params.CoinHourBurnFactor) + require.True(t, tested, "configured params.UserBurnFactor=%d has not been tested", params.UserBurnFactor) } type requiredFeeTestCase struct { @@ -257,7 +257,7 @@ func TestRequiredFee(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == params.CoinHourBurnFactor { + if tcc.burnFactor == params.UserBurnFactor { tested = true } @@ -273,7 +273,7 @@ func TestRequiredFee(t *testing.T) { } } - require.True(t, tested, "configured params.CoinHourBurnFactor=%d has not been tested", params.CoinHourBurnFactor) + require.True(t, tested, "configured params.UserBurnFactor=%d has not been tested", params.UserBurnFactor) } func TestTransactionFee(t *testing.T) { diff --git a/src/visor/blockchain_verify_test.go b/src/visor/blockchain_verify_test.go index 461b67ec10..7e631b8a5e 100644 --- a/src/visor/blockchain_verify_test.go +++ b/src/visor/blockchain_verify_test.go @@ -347,11 +347,11 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // create normal spending txn uxs := coin.CreateUnspents(gb.Head, gb.Body.Transactions[0]) txn := makeSpendTx(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins) - err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.UserBurnFactor) require.NoError(t, err) // Transaction size exceeds maxSize - err = verifySingleTxnSoftHardConstraints(txn, txn.Size()-1, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, txn.Size()-1, params.UserBurnFactor) requireSoftViolation(t, "Transaction size bigger than max block size", err) // Invalid transaction fee @@ -361,12 +361,12 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { hours += ux.Body.Hours } txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 0) - err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.UserBurnFactor) requireSoftViolation(t, "Transaction has zero coinhour fee", err) // Invalid transaction fee, part 2 txn = makeSpendTxWithHoursBurned(t, uxs, []cipher.SecKey{genSecret}, toAddr, coins, 1) - err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.UserBurnFactor) requireSoftViolation(t, "Transaction coinhour fee minimum not met", err) // Transaction locking is tested by TestVerifyTransactionIsLocked @@ -374,7 +374,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { // Test invalid header hash originInnerHash := txn.InnerHash txn.InnerHash = cipher.SHA256{} - err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.UserBurnFactor) requireHardViolation(t, "InnerHash does not match computed hash", err) // Set back the originInnerHash @@ -401,7 +401,7 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { require.NoError(t, err) // A UxOut does not exist, it was already spent - err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(txn, params.MaxUserTransactionSize, params.UserBurnFactor) expectedErr := NewErrTxnViolatesHardConstraint(blockdb.NewErrUnspentNotExist(txn.In[0].Hex())) require.Equal(t, expectedErr, err) @@ -410,21 +410,21 @@ func TestVerifyTransactionSoftHardConstraints(t *testing.T) { _, key := cipher.GenerateKeyPair() toAddr2 := testutil.MakeAddress() tx2 := makeSpendTx(t, uxs, []cipher.SecKey{key, key}, toAddr2, 5e6) - err = verifySingleTxnSoftHardConstraints(tx2, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(tx2, params.MaxUserTransactionSize, params.UserBurnFactor) requireHardViolation(t, "Signature not valid for output being spent", err) // Create lost coin transaction uxs2 := coin.CreateUnspents(b.Head, txn) toAddr3 := testutil.MakeAddress() lostCoinTx := makeLostCoinTx(coin.UxArray{uxs2[1]}, []cipher.SecKey{genSecret}, toAddr3, 10e5) - err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(lostCoinTx, params.MaxUserTransactionSize, params.UserBurnFactor) requireHardViolation(t, "Transactions may not destroy coins", err) // Create transaction with duplicate UxOuts uxs = coin.CreateUnspents(b.Head, txn) toAddr4 := testutil.MakeAddress() dupUxOutTx := makeDuplicateUxOutTx(coin.UxArray{uxs[0]}, []cipher.SecKey{genSecret}, toAddr4, 1e6) - err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = verifySingleTxnSoftHardConstraints(dupUxOutTx, params.MaxUserTransactionSize, params.UserBurnFactor) requireHardViolation(t, "Duplicate output in transaction", err) } @@ -475,7 +475,7 @@ func TestVerifyTxnFeeCoinHoursAdditionFails(t *testing.T) { testutil.RequireError(t, coinHoursErr, "UxOut.CoinHours addition of earned coin hours overflow") // VerifySingleTxnSoftConstraints should fail on this, when trying to calculate the TransactionFee - err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = VerifySingleTxnSoftConstraints(txn, head.Time()+1e6, uxIn, params.MaxUserTransactionSize, params.UserBurnFactor) testutil.RequireError(t, err, NewErrTxnViolatesSoftConstraint(coinHoursErr).Error()) // VerifySingleTxnHardConstraints should fail on this, when performing the extra check of @@ -553,7 +553,7 @@ func testVerifyTransactionAddressLocking(t *testing.T, toAddr string, expectedEr }) require.NoError(t, err) - err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + err = VerifySingleTxnSoftConstraints(txn, head.Time(), uxIn, params.MaxUserTransactionSize, params.UserBurnFactor) if expectedErr == nil { require.NoError(t, err) } else { diff --git a/src/visor/visor.go b/src/visor/visor.go index 0d00cf959b..60c09818ee 100644 --- a/src/visor/visor.go +++ b/src/visor/visor.go @@ -91,9 +91,9 @@ func NewConfig() Config { BlockchainSeckey: cipher.SecKey{}, MaxUnconfirmedTransactionSize: params.MaxUserTransactionSize, - MaxBlockSize: 32 * 1024, - UnconfirmedBurnFactor: params.CoinHourBurnFactor, - CreateBlockBurnFactor: params.CoinHourBurnFactor, + MaxBlockSize: params.MaxUserTransactionSize, + UnconfirmedBurnFactor: params.UserBurnFactor, + CreateBlockBurnFactor: params.UserBurnFactor, GenesisAddress: cipher.Address{}, GenesisSignature: cipher.Sig{}, @@ -112,12 +112,12 @@ func (c Config) Verify() error { } } - if c.UnconfirmedBurnFactor < params.CoinHourBurnFactor { - return fmt.Errorf("UnconfirmedBurnFactor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + if c.UnconfirmedBurnFactor < params.UserBurnFactor { + return fmt.Errorf("UnconfirmedBurnFactor must be >= params.UserBurnFactor (%d)", params.UserBurnFactor) } - if c.CreateBlockBurnFactor < params.CoinHourBurnFactor { - return fmt.Errorf("CreateBlockBurnFactor must be >= params.CoinHourBurnFactor (%d)", params.CoinHourBurnFactor) + if c.CreateBlockBurnFactor < params.UserBurnFactor { + return fmt.Errorf("CreateBlockBurnFactor must be >= params.UserBurnFactor (%d)", params.UserBurnFactor) } if c.MaxBlockSize <= 0 { @@ -923,7 +923,7 @@ func (vs *Visor) InjectUserTransaction(txn coin.Transaction) (bool, error) { if err := vs.DB.Update("InjectUserTransaction", func(tx *dbutil.Tx) error { var err error - known, err = vs.InjectTransactionUserTx(tx, txn) + known, err = vs.InjectUserTransactionTx(tx, txn) return err }); err != nil { return false, err @@ -932,21 +932,21 @@ func (vs *Visor) InjectUserTransaction(txn coin.Transaction) (bool, error) { return known, nil } -// InjectTransactionUserTx records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not +// InjectUserTransactionTx records a coin.Transaction to the UnconfirmedTransactionPool if the txn is not // already in the blockchain. // The bool return value is whether or not the transaction was already in the pool. // If the transaction violates hard or soft constraints, it is rejected, and error will not be nil. // This method is only exported for use by the daemon gateway's InjectBroadcastTransaction method. -func (vs *Visor) InjectTransactionUserTx(tx *dbutil.Tx, txn coin.Transaction) (bool, error) { +func (vs *Visor) InjectUserTransactionTx(tx *dbutil.Tx, txn coin.Transaction) (bool, error) { if err := VerifySingleTxnUserConstraints(txn); err != nil { return false, err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, txn, params.MaxUserTransactionSize, params.UserBurnFactor); err != nil { return false, err } - known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor) + known, softErr, err := vs.Unconfirmed.InjectTransaction(tx, vs.Blockchain, txn, params.MaxUserTransactionSize, params.UserBurnFactor) if softErr != nil { logger.WithError(softErr).Warning("InjectUserTransaction vs.Unconfirmed.InjectTransaction returned a softErr unexpectedly") } @@ -1903,11 +1903,11 @@ func (vs *Visor) GetUnconfirmedTxn(hash cipher.SHA256) (*UnconfirmedTransaction, return txn, nil } -// FilterUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (vs *Visor) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, error) { +// FilterKnownUnconfirmed returns unconfirmed txn hashes with known ones removed +func (vs *Visor) FilterKnownUnconfirmed(txns []cipher.SHA256) ([]cipher.SHA256, error) { var hashes []cipher.SHA256 - if err := vs.DB.View("FilterUnconfirmedKnown", func(tx *dbutil.Tx) error { + if err := vs.DB.View("FilterKnownUnconfirmed", func(tx *dbutil.Tx) error { var err error hashes, err = vs.Unconfirmed.FilterKnown(tx, txns) return err @@ -1918,11 +1918,11 @@ func (vs *Visor) FilterUnconfirmedKnown(txns []cipher.SHA256) ([]cipher.SHA256, return hashes, nil } -// GetUnconfirmedKnown returns unconfirmed txn hashes with known ones removed -func (vs *Visor) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error) { +// GetKnownUnconfirmed returns unconfirmed txn hashes with known ones removed +func (vs *Visor) GetKnownUnconfirmed(txns []cipher.SHA256) (coin.Transactions, error) { var hashes coin.Transactions - if err := vs.DB.View("GetUnconfirmedKnown", func(tx *dbutil.Tx) error { + if err := vs.DB.View("GetKnownUnconfirmed", func(tx *dbutil.Tx) error { var err error hashes, err = vs.Unconfirmed.GetKnown(tx, txns) return err @@ -2209,7 +2209,7 @@ func (vs *Visor) VerifyTxnVerbose(txn *coin.Transaction) ([]wallet.UxBalance, bo return err } - if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := VerifySingleTxnSoftConstraints(*txn, feeCalcTime, uxa, params.MaxUserTransactionSize, params.UserBurnFactor); err != nil { return err } diff --git a/src/visor/visor_test.go b/src/visor/visor_test.go index f97897eef2..40f10669de 100644 --- a/src/visor/visor_test.go +++ b/src/visor/visor_test.go @@ -330,7 +330,7 @@ func TestVisorCreateBlock(t *testing.T) { var softErr *ErrTxnViolatesSoftConstraint err = db.Update("", func(tx *dbutil.Tx) error { var err error - known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, params.CoinHourBurnFactor) + known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, v.Config.CreateBlockBurnFactor) return err }) require.NoError(t, err) @@ -414,7 +414,7 @@ func TestVisorCreateBlock(t *testing.T) { var softErr *ErrTxnViolatesSoftConstraint err = db.Update("", func(tx *dbutil.Tx) error { var err error - known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, params.CoinHourBurnFactor) + known, softErr, err = unconfirmed.InjectTransaction(tx, bc, txn, v.Config.MaxBlockSize, v.Config.CreateBlockBurnFactor) return err }) require.False(t, known) diff --git a/src/visor/visor_wallet.go b/src/visor/visor_wallet.go index a1fc6f1bfb..62ae0811a2 100644 --- a/src/visor/visor_wallet.go +++ b/src/visor/visor_wallet.go @@ -145,7 +145,7 @@ func (vs *Visor) CreateTransaction(p wallet.CreateTransactionParams) (*coin.Tran return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.UserBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } @@ -202,7 +202,7 @@ func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coin return err } - if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.CoinHourBurnFactor); err != nil { + if err := vs.Blockchain.VerifySingleTxnSoftHardConstraints(tx, *txn, params.MaxUserTransactionSize, params.UserBurnFactor); err != nil { logger.WithError(err).Error("Created transaction violates transaction constraints") return err } diff --git a/src/wallet/wallet.go b/src/wallet/wallet.go index a9289bed8c..4d33c3651c 100644 --- a/src/wallet/wallet.go +++ b/src/wallet/wallet.go @@ -1197,8 +1197,8 @@ func (w *Wallet) CreateAndSignTransaction(auxs coin.AddressUxOuts, headTime, coi haveChange := changeCoins > 0 changeHours, addrHours, outputHours := DistributeSpendHours(spending.Hours, 1, haveChange) - logger.Infof("wallet.CreateAndSignTransaction: spending.Hours=%d, fee.VerifyTransactionFeeForHours(%d, %d, %d)", spending.Hours, outputHours, spending.Hours-outputHours, params.CoinHourBurnFactor) - if err := fee.VerifyTransactionFeeForHours(outputHours, spending.Hours-outputHours, params.CoinHourBurnFactor); err != nil { + logger.Infof("wallet.CreateAndSignTransaction: spending.Hours=%d, fee.VerifyTransactionFeeForHours(%d, %d, %d)", spending.Hours, outputHours, spending.Hours-outputHours, params.UserBurnFactor) + if err := fee.VerifyTransactionFeeForHours(outputHours, spending.Hours-outputHours, params.UserBurnFactor); err != nil { logger.Warningf("wallet.CreateAndSignTransaction: fee.VerifyTransactionFeeForHours failed: %v", err) return nil, err } @@ -1318,7 +1318,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(p CreateTransactionParams, aux txn.PushInput(spend.Hash) } - feeHours := fee.RequiredFee(totalInputHours, params.CoinHourBurnFactor) + feeHours := fee.RequiredFee(totalInputHours, params.UserBurnFactor) if feeHours == 0 { return nil, nil, fee.ErrTxnNoFee } @@ -1409,7 +1409,7 @@ func (w *Wallet) CreateAndSignTransactionAdvanced(p CreateTransactionParams, aux } // Calculate the new fee for this new amount of hours - newFee := fee.RequiredFee(newTotalHours, params.CoinHourBurnFactor) + newFee := fee.RequiredFee(newTotalHours, params.UserBurnFactor) if newFee < feeHours { err := errors.New("updated fee after adding extra input for change is unexpectedly less than it was initially") logger.WithError(err).Error() @@ -1599,7 +1599,7 @@ func verifyCreatedTransactionInvariants(p CreateTransactionParams, txn *coin.Tra return errors.New("Total input hours is less than the output hours") } - if inputHours-outputHours < fee.RequiredFee(inputHours, params.CoinHourBurnFactor) { + if inputHours-outputHours < fee.RequiredFee(inputHours, params.UserBurnFactor) { return errors.New("Transaction will not satisy required fee") } @@ -1618,7 +1618,7 @@ func verifyCreatedTransactionInvariants(p CreateTransactionParams, txn *coin.Tra // an array of length nAddrs with the hours to give to each destination address, // and a sum of these values. func DistributeSpendHours(inputHours, nAddrs uint64, haveChange bool) (uint64, []uint64, uint64) { - feeHours := fee.RequiredFee(inputHours, params.CoinHourBurnFactor) + feeHours := fee.RequiredFee(inputHours, params.UserBurnFactor) remainingHours := inputHours - feeHours var changeHours uint64 @@ -1972,7 +1972,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa have.Coins += firstNonzero.Coins have.Hours += firstNonzero.Hours - if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.UserBurnFactor) >= hours { return spending, nil } @@ -1990,7 +1990,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa } } - if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.UserBurnFactor) >= hours { return spending, nil } @@ -2003,7 +2003,7 @@ func ChooseSpends(uxa []UxBalance, coins, hours uint64, sortStrategy func([]UxBa have.Coins += ux.Coins have.Hours += ux.Hours - if have.Coins >= coins && fee.RemainingHours(have.Hours, params.CoinHourBurnFactor) >= hours { + if have.Coins >= coins && fee.RemainingHours(have.Hours, params.UserBurnFactor) >= hours { return spending, nil } } diff --git a/src/wallet/wallet_test.go b/src/wallet/wallet_test.go index c5efa2db9d..b01ea2e83f 100644 --- a/src/wallet/wallet_test.go +++ b/src/wallet/wallet_test.go @@ -1240,7 +1240,7 @@ var burnFactor10TestCases = []distributeSpendHoursTestCase{ } func TestWalletDistributeSpendHours(t *testing.T) { - originalBurnFactor := params.CoinHourBurnFactor + originalBurnFactor := params.UserBurnFactor cases := []struct { burnFactor uint64 @@ -1253,15 +1253,15 @@ func TestWalletDistributeSpendHours(t *testing.T) { tested := false for _, tcc := range cases { - if tcc.burnFactor == params.CoinHourBurnFactor { + if tcc.burnFactor == params.UserBurnFactor { tested = true } for _, tc := range tcc.cases { t.Run(tc.name, func(t *testing.T) { - params.CoinHourBurnFactor = tcc.burnFactor + params.UserBurnFactor = tcc.burnFactor defer func() { - params.CoinHourBurnFactor = originalBurnFactor + params.UserBurnFactor = originalBurnFactor }() changeHours, addrHours, totalHours := DistributeSpendHours(tc.inputHours, tc.nAddrs, tc.haveChange) @@ -1277,16 +1277,16 @@ func TestWalletDistributeSpendHours(t *testing.T) { require.Equal(t, outputHours, totalHours) if tc.inputHours != 0 { - err := fee.VerifyTransactionFeeForHours(outputHours, tc.inputHours-outputHours, params.CoinHourBurnFactor) + err := fee.VerifyTransactionFeeForHours(outputHours, tc.inputHours-outputHours, params.UserBurnFactor) require.NoError(t, err) } }) } t.Run(fmt.Sprintf("burn-factor-%d-range", tcc.burnFactor), func(t *testing.T) { - params.CoinHourBurnFactor = tcc.burnFactor + params.UserBurnFactor = tcc.burnFactor defer func() { - params.CoinHourBurnFactor = originalBurnFactor + params.UserBurnFactor = originalBurnFactor }() // Tests over range of values @@ -1304,13 +1304,13 @@ func TestWalletDistributeSpendHours(t *testing.T) { } if haveChange { - remainingHours := (inputHours - fee.RequiredFee(inputHours, params.CoinHourBurnFactor)) + remainingHours := (inputHours - fee.RequiredFee(inputHours, params.UserBurnFactor)) splitRemainingHours := remainingHours / 2 require.True(t, changeHours == splitRemainingHours || changeHours == splitRemainingHours+1) require.Equal(t, splitRemainingHours, sumAddrHours) } else { require.Equal(t, uint64(0), changeHours) - require.Equal(t, inputHours-fee.RequiredFee(inputHours, params.CoinHourBurnFactor), sumAddrHours) + require.Equal(t, inputHours-fee.RequiredFee(inputHours, params.UserBurnFactor), sumAddrHours) } outputHours := sumAddrHours + changeHours @@ -1318,7 +1318,7 @@ func TestWalletDistributeSpendHours(t *testing.T) { require.Equal(t, outputHours, totalHours) if inputHours != 0 { - err := fee.VerifyTransactionFeeForHours(outputHours, inputHours-outputHours, params.CoinHourBurnFactor) + err := fee.VerifyTransactionFeeForHours(outputHours, inputHours-outputHours, params.UserBurnFactor) require.NoError(t, err) } @@ -1333,7 +1333,7 @@ func TestWalletDistributeSpendHours(t *testing.T) { }) } - require.True(t, tested, "configured BurnFactor=%d has not been tested", params.CoinHourBurnFactor) + require.True(t, tested, "configured BurnFactor=%d has not been tested", params.UserBurnFactor) } func uxBalancesEqual(a, b []UxBalance) bool { diff --git a/template/params.template b/template/params.template index 1613d0362d..72116a34e6 100644 --- a/template/params.template +++ b/template/params.template @@ -23,9 +23,9 @@ const ( ) var ( - // CoinHourBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `COINHOUR_BURN_FACTOR` env var), + // UserBurnFactor inverse fraction of coinhours that must be burned (can be overridden with `USER_BURN_FACTOR` env var), // used when creating a transaction - CoinHourBurnFactor uint64 = {{.CoinHourBurnFactor}} + UserBurnFactor uint64 = {{.UserBurnFactor}} // MaxUserTransactionSize is the maximum size of a user-created transaction MaxUserTransactionSize = {{.MaxUserTransactionSize}} // in bytes From 2a05dd404714d268ae5d342dea48aa1cd5102620 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 5 Nov 2018 15:59:34 +0800 Subject: [PATCH 394/399] Panic if VerifyBlockTxn returns a SoftErr --- src/visor/blockchain.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/visor/blockchain.go b/src/visor/blockchain.go index 330c67b5c9..1568aa4ead 100644 --- a/src/visor/blockchain.go +++ b/src/visor/blockchain.go @@ -554,7 +554,9 @@ func (bc Blockchain) processTransactions(tx *dbutil.Tx, txs coin.Transactions) ( // signature indices and duplicate spends within itself if err := bc.VerifyBlockTxnConstraints(tx, txn); err != nil { switch err.(type) { - case ErrTxnViolatesHardConstraint, ErrTxnViolatesSoftConstraint: + case ErrTxnViolatesSoftConstraint: + logger.WithError(err).Panic("bc.VerifyBlockTxnConstraints should not return a ErrTxnViolatesSoftConstraint error") + case ErrTxnViolatesHardConstraint: if bc.cfg.Arbitrating { skip[i] = struct{}{} continue From df0a4e73a5a39dafacb7158bdd65dfb6df13d641 Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 5 Nov 2018 20:29:09 +0800 Subject: [PATCH 395/399] Increase VERSION_UPGRADE_TEST_WAIT_TIMEOUT for osx builds --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d0069cf5d4..301eead338 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: # Do not start osx build for PR if: type != pull_request osx_image: xcode8 - env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=30s + env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=60s before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update -qq; fi From a7d00df58cbbe098cf00deb2afcc1e4b6043570b Mon Sep 17 00:00:00 2001 From: gz-c Date: Mon, 5 Nov 2018 22:23:58 +0800 Subject: [PATCH 396/399] Again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 301eead338..ad42d0544e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ go: matrix: include: - os: linux - env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=30s + env: VERSION_UPGRADE_TEST_WAIT_TIMEOUT=45s - os: osx # Do not start osx build for PR if: type != pull_request From 60f5b53cb09c6663900d5e697e500484940cb29d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 5 Nov 2018 11:33:06 -0500 Subject: [PATCH 397/399] [lib] refs #1191 - Remove cipher.secp256k1-go and its subpkgs ... as requested in https://github.com/skycoin/skycoin/pull/1639#pullrequestreview-171344692 [====] Synthesis: Tested: 101 | Passing: 101 | Failing: 0 | Crashing: 0 --- lib/cgo/cipher.secp256k1-go.secp256_rand.go | 33 - .../cipher.secp256k1-go.secp256k1-go2.ec.go | 87 -- ...cipher.secp256k1-go.secp256k1-go2.field.go | 170 ---- .../cipher.secp256k1-go.secp256k1-go2.num.go | 73 -- .../cipher.secp256k1-go.secp256k1-go2.sig.go | 146 --- .../cipher.secp256k1-go.secp256k1-go2.xy.go | 108 -- .../cipher.secp256k1-go.secp256k1-go2.xyz.go | 128 --- lib/cgo/cipher.secp256k1-go.secp256k1.go | 154 --- lib/cgo/libsky_handle.go | 29 - .../tests/check_cipher.secp256k1.secp256.c | 956 ------------------ .../check_cipher.secp256k1.secp256k1-go2.ec.c | 151 --- ...eck_cipher.secp256k1.secp256k1-go2.field.c | 41 - ...check_cipher.secp256k1.secp256k1-go2.sig.c | 284 ------ ...check_cipher.secp256k1.secp256k1-go2.xyz.c | 106 -- lib/cgo/tests/cipher.testsuite.c | 5 + lib/cgo/tests/testutils/libsky_criterion.c | 10 - 16 files changed, 5 insertions(+), 2476 deletions(-) delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256_rand.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go delete mode 100644 lib/cgo/cipher.secp256k1-go.secp256k1.go delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256.c delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c delete mode 100644 lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c diff --git a/lib/cgo/cipher.secp256k1-go.secp256_rand.go b/lib/cgo/cipher.secp256k1-go.secp256_rand.go deleted file mode 100644 index d19688d422..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256_rand.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - secp256k1go "github.com/skycoin/skycoin/src/cipher/secp256k1-go" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1_SumSHA256 -func SKY_secp256k1_SumSHA256(_b []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - b := *(*[]byte)(unsafe.Pointer(&_b)) - __arg1 := secp256k1go.SumSHA256(b) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_RandByte -func SKY_secp256k1_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { - n := _n - __arg1 := secp256k1go.RandByte(n) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go deleted file mode 100644 index 16e2aad786..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.ec.go +++ /dev/null @@ -1,87 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_DecompressPoint -func SKY_secp256k1go_DecompressPoint(_X []byte, _off bool, _Y []byte) (____error_code uint32) { - X := *(*[]byte)(unsafe.Pointer(&_X)) - off := _off - Y := *(*[]byte)(unsafe.Pointer(&_Y)) - secp256k1go2.DecompressPoint(X, off, Y) - return -} - -//export SKY_secp256k1go_RecoverPublicKey -func SKY_secp256k1go_RecoverPublicKey(_sigByte []byte, _h []byte, _recid int, _arg3 *C.GoSlice_, _arg4 *int) (____error_code uint32) { - sigByte := *(*[]byte)(unsafe.Pointer(&_sigByte)) - h := *(*[]byte)(unsafe.Pointer(&_h)) - recid := _recid - __arg3, __arg4 := secp256k1go2.RecoverPublicKey(sigByte, h, recid) - copyToGoSlice(reflect.ValueOf(__arg3), _arg3) - *_arg4 = __arg4 - return -} - -//export SKY_secp256k1go_Multiply -func SKY_secp256k1go_Multiply(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - xy := *(*[]byte)(unsafe.Pointer(&_xy)) - k := *(*[]byte)(unsafe.Pointer(&_k)) - __arg1 := secp256k1go2.Multiply(xy, k) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1go_BaseMultiply -func SKY_secp256k1go_BaseMultiply(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - k := *(*[]byte)(unsafe.Pointer(&_k)) - __arg1 := secp256k1go2.BaseMultiply(k) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1go_BaseMultiplyAdd -func SKY_secp256k1go_BaseMultiplyAdd(_xy, _k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - xy := *(*[]byte)(unsafe.Pointer(&_xy)) - k := *(*[]byte)(unsafe.Pointer(&_k)) - __arg1 := secp256k1go2.BaseMultiplyAdd(xy, k) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1go_GeneratePublicKey -func SKY_secp256k1go_GeneratePublicKey(_k []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - k := *(*[]byte)(unsafe.Pointer(&_k)) - __arg1 := secp256k1go2.GeneratePublicKey(k) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1go_SeckeyIsValid -func SKY_secp256k1go_SeckeyIsValid(_seckey []byte, _arg1 *int) (____error_code uint32) { - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - __arg1 := secp256k1go2.SeckeyIsValid(seckey) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1go_PubkeyIsValid -func SKY_secp256k1go_PubkeyIsValid(_pubkey []byte, _arg1 *int) (____error_code uint32) { - pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) - __arg1 := secp256k1go2.PubkeyIsValid(pubkey) - *_arg1 = __arg1 - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go deleted file mode 100644 index 0edf788ace..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.field.go +++ /dev/null @@ -1,170 +0,0 @@ -package main - -import ( - "unsafe" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_Field_String -func SKY_secp256k1go_Field_String(_fd *C.secp256k1go__Field, _arg0 *C.GoString_) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - __arg0 := fd.String() - copyString(__arg0, _arg0) - return -} - -//export SKY_secp256k1go_Field_Print -func SKY_secp256k1go_Field_Print(_fd *C.secp256k1go__Field, _lab string) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - lab := _lab - fd.Print(lab) - return -} - -//export SKY_secp256k1go_Field_SetB32 -func SKY_secp256k1go_Field_SetB32(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - a := *(*[]byte)(unsafe.Pointer(&_a)) - fd.SetB32(a) - return -} - -//export SKY_secp256k1go_Field_SetBytes -func SKY_secp256k1go_Field_SetBytes(_fd *C.secp256k1go__Field, _a []byte) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - a := *(*[]byte)(unsafe.Pointer(&_a)) - fd.SetBytes(a) - return -} - -//export SKY_secp256k1go_Field_SetHex -func SKY_secp256k1go_Field_SetHex(_fd *C.secp256k1go__Field, _s string) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - s := _s - fd.SetHex(s) - return -} - -//export SKY_secp256k1go_Field_IsOdd -func SKY_secp256k1go_Field_IsOdd(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - __arg0 := fd.IsOdd() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_Field_IsZero -func SKY_secp256k1go_Field_IsZero(_fd *C.secp256k1go__Field, _arg0 *bool) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - __arg0 := fd.IsZero() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_Field_SetInt -func SKY_secp256k1go_Field_SetInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - a := _a - fd.SetInt(a) - return -} - -//export SKY_secp256k1go_Field_Normalize -func SKY_secp256k1go_Field_Normalize(_fd *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - fd.Normalize() - return -} - -//export SKY_secp256k1go_Field_GetB32 -func SKY_secp256k1go_Field_GetB32(_fd *C.secp256k1go__Field, _r []byte) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := *(*[]byte)(unsafe.Pointer(&_r)) - fd.GetB32(r) - return -} - -//export SKY_secp256k1go_Field_Equals -func SKY_secp256k1go_Field_Equals(_fd *C.secp256k1go__Field, _b *C.secp256k1go__Field, _arg1 *bool) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) - __arg1 := fd.Equals(b) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1go_Field_SetAdd -func SKY_secp256k1go_Field_SetAdd(_fd *C.secp256k1go__Field, _a *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - a := (*secp256k1go2.Field)(unsafe.Pointer(_a)) - fd.SetAdd(a) - return -} - -//export SKY_secp256k1go_Field_MulInt -func SKY_secp256k1go_Field_MulInt(_fd *C.secp256k1go__Field, _a uint32) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - a := _a - fd.MulInt(a) - return -} - -//export SKY_secp256k1go_Field_Negate -func SKY_secp256k1go_Field_Negate(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field, _m uint32) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - m := _m - fd.Negate(r, m) - return -} - -//export SKY_secp256k1go_Field_Inv -func SKY_secp256k1go_Field_Inv(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - fd.Inv(r) - return -} - -//export SKY_secp256k1go_Field_Sqrt -func SKY_secp256k1go_Field_Sqrt(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - fd.Sqrt(r) - return -} - -//export SKY_secp256k1go_Field_InvVar -func SKY_secp256k1go_Field_InvVar(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - fd.InvVar(r) - return -} - -//export SKY_secp256k1go_Field_Mul -func SKY_secp256k1go_Field_Mul(_fd *C.secp256k1go__Field, _r, _b *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - b := (*secp256k1go2.Field)(unsafe.Pointer(_b)) - fd.Mul(r, b) - return -} - -//export SKY_secp256k1go_Field_Sqr -func SKY_secp256k1go_Field_Sqr(_fd *C.secp256k1go__Field, _r *C.secp256k1go__Field) (____error_code uint32) { - fd := (*secp256k1go2.Field)(unsafe.Pointer(_fd)) - r := (*secp256k1go2.Field)(unsafe.Pointer(_r)) - fd.Sqr(r) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go deleted file mode 100644 index 843e39d28d..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.num.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "encoding/hex" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_Number_Create -func SKY_secp256k1go_Number_Create(handle *C.Number_Handle) (____error_code uint32) { - var num secp256k1go2.Number - *handle = registerNumberHandle(&num) - return -} - -//export SKY_secp256k1go_Number_Print -func SKY_secp256k1go_Number_Print(handle C.Number_Handle, _label string) (____error_code uint32) { - num, ok := lookupNumberHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - num.Print(_label) - return -} - -//export SKY_secp256k1go_Number_SetHex -func SKY_secp256k1go_Number_SetHex(handle C.Number_Handle, _s string) (____error_code uint32) { - num, ok := lookupNumberHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - num.SetHex(_s) - return -} - -//export SKY_secp256k1go_Number_IsOdd -func SKY_secp256k1go_Number_IsOdd(handle C.Number_Handle, _arg0 *bool) (____error_code uint32) { - num, ok := lookupNumberHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0 := num.IsOdd() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_Number_IsEqual -func SKY_secp256k1go_Number_IsEqual(handle1 C.Number_Handle, handle2 C.Number_Handle, result *bool) (____error_code uint32) { - num1, ok := lookupNumberHandle(handle1) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - num2, ok := lookupNumberHandle(handle2) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - *result = hex.EncodeToString(num1.Bytes()) == hex.EncodeToString(num2.Bytes()) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go deleted file mode 100644 index 04a6094d20..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.sig.go +++ /dev/null @@ -1,146 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_Signature_Create -func SKY_secp256k1go_Signature_Create(handle *C.Signature_Handle) (____error_code uint32) { - var sig secp256k1go2.Signature - *handle = registerSignatureHandle(&sig) - return -} - -//export SKY_secp256k1go_Signature_GetR -func SKY_secp256k1go_Signature_GetR(handle C.Signature_Handle, r *C.Number_Handle) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - *r = registerNumberHandle(&sig.R) - return -} - -//export SKY_secp256k1go_Signature_GetS -func SKY_secp256k1go_Signature_GetS(handle C.Signature_Handle, s *C.Number_Handle) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - *s = registerNumberHandle(&sig.S) - return -} - -//export SKY_secp256k1go_Signature_Print -func SKY_secp256k1go_Signature_Print(handle C.Signature_Handle, _lab string) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - sig.Print(_lab) - return -} - -//export SKY_secp256k1go_Signature_Verify -func SKY_secp256k1go_Signature_Verify(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _arg2 *bool) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) - message, okm := lookupNumberHandle(_message) - if !okm { - ____error_code = SKY_BAD_HANDLE - return - } - __arg2 := sig.Verify(pubkey, message) - *_arg2 = __arg2 - return -} - -//export SKY_secp256k1go_Signature_Recover -func SKY_secp256k1go_Signature_Recover(handle C.Signature_Handle, _pubkey *C.secp256k1go__XY, _message C.Number_Handle, _recid int, _arg3 *bool) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - pubkey := (*secp256k1go2.XY)(unsafe.Pointer(_pubkey)) - m, okm := lookupNumberHandle(_message) - if !okm { - ____error_code = SKY_BAD_HANDLE - return - } - recid := _recid - __arg3 := sig.Recover(pubkey, m, recid) - *_arg3 = __arg3 - return -} - -//export SKY_secp256k1go_Signature_Sign -func SKY_secp256k1go_Signature_Sign(handle C.Signature_Handle, _seckey, _message, _nonce C.Number_Handle, _recid *int, _arg2 *int) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - seckey, oks := lookupNumberHandle(_seckey) - if !oks { - ____error_code = SKY_BAD_HANDLE - return - } - message, okm := lookupNumberHandle(_message) - if !okm { - ____error_code = SKY_BAD_HANDLE - return - } - nonce, okn := lookupNumberHandle(_nonce) - if !okn { - ____error_code = SKY_BAD_HANDLE - return - } - recid := _recid - __arg2 := sig.Sign(seckey, message, nonce, recid) - *_arg2 = __arg2 - return -} - -//export SKY_secp256k1go_Signature_ParseBytes -func SKY_secp256k1go_Signature_ParseBytes(handle C.Signature_Handle, _v []byte) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - v := *(*[]byte)(unsafe.Pointer(&_v)) - sig.ParseBytes(v) - return -} - -//export SKY_secp256k1go_Signature_Bytes -func SKY_secp256k1go_Signature_Bytes(handle C.Signature_Handle, _arg0 *C.GoSlice_) (____error_code uint32) { - sig, ok := lookupSignatureHandle(handle) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - __arg0 := sig.Bytes() - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go deleted file mode 100644 index e2e75f4cb7..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xy.go +++ /dev/null @@ -1,108 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_XY_Print -func SKY_secp256k1go_XY_Print(_xy *C.secp256k1go__XY, _lab string) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - lab := _lab - xy.Print(lab) - return -} - -//export SKY_secp256k1go_XY_ParsePubkey -func SKY_secp256k1go_XY_ParsePubkey(_xy *C.secp256k1go__XY, _pub []byte, _arg1 *bool) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - pub := *(*[]byte)(unsafe.Pointer(&_pub)) - __arg1 := xy.ParsePubkey(pub) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1go_XY_Bytes -func SKY_secp256k1go_XY_Bytes(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - xy := *(*secp256k1go2.XY)(unsafe.Pointer(_xy)) - __arg0 := xy.Bytes() - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) - return -} - -//export SKY_secp256k1go_XY_BytesUncompressed -func SKY_secp256k1go_XY_BytesUncompressed(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - __arg0 := xy.BytesUncompressed() - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) - return -} - -//export SKY_secp256k1go_XY_SetXY -func SKY_secp256k1go_XY_SetXY(_xy *C.secp256k1go__XY, _X, _Y *C.secp256k1go__Field) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) - Y := (*secp256k1go2.Field)(unsafe.Pointer(_Y)) - xy.SetXY(X, Y) - return -} - -//export SKY_secp256k1go_XY_IsValid -func SKY_secp256k1go_XY_IsValid(_xy *C.secp256k1go__XY, _arg0 *bool) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - __arg0 := xy.IsValid() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_XY_SetXYZ -func SKY_secp256k1go_XY_SetXYZ(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XYZ) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - a := (*secp256k1go2.XYZ)(unsafe.Pointer(_a)) - xy.SetXYZ(a) - return -} - -//export SKY_secp256k1go_XY_Neg -func SKY_secp256k1go_XY_Neg(_xy *C.secp256k1go__XY, _r *C.secp256k1go__XY) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - r := (*secp256k1go2.XY)(unsafe.Pointer(_r)) - xy.Neg(r) - return -} - -//export SKY_secp256k1go_XY_SetXO -func SKY_secp256k1go_XY_SetXO(_xy *C.secp256k1go__XY, _X *C.secp256k1go__Field, _odd bool) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - X := (*secp256k1go2.Field)(unsafe.Pointer(_X)) - odd := _odd - xy.SetXO(X, odd) - return -} - -//export SKY_secp256k1go_XY_AddXY -func SKY_secp256k1go_XY_AddXY(_xy *C.secp256k1go__XY, _a *C.secp256k1go__XY) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) - xy.AddXY(a) - return -} - -//export SKY_secp256k1go_XY_GetPublicKey -func SKY_secp256k1go_XY_GetPublicKey(_xy *C.secp256k1go__XY, _arg0 *C.GoSlice_) (____error_code uint32) { - xy := (*secp256k1go2.XY)(unsafe.Pointer(_xy)) - __arg0 := xy.GetPublicKey() - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go b/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go deleted file mode 100644 index 7dd90678e7..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1-go2.xyz.go +++ /dev/null @@ -1,128 +0,0 @@ -package main - -import ( - "unsafe" - - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1go_XYZ_Print -func SKY_secp256k1go_XYZ_Print(_xyz *C.secp256k1go__XYZ, _lab string) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - lab := _lab - xyz.Print(lab) - return -} - -//export SKY_secp256k1go_XYZ_SetXY -func SKY_secp256k1go_XYZ_SetXY(_xyz *C.secp256k1go__XYZ, _a *C.secp256k1go__XY) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - a := (*secp256k1go2.XY)(unsafe.Pointer(_a)) - xyz.SetXY(a) - return -} - -//export SKY_secp256k1go_XYZ_IsInfinity -func SKY_secp256k1go_XYZ_IsInfinity(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - __arg0 := xyz.IsInfinity() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_XYZ_IsValid -func SKY_secp256k1go_XYZ_IsValid(_xyz *C.secp256k1go__XYZ, _arg0 *bool) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - __arg0 := xyz.IsValid() - *_arg0 = __arg0 - return -} - -//export SKY_secp256k1go_XYZ_Normalize -func SKY_secp256k1go_XYZ_Normalize(_xyz *C.secp256k1go__XYZ) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - xyz.Normalize() - return -} - -//export SKY_secp256k1go_XYZ_Equals -func SKY_secp256k1go_XYZ_Equals(_xyz *C.secp256k1go__XYZ, _b *C.secp256k1go__XYZ, _arg1 *bool) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) - __arg1 := xyz.Equals(b) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1go_XYZ_ECmult -func SKY_secp256k1go_XYZ_ECmult(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _na, _ng C.Number_Handle) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - na, ok1 := lookupNumberHandle(_na) - if !ok1 { - ____error_code = SKY_BAD_HANDLE - return - } - ng, ok2 := lookupNumberHandle(_ng) - if !ok2 { - ____error_code = SKY_BAD_HANDLE - return - } - xyz.ECmult(r, na, ng) - return -} - -//export SKY_secp256k1go_XYZ_Neg -func SKY_secp256k1go_XYZ_Neg(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - xyz.Neg(r) - return -} - -//export SKY_secp256k1go_XYZ_Double -func SKY_secp256k1go_XYZ_Double(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - xyz.Double(r) - return -} - -//export SKY_secp256k1go_XYZ_AddXY -func SKY_secp256k1go_XYZ_AddXY(_xyz *C.secp256k1go__XYZ, _r *C.secp256k1go__XYZ, _b *C.secp256k1go__XY) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - b := (*secp256k1go2.XY)(unsafe.Pointer(_b)) - xyz.AddXY(r, b) - return -} - -//export SKY_secp256k1go_XYZ_Add -func SKY_secp256k1go_XYZ_Add(_xyz *C.secp256k1go__XYZ, _r, _b *C.secp256k1go__XYZ) (____error_code uint32) { - xyz := *(*secp256k1go2.XYZ)(unsafe.Pointer(_xyz)) - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - b := (*secp256k1go2.XYZ)(unsafe.Pointer(_b)) - xyz.Add(r, b) - return -} - -//export SKY_secp256k1go_ECmultGen -func SKY_secp256k1go_ECmultGen(_r *C.secp256k1go__XYZ, _a C.Number_Handle) (____error_code uint32) { - r := (*secp256k1go2.XYZ)(unsafe.Pointer(_r)) - a, ok := lookupNumberHandle(_a) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - secp256k1go2.ECmultGen(r, a) - return -} diff --git a/lib/cgo/cipher.secp256k1-go.secp256k1.go b/lib/cgo/cipher.secp256k1-go.secp256k1.go deleted file mode 100644 index 014ecca255..0000000000 --- a/lib/cgo/cipher.secp256k1-go.secp256k1.go +++ /dev/null @@ -1,154 +0,0 @@ -package main - -import ( - "reflect" - "unsafe" - - secp256k1go "github.com/skycoin/skycoin/src/cipher/secp256k1-go" -) - -/* - - #include - #include - - #include "skytypes.h" -*/ -import "C" - -//export SKY_secp256k1_GenerateKeyPair -func SKY_secp256k1_GenerateKeyPair(_arg0 *C.GoSlice_, _arg1 *C.GoSlice_) (____error_code uint32) { - __arg0, __arg1 := secp256k1go.GenerateKeyPair() - copyToGoSlice(reflect.ValueOf(__arg0), _arg0) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_PubkeyFromSeckey -func SKY_secp256k1_PubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - __arg1 := secp256k1go.PubkeyFromSeckey(seckey) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_UncompressPubkey -func SKY_secp256k1_UncompressPubkey(_pubkey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) - __arg1 := secp256k1go.UncompressPubkey(pubkey) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_UncompressedPubkeyFromSeckey -func SKY_secp256k1_UncompressedPubkeyFromSeckey(_seckey []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - __arg1 := secp256k1go.UncompressedPubkeyFromSeckey(seckey) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_Secp256k1Hash -func SKY_secp256k1_Secp256k1Hash(_hash []byte, _arg1 *C.GoSlice_) (____error_code uint32) { - hash := *(*[]byte)(unsafe.Pointer(&_hash)) - __arg1 := secp256k1go.Secp256k1Hash(hash) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - return -} - -//export SKY_secp256k1_GenerateDeterministicKeyPair -func SKY_secp256k1_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_) (____error_code uint32) { - seed := *(*[]byte)(unsafe.Pointer(&_seed)) - __arg1, __arg2 := secp256k1go.GenerateDeterministicKeyPair(seed) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - return -} - -//export SKY_secp256k1_DeterministicKeyPairIterator -func SKY_secp256k1_DeterministicKeyPairIterator(_seedIn []byte, _arg1 *C.GoSlice_, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { - seedIn := *(*[]byte)(unsafe.Pointer(&_seedIn)) - __arg1, __arg2, __arg3 := secp256k1go.DeterministicKeyPairIterator(seedIn) - copyToGoSlice(reflect.ValueOf(__arg1), _arg1) - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - copyToGoSlice(reflect.ValueOf(__arg3), _arg3) - return -} - -//export SKY_secp256k1_Sign -func SKY_secp256k1_Sign(_msg []byte, _seckey []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - msg := *(*[]byte)(unsafe.Pointer(&_msg)) - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - __arg2 := secp256k1go.Sign(msg, seckey) - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - return -} - -//export SKY_secp256k1_SignDeterministic -func SKY_secp256k1_SignDeterministic(_msg []byte, _seckey []byte, _nonceSeed []byte, _arg3 *C.GoSlice_) (____error_code uint32) { - msg := *(*[]byte)(unsafe.Pointer(&_msg)) - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - nonceSeed := *(*[]byte)(unsafe.Pointer(&_nonceSeed)) - __arg3 := secp256k1go.SignDeterministic(msg, seckey, nonceSeed) - copyToGoSlice(reflect.ValueOf(__arg3), _arg3) - return -} - -//export SKY_secp256k1_VerifySeckey -func SKY_secp256k1_VerifySeckey(_seckey []byte, _arg1 *int) (____error_code uint32) { - seckey := *(*[]byte)(unsafe.Pointer(&_seckey)) - __arg1 := secp256k1go.VerifySeckey(seckey) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1_VerifyPubkey -func SKY_secp256k1_VerifyPubkey(_pubkey []byte, _arg1 *int) (____error_code uint32) { - pubkey := *(*[]byte)(unsafe.Pointer(&_pubkey)) - __arg1 := secp256k1go.VerifyPubkey(pubkey) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1_VerifySignatureValidity -func SKY_secp256k1_VerifySignatureValidity(_sig []byte, _arg1 *int) (____error_code uint32) { - sig := *(*[]byte)(unsafe.Pointer(&_sig)) - __arg1 := secp256k1go.VerifySignatureValidity(sig) - *_arg1 = __arg1 - return -} - -//export SKY_secp256k1_VerifySignature -func SKY_secp256k1_VerifySignature(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *int) (____error_code uint32) { - __arg3 := secp256k1go.VerifySignature(_msg, _sig, _pubkey1) - *_arg3 = __arg3 - return -} - -//export SKY_secp256k1_SignatureErrorString -func SKY_secp256k1_SignatureErrorString(_msg []byte, _sig []byte, _pubkey1 []byte, _arg3 *C.GoString_) (____error_code uint32) { - msg := *(*[]byte)(unsafe.Pointer(&_msg)) - sig := *(*[]byte)(unsafe.Pointer(&_sig)) - pubkey1 := *(*[]byte)(unsafe.Pointer(&_pubkey1)) - __arg3 := secp256k1go.SignatureErrorString(msg, sig, pubkey1) - copyString(__arg3, _arg3) - return -} - -//export SKY_secp256k1_RecoverPubkey -func SKY_secp256k1_RecoverPubkey(_msg []byte, _sig []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - msg := *(*[]byte)(unsafe.Pointer(&_msg)) - sig := *(*[]byte)(unsafe.Pointer(&_sig)) - __arg2 := secp256k1go.RecoverPubkey(msg, sig) - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - return -} - -//export SKY_secp256k1_ECDH -func SKY_secp256k1_ECDH(_pub []byte, _sec []byte, _arg2 *C.GoSlice_) (____error_code uint32) { - pub := *(*[]byte)(unsafe.Pointer(&_pub)) - sec := *(*[]byte)(unsafe.Pointer(&_sec)) - __arg2 := secp256k1go.ECDH(pub, sec) - copyToGoSlice(reflect.ValueOf(__arg2), _arg2) - return -} diff --git a/lib/cgo/libsky_handle.go b/lib/cgo/libsky_handle.go index 58835afc89..82bff3d3b7 100644 --- a/lib/cgo/libsky_handle.go +++ b/lib/cgo/libsky_handle.go @@ -15,7 +15,6 @@ import ( api "github.com/skycoin/skycoin/src/api" webrpc "github.com/skycoin/skycoin/src/api/webrpc" - secp256k1go2 "github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2" cli "github.com/skycoin/skycoin/src/cli" "github.com/skycoin/skycoin/src/coin" "github.com/skycoin/skycoin/src/readable" @@ -472,34 +471,6 @@ func lookupHashHandle(handle C.Hash_Handle) (*hash.Hash, bool) { return nil, false } -func registerNumberHandle(obj *secp256k1go2.Number) C.Number_Handle { - return (C.Number_Handle)(registerHandle(obj)) -} - -func lookupNumberHandle(handle C.Number_Handle) (*secp256k1go2.Number, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*secp256k1go2.Number); isOK { - return obj, true - } - } - return nil, false -} - -func registerSignatureHandle(obj *secp256k1go2.Signature) C.Signature_Handle { - return (C.Signature_Handle)(registerHandle(obj)) -} - -func lookupSignatureHandle(handle C.Signature_Handle) (*secp256k1go2.Signature, bool) { - obj, ok := lookupHandle(C.Handle(handle)) - if ok { - if obj, isOK := (obj).(*secp256k1go2.Signature); isOK { - return obj, true - } - } - return nil, false -} - func closeHandle(handle Handle) { delete(handleMap, handle) } diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256.c b/lib/cgo/tests/check_cipher.secp256k1.secp256.c deleted file mode 100644 index d91a6b52ce..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256.c +++ /dev/null @@ -1,956 +0,0 @@ - -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" - -#define BUFFER_SIZE 128 -#define TESTS 1 -#define SigSize 65 - -TestSuite(cipher_secp256k1, .init = setup, .fini = teardown); - -int keys_count = 4; -const char *test_keys[] = { - "08efb79385c9a8b0d1c6f5f6511be0c6f6c2902963d874a3a4bacc18802528d3", - "78298d9ecdc0640c9ae6883201a53f4518055442642024d23c45858f45d0c3e6", - "04e04fe65bfa6ded50a12769a3bd83d7351b2dbff08c9bac14662b23a3294b9e", - "2f5141f1b75747996c5de77c911dae062d16ae48799052c04ead20ccd5afa113", -}; - -Test(cipher_secp256k1, Test_Secp256_00) -{ - unsigned char buff[SigSize]; - visor__ReadableOutputs nonce = {buff, 0, 64}; - SKY_secp256k1_RandByte(32, &nonce); - if (nonce.len != 32) - cr_fatal(); -} - -Test(cipher_secp256k1, Test_Secp256_01) -{ - - cipher__PubKey pubkey; - cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - GoInt errorSecKey; - char bufferSecKey[101]; - strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; - SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); - if (!errorSecKey) - cr_fatal(); - - GoInt errorPubKey; - GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); - if (!errorPubKey) - cr_fatal(); -} - -Test(cipher_secp256k1, TestPubkeyFromSeckey) -{ - - unsigned char bufferPrivkey[BUFFER_SIZE]; - unsigned char bufferDesiredPubKey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - - const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char *hexDesiredPubKey = "03fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef1"; - - int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); - int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - - GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; - GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; - - visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - - GoUint32 errocode = SKY_secp256k1_PubkeyFromSeckey(privkey, &pubkey); - if (errocode) - cr_fatal(); - - cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); -} - -Test(cipher_secp256k1, Test_UncompressedPubkeyFromSeckey) -{ - - unsigned char bufferPrivkey[BUFFER_SIZE]; - unsigned char bufferDesiredPubKey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - - const char *hexPrivkey = "f19c523315891e6e15ae0608a35eec2e00ebd6d1984cf167f46336dabd9b2de4"; - const char *hexDesiredPubKey = "04fe43d0c2c3daab30f9472beb5b767be020b81c7cc940ed7a7e910f0c1d9feef10fe85eb3ce193405c2dd8453b7aeb6c1752361efdbf4f52ea8bf8f304aab37ab"; - - int sizePrivkey = hexnstr(hexPrivkey, bufferPrivkey, BUFFER_SIZE); - int sizeDesiredPubKey = hexnstr(hexDesiredPubKey, bufferDesiredPubKey, BUFFER_SIZE); - - GoSlice privkey = {bufferPrivkey, sizePrivkey, BUFFER_SIZE}; - GoSlice_ desiredPubKey = {bufferDesiredPubKey, sizeDesiredPubKey, BUFFER_SIZE}; - - visor__ReadableOutputs pubkey = {bufferPubKey, 0, BUFFER_SIZE}; - - GoUint32 errocode = SKY_secp256k1_UncompressedPubkeyFromSeckey(privkey, &pubkey); - if (errocode) - cr_fatal(); - - cr_assert(eq(type(GoSlice_), pubkey, desiredPubKey)); -} - -Test(cipher_secp256k1, Test_SignatureVerifyPubkey) -{ - unsigned char buff[SigSize]; - char sigBuffer[BUFFER_SIZE]; - cipher__PubKey pubkey; - cipher__SecKey seckey; - cipher__PubKey recoveredPubkey; - GoInt32 error_code; - GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - - error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pubKeySlice, (GoSlice_ *)&secKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - - GoSlice recoveredPubKeySlice = {recoveredPubkey, 0, sizeof(cipher__PubKey)}; - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); - GoInt result = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); - cr_assert(result == 1, "Public key not verified"); - SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&recoveredPubKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), recoveredPubKeySlice, pubKeySlice)); -} - -Test(cipher_secp256k1, Test_verify_functions) -{ - unsigned char buff[SigSize]; - char sigBuffer[BUFFER_SIZE]; - cipher__PubKey pubkey; - cipher__SecKey seckey; - cipher__PubKey recoveredPubkey; - GoInt32 error_code; - GoSlice secKeySlice = {seckey, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice = {pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - - error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pubKeySlice, (GoSlice_ *)&secKeySlice); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - GoSlice msg = {buff, 0, SigSize}; - SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - - GoSlice sig = {sigBuffer, 0, BUFFER_SIZE}; - SKY_secp256k1_Sign(msg, secKeySlice, (GoSlice_ *)&sig); - GoInt result = 0; - - error_code = SKY_secp256k1_VerifySeckey(secKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySeckey failed"); - cr_assert(result == 1, "Sec key not verified"); - - error_code = SKY_secp256k1_VerifyPubkey(pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed"); - cr_assert(result == 1, "Public key not verified"); - - error_code = SKY_secp256k1_VerifySignature(msg, sig, pubKeySlice, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result == 1, "Signature not verified"); -} - -Test(cipher_secp256k1, Test_SignatureVerifySecKey) -{ - cipher__PubKey pubkey; - cipher__SecKey seckey; - SKY_cipher_GenerateKeyPair(&pubkey, &seckey); - GoInt errorSecKey; - char bufferSecKey[101]; - strnhex((unsigned char *)seckey, bufferSecKey, sizeof(cipher__SecKey)); - GoSlice slseckey = {bufferSecKey, sizeof(cipher__SecKey), SigSize}; - SKY_secp256k1_VerifySeckey(slseckey, &errorSecKey); - cr_assert(errorSecKey == 1); - GoInt errorPubKey; - GoSlice slpubkey = {&pubkey, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - SKY_secp256k1_VerifyPubkey(slpubkey, &errorPubKey); - cr_assert(errorPubKey == 1); -} - -//test size of messages -Test(cipher_secp256k1, Test_Secp256_02s) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(pub1.len == 33, "Public key should be 33 bytes long."); - cr_assert(sec1.len == 32, "Private key should be 32 bytes long."); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last <= 4); -} - -//test signing message -Test(cipher_secp256k1, Test_Secp256_02) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); -} - -//test pubkey recovery -Test(cipher_secp256k1, Test_Secp256_02a) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - GoInt result; - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifySignature failed"); - cr_assert(result, "Signature invalid"); - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); -} - -//test random messages for the same pub/private key -Test(cipher_secp256k1, Test_Secp256_03) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - ((unsigned char *)sig.data)[64] = ((unsigned char *)sig.data)[64] % 4; - - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - } -} - -//test random messages for different pub/private keys -Test(cipher_secp256k1, Test_Secp256_04) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - unsigned char last = ((unsigned char *)sig.data)[64]; - cr_assert(last < 4); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(pub2.len > 0, "Invalid public key"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - } -} - -GoInt randSig(GoSlice *sig) -{ - GoInt error_code; - error_code = SKY_secp256k1_RandByte(65, (GoSlice_ *) sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - cr_assert(sig->len == 65, "Signature should be 65 bytes long. is %x", - sig->len); - ((unsigned char *)sig->data)[32] = ((unsigned char *)sig->data)[32] & 0x70; - ((unsigned char *)sig->data)[64] = ((unsigned char *)sig->data)[64] % 4; - return error_code; -} - -Test(cipher_secp256k1, Test_Secp256_06a_alt0) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - char bufferSig2[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice sig2 = {bufferSig2, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - GoInt code; - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - cr_assert(sig.len == 65, "Signature should be 65 bytes long."); - - for (int i = 0; i < TESTS; i++) - { - char bufferPub2[BUFFER_SIZE]; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoInt result; - randSig(&sig2); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig2, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); - if (pub2.len != 0) { - error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub2, &result); - cr_assert(result == 1); - } - error_code = SKY_secp256k1_VerifySignature(msg, sig2, pub1, &result); - cr_assert(result != 1); - } -} - -Test(cipher_secp256k1, Test_Secp256_06b) -{ - GoInt32 error_code; - char bufferPub1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSig1[BUFFER_SIZE]; - unsigned char buff[32]; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sig = {bufferSig1, 0, BUFFER_SIZE}; - GoSlice msg = {buff, 0, 32}; - - error_code = SKY_secp256k1_GenerateKeyPair((GoSlice_ *)&pub1, (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Sign(msg, sec1, (GoSlice_ *)&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Sign failed"); - - GoInt result; - for (int i = 0; i < TESTS; i++) - { - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_RecoverPubkey(msg, sig, (GoSlice_ *)&pub2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RecoverPubkey failed"); - cr_assert(not(eq(type(GoSlice), pub1, pub2)), "Different public keys."); - error_code = SKY_secp256k1_VerifySignature(msg, sig, pub2, &result); - cr_assert(pub2.len == 0 || result, "Public key is not valid"); - SKY_secp256k1_VerifySignature(msg, sig, pub1, &result); - cr_assert(result == 0, "Public key should not be valid"); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_00) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&hash, - (GoSlice_ *)&pub1, - (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (GoSlice_ *)&pub2, - (GoSlice_ *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_01) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&hash, - (GoSlice_ *)&pub1, - (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (GoSlice_ *)&pub2, - (GoSlice_ *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_02) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash[BUFFER_SIZE]; - char bufferPub1[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferPub2[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash = {bufferHash, 0, BUFFER_SIZE}; - GoSlice pub1 = {bufferPub1, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice pub2 = {bufferPub2, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&hash, - (GoSlice_ *)&pub1, - (GoSlice_ *)&sec1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (GoSlice_ *)&pub2, - (GoSlice_ *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed"); - cr_assert(eq(type(GoSlice), pub1, pub2), "Different public keys."); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different private keys."); - } -} - -Test(cipher_secp256k1, Test_Deterministic_Keypairs_03) -{ - int test_count = 16; - const char *testArray[] = { - "tQ93w5Aqcunm9SGUfnmF4fJv", - "9b8c3e36adce64dedc80d6dfe51ff1742cc1d755bbad457ac01177c5a18a789f", - "DC7qdQQtbWSSaekXnFmvQgse", - "d2deaf4a9ff7a5111fe1d429d6976cbde78811fdd075371a2a4449bb0f4d8bf9", - "X8EkuUZC7Td7PAXeS7Duc7vR", - "cad79b6dcf7bd21891cbe20a51c57d59689ae6e3dc482cd6ec22898ac00cd86b", - "tVqPYHHNVPRWyEed62v7f23u", - "2a386e94e9ffaa409517cbed81b9b2d4e1c5fb4afe3cbd67ce8aba11af0b02fa", - "kCy4R57HDfLqF3pVhBWxuMcg", - "26a7c6d8809c476a56f7455209f58b5ff3f16435fcf208ff2931ece60067f305", - "j8bjv86ZNjKqzafR6mtSUVCE", - "ea5c0f8c9f091a70bf38327adb9b2428a9293e7a7a75119920d759ecfa03a995", - "qShryAzVY8EtsuD3dsAc7qnG", - "331206176509bcae31c881dc51e90a4e82ec33cd7208a5fb4171ed56602017fa", - "5FGG7ZBa8wVMBJkmzpXj5ESX", - "4ea2ad82e7730d30c0c21d01a328485a0cf5543e095139ba613929be7739b52c", - "f46TZG4xJHXUGWx8ekbNqa9F", - "dcddd403d3534c4ef5703cc07a771c107ed49b7e0643c6a2985a96149db26108", - "XkZdQJ5LT96wshN8JBH8rvEt", - "3e276219081f072dff5400ca29a9346421eaaf3c419ff1474ac1c81ad8a9d6e1", - "GFDqXU4zYymhJJ9UGqRgS8ty", - "95be4163085b571e725edeffa83fff8e7a7db3c1ccab19d0f3c6e105859b5e10", - "tmwZksH2XyvuamnddYxyJ5Lp", - "2666dd54e469df56c02e82dffb4d3ea067daafe72c54dc2b4f08c4fb3a7b7e42", - "EuqZFsbAV5amTzkhgAMgjr7W", - "40c325c01f2e4087fcc97fcdbea6c35c88a12259ebf1bce0b14a4d77f075abbf", - "TW6j8rMffZfmhyDEt2JUCrLB", - "e676e0685c5d1afd43ad823b83db5c6100135c35485146276ee0b0004bd6689e", - "8rvkBnygfhWP8kjX9aXq68CY", - "21450a646eed0d4aa50a1736e6c9bf99fff006a470aab813a2eff3ee4d460ae4", - "phyRfPDuf9JMRFaWdGh7NXPX", - "ca7bc04196c504d0e815e125f7f1e086c8ae8c10d5e9df984aeab4b41bf9e398", - }; - - GoInt32 error_code; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {NULL, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.data = (void *)testArray[2 * i]; - seed.len = strlen(testArray[2 * i]); - seed.cap = seed.len; - sec1.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&s1, (GoSlice_ *)&s2, - (GoSlice_ *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_DeterministicWallets1) -{ - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "94dd1a9de9ffd57b5516b8a7f090da67f142f7d22356fa5d1b894ee4d4fba95b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "82fba4cc2bc29eef122f116f45d01d82ff488d7ee713f8a95c162a64097239e0", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "44c059496aac871ac168bb6889b9dd3decdb9e1fa082442a95fcbca982643425", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "d709ceb1a6fb906de506ea091c844ca37c65e52778b8d257d1dd3a942ab367fb", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "5fe4986fa964773041e119d2b6549acb392b2277a72232af75cbfb62c357c1a7", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "f784abc2e7f11ee84b4adb72ea4730a6aabe27b09604c8e2b792d8a1a31881ac", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "d495174b8d3f875226b9b939121ec53f9383bd560d34aa5ca3ac6b257512adf4", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "1fdc9fbfc6991b9416b3a8385c9942e2db59009aeb2d8de349b73d9f1d389374", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "c87c85a6f482964db7f8c31720981925b1e357a9fdfcc585bc2164fdef1f54d0", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "e2767d788d1c5620f3ef21d57f2d64559ab203c044f0a5f0730b21984e77019c", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "3fcb80eb1d5b91c491408447ac4e221fcb2254c861adbb5a178337c2750b0846", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "5577d4be25f1b44487140a626c8aeca2a77507a1fc4fd466dd3a82234abb6785", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "c07275582d0681eb07c7b51f0bca0c48c056d571b7b83d84980ab40ac7d7d720", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "f10e2b7675dfa557d9e3188469f12d3e953c2d46dce006cd177b6ae7f465cfc0", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "0bcbebb39d8fe1cb3eab952c6f701656c234e462b945e2f7d4be2c80b8f2d974", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "88ba6f6c66fc0ef01c938569c2dd1f05475cb56444f4582d06828e77d54ffbe6", - }; - GoInt32 error_code; - char bufferSeed[BUFFER_SIZE]; - char bufferSec1[BUFFER_SIZE]; - char bufferSec2[BUFFER_SIZE]; - char buffer1[BUFFER_SIZE]; - char buffer2[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice sec1 = {bufferSec1, 0, BUFFER_SIZE}; - GoSlice sec2 = {bufferSec2, 0, BUFFER_SIZE}; - GoSlice s1 = {buffer1, 0, BUFFER_SIZE}; - GoSlice s2 = {buffer2, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - seed.len = hexnstr(testArray[2 * i], (unsigned char*) bufferSeed, BUFFER_SIZE); - sec1.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferSec1, BUFFER_SIZE); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&s1, (GoSlice_ *)&s2, - (GoSlice_ *)&sec2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), sec1, sec2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_Secp256k1_Hash) -{ - int test_count = 16; - const char *testArray[] = { - "90c56f5b8d78a46fb4cddf6fd9c6d88d6d2d7b0ec35917c7dac12c03b04e444e", - "a70c36286be722d8111e69e910ce4490005bbf9135b0ce8e7a59f84eee24b88b", - "a3b08ccf8cbae4955c02f223be1f97d2bb41d92b7f0c516eb8467a17da1e6057", - "e9db072fe5817325504174253a056be7b53b512f1e588f576f1f5a82cdcad302", - "7048eb8fa93cec992b93dc8e93c5543be34aad05239d4c036cf9e587bbcf7654", - "5e9133e83c4add2b0420d485e1dcda5c00e283c6509388ab8ceb583b0485c13b", - "6d25375591bbfce7f601fc5eb40e4f3dde2e453dc4bf31595d8ec29e4370cd80", - "8d5579cd702c06c40fb98e1d55121ea0d29f3a6c42f5582b902ac243f29b571a", - "7214b4c09f584c5ddff971d469df130b9a3c03e0277e92be159279de39462120", - "3a4e8c72921099a0e6a4e7f979df4c8bced63063097835cdfd5ee94548c9c41a", - "b13e78392d5446ae304b5fc9d45b85f26996982b2c0c86138afdac8d2ea9016e", - "462efa1bf4f639ffaedb170d6fb8ba363efcb1bdf0c5aef0c75afb59806b8053", - "9403bff4240a5999e17e0ab4a645d6942c3a7147c7834e092e461a4580249e6e", - "68dd702ea7c7352632876e9dc2333142fce857a542726e402bb480cad364f260", - "2665312a3e3628f4df0b9bc6334f530608a9bcdd4d1eef174ecda99f51a6db94", - "5db72c31d575c332e60f890c7e68d59bd3d0ac53a832e06e821d819476e1f010", - "6cb37532c80765b7c07698502a49d69351036f57a45a5143e33c57c236d841ca", - "0deb20ec503b4c678213979fd98018c56f24e9c1ec99af3cd84b43c161a9bb5c", - "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c", - "36f3ede761aa683813013ffa84e3738b870ce7605e0a958ed4ffb540cd3ea504", - "66d1945ceb6ef8014b1b6703cb624f058913e722f15d03225be27cb9d8aabe4a", - "6bcb4819a96508efa7e32ee52b0227ccf5fbe5539687aae931677b24f6d0bbbd", - "22c7623bf0e850538329e3e6d9a6f9b1235350824a3feaad2580b7a853550deb", - "8bb257a1a17fd2233935b33441d216551d5ff1553d02e4013e03f14962615c16", - "a5eebe3469d68c8922a1a8b5a0a2b55293b7ff424240c16feb9f51727f734516", - "d6b780983a63a3e4bcf643ee68b686421079c835a99eeba6962fe41bb355f8da", - "479ec3b589b14aa7290b48c2e64072e4e5b15ce395d2072a5a18b0a2cf35f3fd", - "39c5f108e7017e085fe90acfd719420740e57768ac14c94cb020d87e36d06752", - "63952334b731ec91d88c54614925576f82e3610d009657368fc866e7b1efbe73", - "79f654976732106c0e4a97ab3b6d16f343a05ebfcc2e1d679d69d396e6162a77", - "256472ee754ef6af096340ab1e161f58e85fb0cc7ae6e6866b9359a1657fa6c1", - "387883b86e2acc153aa334518cea48c0c481b573ccaacf17c575623c392f78b2", - }; - GoInt32 error_code; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferHash3[BUFFER_SIZE]; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice hash3 = {bufferHash3, 0, BUFFER_SIZE}; - - for (int i = 0; i < test_count; i++) - { - hash1.len = hexnstr(testArray[2 * i], (unsigned char*) bufferHash1, BUFFER_SIZE); - hash2.len = hexnstr(testArray[2 * i + 1], (unsigned char*) bufferHash2, BUFFER_SIZE); - error_code = SKY_secp256k1_Secp256k1Hash(hash1, (GoSlice_ *)&hash3); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - cr_assert(eq(type(GoSlice), hash2, hash3), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_Secp256k1_Equal) -{ - char bufferSeed[BUFFER_SIZE]; - char bufferHash1[BUFFER_SIZE]; - char bufferHash2[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice hash1 = {bufferHash1, 0, BUFFER_SIZE}; - GoSlice hash2 = {bufferHash2, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 64; i++) - { - error_code = SKY_secp256k1_RandByte(128, (GoSlice_ *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed"); - error_code = SKY_secp256k1_Secp256k1Hash(seed, (GoSlice_ *)&hash1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_Secp256k1Hash failed"); - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&hash2, - (GoSlice_ *)&public, - (GoSlice_ *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - cr_assert(eq(type(GoSlice), hash1, hash2), "Different hashes"); - } -} - -Test(cipher_secp256k1, Test_DeterministicWalletGeneration) -{ - const char *pSeed = "8654a32fa120bfdb7ca02c487469070eba4b5a81b03763a2185fdf5afd756f3c"; - const char *pSecOut = "10ba0325f1b8633ca463542950b5cd5f97753a9829ba23477c584e7aee9cfbd5"; - const char *pPubOut = "0249964ac7e3fe1b2c182a2f10abe031784e374cc0c665a63bc76cc009a05bc7c6"; - - char bufferSeed[BUFFER_SIZE]; - char bufferPrivate[BUFFER_SIZE]; - char bufferPublic[BUFFER_SIZE]; - char bufferNewSeed[BUFFER_SIZE]; - char bufferPrivateExpected[BUFFER_SIZE]; - char bufferPublicExpected[BUFFER_SIZE]; - - GoSlice seed = {bufferSeed, 0, BUFFER_SIZE}; - GoSlice private = {bufferPrivate, 0, BUFFER_SIZE}; - GoSlice public = {bufferPublic, 0, BUFFER_SIZE}; - GoSlice newSeed = {bufferNewSeed, 0, BUFFER_SIZE}; - GoSlice privateExpected = {bufferPrivateExpected, 0, BUFFER_SIZE}; - GoSlice publicExpected = {bufferPublicExpected, 0, BUFFER_SIZE}; - - strcpy(bufferSeed, pSeed); - seed.len = strlen(pSeed); - - GoInt32 error_code; - - for (int i = 0; i < 1024; i++) - { - error_code = SKY_secp256k1_DeterministicKeyPairIterator(seed, - (GoSlice_ *)&newSeed, - (GoSlice_ *)&public, - (GoSlice_ *)&private); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_DeterministicKeyPairIterator failed"); - memcpy(seed.data, newSeed.data, newSeed.len); - seed.len = newSeed.len; - } - - privateExpected.len = hexnstr(pSecOut, (unsigned char*)bufferPrivateExpected, BUFFER_SIZE); - publicExpected.len = hexnstr(pPubOut, (unsigned char*)bufferPublicExpected, BUFFER_SIZE); - - cr_assert(eq(type(GoSlice), privateExpected, private), "Private keyd didn\'t match"); - cr_assert(eq(type(GoSlice), public, publicExpected), "Public keyd didn\'t match"); -} - -Test(cipher_secp256k1, Test_ECDH) -{ - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pubKeySlice1, (GoSlice_ *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pubKeySlice2, (GoSlice_ *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (GoSlice_ *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (GoSlice_ *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); -} - -Test(cipher_secp256k1, Test_ECDH2) -{ - cipher__PubKey pubkey1; - cipher__SecKey seckey1; - cipher__PubKey pubkey2; - cipher__SecKey seckey2; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - GoInt32 error_code; - GoSlice secKeySlice1 = {seckey1, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice1 = {pubkey1, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice secKeySlice2 = {seckey2, sizeof(cipher__SecKey), sizeof(cipher__SecKey)}; - GoSlice pubKeySlice2 = {pubkey2, sizeof(cipher__PubKey), sizeof(cipher__PubKey)}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pubKeySlice1, (GoSlice_ *)&secKeySlice1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - error_code = SKY_secp256k1_GenerateKeyPair( - (GoSlice_ *)&pubKeySlice2, (GoSlice_ *)&secKeySlice2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateKeyPair failed"); - - SKY_secp256k1_ECDH(pubKeySlice1, secKeySlice2, (GoSlice_ *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKeySlice2, secKeySlice1, (GoSlice_ *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys) -{ - char seedBuffer[64]; - GoSlice seed = {seedBuffer, 0, 64}; - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < 32; i++) - { - error_code = SKY_secp256k1_RandByte(32, (GoSlice_ *)&seed); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_RandByte failed."); - error_code = SKY_secp256k1_GenerateDeterministicKeyPair(seed, - (GoSlice_ *)&privatekey, (GoSlice_ *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_GenerateDeterministicKeyPair failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys2) -{ - unsigned char bufferPrivatekey[BUFFER_SIZE]; - unsigned char bufferPubKey[BUFFER_SIZE]; - - GoSlice privatekey = {bufferPrivatekey, 0, BUFFER_SIZE}; - GoSlice pubKey = {bufferPubKey, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int sizePrivatekey = hexnstr(test_keys[i], bufferPrivatekey, BUFFER_SIZE); - privatekey.len = sizePrivatekey; - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey, (GoSlice_ *)&pubKey); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - GoInt verified = 0; - error_code = SKY_secp256k1_VerifyPubkey(pubKey, &verified); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_VerifyPubkey failed."); - cr_assert(verified != 0, "Failed verifying key"); - } -} - -Test(cipher_secp256k1, Test_Abnormal_Keys3) -{ - unsigned char bufferPrivatekey1[BUFFER_SIZE]; - unsigned char bufferPubKey1[BUFFER_SIZE]; - unsigned char bufferPrivatekey2[BUFFER_SIZE]; - unsigned char bufferPubKey2[BUFFER_SIZE]; - unsigned char bufferECDH1[BUFFER_SIZE]; - unsigned char bufferECDH2[BUFFER_SIZE]; - - int sizePrivatekey1, sizePrivatekey2; - int sizePubKey1, sizePubKey2; - GoSlice privatekey1 = {bufferPrivatekey1, 0, BUFFER_SIZE}; - GoSlice privatekey2 = {bufferPrivatekey2, 0, BUFFER_SIZE}; - GoSlice pubKey1 = {bufferPubKey1, 0, BUFFER_SIZE}; - GoSlice pubKey2 = {bufferPubKey2, 0, BUFFER_SIZE}; - GoSlice ecdh1 = {bufferECDH1, 0, BUFFER_SIZE}; - GoSlice ecdh2 = {bufferECDH2, 0, BUFFER_SIZE}; - GoInt32 error_code; - - for (int i = 0; i < keys_count; i++) - { - int randn = rand() % keys_count; - sizePrivatekey1 = hexnstr(test_keys[i], bufferPrivatekey1, BUFFER_SIZE); - sizePrivatekey2 = hexnstr(test_keys[randn], bufferPrivatekey2, BUFFER_SIZE); - privatekey1.len = sizePrivatekey1; - privatekey2.len = sizePrivatekey2; - - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey1, (GoSlice_ *)&pubKey1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey1.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - error_code = SKY_secp256k1_PubkeyFromSeckey(privatekey2, (GoSlice_ *)&pubKey2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_PubkeyFromSeckey failed."); - cr_assert(pubKey2.len > 0, "SKY_secp256k1_PubkeyFromSeckey failed."); - - SKY_secp256k1_ECDH(pubKey1, privatekey2, (GoSlice_ *)&ecdh1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - SKY_secp256k1_ECDH(pubKey2, privatekey1, (GoSlice_ *)&ecdh2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1_ECDH failed."); - - cr_assert(eq(type(GoSlice), ecdh1, ecdh2)); - } -} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c deleted file mode 100644 index 51156f8c09..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.ec.c +++ /dev/null @@ -1,151 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "base64.h" - -#define AX "0EAEBCD1DF2DF853D66CE0E1B0FDA07F67D1CABEFDE98514AAD795B86A6EA66D" -#define AY "BEB26B67D7A00E2447BAECCC8A4CEF7CD3CAD67376AC1C5785AEEBB4F6441C16" -#define AZ "0000000000000000000000000000000000000000000000000000000000000001" - -#define EX "EB6752420B6BDB40A760AC26ADD7E7BBD080BF1DF6C0B009A0D310E4511BDF49" -#define EY "8E8CEB84E1502FC536FFE67967BC44314270A0B38C79865FFED5A85D138DCA6B" -#define EZ "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" - -#define U1 "B618EBA71EC03638693405C75FC1C9ABB1A74471BAAF1A3A8B9005821491C4B4" -#define U2 "8554470195DE4678B06EDE9F9286545B51FF2D9AA756CE35A39011783563EA60" - -#define NONCE "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E" - -#define E2X "02D1BF36D37ACD68E4DD00DB3A707FD176A37E42F81AEF9386924032D3428FF0" -#define E2Y "FD52E285D33EC835230EA69F89D9C38673BD5B995716A4063C893AF02F938454" -#define E2Z "4C6ACE7C8C062A1E046F66FD8E3981DC4E8E844ED856B5415C62047129268C1B" - -TestSuite(cipher_secp256k1_xyz, .init = setup, .fini = teardown); - -Test(cipher_secp256k1_xyz, TestXYZECMult){ - - secp256k1go__XYZ pubkey; //pubkey - secp256k1go__XYZ pr; //result of ECmult - secp256k1go__XYZ e; //expected - Number_Handle u1, u2; - secp256k1go__Field x, y, z; - - GoInt32 error_code; - memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); - memset(&pr, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - u1 = 0; - u2 = 0; - memset(&x, 0, sizeof(secp256k1go__Field)); - memset(&y, 0, sizeof(secp256k1go__Field)); - memset(&z, 0, sizeof(secp256k1go__Field)); - - GoString strAx = {AX, strlen(AX)}; - GoString strAy = {AY, strlen(AY)}; - GoString strAz = {AZ, strlen(AZ)}; - - GoString strEx = {EX, strlen(EX)}; - GoString strEy = {EY, strlen(EY)}; - GoString strEz = {EZ, strlen(EZ)}; - - GoString strU1 = {U1, strlen(U1)}; - GoString strU2 = {U2, strlen(U2)}; - - error_code = SKY_secp256k1go_Number_Create(&u1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(u1); - - error_code = SKY_secp256k1go_Number_Create(&u2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(u2); - - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.X, strAx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Y, strAy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&pubkey.Z, strAz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Number_SetHex(u1, strU1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - error_code = SKY_secp256k1go_Number_SetHex(u2, strU2); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - error_code = SKY_secp256k1go_XYZ_ECmult(&pubkey, &pr, u2, u1); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_ECmult failed"); - - GoUint8 equal = 0; - error_code = SKY_secp256k1go_XYZ_Equals(&pr, &e, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_XYZ_ECmult failed, result is different than expected."); -} - -Test(cipher_secp256k1_xyz, TestXYZECMultGen){ - secp256k1go__XYZ pubkey; //pubkey - secp256k1go__XYZ pr; //result of ECmult - secp256k1go__XYZ e; //expected - Number_Handle nonce; - secp256k1go__Field x, y, z; - - GoInt32 error_code; - memset(&pubkey, 0, sizeof(secp256k1go__XYZ)); - memset(&pr, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - nonce = 0; - memset(&x, 0, sizeof(secp256k1go__Field)); - memset(&y, 0, sizeof(secp256k1go__Field)); - memset(&z, 0, sizeof(secp256k1go__Field)); - - GoString strNonce = {NONCE, strlen(NONCE)}; - GoString strEx = {E2X, strlen(E2X)}; - GoString strEy = {E2Y, strlen(E2Y)}; - GoString strEz = {E2Z, strlen(E2Z)}; - - error_code = SKY_secp256k1go_Number_Create(&nonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(nonce); - - error_code = SKY_secp256k1go_Number_SetHex(nonce, strNonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&x, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - error_code = SKY_secp256k1go_Field_SetHex(&z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed."); - - error_code = SKY_secp256k1go_ECmultGen(&pr, nonce); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_ECmultGen failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - error_code = SKY_secp256k1go_Field_Normalize(&pr.Z); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Normalize failed."); - - GoUint8 equal = 0; - error_code = SKY_secp256k1go_Field_Equals(&pr.X, &x, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. X is different than expected"); - error_code = SKY_secp256k1go_Field_Equals(&pr.Y, &y, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Y is different than expected"); - error_code = SKY_secp256k1go_Field_Equals(&pr.Z, &z, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_ECmultGen failed. Z is different than expected"); -} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c deleted file mode 100644 index d3a3f4d2db..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.field.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "base64.h" - -#define INHEX "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31" -#define EXPHEX "7F586430EA30F914965770F6098E492699C62EE1DF6CAFFA77681C179FDF3117" - -TestSuite(cipher_secp256k1_field, .init = setup, .fini = teardown); - -Test(cipher_secp256k1_field, TestFieldInv){ - secp256k1go__Field in; - secp256k1go__Field out; - secp256k1go__Field expected; - - memset(&in, 0, sizeof(secp256k1go__Field)); - memset(&out, 0, sizeof(secp256k1go__Field)); - memset(&expected, 0, sizeof(secp256k1go__Field)); - - GoUint32 error_code; - GoUint8 equal = 0; - - GoString InStr = {INHEX, strlen(INHEX)}; - GoString ExpStr = {EXPHEX, strlen(EXPHEX)}; - error_code = SKY_secp256k1go_Field_SetHex(&in, InStr); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected, ExpStr); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_Inv(&in, &out); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_Inv failed"); - error_code = SKY_secp256k1go_Field_Equals(&out, &expected, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Field_Inv failed, result is different than expected."); -} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c deleted file mode 100644 index e8bd4954be..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.sig.c +++ /dev/null @@ -1,284 +0,0 @@ - -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" - -#define BUFFER_SIZE 1024 - -#define R1 "6028b9e3a31c9e725fcbd7d5d16736aaaafcc9bf157dfb4be62bcbcf0969d488" -#define S1 "036d4a36fa235b8f9f815aa6f5457a607f956a71a035bf0970d8578bf218bb5a" -#define MSG1 "9cff3da1a4f86caf3683f865232c64992b5ed002af42b321b8d8a48420680487" -#define X1 "56dc5df245955302893d8dda0677cc9865d8011bc678c7803a18b5f6faafec08" -#define Y1 "54b5fbdcd8fac6468dac2de88fadce6414f5f3afbb103753e25161bef77705a6" - -#define R2 "b470e02f834a3aaafa27bd2b49e07269e962a51410f364e9e195c31351a05e50" -#define S2 "560978aed76de9d5d781f87ed2068832ed545f2b21bf040654a2daff694c8b09" -#define MSG2 "9ce428d58e8e4caf619dc6fc7b2c2c28f0561654d1f80f322c038ad5e67ff8a6" -#define X2 "15b7e7d00f024bffcd2e47524bb7b7d3a6b251e23a3a43191ed7f0a418d9a578" -#define Y2 "bf29a25e2d1f32c5afb18b41ae60112723278a8af31275965a6ec1d95334e840" - -#define forceLowS true - -TestSuite(cipher_secp256k1_sig, .init = setup, .fini = teardown); - -Test(cipher_secp256k1_sig, TestSigRecover){ - GoUint32 error_code; - Signature_Handle sig; - Number_Handle msg; - secp256k1go__XY pubKey; - secp256k1go__XY expected; - - memset(&pubKey, 0, sizeof(secp256k1go__XY)); - memset(&expected, 0, sizeof(secp256k1go__XY)); - sig = 0; - msg = 0; - - GoString R = {R1, strlen(R1)}; - GoString S = {S1, strlen(S1)}; - GoString MSG = {MSG1, strlen(MSG1)}; - GoString X = {X1, strlen(X1)}; - GoString Y = {Y1, strlen(Y1)}; - GoInt rid = 0; - GoUint8 result; - - error_code = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); - Number_Handle r; - error_code = SKY_secp256k1go_Signature_GetR(sig, &r); - registerHandleClose(r); - Number_Handle s; - error_code = SKY_secp256k1go_Signature_GetS(sig, &s); - registerHandleClose(s); - error_code = SKY_secp256k1go_Number_Create(&msg); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - error_code = SKY_secp256k1go_Number_SetHex(r, R); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(s, S); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - - error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); - cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - - cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.X, &expected.X), "SKY_secp256k1go_Signature_Recover Xs different."); - cr_assert(cr_user_secp256k1go__Field_eq(&pubKey.Y, &expected.Y), "SKY_secp256k1go_Signature_Recover Xs different."); - - R.p = R2; - R.n = strlen(R2); - S.p = S2; - S.n = strlen(S2); - MSG.p = MSG2; - MSG.n = strlen(MSG2); - X.p = X2; - X.n = strlen(X2); - Y.p = Y2; - Y.n = strlen(Y2); - rid = 1; - - error_code = SKY_secp256k1go_Number_SetHex(r, R); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for R failed"); - error_code = SKY_secp256k1go_Number_SetHex(s, S); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for S failed"); - error_code = SKY_secp256k1go_Number_SetHex(msg, MSG); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for MSG failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.X, X); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for X failed"); - error_code = SKY_secp256k1go_Field_SetHex(&expected.Y, Y); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Number_SetHex for Y failed"); - - error_code = SKY_secp256k1go_Signature_Recover(sig, &pubKey, msg, rid, &result); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Signature_Recover failed"); - cr_assert(result, "SKY_secp256k1go_Signature_Recover failed"); - - GoUint8 equal; - error_code = SKY_secp256k1go_Field_Equals(&pubKey.X, &expected.X, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Xs different."); - SKY_secp256k1go_Field_Equals(&pubKey.Y, &expected.Y, &equal); - cr_assert(error_code == SKY_OK && equal, "SKY_secp256k1go_Signature_Recover Ys different."); -} - -Test(cipher_secp256k1_sig, TestSigVerify) { - - Number_Handle msg; - Signature_Handle sig; - secp256k1go__XY key; - - msg = 0; - sig = 0; - memset(&key, 0, sizeof(secp256k1go__XY)); - GoUint32 result; - - result = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); - Number_Handle r; - result = SKY_secp256k1go_Signature_GetR(sig, &r); - registerHandleClose(r); - Number_Handle s; - result = SKY_secp256k1go_Signature_GetS(sig, &s); - registerHandleClose(s); - result = SKY_secp256k1go_Number_Create(&msg); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - GoString str = { - "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA", 64}; - - result = SKY_secp256k1go_Number_SetHex(msg, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "98F9D784BA6C5C77BB7323D044C0FC9F2B27BAA0A5B0718FE88596CC56681980"; - result = SKY_secp256k1go_Number_SetHex(r, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; - result = SKY_secp256k1go_Number_SetHex(s, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "7d709f85a331813f9ae6046c56b3a42737abf4eb918b2e7afee285070e968b93"; - result = SKY_secp256k1go_Field_SetHex(&key.X, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - str.p = "26150d1a63b342986c373977b00131950cb5fc194643cad6ea36b5157eba4602"; - result = SKY_secp256k1go_Field_SetHex(&key.Y, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - GoUint8 valid; - result = SKY_secp256k1go_Signature_Verify(sig, &key, msg, &valid); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); - cr_assert(valid, "sig.Verify 1"); - - str.p = "2c43a883f4edc2b66c67a7a355b9312a565bb3d33bb854af36a06669e2028377"; - result = SKY_secp256k1go_Number_SetHex(msg, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "6b2fa9344462c958d4a674c2a42fbedf7d6159a5276eb658887e2e1b3915329b"; - result = SKY_secp256k1go_Number_SetHex(r, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "eddc6ea7f190c14a0aa74e41519d88d2681314f011d253665f301425caf86b86"; - result = SKY_secp256k1go_Number_SetHex(s, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - char buffer_xy[1024]; - GoSlice xy = {buffer_xy, 0, 1024}; - str.p = "02a60d70cfba37177d8239d018185d864b2bdd0caf5e175fd4454cc006fd2d75ac"; - str.n = 66; - result = SKY_base58_String2Hex(str, (GoSlice_ *) &xy); - cr_assert(result == SKY_OK, "SKY_base58_String2Hex"); - GoSlice xyConvert = {xy.data, xy.len, xy.cap}; - result = SKY_secp256k1go_XY_ParsePubkey(&key, xyConvert, &valid); - cr_assert(result == SKY_OK && valid, "SKY_secp256k1go_XY_ParsePubkey failed"); - result = SKY_secp256k1go_Signature_Verify(sig, &key, msg, &valid); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Verify failed"); - cr_assert(valid, "sig.Verify 2"); -} - -Test(cipher_secp256k1_sig, TestSigSign) { - - Number_Handle sec; - Number_Handle msg; - Number_Handle non; - Signature_Handle sig; - GoInt recid; - GoUint32 result; - - sec = 0; - msg = 0; - non = 0; - sig = 0; - - result = SKY_secp256k1go_Number_Create(&sec); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - result = SKY_secp256k1go_Number_Create(&msg); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - result = SKY_secp256k1go_Number_Create(&non); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_Create failed"); - registerHandleClose(msg); - - GoString str = { - "73641C99F7719F57D8F4BEB11A303AFCD190243A51CED8782CA6D3DBE014D146", 64}; - result = SKY_secp256k1go_Number_SetHex(sec, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "D474CBF2203C1A55A411EEC4404AF2AFB2FE942C434B23EFE46E9F04DA8433CA"; - str.n = 64; - result = SKY_secp256k1go_Number_SetHex(msg, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - str.p = "9E3CD9AB0F32911BFDE39AD155F527192CE5ED1F51447D63C4F154C118DA598E"; - str.n = 64; - result = SKY_secp256k1go_Number_SetHex(non, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - result = SKY_secp256k1go_Signature_Create(&sig); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Create failed"); - registerHandleClose(sig); - - GoInt res; - GoUint8 equal; - - result = SKY_secp256k1go_Signature_Sign(sig, sec, msg, non, &recid, &res); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_Sign failed"); - cr_assert(res == 1, "res failed %d", res); - - if (forceLowS) { - cr_assert(recid == 0, " recid failed %d", recid); - } else { - cr_assert(recid == 1, " recid failed %d", recid); - } - str.p = "98f9d784ba6c5c77bb7323d044c0fc9f2b27baa0a5b0718fe88596cc56681980"; - str.n = 64; - result = SKY_secp256k1go_Number_SetHex(non, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - - Number_Handle r; - result = SKY_secp256k1go_Signature_GetR(sig, &r); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetR failed"); - registerHandleClose(r); - - equal = 0; - result = SKY_secp256k1go_Number_IsEqual(r, non, &equal); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_IsEqual failed"); - cr_assert(equal != 0); - - if (forceLowS) { - str.p = "1ca662aaefd6cc958ba4604fea999db133a75bf34c13334dabac7124ff0cfcc1"; - str.n = 64; - result = SKY_secp256k1go_Number_SetHex(non, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - } else { - str.p = "E3599D551029336A745B9FB01566624D870780F363356CEE1425ED67D1294480"; - str.n = 64; - result = SKY_secp256k1go_Number_SetHex(non, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Number_SetHex failed"); - } - Number_Handle s; - result = SKY_secp256k1go_Signature_GetS(sig, &s); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); - registerHandleClose(s); - - equal = 0; - result = SKY_secp256k1go_Number_IsEqual(s, non, &equal); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Signature_GetS failed"); - cr_assert(equal != 0); -} diff --git a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c b/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c deleted file mode 100644 index 9f006db10e..0000000000 --- a/lib/cgo/tests/check_cipher.secp256k1.secp256k1-go2.xyz.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "libskycoin.h" -#include "skyerrors.h" -#include "skystring.h" -#include "skytest.h" -#include "base64.h" - -#define AX "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" -#define AY "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" -#define AZ "01" -#define EX "7D152C041EA8E1DC2191843D1FA9DB55B68F88FEF695E2C791D40444B365AFC2" -#define EY "56915849F52CC8F76F5FD7E4BF60DB4A43BF633E1B1383F85FE89164BFADCBDB" -#define EZ "9075B4EE4D4788CABB49F7F81C221151FA2F68914D0AA833388FA11FF621A970" - - - -Test(cipher_secp256k1_xyz, TestXYZDouble){ - GoInt32 error_code; - secp256k1go__XYZ a; //sample data - secp256k1go__XYZ r; //result of double - secp256k1go__XYZ e; //expected - - memset(&a, 0, sizeof(secp256k1go__XYZ)); - memset(&e, 0, sizeof(secp256k1go__XYZ)); - memset(&r, 0, sizeof(secp256k1go__XYZ)); - - GoString strAx = {AX, strlen(AX)}; - GoString strAy = {AY, strlen(AY)}; - GoString strAz = {AZ, strlen(AZ)}; - - GoString strEx = {EX, strlen(EX)}; - GoString strEy = {EY, strlen(EY)}; - GoString strEz = {EZ, strlen(EZ)}; - - error_code = SKY_secp256k1go_Field_SetHex(&a.X, strAx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&a.Y, strAy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&a.Z, strAz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_Field_SetHex(&e.X, strEx); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Y, strEy); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - error_code = SKY_secp256k1go_Field_SetHex(&e.Z, strEz); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - error_code = SKY_secp256k1go_XYZ_Double(&a, &r); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Double failed"); - - GoUint8 equal = 0; - error_code = SKY_secp256k1go_XYZ_Equals(&r, &e, &equal); - cr_assert(error_code == SKY_OK, "SKY_secp256k1go_XYZ_Equals failed."); - cr_assert(equal, "SKY_secp256k1go_XYZ_Double failed, result is different than expected."); -} - - -// TestGejMulLambda not impleme - -Test(cipher_secp256k1_xyz, TestGejGetX) { - secp256k1go__XYZ a; - secp256k1go__Field X; - secp256k1go__Field exp; - GoUint32 result; - memset(&a, 0, sizeof(secp256k1go__XYZ)); - memset(&X, 0, sizeof(secp256k1go__Field)); - memset(&a, 0, sizeof(secp256k1go__Field)); - - GoString str = { - "EB6752420B6BDB40A760AC26ADD7E7BBD080BF1DF6C0B009A0D310E4511BDF49", 64}; - - result = SKY_secp256k1go_Field_SetHex(&a.X, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - str.p = "8E8CEB84E1502FC536FFE67967BC44314270A0B38C79865FFED5A85D138DCA6B"; - result = SKY_secp256k1go_Field_SetHex(&a.Y, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - str.p = "813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31"; - result = SKY_secp256k1go_Field_SetHex(&a.Z, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - str.p = "fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b10"; - result = SKY_secp256k1go_Field_SetHex(&exp, str); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_SetHex failed"); - - secp256k1go__Field zi2; - secp256k1go__Field r; - memset(&zi2, 0, sizeof(secp256k1go__Field)); - memset(&r, 0, sizeof(secp256k1go__Field)); - result = SKY_secp256k1go_Field_InvVar(&a.Z, &zi2); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_InvVar failed"); - result = SKY_secp256k1go_Field_Sqr(&zi2, &zi2); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Sqr failed"); - result = SKY_secp256k1go_Field_Mul(&a.X, &X, &zi2); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Mul failed"); - GoUint8 valid; - result = SKY_secp256k1go_Field_Equals(&X, &exp, &valid); - cr_assert(result == SKY_OK, "SKY_secp256k1go_Field_Equals failed"); - cr_assert(valid, "get.get_x() fail"); -} diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 3c3c8bee4a..16bf882695 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -430,6 +430,10 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { cr_assert(eq(type(cipher__Address), addr1, addr2), "%d-th SKY_cipher_AddressFromPubKey and SKY_cipher_AddressFromSecKey must generate same addresses", i); + //----------------------------------------------- + // secp256k1 not exported in the libc API + //----------------------------------------------- + /* GoInt validSec; char bufferSecKey[101]; strnhex((unsigned char *)s, bufferSecKey, sizeof(cipher__SecKey)); @@ -445,6 +449,7 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) { // FIXME: without cond : 'not give a valid preprocessing token' bool cond = (!(inputData == NULL && expected->Signatures.len != 0)); cr_assert(cond, "%d seed data contains signatures but input data was not provided", i); + */ if (inputData != NULL) { cr_assert(expected->Signatures.len == inputData->Hashes.len, diff --git a/lib/cgo/tests/testutils/libsky_criterion.c b/lib/cgo/tests/testutils/libsky_criterion.c index c7d7b414df..0e8fe4f0a4 100644 --- a/lib/cgo/tests/testutils/libsky_criterion.c +++ b/lib/cgo/tests/testutils/libsky_criterion.c @@ -159,16 +159,6 @@ char *cr_user_GoSlice__tostr(GoSlice_ *slice1) return out; } -int cr_user_secp256k1go__Field_eq(secp256k1go__Field *f1, secp256k1go__Field *f2) -{ - for (int i = 0; i < 10; i++) - { - if (f1->n[i] != f2->n[i]) - return 0; - } - return 1; -} - int cr_user_coin__Transactions_eq(coin__Transactions *x1, coin__Transactions *x2) { return equalTransactions(x1, x2); From d823562310e99d68ac05007ded9c66271e8ddf81 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 5 Nov 2018 14:58:57 -0500 Subject: [PATCH 398/399] [lib] refs #1191 - Burn factor in util/fee - SKY_fee_VerifyTransactionFee - SKY_fee_VerifyTransactionFeeForHours - SKY_fee_RequiredFee - SKY_fee_RemainingHours [====] Synthesis: Tested: 101 | Passing: 101 | Failing: 0 | Crashing: 0 --- lib/cgo/util.fee.fee.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/cgo/util.fee.fee.go b/lib/cgo/util.fee.fee.go index 4437260dd2..527ffb2283 100644 --- a/lib/cgo/util.fee.fee.go +++ b/lib/cgo/util.fee.fee.go @@ -17,13 +17,13 @@ import ( import "C" //export SKY_fee_VerifyTransactionFee -func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____error_code uint32) { +func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64, _burnFactor uint64) (____error_code uint32) { t, ok := lookupTransactionHandle(_t) if !ok { ____error_code = SKY_BAD_HANDLE return } - ____return_err := fee.VerifyTransactionFee(t, _fee) + ____return_err := fee.VerifyTransactionFee(t, _fee, _burnFactor) ____error_code = libErrorCode(____return_err) if ____return_err == nil { } @@ -31,9 +31,9 @@ func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64) (____er } //export SKY_fee_VerifyTransactionFeeForHours -func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code uint32) { +func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64, _burnFactor uint64) (____error_code uint32) { hours := _hours - ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee) + ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee, _burnFactor) ____error_code = libErrorCode(____return_err) if ____return_err == nil { } @@ -41,17 +41,17 @@ func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64) (____error_code u } //export SKY_fee_RequiredFee -func SKY_fee_RequiredFee(_hours uint64, _arg1 *uint64) (____error_code uint32) { +func SKY_fee_RequiredFee(_hours uint64, _burnFactor uint64, _arg1 *uint64) (____error_code uint32) { hours := _hours - __arg1 := fee.RequiredFee(hours) + __arg1 := fee.RequiredFee(hours, _burnFactor) *_arg1 = __arg1 return } //export SKY_fee_RemainingHours -func SKY_fee_RemainingHours(_hours uint64, _arg1 *uint64) (____error_code uint32) { +func SKY_fee_RemainingHours(_hours uint64, _burnFactor uint64, _arg1 *uint64) (____error_code uint32) { hours := _hours - __arg1 := fee.RemainingHours(hours) + __arg1 := fee.RemainingHours(hours, _burnFactor) *_arg1 = __arg1 return } From be1de9197a2c603b49dc6859aa9049ff8182a13a Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 5 Nov 2018 19:03:14 -0500 Subject: [PATCH 399/399] [lib] refs #1191 - Document usage of libc memory handles --- lib/cgo/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/cgo/README.md b/lib/cgo/README.md index 4e2ed9c6bd..20208aa57f 100644 --- a/lib/cgo/README.md +++ b/lib/cgo/README.md @@ -120,6 +120,26 @@ invocation. The caller will be responsible for [reallocating another memory buffer](http://en.cppreference.com/w/c/memory/realloc) using a higher `cap` and retry. +#### Memory handles + +Complex objects represent a challenge to proper memory management, +especially when mutable values move across API boundaries. Hence some objects +always remain managed by `libskycoin` C API. Client applications can refer +to them using memory handles created by multiple functions distributed all over +the API. The memory associated to these objects remains allocated until +`SKY_handle_close` API function is applied upon the corresponding handle +value. + +Opening and closing handles can lead to memory leaks under certain circumstances, +including but not limited to nested scopes, and recursive function calls. +In order to cope with this, the API provides the means to duplicate references to +the same complex object by applying `SKY_handle_copy` function upon an existing +(valid) handle pointing at the object. There are no copy semantics involved for +the object. After the call a new handle reference is created pointing at the same +object referred to by the original handle value. The target will remain allocated +in memory (at least) until all open handles pointing at it will be closed by +invoking `SKY_handle_close` API function. + ## Generating documentation Follow these steps to generate API documentation.