Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sphinx.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,12 @@ func (r *Router) NextEphemeral(ephemPub *btcec.PublicKey) (*btcec.PublicKey,
return NextEphemeral(r.onionKey, ephemPub)
}

// OnionPublicKey returns the public key representing the onion key backing this
// router.
func (r *Router) OnionPublicKey() *btcec.PublicKey {
return r.onionKey.PubKey()
}

// unwrapPacket wraps a layer of the passed onion packet using the specified
// shared secret and associated data. The associated data will be used to check
// the HMAC at each hop to ensure the same data is passed along with the onion
Expand Down
12 changes: 6 additions & 6 deletions sphinx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ func TestSphinxNodeRelpaySameBatch(t *testing.T) {

// Allow the node to process the initial packet, this should proceed
// without any failures.
if err := tx.ProcessOnionPacket(0, fwdMsg, nil, 1, nil); err != nil {
if err := tx.ProcessOnionPacket(0, fwdMsg, nil, 1); err != nil {
t.Fatalf("unable to process sphinx packet: %v", err)
}

// Now, force the node to process the packet a second time, this call
// should not fail, even though the batch has internally recorded this
// as a duplicate.
err = tx.ProcessOnionPacket(1, fwdMsg, nil, 1, nil)
err = tx.ProcessOnionPacket(1, fwdMsg, nil, 1)
if err != nil {
t.Fatalf("adding duplicate sphinx packet to batch should not "+
"result in an error, instead got: %v", err)
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestSphinxNodeRelpayLaterBatch(t *testing.T) {

// Allow the node to process the initial packet, this should proceed
// without any failures.
err = tx.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1, nil)
err = tx.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1)
if err != nil {
t.Fatalf("unable to process sphinx packet: %v", err)
}
Expand All @@ -363,7 +363,7 @@ func TestSphinxNodeRelpayLaterBatch(t *testing.T) {

// Now, force the node to process the packet a second time, this should
// fail with a detected replay error.
err = tx2.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1, nil)
err = tx2.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1)
if err != nil {
t.Fatalf("sphinx packet replay should not have been rejected, "+
"instead error is %v", err)
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestSphinxNodeReplayBatchIdempotency(t *testing.T) {

// Allow the node to process the initial packet, this should proceed
// without any failures.
err = tx.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1, nil)
err = tx.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1)
if err != nil {
t.Fatalf("unable to process sphinx packet: %v", err)
}
Expand All @@ -409,7 +409,7 @@ func TestSphinxNodeReplayBatchIdempotency(t *testing.T) {

// Now, force the node to process the packet a second time, this should
// not fail with a detected replay error.
err = tx2.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1, nil)
err = tx2.ProcessOnionPacket(uint16(0), fwdMsg, nil, 1)
if err != nil {
t.Fatalf("sphinx packet replay should not have been rejected, "+
"instead error is %v", err)
Expand Down