Messages for funding flow.

This is the most different due to segwit (the rest of the messages are
simple).

I still need to simplify/refactor the tests, they're "messy".
This commit is contained in:
Joseph Poon
2015-12-30 05:38:57 -08:00
parent a5f0d3e56e
commit a93b6dcee4
12 changed files with 986 additions and 71 deletions

View File

@@ -14,7 +14,10 @@ const MessageHeaderSize = 12
const MaxMessagePayload = 1024 * 1024 * 32 // 32MB
const (
CmdFundingRequest = uint32(20)
CmdFundingRequest = uint32(200)
CmdFundingResponse = uint32(210)
CmdFundingSignAccept = uint32(220)
CmdFundingSignComplete = uint32(230)
)
//Every message has these functions:
@@ -33,8 +36,14 @@ func makeEmptyMessage(command uint32) (Message, error) {
switch command {
case CmdFundingRequest:
msg = &FundingRequest{}
case CmdFundingResponse:
msg = &FundingResponse{}
case CmdFundingSignAccept:
msg = &FundingSignAccept{}
case CmdFundingSignComplete:
msg = &FundingSignComplete{}
default:
return nil, fmt.Errorf("unhandled command [%x]", command)
return nil, fmt.Errorf("unhandled command [%d]", command)
}
return msg, nil
@@ -194,7 +203,7 @@ func ReadMessage(r io.Reader, pver uint32, btcnet wire.BitcoinNet) (int, Message
}
//Validate the data
msg.Validate()
err = msg.Validate()
if err != nil {
return totalBytes, nil, nil, err
}