File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ package lnwire
2+
3+ import "github.com/lightningnetwork/lnd/tlv"
4+
5+ // AttrDataTlvType is the TlvType that hosts the attribution data in the
6+ // update_fail_htlc wire message.
7+ var AttrDataTlvType tlv.TlvType101
8+
9+ // AttrDataTlvTypeVal is the value of the type of the TLV record for the
10+ // attribution data.
11+ var AttrDataTlvTypeVal = AttrDataTlvType .TypeVal ()
12+
13+ // AttrDataToExtraData converts the provided attribution data to the extra
14+ // opaque data to be included in the wire message.
15+ func AttrDataToExtraData (attrData []byte ) (ExtraOpaqueData , error ) {
16+ attrRecs := make (tlv.TypeMap )
17+
18+ attrType := AttrDataTlvType .TypeVal ()
19+
20+ attrRecs [attrType ] = attrData
21+
22+ return NewExtraOpaqueData (attrRecs )
23+ }
24+
25+ // ExtraDataToAttrData takes the extra opaque data of the wire message and tries
26+ // to extract the attribution data.
27+ func ExtraDataToAttrData (extraData ExtraOpaqueData ) ([]byte , error ) {
28+ extraRecords , err := extraData .ExtractRecords ()
29+ if err != nil {
30+ return nil , err
31+ }
32+
33+ attrType := AttrDataTlvTypeVal
34+ var attrData []byte
35+ if value , ok := extraRecords [attrType ]; ok {
36+ attrData = value
37+ }
38+
39+ return attrData , nil
40+ }
You can’t perform that action at this time.
0 commit comments